Huge Modification to Code

This commit is contained in:
Daniel Odendahl Jr
2017-03-21 19:20:47 +00:00
parent 65bf037068
commit d49fe32bf6
100 changed files with 1541 additions and 2049 deletions
+15 -21
View File
@@ -1,35 +1,29 @@
const commando = require('discord.js-commando');
const Discord = require('discord.js');
class WarnCommand extends commando.Command {
module.exports = class WarnCommand extends commando.Command {
constructor(Client){
super(Client, {
name: 'warn',
name: 'warn',
group: 'moderation',
memberName: 'warn',
description: 'Warns a user. (;warn @User being a jerk **Note: You must have a channel called "mod_logs!"**)',
examples: [";warn @User being a jerk. **Note: You must have a channel called 'mod_logs!**"]
description: 'Warns a user. (;warn @User being a jerk)',
examples: [";warn @User being a jerk."]
});
}
async run(message, args) {
async run(message) {
if(message.channel.type !== 'dm') {
if(!message.channel.permissionsFor(this.client.user).hasPermission('SEND_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGES')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('KICK_MEMBERS')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission('BAN_MEMBERS')) return;
if(!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES', 'EMBED_LINKS'])) return;
}
console.log("[Command] " + message.content);
if (message.channel.type === 'dm') {
message.channel.send(":x: This is a DM!");
if (message.channel.type !== 'dm') {
message.channel.send(":x: Error! This command does not work in DM!");
} else {
let username = message.mentions.users.first();
let userToWarn = message.mentions.users.first();
let reason = message.content.split(" ").slice(2).join(" ");
if (message.mentions.users.size !== 1) {
message.channel.send(":x: Either too many or no members, only mention one person!");
} else {
if(message.member.hasPermission('KICK_MEMBERS')) {
if(message.member.hasPermission('MANAGE_MESSAGES')) {
message.channel.send(":ok_hand:");
if(message.guild.channels.exists("name", "mod_logs")) {
const embed = new Discord.RichEmbed()
@@ -37,17 +31,17 @@ class WarnCommand extends commando.Command {
.setColor(0xFFFF00)
.setFooter('XiaoBot Moderation', this.client.user.avatarURL)
.setTimestamp()
.setDescription('**Member:** ' + username.username + '#' + username.discriminator + ' (' + username.id + ')\n**Action:** Warn\n**Reason:** ' + reason);
.setDescription('**Member:** ' + userToWarn.username + '#' + userToWarn.discriminator + ' (' + userToWarn.id + ')\n**Action:** Warn\n**Reason:** ' + reason);
message.guild.channels.find('name', 'mod_logs').sendEmbed(embed).catch(console.error);
} else {
message.channel.send("**Note: No log will be sent, as there is not a channel named 'mod_logs'. Please create it to use the logging feature.**");
}
} else {
message.channel.send(":x: You don't have the Kick Members Permission!");
message.channel.send(":x: Error! You don't have the Manage Messages Permission!");
}
} else {
message.channel.send(":x: Error! Please mention one user!");
}
}
}
}
module.exports = WarnCommand;
};