Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(ChannelUpdate): Check against unknown channels (#9698)
fix(ChannelUpdate): check against unknown channels
  • Loading branch information
Jiralite committed Jul 11, 2023
1 parent f9e9843 commit 630b9d5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/client/actions/ChannelUpdate.js
Expand Up @@ -7,14 +7,23 @@ const { ChannelTypes } = require('../../util/Constants');
class ChannelUpdateAction extends Action {
handle(data) {
const client = this.client;

let channel = client.channels.cache.get(data.id);

if (channel) {
const old = channel._update(data);

if (ChannelTypes[channel.type] !== data.type) {
const newChannel = Channel.create(this.client, data, channel.guild);
for (const [id, message] of channel.messages.cache) newChannel.messages.cache.set(id, message);

if (!newChannel) {
this.client.channels.cache.delete(channel.id);
return {};
}

if (channel.isText() && newChannel.isText()) {
for (const [id, message] of channel.messages.cache) newChannel.messages.cache.set(id, message);
}

channel = newChannel;
this.client.channels.cache.set(channel.id, channel);
}
Expand Down

0 comments on commit 630b9d5

Please sign in to comment.