woomy/src/events/guildMemberAdd.js
2020-03-09 12:11:33 +11:00

94 lines
3.1 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module.exports = async (client, member) => {
const settings = client.getSettings(member.guild.id);
if (settings.welcomeMessage !== "off") {
let chanExists = member.guild.channels.cache.get(settings.welcomeChannel)
if (!chanExists) {
return;
};
welcomeMessage = settings.welcomeMessage.replace("[[user]]", member.user);
welcomeMessage = welcomeMessage.replace("[[server]]", member.guild.name);
welcomeMessage = welcomeMessage.replace("[[members]]", member.guild.memberCount);
member.guild.channels
.cache.get(settings.welcomeChannel)
.send(welcomeMessage)
.catch(console.error);
}
if (settings.autorole !== "off") {
let aRole = member.guild.roles.cache.get(settings.autorole)
if (!aRole) {
return;
};
await member.roles.add(aRole.id).catch(console.error);
};
if(settings.raidMode !== "off") {
if(settings.raidModeStrict == "on") {
member.kick("User bounced.")
if (settings.chatlogsChannel !== "off") {
const channel = member.guild.channels.cache.find(
channel => channel.name === settings.chatlogsChannel
);
if (channel) {
let embed = new Discord.MessageEmbed();
embed.setColor("#1f1f1f");
embed.setAuthor("User bounced:", member.user.avatarURL({dynamic: true}));
embed.setDescription(` User: ${member} (${member.user.id})`, true);
embed.setFooter(`New users are being automatically kicked because raidmode is enabled.`)
try {
channel.send(embed);
} catch (err) {
// probably no permissions to send messages/embeds there
};
};
return;
}
}
let mRole = member.guild.roles.cache.get(settings.mutedRole)
if (!mRole) {
return;
};
await member.roles.add(mRole.id).catch(console.error);
if (settings.chatlogsChannel !== "off") {
const channel = member.guild.channels.cache.find(
channel => channel.name === settings.chatlogsChannel
);
if (channel) {
let embed = new Discord.MessageEmbed();
embed.setColor("#1f1f1f");
embed.setAuthor("User automatically muted:", member.user.avatarURL({dynamic: true}));
embed.setDescription(` User: ${member} (${member.user.id})`, true);
embed.setFooter(`New users are being automatically muted because raidmode is enabled.`)
try {
channel.send(embed);
} catch (err) {
// probably no permissions to send messages/embeds there
};
};
};
};
if (settings.chatlogsChannel !== "off") {
const channel = member.guild.channels.cache.find(
channel => channel.name === settings.chatlogsChannel
);
if (channel) {
let embed = new Discord.MessageEmbed();
embed.setColor("#0099e1");
embed.setAuthor("User joined:", member.user.avatarURL({dynamic: true}));
embed.setDescription(` User: ${member} (${member.user.id})`, true);
try {
channel.send({ embed });
} catch (err) {
// probably no permissions to send messages/embeds there
};
};
};
};