From e22cb53ccfa82b8e6e45d5c05b409b023a3f8216 Mon Sep 17 00:00:00 2001 From: Claude Owner Date: Tue, 26 May 2026 14:38:46 +0900 Subject: [PATCH] fix(tts): correct Discord snowflake regex and getSource typo - Mention/emoji regexes used [(0-9)]{18}; '(' and ')' inside a character class are literal so this matched the bracket chars themselves and hard-fixed the ID length to 18. Discord snowflakes are 17-20 digits (older 2015-2017 accounts are 17, 2024+ trend toward 19-20). Switch to \\d{17,20} and capture the ID for member lookup. - Tighten emoji regex name segment from .* (greedy, eats across emojis) to [^:]+ so adjacent emojis no longer collapse into one match. - Rename getSorce -> getSource. --- src/classes/TTSClient.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/classes/TTSClient.ts b/src/classes/TTSClient.ts index 465d999..7e52b42 100644 --- a/src/classes/TTSClient.ts +++ b/src/classes/TTSClient.ts @@ -62,7 +62,7 @@ export class TTSClient { } text = this.textEditor(channel.guild, text); - const buf = await this.getSorce(text); + const buf = await this.getSource(text); if (!buf) return; const session = this.getSession(channel.guild, voiceChannel); @@ -91,7 +91,7 @@ export class TTSClient { } - private async getSorce(text: string): Promise { + private async getSource(text: string): Promise { const parts = text.split(signature.regex); const bufferList: Buffer[] = []; @@ -119,11 +119,11 @@ export class TTSClient { if (text.length === 0) return "파일"; return text .replace(URL_RE, (u) => labelForUrl(u) ?? u) - .replace(/\<\@\!?[(0-9)]{18}\>/g, (t) => { - const member = guild.members.cache.get(t.replace(/[^0-9]/g,"")); + .replace(/<@!?(\d{17,20})>/g, (_t, id: string) => { + const member = guild.members.cache.get(id); return member?.nickname ?? member?.user.username ?? "유저"; }) - .replace(/\/g, () => { + .replace(//g, () => { return "이모티콘"; }); }