mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-18 21:40:49 +02:00
Better Error Handling
This commit is contained in:
@@ -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}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user