]> git.puffer.fish Git - matthieu/gru.git/commitdiff
update the probability algorithm
authorMatthieu Pignolet <matthieu@matthieu-dev.xyz>
Thu, 6 Jun 2024 08:55:49 +0000 (12:55 +0400)
committerMatthieu Pignolet <matthieu@matthieu-dev.xyz>
Thu, 6 Jun 2024 08:55:49 +0000 (12:55 +0400)
discordjs/src/index.mjs

index 0e411645c5bb21fa50b6e0a34fd37c29394852aa..d9e70a2c2708f24d5efd7be8053c77ad241e9277 100644 (file)
@@ -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);