From 399b3285df8e3d77ac0e82592010a850696225b6 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 31 Oct 2024 17:58:54 +0100 Subject: [PATCH] fix don't mention multiple times (fix #199) --- src/utils/commands/reminder.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/utils/commands/reminder.ts b/src/utils/commands/reminder.ts index 139a534..1005b8c 100644 --- a/src/utils/commands/reminder.ts +++ b/src/utils/commands/reminder.ts @@ -199,16 +199,20 @@ const sendReminderAux = (client: Client, info: infoReminder, option: OptionRemin // Channel client.channels.fetch(info.channelId!).then((channel) => { if (channel?.isSendable()) { - let content = `<@${info.userId}>`; + const author_mention = `<@${info.userId}>`; + + let content = author_mention; embed.setFooter({ text: `${loc.get("c_reminder17")} ${timeDeltaToString(info.createdAt)}`, }); // Mention everybody if needed if (option === OptionReminder.Mention) { - (info.message?.match(/<@\d+>/g) ?? []).forEach((mention) => { - content += " " + mention; - }); + [...new Set(info.message?.match(/<@\d+>/g) ?? [])] + .filter((mention) => mention !== author_mention) + .forEach((mention: string) => { + content += " " + mention; + }); } channel.send({ content, embeds: [embed] });