Forráskód Böngészése

Fix mention commands not working

ghorsington 3 éve
szülő
commit
0659a2d5c6
2 módosított fájl, 6 hozzáadás és 2 törlés
  1. 5 1
      bot/src/client.ts
  2. 1 1
      bot/src/main.ts

+ 5 - 1
bot/src/client.ts

@@ -1,4 +1,4 @@
-import { Client, ClientUser } from "discord.js";
+import { Client, ClientUser, Util } from "discord.js";
 import { XenforoClient } from "./xenforo";
 
 export const FORUMS_DOMAIN = "https://custommaid3d2.com";
@@ -20,6 +20,10 @@ export class BotClient {
     get nameMention(): string {
         return `<@!${this.botUser.id}>`;
     }
+
+    get cleanMention(): string {
+        return Util.removeMentions(`@${client.botUser.username}`);
+    }
 }
 
 export const client = new BotClient();

+ 1 - 1
bot/src/main.ts

@@ -43,7 +43,7 @@ client.bot.on("message", async m => {
     if (m.mentions.users.size > 0 && m.mentions.users.has(client.botUser.id)) {
         const trimmedContent = m.content.trim();
         if (trimmedContent.startsWith(client.nameMention) || trimmedContent.startsWith(client.usernameMention)) {
-            content = content.substring(`@${client.botUser.username}`.length).trim();
+            content = content.substring(client.cleanMention.length).trim();
             const lowerCaseContent = content.toLowerCase();
             
             if (await plgMgr.runCommand("mention", m, content))