Skip to content

Commit 7fb91c5

Browse files
authored
fix(ChannelUpdate): Check against unknown channels (#9697)
fix(ChannelUpdate): check against unknown channels
1 parent 09b0382 commit 7fb91c5

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

packages/discord.js/src/client/actions/ChannelUpdate.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,23 @@ const { createChannel } = require('../../util/Channels');
66
class ChannelUpdateAction extends Action {
77
handle(data) {
88
const client = this.client;
9-
109
let channel = client.channels.cache.get(data.id);
10+
1111
if (channel) {
1212
const old = channel._update(data);
1313

1414
if (channel.type !== data.type) {
1515
const newChannel = createChannel(this.client, data, channel.guild);
16-
for (const [id, message] of channel.messages.cache) newChannel.messages.cache.set(id, message);
16+
17+
if (!newChannel) {
18+
this.client.channels.cache.delete(channel.id);
19+
return {};
20+
}
21+
22+
if (channel.isTextBased() && newChannel.isTextBased()) {
23+
for (const [id, message] of channel.messages.cache) newChannel.messages.cache.set(id, message);
24+
}
25+
1726
channel = newChannel;
1827
this.client.channels.cache.set(channel.id, channel);
1928
}

0 commit comments

Comments
 (0)