From cb70e365b15921e1628b9c80d1a5b364b905cfe8 Mon Sep 17 00:00:00 2001 From: Matthieu Pignolet Date: Wed, 30 Apr 2025 18:16:14 +0400 Subject: 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 --- discordjs/src/index.mjs | 1 + 1 file changed, 1 insertion(+) 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); -- cgit v1.2.3