From: Matthieu Pignolet Date: Thu, 6 Jun 2024 08:55:49 +0000 (+0400) Subject: update the probability algorithm X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=76939f7e11dd032f32b47fe57d8075b87036880d;p=matthieu%2Fgru.git update the probability algorithm --- diff --git a/discordjs/src/index.mjs b/discordjs/src/index.mjs index 0e41164..d9e70a2 100644 --- a/discordjs/src/index.mjs +++ b/discordjs/src/index.mjs @@ -36,22 +36,20 @@ const cutWord = (sentence) => { }; client.on("messageCreate", async (message) => { - // we shall not repond to bots - if (message.author.bot) return; - - if (Math.random() > 0.6) { - try { - // Get the completed word found by the db. - let response = await completeWord(cutWord(message.content)); - - // Ignore if there is no completion - if (response || response === "") { - message.reply(response); - } - } catch (e) { - console.log(e); - } + // we shall not repond to bots + if (message.author.bot) return; + + try { + // Get the completed word found by the db. + let response = await completeWord(cutWord(message.content)); + + // Ignore if there is no completion + if ((response || response === "") && Math.random() > 0.6) { + message.reply(response); } + } catch (e) { + console.log(e); + } }) client.login(process.env.TOKEN);