From b4cfdeb02a4c264c143c4542772d10fc6135bb46 Mon Sep 17 00:00:00 2001 From: Timotej Rojko <33236065+timotejroiko@users.noreply.github.com> Date: Thu, 17 Mar 2022 02:42:48 -0300 Subject: [PATCH] ignore messages from voice channels yes, discord is adding text to voice... --- actions.js | 20 ++++++++++---------- functions.js | 1 + 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/actions.js b/actions.js index 1977138..b0ceb23 100644 --- a/actions.js +++ b/actions.js @@ -435,7 +435,7 @@ module.exports = { const c = this.client; const guild = data.guild_id ? getOrCreateGuild(c, data.guild_id, data.shardId) : void 0; const channel = getOrCreateChannel(c, data.channel_id, guild); - if(!channel) { return {}; } + if(!channel || !channel.messages) { return {}; } channel.lastMessageId = data.id; const message = channel.messages._add(data); return { message }; @@ -446,7 +446,7 @@ module.exports = { const c = this.client; const guild = data.guild_id ? getOrCreateGuild(c, data.guild_id, data.shardId) : void 0; const channel = getOrCreateChannel(c, data.channel_id, guild); - if(!channel) { return {}; } + if(!channel || !channel.messages) { return {}; } const message = getOrCreateMessage(channel, data.id); channel.messages.cache.delete(message.id); message.deleted = true; @@ -457,7 +457,7 @@ module.exports = { const c = this.client; const guild = data.guild_id ? getOrCreateGuild(c, data.guild_id, data.shardId) : void 0; const channel = getOrCreateChannel(c, data.channel_id, guild); - if(!channel) { return {}; } + if(!channel || !channel.messages) { return {}; } const deleted = new Collection(); for(const id of data.ids) { const message = getOrCreateMessage(channel, id); @@ -472,7 +472,7 @@ module.exports = { const c = this.client; const guild = data.guild_id ? getOrCreateGuild(c, data.guild_id, data.shardId) : void 0; const channel = getOrCreateChannel(c, data.channel_id, guild); - if(!channel) { return {}; } + if(!channel || !channel.messages) { return {}; } let message = channel.messages.cache.get(data.id); let old; if(message) { @@ -494,7 +494,7 @@ module.exports = { if(!channel) { const guild = data.guild_id ? getOrCreateGuild(c, data.guild_id, data.shardId) : void 0; channel = getOrCreateChannel(c, data.channel_id, guild); - if(!channel) { return {}; } + if(!channel || !channel.messages) { return {}; } } let user = data.user || c.users.cache.get(data.user_id); if(!user) { @@ -522,7 +522,7 @@ module.exports = { const c = this.client; const guild = data.guild_id ? getOrCreateGuild(c, data.guild_id, data.shardId) : void 0; const channel = getOrCreateChannel(c, data.channel_id, guild); - if(!channel) { return {}; } + if(!channel || !channel.messages) { return {}; } let user = c.users.cache.get(data.user_id); if(!user) { user = c.users._add({ id: data.user_id }, false); // has built in partial @@ -548,7 +548,7 @@ module.exports = { const c = this.client; const guild = data.guild_id ? getOrCreateGuild(c, data.guild_id, data.shardId) : void 0; const channel = getOrCreateChannel(c, data.channel_id, guild); - if(!channel) { return {}; } + if(!channel || !channel.messages) { return {}; } const message = getOrCreateMessage(channel, data.message_id); const removed = message.reactions.cache.clone(); message.reactions.cache.clear(); @@ -559,7 +559,7 @@ module.exports = { const c = this.client; const guild = data.guild_id ? getOrCreateGuild(c, data.guild_id, data.shardId) : void 0; const channel = getOrCreateChannel(c, data.channel_id, guild); - if(!channel) { return {}; } + if(!channel || !channel.messages) { return {}; } const message = getOrCreateMessage(channel, data.message_id); let reaction = message.reactions.cache.get(data.emoji.id ?? decodeURIComponent(data.emoji.name)); if(!reaction) { @@ -662,7 +662,7 @@ 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) { + if(!channel || !channel.messages) { return {}; } makePartial(channel); @@ -752,7 +752,7 @@ module.exports = { const c = this.client; const guild = data.guild_id ? getOrCreateGuild(c, data.guild_id, data.shardId) : void 0; const channel = getOrCreateChannel(c, data.channel_id, guild); - if(!channel) { return; } + if(!channel || !channel.messages) { return; } let user = c.users.cache.get(data.user_id); if(!user) { if(data.member?.user) { diff --git a/functions.js b/functions.js index d51444d..38dcf25 100644 --- a/functions.js +++ b/functions.js @@ -51,6 +51,7 @@ function getOrCreateChannel(client, id, guild) { } function getOrCreateMessage(channel, id) { + if(!channel.messages) { return null; } let message = channel.messages.cache.get(id); if(!message) { message = channel.messages._add({