mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 14:19:56 +02:00
Destructuring Args
This commit is contained in:
@@ -16,7 +16,7 @@ module.exports = class BanCommand extends Command {
|
||||
args: [{
|
||||
key: 'member',
|
||||
prompt: 'What member do you want to ban?',
|
||||
type: 'user'
|
||||
type: 'member'
|
||||
}, {
|
||||
key: 'reason',
|
||||
prompt: 'What do you want to set the reason as?',
|
||||
@@ -42,9 +42,7 @@ module.exports = class BanCommand extends Command {
|
||||
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.guild.channels.exists('name', 'mod_logs')) return message.say(':x: Error! Could not find the mod_logs channel! Please create it!');
|
||||
let member = message.guild.member(args.member);
|
||||
if (!member) member = await message.guild.fetchMember(args.member);
|
||||
const reason = args.reason;
|
||||
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?');
|
||||
try {
|
||||
await member.ban(7);
|
||||
|
||||
@@ -13,7 +13,7 @@ module.exports = class KickCommand extends Command {
|
||||
args: [{
|
||||
key: 'member',
|
||||
prompt: 'What member do you want to kick?',
|
||||
type: 'user'
|
||||
type: 'member'
|
||||
}, {
|
||||
key: 'reason',
|
||||
prompt: 'What do you want to set the reason as?',
|
||||
@@ -39,9 +39,7 @@ module.exports = class KickCommand extends Command {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('KICK_MEMBERS')) return message.say(':x: Error! I don\'t have the Kick Members Permission!');
|
||||
}
|
||||
if (!message.guild.channels.exists('name', 'mod_logs')) return message.say(':x: Error! Could not find the mod_logs channel! Please create it!');
|
||||
let member = message.guild.member(args.member);
|
||||
if (!member) member = await message.guild.fetchMember(args.member);
|
||||
const reason = args.reason;
|
||||
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?');
|
||||
try {
|
||||
await member.kick();
|
||||
|
||||
@@ -18,6 +18,9 @@ module.exports = class LockdownCommand extends Command {
|
||||
return true;
|
||||
}
|
||||
return 'Please enter either start or stop.';
|
||||
},
|
||||
parse: text => {
|
||||
return text.toLowerCase();
|
||||
}
|
||||
}]
|
||||
});
|
||||
@@ -32,7 +35,7 @@ module.exports = class LockdownCommand extends Command {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['READ_MESSAGES', 'SEND_MESSAGES'])) return;
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('ADMINISTRATOR')) return message.say(':x: Error! I don\'t have the Administrator permission! This is not given by default, as that\'s quite bad practice. Please give it to me to use the lockdown command!');
|
||||
}
|
||||
const type = args.type.toLowerCase();
|
||||
const { type } = args;
|
||||
if (type === 'start') {
|
||||
try {
|
||||
await message.channel.overwritePermissions(message.guild.defaultRole, {
|
||||
|
||||
@@ -30,6 +30,9 @@ module.exports = class PruneCommand extends Command {
|
||||
return true;
|
||||
}
|
||||
return 'Too many or two few messages to delete. Limit 1-99.';
|
||||
},
|
||||
parse: count => {
|
||||
return count + 1;
|
||||
}
|
||||
}]
|
||||
});
|
||||
@@ -45,7 +48,7 @@ module.exports = class PruneCommand extends Command {
|
||||
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!');
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('MANAGE_MESSAGES')) return message.say(':x: Error! I don\'t have the Manage Messages Permission!');
|
||||
}
|
||||
const count = args.count + 1;
|
||||
const { count } = args;
|
||||
try {
|
||||
const messages = await message.channel.fetchMessages({
|
||||
limit: count
|
||||
|
||||
@@ -48,8 +48,7 @@ module.exports = class UnbanCommand extends Command {
|
||||
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.guild.channels.exists('name', 'mod_logs')) return message.say(':x: Error! Could not find the mod_logs channel! Please create it!');
|
||||
const memberID = args.memberID;
|
||||
const reason = args.reason;
|
||||
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.');
|
||||
const unbanUser = await bans.get(memberID);
|
||||
|
||||
@@ -13,7 +13,7 @@ module.exports = class WarnCommand extends Command {
|
||||
args: [{
|
||||
key: 'member',
|
||||
prompt: 'What member do you want to warn?',
|
||||
type: 'user'
|
||||
type: 'member'
|
||||
}, {
|
||||
key: 'reason',
|
||||
prompt: 'What do you want to set the reason as?',
|
||||
@@ -37,9 +37,7 @@ module.exports = class WarnCommand extends Command {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!');
|
||||
}
|
||||
let member = message.guild.member(args.member);
|
||||
if (!member) member = await message.guild.fetchMember(args.member);
|
||||
const reason = args.reason;
|
||||
const { member, reason } = args;
|
||||
if (!message.guild.channels.exists('name', 'mod_logs')) return message.say(':x: Error! Could not find the mod_logs channel! Please create it!');
|
||||
try {
|
||||
await message.say(':ok_hand:');
|
||||
|
||||
Reference in New Issue
Block a user