This commit is contained in:
Daniel Odendahl Jr
2017-06-01 08:44:02 +00:00
parent 7802bb49cb
commit 14f85f94bd
129 changed files with 1915 additions and 1720 deletions
+48 -27
View File
@@ -6,11 +6,11 @@ module.exports = class WarnCommand extends Command {
constructor(client) {
super(client, {
name: 'warn',
aliases: ['warnne'],
group: 'moderation',
memberName: 'warn',
description: 'Warns a user and logs the warn to the mod logs.',
guildOnly: true,
allowStaff: true,
userPermissions: ['KICK_MEMBERS'],
args: [
{
@@ -22,9 +22,12 @@ module.exports = class WarnCommand extends Command {
key: 'reason',
prompt: 'What do you want to set the reason as?',
type: 'string',
validate: reason => {
if (reason.length < 140) return true;
return 'Invalid Reason. Reason must be under 140 characters.';
validate: (reason) => {
if (reason.length < 140) {
return true;
} else {
return 'Invalid Reason. Reason must be under 140 characters.';
}
}
}
]
@@ -33,32 +36,50 @@ module.exports = class WarnCommand extends Command {
async run(msg, args) {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
if (!modlogs) return msg.say('This Command requires a channel set with the `mod-channel` command.');
if (!modlogs.permissionsFor(this.client.user).has('SEND_MESSAGES'))
return msg.say('This Command requires the `SEND_MESSAGES` Permission for the Mod Log Channel.');
if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
return msg.say('This Command requires the `EMBED_LINKS` Permission for the Mod Log Channel.');
const { member, reason } = args;
if (!member.kickable) return msg.say('This member is not warnable. Perhaps they have a higher role than me?');
try {
await member.user.send(stripIndents`
You were warned in ${msg.guild.name}!
Reason: ${reason}.
`);
await msg.say(`Are you sure you want to warn ${member.user.tag} (${member.id})?`);
const collected = await msg.channel.awaitMessages((res) => res.author.id === msg.author.id, {
max: 1,
time: 15000,
errors: ['time']
});
if (['y', 'yes'].includes(collected.first().content.toLowerCase())) {
try {
await member.user.send(stripIndents`
You were warned in ${msg.guild.name}!
Reason: ${reason}
`);
} catch (err) {
await msg.say('Failed to Send DM.');
}
await msg.say(`Successfully warned ${member.user.tag}.`);
if (!modlogs || !modlogs.permissionsFor(this.client.user.has('SEND_MESSAGES'))) {
return msg.say('Could not log the warn to the mod logs.');
} else if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return modlogs.send(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Warn
**Reason:** ${reason}
**Moderator:** ${msg.author.tag}
`);
} else {
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFFFF00)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Warn
**Reason:** ${reason}
`);
return modlogs.send({ embed });
}
} else {
return msg.say('Aborting Warn.');
}
} catch (err) {
await msg.say('Failed to Send DM.');
return msg.say('Aborting Warn.');
}
msg.say(':ok_hand:');
const embed = new RichEmbed()
.setAuthor(msg.author.tag, msg.author.displayAvatarURL)
.setColor(0xFFFF00)
.setTimestamp()
.setDescription(stripIndents`
**Member:** ${member.user.tag} (${member.id})
**Action:** Warn
**Reason:** ${reason}
`);
await modlogs.send({ embed });
return null;
}
};