From 14f61d88ffb5ac7f66d46e0155833d32d46802d6 Mon Sep 17 00:00:00 2001 From: Zachery Notz Date: Sat, 23 May 2020 17:14:31 -0700 Subject: Improved regex so that TELLRAW templates can use variables more than once --- src/Discord.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Discord.ts b/src/Discord.ts index 2893c8b..c9b3b74 100644 --- a/src/Discord.ts +++ b/src/Discord.ts @@ -140,9 +140,9 @@ class Discord { } return this.config.MINECRAFT_TELLRAW_TEMPLATE - .replace('%username%', variables.username) - .replace('%discriminator%', variables.discriminator) - .replace('%message%', variables.text) + .replace(/%username%/g, variables.username) + .replace(/%discriminator%/g, variables.discriminator) + .replace(/%message%/g, variables.text) } private replaceDiscordMentions(message: string): string { -- cgit 1.4.1 From 1a69fea1b06215ecc0939c743b5157c09f0d8734 Mon Sep 17 00:00:00 2001 From: Zachery Notz Date: Sat, 23 May 2020 19:31:24 -0700 Subject: Fixed user mention detection --- src/Discord.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Discord.ts b/src/Discord.ts index c9b3b74..ffdd05b 100644 --- a/src/Discord.ts +++ b/src/Discord.ts @@ -146,7 +146,7 @@ class Discord { } private replaceDiscordMentions(message: string): string { - const possibleMentions = message.match(/@(\S+)/gim) + const possibleMentions = message.match(/@*.*#[0-9]{4}/gim) if (possibleMentions) { for (let mention of possibleMentions) { const mentionParts = mention.split('#') -- cgit 1.4.1