1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-16 20:00:59 -05:00

Improved the regex pattern for handling invite links

This commit is contained in:
toast-ts 2024-05-29 23:21:34 +10:00
parent ed54dc32e7
commit 68fffba887

View File

@ -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)\/(?<code>[\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)\/(?<code>[\w-]+)/ui))).catch(()=>null);
if (validInvite && validInvite.guild?.id !== client.config.dcServer.id) {
automodded = true;
message.delete().catch(()=>Logger.console('log', `${automodLog}Advertisement`, automodFailReason));