From 3287286fa21d21ed1e0a9f0b8c354e23109f4673 Mon Sep 17 00:00:00 2001 From: aronson Date: Wed, 15 Nov 2023 04:54:32 -0600 Subject: [PATCH] Don't crash on empty pings (#57) --- lib/mediator.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/mediator.ts b/lib/mediator.ts index 0d480ac..60d2bdb 100644 --- a/lib/mediator.ts +++ b/lib/mediator.ts @@ -583,7 +583,10 @@ export class Mediator { input, /([^@\s:,]+):|@([^\s]+)?/g, async (match, colonRef, atRef) => { - const reference: string = colonRef || atRef; + const reference: string | undefined = colonRef || atRef; + if (!reference) { + return match; + } // Remove discriminator from bot mentions const member = await this.getDiscordUserByString(reference.split('#')[0], this.guild);