diff --git a/src/core/megahal.ts b/src/core/megahal.ts index f77d2bb..aee3703 100644 --- a/src/core/megahal.ts +++ b/src/core/megahal.ts @@ -6,6 +6,7 @@ import path from 'node:path' import { fileExists, getFileSize } from '@/utils/file_utils' import { formatBytes } from '@/utils/string_utils' import { isWhitelisted } from '@/lib/whitelist' +import { getMentionUsername } from '@/utils/discord_utils' let muted = false const BRAIN_FILE = path.resolve(process.cwd(), 'data', 'brain.dat') // every 20 messages @@ -75,7 +76,7 @@ export async function trainMegahal(message: Discord.Message, replyChance: number (msg, trigger) => msg.toLowerCase().startsWith(trigger.toLowerCase()) ? msg.substring(trigger.length) : msg, message.content, - ) + ).replace(/<@!?(\d+)>/g, (_, id) => getMentionUsername(message, id)) logger.debug('Learning from message:', JSON.stringify(input)) if (totalMsgCount >= SAVE_RATE) { diff --git a/src/utils/discord_utils.ts b/src/utils/discord_utils.ts index a71dece..fcc5267 100644 --- a/src/utils/discord_utils.ts +++ b/src/utils/discord_utils.ts @@ -4,3 +4,21 @@ export async function isAdministrator(member: Discord.GuildMember): Promise