userPermissions and clientPermissions are in commando now

This commit is contained in:
Daniel Odendahl Jr
2017-09-03 22:26:43 +00:00
parent d50182ea9d
commit 2c12f15e12
2 changed files with 2 additions and 21 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "35.1.6",
"version": "35.1.7",
"description": "Your personal server companion.",
"main": "Shard.js",
"scripts": {
@@ -35,7 +35,7 @@
"common-tags": "^1.4.0",
"custom-translate": "github:dragonfire535/custom-translate",
"discord.js": "github:hydrabolt/discord.js",
"discord.js-commando": "github:dragonfire535/discord.js-commando#test",
"discord.js-commando": "github:gawdl3y/discord.js-commando",
"erlpack": "github:hammerandchisel/erlpack",
"node-opus": "^0.2.6",
"snekfetch": "^3.3.0",
-19
View File
@@ -1,13 +1,10 @@
const { Command } = require('discord.js-commando');
const perms = require('../assets/json/permissions');
class XiaoCommand extends Command {
constructor(client, info) {
super(client, info);
this.ownerOnly = info.ownerOnly;
this.clientPermissions = info.clientPermissions;
this.userPermissions = info.userPermissions;
this.throttling = info.throttling || {
usages: 1,
duration: 2
@@ -18,22 +15,6 @@ class XiaoCommand extends Command {
if (this.ownerOnly && !this.client.isOwner(msg.author)) {
return `The \`${this.name}\` command can only be used by the bot owner.`;
}
if (msg.channel.type === 'text') {
if (this.clientPermissions) {
for (const permission of this.clientPermissions) {
if (!msg.channel.permissionsFor(this.client.user).has(permission)) {
return `The \`${this.name}\` command requires me to have the \`${perms[permission]}\` permission.`;
}
}
}
if (this.userPermissions) {
for (const permission of this.userPermissions) {
if (!msg.channel.permissionsFor(msg.author).has(permission)) {
return `The \`${this.name}\` command requires you to have the \`${perms[permission]}\` permission.`;
}
}
}
}
return true;
}
}