From: Matthieu Pignolet Date: Tue, 9 Jul 2024 10:21:58 +0000 (+0400) Subject: change response algorithm X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=8960400eda94c27bb2af73df39df77c81c2a8847;p=matthieu%2Fgru.git change response algorithm --- diff --git a/discordjs/src/index.mjs b/discordjs/src/index.mjs index 354d651..9a37a1f 100644 --- a/discordjs/src/index.mjs +++ b/discordjs/src/index.mjs @@ -47,20 +47,29 @@ const specialChannels = [ "1248226018406301696" ] +let counter = 0; const messageAction = async (message) => { if (message.author.bot) return; - const cleanText = sanitizeWord(message.cleanContent); - if (countChars(cleanText) > 0) { - let response = await completeWord(cleanText); - // Ignore if there is no completion - const shouldReply = (Math.random() > 0.995 || specialChannels.includes(message.channelId) || message.guild == null); - if ((response || response === "") && shouldReply) { - message.reply(response); + counter += 1; + + let shouldReply = (counter >= 75 || specialChannels.includes(message.channelId) || message.guild == null); + + if (shouldReply) { + const cleanText = sanitizeWord(message.cleanContent); + if (countChars(cleanText) > 0) { + let response = await completeWord(cleanText); + + // Ignore if there is no completion + if ((response || response === "")) { + message.reply(response); + counter = 0; + } } } - if ((message.content.includes("@everyone") && message.guild.id === "1055126989566124083") || specialChannels.includes(message.channelId)) { + let isEveryone = message.cleanContent.includes("@everyone") && message.guild.id === "1055126989566124083"; + if (isEveryone) { message.reply("https://cdn.mpgn.dev/pascontent-gabe.gif"); } };