summaryrefslogtreecommitdiff
path: root/node_modules/discord.js/src/client/actions/GuildDelete.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/discord.js/src/client/actions/GuildDelete.js')
-rw-r--r--node_modules/discord.js/src/client/actions/GuildDelete.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/node_modules/discord.js/src/client/actions/GuildDelete.js b/node_modules/discord.js/src/client/actions/GuildDelete.js
new file mode 100644
index 0000000..eb0a44d
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildDelete.js
@@ -0,0 +1,44 @@
+'use strict';
+
+const Action = require('./Action');
+const Events = require('../../util/Events');
+
+class GuildDeleteAction extends Action {
+ handle(data) {
+ const client = this.client;
+
+ let guild = client.guilds.cache.get(data.id);
+ if (guild) {
+ if (data.unavailable) {
+ // Guild is unavailable
+ guild.available = false;
+
+ /**
+ * Emitted whenever a guild becomes unavailable, likely due to a server outage.
+ * @event Client#guildUnavailable
+ * @param {Guild} guild The guild that has become unavailable
+ */
+ client.emit(Events.GuildUnavailable, guild);
+
+ // Stops the GuildDelete packet thinking a guild was actually deleted,
+ // handles emitting of event itself
+ return;
+ }
+
+ for (const channel of guild.channels.cache.values()) this.client.channels._remove(channel.id);
+ client.voice.adapters.get(data.id)?.destroy();
+
+ // Delete guild
+ client.guilds.cache.delete(guild.id);
+
+ /**
+ * Emitted whenever a guild kicks the client or the guild is deleted/left.
+ * @event Client#guildDelete
+ * @param {Guild} guild The guild that was deleted
+ */
+ client.emit(Events.GuildDelete, guild);
+ }
+ }
+}
+
+module.exports = GuildDeleteAction;