Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/discord.js/src/client/actions/ActionsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ActionsManager {
this.GuildChannelsPositionUpdate = this.load(
require('./GuildChannelsPositionUpdate.js').GuildChannelsPositionUpdateAction,
);
this.GuildDelete = this.load(require('./GuildDelete.js').GuildDeleteAction);
this.GuildEmojiCreate = this.load(require('./GuildEmojiCreate.js').GuildEmojiCreateAction);
this.GuildEmojiDelete = this.load(require('./GuildEmojiDelete.js').GuildEmojiDeleteAction);
this.GuildEmojiUpdate = this.load(require('./GuildEmojiUpdate.js').GuildEmojiUpdateAction);
Expand Down
16 changes: 16 additions & 0 deletions packages/discord.js/src/client/actions/GuildDelete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

const { Action } = require('./Action.js');

class GuildDeleteAction extends Action {
handle(guild) {
const { client } = this;

for (const channel of guild.channels.cache.values()) client.channels._remove(channel.id);
client.voice.adapters.get(guild.id)?.destroy();

client.guilds.cache.delete(guild.id);
}
}

exports.GuildDeleteAction = GuildDeleteAction;
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ module.exports = (client, { d: data }) => {
return;
}

for (const channel of guild.channels.cache.values()) client.channels._remove(channel.id);
client.voice.adapters.get(data.id)?.destroy();

client.guilds.cache.delete(guild.id);
client.actions.GuildDelete.handle(guild);

/**
* Emitted whenever a guild kicks the client or the guild is deleted/left.
Expand Down
6 changes: 6 additions & 0 deletions packages/discord.js/src/client/websocket/handlers/READY.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ module.exports = (client, { d: data }, shardId) => {
client.users.cache.set(client.user.id, client.user);
}

client.expectedGuilds.clear();
for (const guild of data.guilds) {
client.expectedGuilds.add(guild.id);
guild.shardId = shardId;
client.guilds._add(guild);
}

for (const guild of client.guilds.cache.values()) {
if (client.expectedGuilds.has(guild.id)) continue;
client.actions.GuildDelete.handle(guild);
}
Comment thread
vakiliner marked this conversation as resolved.
Outdated
Comment thread
vakiliner marked this conversation as resolved.

if (client.application) {
client.application._patch(data.application);
} else {
Expand Down
Loading