]> git.puffer.fish Git - matthieu/gru.git/commitdiff
remove the ? and ! characters
authorMatthieu Pignolet <matthieu@matthieu-dev.xyz>
Thu, 6 Jun 2024 10:38:15 +0000 (14:38 +0400)
committerMatthieu Pignolet <matthieu@matthieu-dev.xyz>
Thu, 6 Jun 2024 10:38:15 +0000 (14:38 +0400)
discordjs/src/index.mjs

index 00cec618cd8e6d97664bfc72f79fbba6455640f6..73b5120d6c9e85415ebfb79671a0925d91b7841d 100644 (file)
@@ -29,6 +29,9 @@ export const completeWord = (grapheme) => {
  */
 const cutWord = (sentence) => {
   let lastWord = sentence
+    .replaceAll("?", "")
+    .replaceAll("!", "")
+    .trim()
     .split(" ")
     .slice(-1)[0]
     .replaceAll(/(\s)?([^\x41-\x5A\s^\x61-\x7A^\xC0-\xFF])/g, "")
@@ -42,11 +45,11 @@ client.on("messageCreate", async (message) => {
 
   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.8) {
+    if ((response || response === "") && Math.random() > 0.95) {
       message.reply(response);
     }
   } catch (e) {