mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 06:42:51 +02:00
Rewrite Permission Checks and Validators
This commit is contained in:
@@ -13,9 +13,8 @@ module.exports = class LockdownCommand extends Command {
|
||||
prompt: 'Please enter either start or stop.',
|
||||
type: 'string',
|
||||
validate: type => {
|
||||
if (type.toLowerCase() === 'start' || type.toLowerCase() === 'stop') {
|
||||
if (['start', 'stop'].includes(type.toLowerCase()))
|
||||
return true;
|
||||
}
|
||||
return 'Please enter either `start` or `stop`.';
|
||||
},
|
||||
parse: text => text.toLowerCase()
|
||||
@@ -28,10 +27,8 @@ module.exports = class LockdownCommand extends Command {
|
||||
}
|
||||
|
||||
async run(message, args) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
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!');
|
||||
}
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission('ADMINISTRATOR'))
|
||||
return message.say(':x: Error! I don\'t have the Administrator Permission!');
|
||||
const { type } = args;
|
||||
if (type === 'start') {
|
||||
try {
|
||||
@@ -42,8 +39,7 @@ module.exports = class LockdownCommand extends Command {
|
||||
} catch (err) {
|
||||
return message.say(':x: Error! Something went wrong!');
|
||||
}
|
||||
}
|
||||
if (type === 'stop') {
|
||||
} else if (type === 'stop') {
|
||||
try {
|
||||
await message.channel.overwritePermissions(message.guild.defaultRole, {
|
||||
SEND_MESSAGES: true
|
||||
|
||||
Reference in New Issue
Block a user