mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 22:32:52 +02:00
Rewrite Permission Checks and Validators
This commit is contained in:
@@ -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}`]});
|
||||
}
|
||||
|
||||
@@ -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}`]});
|
||||
}
|
||||
|
||||
@@ -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,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);
|
||||
}
|
||||
|
||||
@@ -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}`]});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user