From b7d26191a1a0868abfc211a28602dda90cc18867 Mon Sep 17 00:00:00 2001 From: SAILLY Kevin <75009579+LJ5O@users.noreply.github.com> Date: Fri, 16 Sep 2022 22:24:41 +0200 Subject: [PATCH 1/4] Fixed a bug with "message updated" event When this event was used, and message containing a link is sent, the link's embed loading may occasionally trigger this event. If we ask the bot to repost the content of the message, the same problem will occur, creating an infinite loop of messages. --- modules/event_functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/event_functions.js b/modules/event_functions.js index 93570e4..d026a42 100644 --- a/modules/event_functions.js +++ b/modules/event_functions.js @@ -91,7 +91,7 @@ module.exports = { return; } - if(eventNewMessage.channel.type == Discord.ChannelType.DM){return;}//Do nothing if done in PM channel + if(eventNewMessage.channel.type == Discord.ChannelType.DM || eventNewMessage.author.bot){return;}//Do nothing if done in PM channel or author is bot const CURRENT_GUILD = eventNewMessage.guild;//We save here the guild we're working on logger.debug("A message was edited in guild "+CURRENT_GUILD.id+", creating a SQL request..."); From ea02cbf730f5acc7f75a146f2aaab36789b94768 Mon Sep 17 00:00:00 2001 From: SAILLY Kevin <75009579+LJ5O@users.noreply.github.com> Date: Fri, 16 Sep 2022 22:38:34 +0200 Subject: [PATCH 2/4] Fixed bug with "message updated" event To complete the last commit and correctly fix this bug, this event isn't triggered anymore if the message's content is the same in old and new states. --- modules/event_functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/event_functions.js b/modules/event_functions.js index d026a42..f7be159 100644 --- a/modules/event_functions.js +++ b/modules/event_functions.js @@ -91,7 +91,7 @@ module.exports = { return; } - if(eventNewMessage.channel.type == Discord.ChannelType.DM || eventNewMessage.author.bot){return;}//Do nothing if done in PM channel or author is bot + if(eventNewMessage.channel.type == Discord.ChannelType.DM || eventNewMessage.author.bot || eventOldMessage.content === eventNewMessage.content ){return;}//Do nothing if done in PM channel or author is bot or content wasn't edited const CURRENT_GUILD = eventNewMessage.guild;//We save here the guild we're working on logger.debug("A message was edited in guild "+CURRENT_GUILD.id+", creating a SQL request..."); From 7e9d0bcb6885786f2a6da70cc3d709219f31184b Mon Sep 17 00:00:00 2001 From: LJ50 <75009579+LJ5O@users.noreply.github.com> Date: Sun, 18 Sep 2022 21:46:28 +0200 Subject: [PATCH 3/4] Update package-lock.json --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index a3f0b31..6678985 100644 --- a/package-lock.json +++ b/package-lock.json @@ -640,9 +640,9 @@ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" }, "node_modules/vm2": { - "version": "3.9.10", - "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.10.tgz", - "integrity": "sha512-AuECTSvwu2OHLAZYhG716YzwodKCIJxB6u1zG7PgSQwIgAlEaoXH52bxdcvT8GkGjnYK7r7yWDW0m0sOsPuBjQ==", + "version": "3.9.11", + "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.11.tgz", + "integrity": "sha512-PFG8iJRSjvvBdisowQ7iVF580DXb1uCIiGaXgm7tynMR1uTBlv7UJlB1zdv5KJ+Tmq1f0Upnj3fayoEOPpCBKg==", "dependencies": { "acorn": "^8.7.0", "acorn-walk": "^8.2.0" @@ -1199,9 +1199,9 @@ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" }, "vm2": { - "version": "3.9.10", - "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.10.tgz", - "integrity": "sha512-AuECTSvwu2OHLAZYhG716YzwodKCIJxB6u1zG7PgSQwIgAlEaoXH52bxdcvT8GkGjnYK7r7yWDW0m0sOsPuBjQ==", + "version": "3.9.11", + "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.11.tgz", + "integrity": "sha512-PFG8iJRSjvvBdisowQ7iVF580DXb1uCIiGaXgm7tynMR1uTBlv7UJlB1zdv5KJ+Tmq1f0Upnj3fayoEOPpCBKg==", "requires": { "acorn": "^8.7.0", "acorn-walk": "^8.2.0" From e3bed9feee6d1e088feb2903c50befc55b3ec057 Mon Sep 17 00:00:00 2001 From: LJ50 <75009579+LJ5O@users.noreply.github.com> Date: Mon, 19 Sep 2022 19:45:29 +0200 Subject: [PATCH 4/4] Disabled roleUpdate and typingStart events These events were sometime triggered multiples time when only one real event occured. We will try to fix this later --- index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 96ece9a..fc80385 100644 --- a/index.js +++ b/index.js @@ -34,7 +34,7 @@ const discordClient = new Discord.Client({ Discord.GatewayIntentBits.GuildPresences, Discord.GatewayIntentBits.GuildMessages, Discord.GatewayIntentBits.GuildMessageReactions, - Discord.GatewayIntentBits.GuildMessageTyping, + //Discord.GatewayIntentBits.GuildMessageTyping, Discord.GatewayIntentBits.DirectMessages, Discord.GatewayIntentBits.DirectMessageReactions, //Discord.GatewayIntentBits.DirectMessageTyping, @@ -242,9 +242,10 @@ discordClient.on("roleDelete", async (eventRole) =>{ }); //A rank is edited -discordClient.on("roleUpdate", async (eventOldRole, eventNewRole) =>{ +//Disabled : sometimes, when a role is created, this event will be triggered multiple times +/*discordClient.on("roleUpdate", async (eventOldRole, eventNewRole) =>{ event_functions.roleUpdate(eventOldRole, eventNewRole, logger, database_pool); -}); +});*/ //An user is banned from the guild discordClient.on("guildBanAdd", async (eventBan) =>{ @@ -279,9 +280,10 @@ discordClient.on("voiceStateUpdate", async (oldState, newState) =>{ });*/ //A guildMember is typing -discordClient.on("typingStart", async (typingState) =>{ +//Disabled : This event is always triggered multiple times when a big message is written +/*discordClient.on("typingStart", async (typingState) =>{ event_functions.typingStart(typingState, logger, database_pool); -}); +});*/ /*############################################*/ /* Starting the bot */