changed guild to member and added role functionality
This commit is contained in:
parent
3ad46b7950
commit
90d29dd210
1 changed files with 28 additions and 10 deletions
|
@ -10,13 +10,13 @@ class guildMemberAddListener extends Listener {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(guild) {
|
async exec(member) {
|
||||||
if (guild.guild.id == 240843640375607296) {
|
if (member.guild.id == 240843640375607296) {
|
||||||
guild.setNickname('fart piss');
|
member.setNickname('fart piss');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const join = await joinChannel.findOne({where: {guildID: guild.guild.id}});
|
const join = await joinChannel.findOne({where: {guildID: member.guild.id}});
|
||||||
|
|
||||||
if (join) {
|
if (join) {
|
||||||
const channel = this.client.channels.resolve(join.get('channelID'));
|
const channel = this.client.channels.resolve(join.get('channelID'));
|
||||||
|
@ -26,17 +26,18 @@ class guildMemberAddListener extends Listener {
|
||||||
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 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 username = member.user.username;
|
||||||
let user = guild.user;
|
let user = member.user;
|
||||||
if (username.match(invite)) {
|
if (username.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]');
|
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;
|
user = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
welcomeMessage = welcomeMessage.replace(/\[member\]/, username);
|
welcomeMessage = welcomeMessage.replace(/\[member\]/g, username);
|
||||||
welcomeMessage = welcomeMessage.replace(/\[memberPing\]/, user);
|
welcomeMessage = welcomeMessage.replace(/\[memberPing\]/g, user);
|
||||||
welcomeMessage = welcomeMessage.replace(/\[server\]/, guild.guild.name);
|
welcomeMessage = welcomeMessage.replace(/\[server\]/g, member.guild.name);
|
||||||
|
|
||||||
|
// add attachment
|
||||||
let attach;
|
let attach;
|
||||||
if (welcomeMessage.includes('[attach:')) {
|
if (welcomeMessage.includes('[attach:')) {
|
||||||
attach = welcomeMessage.split(/(\[attach:.*?])/);
|
attach = welcomeMessage.split(/(\[attach:.*?])/);
|
||||||
|
@ -49,6 +50,23 @@ class guildMemberAddListener extends Listener {
|
||||||
welcomeMessage = welcomeMessage.replace(/(\[attach:.*?])/, '');
|
welcomeMessage = welcomeMessage.replace(/(\[attach:.*?])/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Give a role
|
||||||
|
let role;
|
||||||
|
if (welcomeMessage.includes('[role:')) {
|
||||||
|
role = welcomeMessage.split(/(\[role:.*?])/);
|
||||||
|
for (let i = 0, l = role.length; i < l; i++) {
|
||||||
|
if (role[i].includes('[role:')) {
|
||||||
|
role = role[i].replace('[role:', '').slice(0, -1);
|
||||||
|
i = role.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const rank = member.guild.roles.cache.find(rank => rank.name === role);
|
||||||
|
member.roles.add(rank);
|
||||||
|
|
||||||
|
welcomeMessage = welcomeMessage.replace(/(\[role:.*?])/, '');
|
||||||
|
}
|
||||||
|
|
||||||
welcomeMessage = rand.random(welcomeMessage);
|
welcomeMessage = rand.random(welcomeMessage);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue