]> git.puffer.fish Git - matthieu/gru.git/commitdiff
handle dm(s) and edits
authorMatthieu Pignolet <matthieu@matthieu-dev.xyz>
Thu, 6 Jun 2024 15:23:36 +0000 (19:23 +0400)
committerMatthieu Pignolet <matthieu@matthieu-dev.xyz>
Thu, 6 Jun 2024 15:23:36 +0000 (19:23 +0400)
discordjs/src/index.mjs

index 46c22a2e6800a912e024fe4f38d86fd6456e9779..2d2842b8db3bd09be755b81d3ff9784bab367c45 100644 (file)
@@ -1,9 +1,9 @@
 // Require the necessary discord.js classes
-import { Client, GatewayIntentBits, Message } from 'discord.js';
+import { Client, GatewayIntentBits, Message, MessageType } from 'discord.js';
 import { request } from "undici";
 
 // Create a new client instance
-const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMessages] });
+const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildMessages, GatewayIntentBits.DirectMessages] });
 
 // `autofeur_db` service
 export const DB = process.env.DB || "http://localhost:3000";
@@ -69,7 +69,7 @@ client.on("messageUpdate", async (message) => {
     let response = await completeWord(cutWord(message.cleanContent));
 
     // Ignore if there is no completion
-    if ((response || response === "") && (Math.random() > 0.95 || message.channelId == '1248226018406301696')) {
+    if ((response || response === "") && (Math.random() > 0.95 || message.channelId == '1248226018406301696' || message.guild == null)) {
       message.reply(response);
     }
   } catch (e) {