From 7e3175eb205de1d1927ac867eac2ddbf688c247f Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Sun, 17 Sep 2023 20:33:37 +1200 Subject: [PATCH] //invite: Guard against accidental mentions --- discord/discord-command-handler.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/discord/discord-command-handler.js b/discord/discord-command-handler.js index 866999d..089286a 100644 --- a/discord/discord-command-handler.js +++ b/discord/discord-command-handler.js @@ -141,6 +141,12 @@ const commands = [{ }) } + // Guard against accidental mentions instead of the MXID + if (message.content.match(/<[@#:].*>/)) return discord.snow.channel.createMessage(channel.id, { + ...ctx, + content: "You have to say the Matrix ID of the person you want to invite, but you mentioned a Discord user in your message.\nOne way to fix this is by writing `` ` `` backticks `` ` `` around the Matrix ID." + }) + // Get named MXID const mxid = message.content.match(/@([^:]+):([a-z0-9:-]+\.[a-z0-9.:-]+)/)?.[0] if (!mxid) return discord.snow.channel.createMessage(channel.id, {