summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Pignolet <m@mpgn.dev>2025-04-30 18:16:14 +0400
committerMatthieu Pignolet <m@mpgn.dev>2025-04-30 18:16:14 +0400
commitcb70e365b15921e1628b9c80d1a5b364b905cfe8 (patch)
tree7fa7f4b8c7bd138feca8a4094a486665fe027e1d
parenta12a7ba11e99171c97edaa4f68d45d92f9ff6255 (diff)
fix: ignore message-updates event when the given message wasn't edited by a user
This fixes an issue where sending non-cached discord links would trigger a message update event from discord's side and thus trigger gru's reponse twice when handlng events. For example such issue could occur when sending a message using the `@everyone` mention together with a link. Before this commit, Gru would be triggered once with the message-create event, and a second time with the message-update from discord when adding the link embed information. This commit fixes this issue by ignoring the message from the message-update event if the message in question doesn't have the edited-at property be a non-null value. Signed-off-by: Matthieu Pignolet <m@mpgn.dev>
-rw-r--r--discordjs/src/index.mjs1
1 files changed, 1 insertions, 0 deletions
diff --git a/discordjs/src/index.mjs b/discordjs/src/index.mjs
index 589d75a..b456eec 100644
--- a/discordjs/src/index.mjs
+++ b/discordjs/src/index.mjs
@@ -65,6 +65,7 @@ const ignoredChannels = [
let messageReplyCounter = 0;
const messageAction = async (message, ctx) => {
if (message.author.bot) return;
+ if (message.editedAt == null && ctx == SYMBOL_FOR_UPDATE) return;
messageReplyCounter += 1;
console.log("counter is at", messageReplyCounter);