mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-21 05:54:33 +02:00
Better Error Handling
This commit is contained in:
@@ -11,7 +11,7 @@ module.exports = class BanCommand extends Command {
|
||||
],
|
||||
group: 'moderation',
|
||||
memberName: 'ban',
|
||||
description: 'Bans a user and logs the ban to the mod_logs.',
|
||||
description: 'Bans a user and logs the ban to the mod logs.',
|
||||
guildOnly: true,
|
||||
args: [
|
||||
{
|
||||
@@ -24,9 +24,8 @@ module.exports = class BanCommand 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.';
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -55,7 +54,7 @@ module.exports = class BanCommand extends Command {
|
||||
Reason: ${reason}.
|
||||
`);
|
||||
} catch(err) {
|
||||
await msg.say('Failed to send DM to user.');
|
||||
await msg.say('Failed to send DM to the user.');
|
||||
}
|
||||
await member.ban({ days: 7, reason });
|
||||
await msg.say(':ok_hand:');
|
||||
@@ -70,7 +69,7 @@ module.exports = class BanCommand extends Command {
|
||||
`);
|
||||
return modlogs.send({ embed });
|
||||
} catch(err) {
|
||||
return msg.say('An Unknown Error Occurred.');
|
||||
return msg.say(`An Error Occurred: ${err}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ module.exports = class KickCommand extends Command {
|
||||
name: 'kick',
|
||||
group: 'moderation',
|
||||
memberName: 'kick',
|
||||
description: 'Kicks a user and logs the kick to the mod_logs.',
|
||||
description: 'Kicks a user and logs the kick to the mod logs.',
|
||||
guildOnly: true,
|
||||
args: [
|
||||
{
|
||||
@@ -21,9 +21,8 @@ module.exports = class KickCommand 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.';
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -67,7 +66,7 @@ module.exports = class KickCommand extends Command {
|
||||
`);
|
||||
return modlogs.send({ embed });
|
||||
} catch(err) {
|
||||
return msg.say('An Unknown Error Occurred.');
|
||||
return msg.say(`An Error Occurred: ${err}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,8 +15,7 @@ module.exports = class LockdownCommand extends Command {
|
||||
prompt: 'Please enter either `start` or `stop`.',
|
||||
type: 'string',
|
||||
validate: type => {
|
||||
if(['start', 'stop'].includes(type.toLowerCase()))
|
||||
return true;
|
||||
if(['start', 'stop'].includes(type.toLowerCase())) return true;
|
||||
return 'Please enter either `start` or `stop`.';
|
||||
},
|
||||
parse: type => type.toLowerCase()
|
||||
@@ -38,17 +37,17 @@ module.exports = class LockdownCommand extends Command {
|
||||
await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: false });
|
||||
return msg.say(stripIndents`
|
||||
Lockdown Started, users without Administrator can no longer post messages.
|
||||
Please use \`;lockdown stop\` to end the lockdown.
|
||||
Please use \`lockdown stop\` to end the lockdown.
|
||||
`);
|
||||
} catch(err) {
|
||||
return msg.say('Something went wrong!');
|
||||
return msg.say(`An Error Occurred: ${err}`);
|
||||
}
|
||||
} else if(type === 'stop') {
|
||||
try {
|
||||
await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: true });
|
||||
return msg.say('Lockdown Ended, users without Administrator can now post messages.');
|
||||
} catch(err) {
|
||||
return msg.say('An Unknown Error Occurred.');
|
||||
return msg.say(`An Error Occurred: ${err}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,8 @@ module.exports = class PruneCommand extends Command {
|
||||
prompt: 'How many messages do you want to delete? Limit of up to 99.',
|
||||
type: 'integer',
|
||||
validate: count => {
|
||||
if(count < 100 && count > 0)
|
||||
return true;
|
||||
return `${count} is not a valid amount of messages. Limit 1-99.`;
|
||||
if(count < 100 && count > 0) return true;
|
||||
return 'Invalid Count. Count must be from 1-99.';
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -8,7 +8,7 @@ module.exports = class SoftbanCommand extends Command {
|
||||
name: 'softban',
|
||||
group: 'moderation',
|
||||
memberName: 'softban',
|
||||
description: 'Kicks a user and deletes their messages, and logs the softban to the mod_logs.',
|
||||
description: 'Kicks a user and deletes their messages, and logs the softban to the mod logs.',
|
||||
guildOnly: true,
|
||||
args: [
|
||||
{
|
||||
@@ -21,9 +21,8 @@ module.exports = class SoftbanCommand 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.';
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -70,7 +69,7 @@ module.exports = class SoftbanCommand extends Command {
|
||||
`);
|
||||
return modlogs.send({ embed });
|
||||
} catch(err) {
|
||||
return msg.say('An Unknown Error Occurred.');
|
||||
return msg.say(`An Error Occurred: ${err}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ module.exports = class UnbanCommand extends Command {
|
||||
],
|
||||
group: 'moderation',
|
||||
memberName: 'unban',
|
||||
description: 'Unbans a user and logs the unban to the mod_logs.',
|
||||
description: 'Unbans a user and logs the unban to the mod logs.',
|
||||
guildOnly: true,
|
||||
args: [
|
||||
{
|
||||
@@ -19,9 +19,8 @@ module.exports = class UnbanCommand extends Command {
|
||||
prompt: 'What member do you want to unban? Please enter the ID of the user.',
|
||||
type: 'string',
|
||||
validate: id => {
|
||||
if(id.length === 18)
|
||||
return true;
|
||||
return `${id} is not a valid ID. Please enter the user you wish to unban's ID.`;
|
||||
if(id.length === 18) return true;
|
||||
return 'Invalid ID.';
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -29,9 +28,8 @@ module.exports = class UnbanCommand 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.';
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -45,7 +43,7 @@ module.exports = class UnbanCommand extends Command {
|
||||
async run(msg, args) {
|
||||
if(!msg.channel.permissionsFor(this.client.user).has('BAN_MEMBERS'))
|
||||
return msg.say('This Command requires the `Ban Members` Permission.');
|
||||
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'))
|
||||
@@ -69,7 +67,7 @@ module.exports = class UnbanCommand extends Command {
|
||||
`);
|
||||
return modlogs.send({ embed });
|
||||
} catch(err) {
|
||||
return msg.say('An Unknown Error Occurred.');
|
||||
return msg.say(`An Error Occurred: ${err}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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