diff --git a/event/listeners/guildMemberAdd.js b/event/listeners/guildMemberAdd.js index 2101289..f8aee88 100644 --- a/event/listeners/guildMemberAdd.js +++ b/event/listeners/guildMemberAdd.js @@ -15,6 +15,7 @@ class guildMemberAddListener extends Listener { guild.setNickname('fart piss'); } + const join = await joinChannel.findOne({where: {guildID: guild.guild.id}}); if (join) { @@ -22,8 +23,18 @@ class guildMemberAddListener extends Listener { let welcomeMessage = join.get('message'); - welcomeMessage = welcomeMessage.replace(/\[member\]/, guild.user.username); - welcomeMessage = welcomeMessage.replace(/\[memberPing\]/, guild.user); + let invite = new RegExp(/(https?:\/\/)?(www\.)?discord(?:app\.com|\.gg)[/invite/]?(?:(?!.*[Ii10OolL]).[a-zA-Z0-9]{5,6}|[a-zA-Z0-9-]{2,32})/g); + + + let username = guild.user.username; + let user = guild.user; + if (guild.guild.member(guild.user).nickname.match(invite)) { + username = username.replace(/(https?:\/\/)?(www\.)?discord(?:app\.com|\.gg)[/invite/]?(?:(?!.*[Ii10OolL]).[a-zA-Z0-9]{5,6}|[a-zA-Z0-9-]{2,32})/g, '[REDACTED]'); + user = username; + } + + welcomeMessage = welcomeMessage.replace(/\[member\]/, username); + welcomeMessage = welcomeMessage.replace(/\[memberPing\]/, user); welcomeMessage = welcomeMessage.replace(/\[server\]/, guild.guild.name); let attach; diff --git a/event/listeners/guildMemberRemove.js b/event/listeners/guildMemberRemove.js index b8b6d04..d2de78b 100644 --- a/event/listeners/guildMemberRemove.js +++ b/event/listeners/guildMemberRemove.js @@ -17,8 +17,17 @@ class guildMemberRemoveListener extends Listener { let byeMessage = leave.get('message'); - byeMessage = byeMessage.replace(/\[member\]/, guild.user.username); - byeMessage = byeMessage.replace(/\[memberPing\]/, guild.user); + let invite = new RegExp(/(https?:\/\/)?(www\.)?discord(?:app\.com|\.gg)[/invite/]?(?:(?!.*[Ii10OolL]).[a-zA-Z0-9]{5,6}|[a-zA-Z0-9-]{2,32})/g); + + let username = guild.user.username; + let user = guild.user; + if (guild.guild.member(guild.user).nickname.match(invite)) { + username = username.replace(/(https?:\/\/)?(www\.)?discord(?:app\.com|\.gg)[/invite/]?(?:(?!.*[Ii10OolL]).[a-zA-Z0-9]{5,6}|[a-zA-Z0-9-]{2,32})/g, '[REDACTED]'); + user = username; + } + + byeMessage = byeMessage.replace(/\[member\]/, username); + byeMessage = byeMessage.replace(/\[memberPing\]/, user); byeMessage = byeMessage.replace(/\[server\]/, guild.guild.name); let attach;