diff options
| -rw-r--r-- | discordjs/src/index.mjs | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/discordjs/src/index.mjs b/discordjs/src/index.mjs index 0e41164..d9e70a2 100644 --- a/discordjs/src/index.mjs +++ b/discordjs/src/index.mjs @@ -36,22 +36,20 @@ const cutWord = (sentence) => { }; client.on("messageCreate", async (message) => { - // we shall not repond to bots - if (message.author.bot) return; - - if (Math.random() > 0.6) { - try { - // Get the completed word found by the db. - let response = await completeWord(cutWord(message.content)); - - // Ignore if there is no completion - if (response || response === "") { - message.reply(response); - } - } catch (e) { - console.log(e); - } + // we shall not repond to bots + if (message.author.bot) return; + + try { + // Get the completed word found by the db. + let response = await completeWord(cutWord(message.content)); + + // Ignore if there is no completion + if ((response || response === "") && Math.random() > 0.6) { + message.reply(response); } + } catch (e) { + console.log(e); + } }) client.login(process.env.TOKEN); |
