Better Error Handling

This commit is contained in:
Daniel Odendahl Jr
2017-05-05 21:37:30 +00:00
parent d8a773958d
commit 13cbd23f2f
54 changed files with 120 additions and 156 deletions
+5 -6
View File
@@ -8,7 +8,7 @@ module.exports = class WarnCommand extends Command {
name: 'warn',
group: 'moderation',
memberName: 'warn',
description: 'Warns a user and logs the warn to the mod_logs.',
description: 'Warns a user and logs the warn to the mod logs.',
guildOnly: true,
args: [
{
@@ -21,9 +21,8 @@ module.exports = class WarnCommand extends Command {
prompt: 'What do you want to set the reason as?',
type: 'string',
validate: reason => {
if(reason.length < 140)
return true;
return `Please keep your reason under 140 characters, you have ${reason.length}.`;
if(reason.length < 140) return true;
return 'Invalid Reason. Reason must be under 140 characters.';
}
}
]
@@ -35,7 +34,7 @@ module.exports = class WarnCommand extends Command {
}
async run(msg, args) {
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog', 'mod_logs'));
const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog'));
if(!modlogs)
return msg.say('This Command requires a channel set with the `modchannel` command.');
if(!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS'))
@@ -54,7 +53,7 @@ module.exports = class WarnCommand extends Command {
`);
return modlogs.send({ embed });
} catch(err) {
return msg.say('An Unknown Error Occurred.');
return msg.say(`An Error Occurred: ${err}`);
}
}
};