Skip to content

Commit

Permalink
ignore messages from voice channels
Browse files Browse the repository at this point in the history
yes, discord is adding text to voice...
  • Loading branch information
timotejroiko committed Mar 17, 2022
1 parent 61279a0 commit b4cfdeb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
20 changes: 10 additions & 10 deletions actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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();
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit b4cfdeb

Please sign in to comment.