mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 17:13:31 +01:00
refactor: make Structure#deleted a getter to a WeakSet (#7074)
This commit is contained in:
@@ -37,6 +37,13 @@ const Util = require('../util/Util');
|
||||
let deprecationEmittedForSetChannelPositions = false;
|
||||
let deprecationEmittedForSetRolePositions = false;
|
||||
|
||||
/**
|
||||
* @type {WeakSet<Guild>}
|
||||
* @private
|
||||
* @internal
|
||||
*/
|
||||
const deletedGuilds = new WeakSet();
|
||||
|
||||
/**
|
||||
* Represents a guild (or a server) on Discord.
|
||||
* <info>It's recommended to see if a guild is available before performing operations or reading data from it. You can
|
||||
@@ -101,12 +108,6 @@ class Guild extends AnonymousGuild {
|
||||
*/
|
||||
this.invites = new GuildInviteManager(this);
|
||||
|
||||
/**
|
||||
* Whether the bot has been removed from the guild
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.deleted = false;
|
||||
|
||||
if (!data) return;
|
||||
if (data.unavailable) {
|
||||
/**
|
||||
@@ -126,6 +127,19 @@ class Guild extends AnonymousGuild {
|
||||
this.shardId = data.shardId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not the structure has been deleted
|
||||
* @type {boolean}
|
||||
*/
|
||||
get deleted() {
|
||||
return deletedGuilds.has(this);
|
||||
}
|
||||
|
||||
set deleted(value) {
|
||||
if (value) deletedGuilds.add(this);
|
||||
else deletedGuilds.delete(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* The Shard this Guild belongs to.
|
||||
* @type {WebSocketShard}
|
||||
@@ -1399,7 +1413,8 @@ class Guild extends AnonymousGuild {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Guild;
|
||||
exports.Guild = Guild;
|
||||
exports.deletedGuilds = deletedGuilds;
|
||||
|
||||
/**
|
||||
* @external APIGuild
|
||||
|
||||
Reference in New Issue
Block a user