]> git.puffer.fish Git - matthieu/gru.git/commitdiff
handle dm(s) and edits
authorMatthieu Pignolet <matthieu@matthieu-dev.xyz>
Thu, 6 Jun 2024 14:06:55 +0000 (18:06 +0400)
committerMatthieu Pignolet <matthieu@matthieu-dev.xyz>
Thu, 6 Jun 2024 14:06:55 +0000 (18:06 +0400)
discordjs/src/index.mjs

index b9d43bb95edbd1ac2cb351b1de44c83b23f9edcf..46c22a2e6800a912e024fe4f38d86fd6456e9779 100644 (file)
@@ -58,6 +58,23 @@ client.on("messageCreate", async (message) => {
   } catch (e) {
     console.log(e);
   }
-})
+});
+
+client.on("messageUpdate", async (message) => {
+  if (message.author.bot) return;
+
+  try {
+    // Get the completed word found by the db.
+
+    let response = await completeWord(cutWord(message.cleanContent));
+
+    // Ignore if there is no completion
+    if ((response || response === "") && (Math.random() > 0.95 || message.channelId == '1248226018406301696')) {
+      message.reply(response);
+    }
+  } catch (e) {
+    console.log(e);
+  }
+});
 
 client.login(process.env.TOKEN);