summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Pignolet <matthieu@matthieu-dev.xyz>2024-06-06 18:06:55 +0400
committerMatthieu Pignolet <matthieu@matthieu-dev.xyz>2024-06-06 18:06:55 +0400
commit11ab5f3ad4e754187de2590c0738a798e7f86511 (patch)
tree0178be9787122b541f35b83175a94d189ff897c8
parentddd0543284dc19a15740153ff26389e6d5e74fab (diff)
handle dm(s) and edits
-rw-r--r--discordjs/src/index.mjs19
1 files changed, 18 insertions, 1 deletions
diff --git a/discordjs/src/index.mjs b/discordjs/src/index.mjs
index b9d43bb..46c22a2 100644
--- a/discordjs/src/index.mjs
+++ b/discordjs/src/index.mjs
@@ -58,6 +58,23 @@ client.on("messageCreate", async (message) => {
} catch (e) {
console.log(e);
}
-})
+});
+
+client.on("messageUpdate", async (message) => {
+ if (message.author.bot) return;
+
+ 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.95 || message.channelId == '1248226018406301696')) {
+ message.reply(response);
+ }
+ } catch (e) {
+ console.log(e);
+ }
+});
client.login(process.env.TOKEN);