mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
refactor: make Structure#deleted a getter to a WeakSet (#7074)
This commit is contained in:
@@ -6,6 +6,13 @@ const Permissions = require('../util/Permissions');
|
||||
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
/**
|
||||
* @type {WeakSet<Role>}
|
||||
* @private
|
||||
* @internal
|
||||
*/
|
||||
const deletedRoles = new WeakSet();
|
||||
|
||||
/**
|
||||
* Represents a role on Discord.
|
||||
* @extends {Base}
|
||||
@@ -32,12 +39,6 @@ class Role extends Base {
|
||||
*/
|
||||
this.unicodeEmoji = null;
|
||||
|
||||
/**
|
||||
* Whether the role has been deleted
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.deleted = false;
|
||||
|
||||
if (data) this._patch(data);
|
||||
}
|
||||
|
||||
@@ -146,6 +147,19 @@ class Role extends Base {
|
||||
return new Date(this.createdTimestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not the role has been deleted
|
||||
* @type {boolean}
|
||||
*/
|
||||
get deleted() {
|
||||
return deletedRoles.has(this);
|
||||
}
|
||||
|
||||
set deleted(value) {
|
||||
if (value) deletedRoles.add(this);
|
||||
else deletedRoles.delete(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* The hexadecimal version of the role color, with a leading hashtag
|
||||
* @type {string}
|
||||
@@ -462,7 +476,8 @@ class Role extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Role;
|
||||
exports.Role = Role;
|
||||
exports.deletedRoles = deletedRoles;
|
||||
|
||||
/**
|
||||
* @external APIRole
|
||||
|
||||
Reference in New Issue
Block a user