mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 14:19:11 +02:00
A variety of fixes and a change in the way errors are handled.
This commit is contained in:
@@ -36,16 +36,21 @@ module.exports = class BanCommand extends Command {
|
||||
|
||||
async run(message, args) {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('BAN_MEMBERS'))
|
||||
return message.say(':x: Error! I don\'t have the Ban Members Permission!');
|
||||
return message.say('This Command requires the `Ban Members` Permission.');
|
||||
const modlogs = message.guild.channels.find('name', 'mod_logs');
|
||||
if (!modlogs)
|
||||
return message.say(':x: Error! Could not find the mod_logs channel! Please create it!');
|
||||
return message.say('This Command requires a channel named `mod_logs`.');
|
||||
if (!modlogs.permissionsFor(this.client.user).hasPermission('EMBED_LINKS'))
|
||||
return message.say(':x: Error! I don\'t have the Embed Links Permission!');
|
||||
return message.say('This Command requires the `Embed Links` Permission.');
|
||||
const { member, reason } = args;
|
||||
if (!member.bannable)
|
||||
return message.say(':x: Error! This member cannot be banned! Perhaps they have a higher role than me?');
|
||||
return message.say('This member is not bannable. Perhaps they have a higher role than me?');
|
||||
try {
|
||||
try {
|
||||
await member.send(`You were banned from ${message.guild.name}!\nReason: ${reason}.`);
|
||||
} catch (err) {
|
||||
await message.say('Failed to send DM to user.');
|
||||
}
|
||||
await member.ban(7);
|
||||
await message.say(':ok_hand:');
|
||||
const embed = new RichEmbed()
|
||||
@@ -55,7 +60,7 @@ module.exports = class BanCommand extends Command {
|
||||
.setDescription(`**Member:** ${member.user.tag} (${member.id})\n**Action:** Ban\n**Reason:** ${reason}`);
|
||||
return modlogs.send({embed});
|
||||
} catch (err) {
|
||||
return message.say(':x: Error! Something went wrong!');
|
||||
return message.say('An Unknown Error Occurred.');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -32,17 +32,22 @@ module.exports = class KickCommand extends Command {
|
||||
}
|
||||
|
||||
async run(message, args) {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('BAN_MEMBERS'))
|
||||
return message.say(':x: Error! I don\'t have the Ban Members Permission!');
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('KICK_MEMBERS'))
|
||||
return message.say('This Command requires the `Kick Members` Permission.');
|
||||
const modlogs = message.guild.channels.find('name', 'mod_logs');
|
||||
if (!modlogs)
|
||||
return message.say(':x: Error! Could not find the mod_logs channel! Please create it!');
|
||||
return message.say('This Command requires a channel named `mod_logs`.');
|
||||
if (!modlogs.permissionsFor(this.client.user).hasPermission('EMBED_LINKS'))
|
||||
return message.say(':x: Error! I don\'t have the Embed Links Permission!');
|
||||
return message.say('This Command requires the `Embed Links` Permission.');
|
||||
const { member, reason } = args;
|
||||
if (!member.bannable)
|
||||
return message.say(':x: Error! This member cannot be kicked! Perhaps they have a higher role than me?');
|
||||
if (!member.kickable)
|
||||
return message.say('This member is not kickable. Perhaps they have a higher role than me?');
|
||||
try {
|
||||
try {
|
||||
await member.send(`You were kicked from ${message.guild.name}!\nReason: ${reason}.`);
|
||||
} catch (err) {
|
||||
await message.say('Failed to send DM.');
|
||||
}
|
||||
await member.kick();
|
||||
await message.say(':ok_hand:');
|
||||
const embed = new RichEmbed()
|
||||
@@ -52,7 +57,7 @@ module.exports = class KickCommand extends Command {
|
||||
.setDescription(`**Member:** ${member.user.tag} (${member.id})\n**Action:** Kick\n**Reason:** ${reason}`);
|
||||
return modlogs.send({embed});
|
||||
} catch (err) {
|
||||
return message.say(':x: Error! Something went wrong!');
|
||||
return message.say('An Unknown Error Occurred.');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -6,11 +6,11 @@ module.exports = class LockdownCommand extends Command {
|
||||
name: 'lockdown',
|
||||
group: 'moderation',
|
||||
memberName: 'lockdown',
|
||||
description: 'Locks down the current channel or removes a lockdown, which prevents non-roled members from speaking.',
|
||||
description: 'Locks down the current channel or removes a lockdown, which prevents non-administrator members from speaking.',
|
||||
guildOnly: true,
|
||||
args: [{
|
||||
key: 'type',
|
||||
prompt: 'Please enter either start or stop.',
|
||||
prompt: 'Please enter either `start` or `stop`.',
|
||||
type: 'string',
|
||||
validate: type => {
|
||||
if (['start', 'stop'].includes(type.toLowerCase()))
|
||||
@@ -28,25 +28,25 @@ module.exports = class LockdownCommand extends Command {
|
||||
|
||||
async run(message, args) {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('ADMINISTRATOR'))
|
||||
return message.say(':x: Error! I don\'t have the Administrator Permission!');
|
||||
return message.say('This Command requires the `Administrator` Permission.');
|
||||
const { type } = args;
|
||||
if (type === 'start') {
|
||||
try {
|
||||
await message.channel.overwritePermissions(message.guild.defaultRole, {
|
||||
SEND_MESSAGES: false
|
||||
});
|
||||
return message.say('**Lockdown Started, users without Administrator can no longer post messages. Please use `;lockdown stop` to end the lockdown.**');
|
||||
return message.say('Lockdown Started, users without Administrator can no longer post messages. Please use `;lockdown stop` to end the lockdown.');
|
||||
} catch (err) {
|
||||
return message.say(':x: Error! Something went wrong!');
|
||||
return message.say('Something went wrong!');
|
||||
}
|
||||
} else if (type === 'stop') {
|
||||
try {
|
||||
await message.channel.overwritePermissions(message.guild.defaultRole, {
|
||||
SEND_MESSAGES: true
|
||||
});
|
||||
return message.say('**Lockdown Ended, users without Administrator can now post messages.**');
|
||||
return message.say('Lockdown Ended, users without Administrator can now post messages.');
|
||||
} catch (err) {
|
||||
return message.say(':x: Error! Something went wrong!');
|
||||
return message.say('An Unknown Error Occurred.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ module.exports = class PruneCommand extends Command {
|
||||
|
||||
async run(message, args) {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGE_HISTORY'))
|
||||
return message.say(':x: Error! I don\'t have the Read Message History Permission!');
|
||||
return message.say('This Command requires the `Read Message History` Permission.');
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('MANAGE_MESSAGES'))
|
||||
return message.say(':x: Error! I don\'t have the Manage Messages Permission!');
|
||||
return message.say('This Command requires the `Manage Messages` Permission.');
|
||||
let { count } = args;
|
||||
count = count + 1;
|
||||
try {
|
||||
@@ -43,7 +43,7 @@ module.exports = class PruneCommand extends Command {
|
||||
await message.channel.bulkDelete(messages, true);
|
||||
return null;
|
||||
} catch (err) {
|
||||
return message.say(':x: Error! Something went wrong! Perhaps there are not enough messages in the channel from earlier than two weeks?');
|
||||
return message.say('There are no messages younger than two weeks that can be deleted.');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -40,16 +40,16 @@ module.exports = class UnbanCommand extends Command {
|
||||
|
||||
async run(message, args) {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('BAN_MEMBERS'))
|
||||
return message.say(':x: Error! I don\'t have the Ban Members Permission!');
|
||||
return message.say('This Command requires the `Ban Members` Permission.');
|
||||
const modlogs = message.guild.channels.find('name', 'mod_logs');
|
||||
if (!modlogs)
|
||||
return message.say(':x: Error! Could not find the mod_logs channel! Please create it!');
|
||||
return message.say('This Command requires a channel named `mod_logs`.');
|
||||
if (!modlogs.permissionsFor(this.client.user).hasPermission('EMBED_LINKS'))
|
||||
return message.say(':x: Error! I don\'t have the Embed Links Permission!');
|
||||
return message.say('This Command requires the `Embed Links` Permission.');
|
||||
const { memberID, reason } = args;
|
||||
const bans = await message.guild.fetchBans();
|
||||
if (!bans.has(memberID))
|
||||
return message.say(':x: Error! Could not find this user in the bans.');
|
||||
return message.say('This ID is not in the Guild Banlist.');
|
||||
const unbanUser = await bans.get(memberID);
|
||||
try {
|
||||
await message.guild.unban(unbanUser);
|
||||
@@ -61,7 +61,7 @@ module.exports = class UnbanCommand extends Command {
|
||||
.setDescription(`**Member:** ${unbanUser.tag} (${unbanUser.id})\n**Action:** Unban\n**Reason:** ${reason}`);
|
||||
return modlogs.send({embed});
|
||||
} catch (err) {
|
||||
return message.say(':x: Error! Something went wrong!');
|
||||
return message.say('An Unknown Error Occurred.');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -31,13 +31,11 @@ module.exports = class WarnCommand extends Command {
|
||||
}
|
||||
|
||||
async run(message, args) {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('BAN_MEMBERS'))
|
||||
return message.say(':x: Error! I don\'t have the Ban Members Permission!');
|
||||
const modlogs = message.guild.channels.find('name', 'mod_logs');
|
||||
if (!modlogs)
|
||||
return message.say(':x: Error! Could not find the mod_logs channel! Please create it!');
|
||||
return message.say('This Command requires a channel named `mod_logs`.');
|
||||
if (!modlogs.permissionsFor(this.client.user).hasPermission('EMBED_LINKS'))
|
||||
return message.say(':x: Error! I don\'t have the Embed Links Permission!');
|
||||
return message.say('This Command requires the `Embed Links` Permission.');
|
||||
const { member, reason } = args;
|
||||
try {
|
||||
await message.say(':ok_hand:');
|
||||
@@ -48,7 +46,7 @@ module.exports = class WarnCommand extends Command {
|
||||
.setDescription(`**Member:** ${member.user.tag} (${member.id})\n**Action:** Warn\n**Reason:** ${reason}`);
|
||||
return modlogs.send({embed});
|
||||
} catch (err) {
|
||||
return message.say(':x: Error! Something went wrong!');
|
||||
return message.say('An Unknown Error Occurred.');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user