From 63a87bfb87985130c77f9aeca95417a53e563a3f Mon Sep 17 00:00:00 2001 From: ZickZenni Date: Thu, 5 Sep 2024 00:02:06 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=B0=EF=B8=8F=20Removed=20unused=20parser?= =?UTF-8?q?=20utils?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/utils/parser.ts | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 src/renderer/utils/parser.ts diff --git a/src/renderer/utils/parser.ts b/src/renderer/utils/parser.ts deleted file mode 100644 index 4f11820..0000000 --- a/src/renderer/utils/parser.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { User } from '../../common/discord/user'; - -const MENTION_REGEX = /<@(.*?)>/g; - -// eslint-disable-next-line import/prefer-default-export -export async function parseMentions(content: string): Promise { - const tags = content.match(/<(.*?)>/g); - - // No tags found (<@0123456789012345678> <:Test:0123456789012345678> etc..) - if (tags === null) return content; - - let newContent = content; - - for (let i = 0; i < tags.length; i += 1) { - const tag = tags[i]; - - const result = MENTION_REGEX.exec(tag); - - // Tag is not a mention - if (result === null) continue; - - const mentionId = result[1]; - // eslint-disable-next-line no-await-in-loop - const user: User | null = await window.electron.ipcRenderer - .invoke('discord:user', mentionId) - .catch((err) => window.logger.error(err)); - - newContent = newContent.replaceAll( - `<@${mentionId}>`, - user ? user.globalName : '', - ); - } - - return newContent; -}