Skip to content

Commit

Permalink
ignore unsupported channel types
Browse files Browse the repository at this point in the history
  • Loading branch information
timotejroiko committed Mar 12, 2022
1 parent a00fb00 commit a18279b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ module.exports = {
const c = this.client;
const guild = data.guild_id ? getOrCreateGuild(c, data.guild_id, data.shardId) : void 0;
const channel = c.channels.cache.get(data.id) || c.channels._add(data, guild);
if(!channel) {
return {};
}
if(channel.messages?.cache.size && !(channel instanceof DMChannel)) {
for(const message of channel.messages.cache.values()) { message.deleted = true; }
}
Expand All @@ -62,7 +65,9 @@ module.exports = {
} else {
channel = c.channels._add(data, guild);
old = c.channels._add({ id: data.id, type: data.type }, guild, { cache: false, allowUnknownGuild: true });
makePartial(old);
if(old) {
makePartial(old);
}
}
return {
old,
Expand Down Expand Up @@ -631,6 +636,9 @@ module.exports = {
const c = this.client;
const guild = getOrCreateGuild(c, data.guild_id, data.shardId);
const thread = c.channels._add(data, guild);
if(!thread) {
return {};
}
c.emit(Constants.Events.THREAD_CREATE, thread);
return { thread };
},
Expand All @@ -641,6 +649,9 @@ module.exports = {
if(!channel) {
const guild = getOrCreateGuild(c, data.guild_id, data.shardId);
channel = c.channels._add(data, guild, { cache: false, allowUnknownGuild: true });
if(!channel) {
return {};
}
makePartial(channel);
}
for(const message of channel.messages.cache.values()) { message.deleted = true; }
Expand All @@ -665,6 +676,9 @@ module.exports = {
}
const syncedThreads = data.threads.reduce((coll, rawThread) => {
const thread = c.channels._add(rawThread);
if(!thread) {
return coll;
}
return coll.set(thread.id, thread);
}, new Collection());
for(const rawMember of Object.values(data.members)) {
Expand Down

0 comments on commit a18279b

Please sign in to comment.