From a5fbafbf18822640c9f2801fd69f0fcd10add89c Mon Sep 17 00:00:00 2001 From: Matthieu Pignolet Date: Thu, 6 Jun 2024 14:38:15 +0400 Subject: [PATCH] remove the ? and ! characters --- discordjs/src/index.mjs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/discordjs/src/index.mjs b/discordjs/src/index.mjs index 00cec61..73b5120 100644 --- a/discordjs/src/index.mjs +++ b/discordjs/src/index.mjs @@ -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) { -- 2.39.5