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 -5
View File
@@ -1,5 +1,5 @@
const { Command } = require('discord.js-commando');
const cats = require('./cats.json');
const cats = require('./cats');
module.exports = class CatCommand extends Command {
constructor(client) {
@@ -15,10 +15,9 @@ module.exports = class CatCommand extends Command {
}
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('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!');
}
if (message.channel.type !== 'dm')
if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES'))
return message.say(':x: Error! I don\'t have the Attach Files Permission!');
const cat = cats[Math.floor(Math.random() * cats.length)];
return message.channel.send({files: [`./images/Cat${cat}`]});
}
+4 -5
View File
@@ -1,5 +1,5 @@
const { Command } = require('discord.js-commando');
const potatoes = require('./potatoes.json');
const potatoes = require('./potatoes');
module.exports = class PotatoCommand extends Command {
constructor(client) {
@@ -15,10 +15,9 @@ module.exports = class PotatoCommand extends Command {
}
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('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!');
}
if (message.channel.type !== 'dm')
if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES'))
return message.say(':x: Error! I don\'t have the Attach Files Permission!');
const potato = potatoes[Math.floor(Math.random() * potatoes.length)];
return message.channel.send({files: [`./images/Potato${potato}`]});
}
+4 -5
View File
@@ -1,5 +1,5 @@
const { Command } = require('discord.js-commando');
const puns = require('./puns.json');
const puns = require('./puns');
module.exports = class RandomPunCommand extends Command {
constructor(client) {
@@ -12,10 +12,9 @@ module.exports = class RandomPunCommand extends Command {
}
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('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!');
}
if (message.channel.type !== 'dm')
if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES'))
return message.say(':x: Error! I don\'t have the Attach Files Permission!');
const pun = puns[Math.floor(Math.random() * puns.length)];
return message.channel.send({files: [`./images/Pun${pun}`]});
}
+1 -7
View File
@@ -1,13 +1,10 @@
const { Command } = require('discord.js-commando');
const songs = require('./songs.json');
const songs = require('./songs');
module.exports = class VocaloidCommand extends Command {
constructor(client) {
super(client, {
name: 'vocaloid',
aliases: [
'vocaloidsong'
],
group: 'randomimg',
memberName: 'vocaloid',
description: 'Sends a random VOCALOID song.'
@@ -15,9 +12,6 @@ module.exports = class VocaloidCommand extends Command {
}
run(message) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
const song = songs[Math.floor(Math.random() * songs.length)];
return message.say(song);
}
+4 -5
View File
@@ -1,5 +1,5 @@
const { Command } = require('discord.js-commando');
const xiaos = require('./xiaos.json');
const xiaos = require('./xiaos');
module.exports = class XiaoCommand extends Command {
constructor(client) {
@@ -15,10 +15,9 @@ module.exports = class XiaoCommand extends Command {
}
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('ATTACH_FILES')) return message.say(':x: Error! I don\'t have the Attach Files Permission!');
}
if (message.channel.type !== 'dm')
if (!message.channel.permissionsFor(this.client.user).hasPermission('ATTACH_FILES'))
return message.say(':x: Error! I don\'t have the Attach Files Permission!');
const xiao = xiaos[Math.floor(Math.random() * xiaos.length)];
return message.channel.send({files: [`./images/Xiao${xiao}`]});
}