diff options
| author | Matthieu Pignolet <matthieu@matthieu-dev.xyz> | 2024-06-06 14:38:15 +0400 |
|---|---|---|
| committer | Matthieu Pignolet <matthieu@matthieu-dev.xyz> | 2024-06-06 14:38:15 +0400 |
| commit | a5fbafbf18822640c9f2801fd69f0fcd10add89c (patch) | |
| tree | 82a5e19a49c7794c76d556e54e331bcf383a059a | |
| parent | ddac41968707f6f5bc4c6529247d871b046b5e5c (diff) | |
remove the ? and ! characters
| -rw-r--r-- | discordjs/src/index.mjs | 7 |
1 files 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) { |
