From: Matthieu Pignolet Date: Thu, 6 Jun 2024 10:00:56 +0000 (+0400) Subject: use clean string for completion X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=fbb787140e20b5c2aeca2f1cec1e8ba747ac1d3d;p=matthieu%2Fgru.git use clean string for completion --- diff --git a/discordjs/src/index.mjs b/discordjs/src/index.mjs index d9e70a2..94499e5 100644 --- a/discordjs/src/index.mjs +++ b/discordjs/src/index.mjs @@ -31,7 +31,8 @@ const cutWord = (sentence) => { let lastWord = sentence .split(" ") .slice(-1)[0] - .replaceAll(/(\s)?([^\x41-\x5A\s^\x61-\x7A^\xC0-\xFF])/g, ""); + .replaceAll(/(\s)?([^\x41-\x5A\s^\x61-\x7A^\xC0-\xFF])/g, "") + .replaceAll(/(?:https?|ftp):\/\/[\n\S]+/g, ''); return lastWord; }; @@ -41,7 +42,7 @@ client.on("messageCreate", async (message) => { try { // Get the completed word found by the db. - let response = await completeWord(cutWord(message.content)); + let response = await completeWord(cutWord(message.cleanContent)); // Ignore if there is no completion if ((response || response === "") && Math.random() > 0.6) {