Actually fix partial messages

This commit is contained in:
loicbersier 2020-06-17 15:42:46 +02:00
parent 890d294f9d
commit 00389b326d
3 changed files with 332 additions and 336 deletions

View file

@ -31,9 +31,6 @@ class messageListener extends Listener {
return console.error(err); return console.error(err);
}); });
} else { } else {
return;
}
if (message.author.bot) return; if (message.author.bot) return;
/* Banned words section /* Banned words section
@ -289,6 +286,9 @@ class messageListener extends Listener {
} }
} }
} }
}
} }
module.exports = messageListener; module.exports = messageListener;

View file

@ -12,18 +12,15 @@ class MessageReactionAddListener extends Listener {
} }
async exec(reaction) { async exec(reaction) {
let starboardChannel, shameboardChannel;
let reactionCount = reaction.count;
if (reaction.message.partial) { if (reaction.message.partial) {
await reaction.message.fetch() await reaction.message.fetch()
.catch(err => { .catch(err => {
return console.error(err); return console.error(err);
}); });
} else { } else {
return;
}
let starboardChannel, shameboardChannel;
let reactionCount = reaction.count;
// If one of the reaction is the author of the message remove 1 to the reaction count // If one of the reaction is the author of the message remove 1 to the reaction count
reaction.users.cache.forEach(user => { reaction.users.cache.forEach(user => {
if (reaction.message.author == user) reactionCount--; if (reaction.message.author == user) reactionCount--;
@ -70,6 +67,7 @@ class MessageReactionAddListener extends Listener {
} }
} }
} }
}
async function editEmbed(name, emote, boardID, client) { async function editEmbed(name, emote, boardID, client) {
let channel; let channel;

View file

@ -11,18 +11,15 @@ class messageReactionRemoveListener extends Listener {
} }
async exec(reaction) { async exec(reaction) {
let starboardChannel, shameboardChannel;
let reactionCount = reaction.count;
if (reaction.message.partial) { if (reaction.message.partial) {
await reaction.message.fetch() await reaction.message.fetch()
.catch(err => { .catch(err => {
return console.error(err); return console.error(err);
}); });
} else { } else {
return;
}
let starboardChannel, shameboardChannel;
let reactionCount = reaction.count;
// If one of the reaction removed is the author of the message add 1 to the reaction count // If one of the reaction removed is the author of the message add 1 to the reaction count
reaction.users.cache.forEach(user => { reaction.users.cache.forEach(user => {
if (reaction.message.author == user) reactionCount++; if (reaction.message.author == user) reactionCount++;
@ -74,6 +71,7 @@ class messageReactionRemoveListener extends Listener {
return editEmbed('shameboard', shameemote, messageID[reaction.message.id], this.client); return editEmbed('shameboard', shameemote, messageID[reaction.message.id], this.client);
} }
} }
}
async function editEmbed(name, emote, boardID, client) { async function editEmbed(name, emote, boardID, client) {
let channel; let channel;