Rewrite Permission Checks and Validators

This commit is contained in:
Daniel Odendahl Jr
2017-04-25 02:37:14 +00:00
parent 9a75ee549b
commit 3ccce0ba66
105 changed files with 248 additions and 581 deletions
+4 -6
View File
@@ -1,6 +1,6 @@
const { Command } = require('discord.js-commando');
const { RichEmbed } = require('discord.js');
const { version } = require('../../package.json');
const { version } = require('../../package');
const moment = require('moment');
require('moment-duration-format');
@@ -9,7 +9,6 @@ module.exports = class InfoCommand extends Command {
super(client, {
name: 'info',
aliases: [
'data',
'information'
],
group: 'util',
@@ -19,10 +18,9 @@ module.exports = class InfoCommand extends Command {
}
async run(message) {
if (message.channel.type !== 'dm') {
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!');
}
if (message.channel.type !== 'dm')
if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS'))
return message.say(':x: Error! I don\'t have the Embed Links Permission!');
const guilds = await this.client.shard.fetchClientValues('guilds.size');
const embed = new RichEmbed()
.setColor(0x00AE86)
-3
View File
@@ -11,9 +11,6 @@ module.exports = class InviteCommand extends Command {
}
async run(message) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
const invite = await this.client.generateInvite('1345846343');
return message.say(`Add me to your server with this link:\n${invite}\nOr, come to my server with this link:\n${this.client.options.invite}`);
}
+6 -9
View File
@@ -1,6 +1,6 @@
const { Command } = require('discord.js-commando');
const { RichEmbed } = require('discord.js');
const { version } = require('../../package.json');
const { version } = require('../../package');
const moment = require('moment');
require('moment-duration-format');
@@ -9,9 +9,6 @@ module.exports = class ShardInfoCommand extends Command {
super(client, {
name: 'shardinfo',
aliases: [
'shard-info',
'shard-data',
'sharddata',
'shard'
],
group: 'util',
@@ -26,12 +23,12 @@ module.exports = class ShardInfoCommand extends Command {
}
async run(message, args) {
if (message.channel.type !== 'dm') {
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!');
}
if (message.channel.type !== 'dm')
if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS'))
return message.say(':x: Error! I don\'t have the Embed Links Permission!');
const { shardID } = args;
if (shardID > this.client.options.shardCount - 1 || shardID < 0) return message.say(':x: Error! Invalid Shard!');
if (shardID > this.client.options.shardCount - 1 || shardID < 0)
return message.say(':x: Error! Invalid Shard!');
const memory = await this.client.shard.broadcastEval('Math.round(process.memoryUsage().heapUsed / 1024 / 1024)');
const uptime = await this.client.shard.fetchClientValues('uptime');
const guilds = await this.client.shard.fetchClientValues('guilds.size');
-3
View File
@@ -13,9 +13,6 @@ module.exports = class UptimeCommand extends Command {
}
run(message) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
return message.say(`I've been active on this shard for: **${moment.duration(this.client.uptime).format('d[ days], h[ hours], m[ minutes, and ]s[ seconds]')}**!`);
}
};