From 68fffba88770704a9e44ae2fc65171c53bc7e766 Mon Sep 17 00:00:00 2001 From: toast-ts <96593068+toast-ts@users.noreply.github.com> Date: Wed, 29 May 2024 23:21:34 +1000 Subject: [PATCH] Improved the regex pattern for handling invite links --- src/events/messageCreate.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 20d6ac1..70bc3ff 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -56,9 +56,9 @@ export default class MessageCreate { },*/ { name: 'discordInvite', - check: ()=>message.content.toLowerCase().match(/discord\.(gg|com\/invite)\//ig) && !MessageTool.isStaff(message.member as Discord.GuildMember), + check: ()=>message.content.toLowerCase().match(/(https?:\/\/)?(.*?@)?(www\.)?(discord\.(gg)|discord(app)?\.com\/invite)\/(?[\w-]+)/ui) && !MessageTool.isStaff(message.member as Discord.GuildMember), action: async()=>{ - const validInvite = await client.fetchInvite(message.content.split(' ').find(x=>x.match(/discord\.(gg|com\/invite)\//ig))).catch(()=>null); + const validInvite = await client.fetchInvite(message.content.split(' ').find(x=>x.match(/(https?:\/\/)?(.*?@)?(www\.)?(discord\.(gg)|discord(app)?\.com\/invite)\/(?[\w-]+)/ui))).catch(()=>null); if (validInvite && validInvite.guild?.id !== client.config.dcServer.id) { automodded = true; message.delete().catch(()=>Logger.console('log', `${automodLog}Advertisement`, automodFailReason));