formatting

This commit is contained in:
Alex Brow 2020-03-23 13:00:24 -04:00
parent 0111786fcc
commit 0f4bf40b83
No known key found for this signature in database
GPG Key ID: F48926893F475C25
1 changed files with 35 additions and 36 deletions

View File

@ -27,8 +27,8 @@ client.on("guildCreate", guild => {
client.on('guildMemberAdd', member => {
console.log(`New member joined: ${member.name} (id: ${member.id}).`);
client.user.setActivity(`${client.users.cache.size} of you horrible people`,{ type: 'LISTENING' });
});
client.user.setActivity(`${client.users.cache.size} of you horrible people`,{ type: 'LISTENING' });
client.on('guildMemberRemove', member => {
console.log(` member left: ${member.name} (id: ${member.id}).`);
client.user.setActivity(`${client.users.cache.size} of you horrible people`,{ type: 'LISTENING' });
@ -94,48 +94,47 @@ client.on("message", async message => {
}
}
if(command === "kick") {
// This command must be limited to mods and admins. In this example we just hardcode the role names.
// Please read on Array.some() to understand this bit:
// https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/some?
if(!message.member.roles.cache.some(r=>["Admin", "Moderator","Member of the Order of the b l u e","Botmeister"].includes(r.name)) )
return message.reply("Sorry, you don't have permissions to use this!");
if(command === "kick") {
// This command must be limited to mods and admins. In this example we just hardcode the role names.
// Please read on Array.some() to understand this bit:
// https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/some?
if(!message.member.roles.cache.some(r=>["Admin", "Moderator","Member of the Order of the b l u e","Botmeister"].includes(r.name)) )
return message.reply("Sorry, you don't have permissions to use this!");
// Let's first check if we have a member and if we can kick them!
// message.mentions.members is a collection of people that have been mentioned, as GuildMembers.
// We can also support getting the member by ID, which would be args[0]
let member = message.mentions.members.first() || message.guild.members.get(args[0]);
if(!member)
return message.reply("Please mention a valid member of this server");
if(!member.kickable)
return message.reply("I cannot kick this user! Do they have a higher role? Do I have kick permissions?");
// Let's first check if we have a member and if we can kick them!
// message.mentions.members is a collection of people that have been mentioned, as GuildMembers.
// We can also support getting the member by ID, which would be args[0]
let member = message.mentions.members.first() || message.guild.members.get(args[0]);
if(!member)
return message.reply("Please mention a valid member of this server");
if(!member.kickable)
return message.reply("I cannot kick this user! Do they have a higher role? Do I have kick permissions?");
// slice(1) removes the first part, which here should be the user mention or ID
// join(' ') takes all the various parts to make it a single string.
let reason = args.slice(1).join(' ');
if(!reason) reason = "No reason provided";
// Now, time for a swift kick in the nuts!
await member.kick(reason)
.catch(error => message.reply(`Sorry ${message.author} I couldn't kick because of : ${error}`));
message.reply(`${member.user.tag} has been kicked by ${message.author.tag} because: ${reason}`);
// slice(1) removes the first part, which here should be the user mention or ID
// join(' ') takes all the various parts to make it a single string.
let reason = args.slice(1).join(' ');
if(!reason) reason = "No reason provided";
// Now, time for a swift kick in the nuts!
await member.kick(reason)
.catch(error => message.reply(`Sorry ${message.author} I couldn't kick because of : ${error}`));
message.reply(`${member.user.tag} has been kicked by ${message.author.tag} because: ${reason}`);
}
if(command === "ban") {
// Most of this command is identical to kick, except that here we'll only let admins do it.
// In the real world mods could ban too, but this is just an example, right? ;)
if(!message.member.roles.cache.some(r=>["Administrator","Member of the Order of the b l u e"].includes(r.name)) )
return message.reply("Sorry, you don't have permissions to use this!");
if(command === "ban") {
// Most of this command is identical to kick, except that here we'll only let admins do it.
// In the real world mods could ban too, but this is just an example, right? ;)
if(!message.member.roles.cache.some(r=>["Administrator","Member of the Order of the b l u e"].includes(r.name)) )
return message.reply("Sorry, you don't have permissions to use this!");
let member = message.mentions.members.first();
if(!member)
return message.reply("Please mention a valid member of this server");
if(!member.bannable)
return message.reply("I cannot ban this user! Do they have a higher role? Do I have ban permissions?");
let member = message.mentions.members.first();
if(!member)
return message.reply("Please mention a valid member of this server");
if(!member.bannable)
return message.reply("I cannot ban this user! Do they have a higher role? Do I have ban permissions?");
let reason = args.slice(1).join(' ');
if(!reason) reason = "No reason provided";
let reason = args.slice(1).join(' ');
if(!reason) reason = "No reason provided";
await member.ban(reason)
.catch(error => message.reply(`Sorry ${message.author} I couldn't ban because of : ${error}`));