mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-20 14:00:22 +02:00
Rewrite Permission Checks and Validators
This commit is contained in:
@@ -11,9 +11,6 @@ module.exports = class CanYouNotCommand 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('Can YOU not?');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const eastereggs = require('./eastereggs.json');
|
||||
const eastereggs = require('./eastereggs');
|
||||
|
||||
module.exports = class EasterEggCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'easteregg',
|
||||
aliases: [
|
||||
'tag',
|
||||
'easter-egg'
|
||||
'tag'
|
||||
],
|
||||
group: 'random',
|
||||
memberName: 'easteregg',
|
||||
@@ -17,9 +16,8 @@ module.exports = class EasterEggCommand extends Command {
|
||||
prompt: 'What easter egg do you want to view?',
|
||||
type: 'string',
|
||||
validate: tag => {
|
||||
if (eastereggs[tag.toLowerCase()]) {
|
||||
if (eastereggs[tag.toLowerCase()])
|
||||
return true;
|
||||
}
|
||||
return 'Nope, that\'s not a valid easter egg. Try again!';
|
||||
},
|
||||
parse: text => text.toLowerCase()
|
||||
@@ -28,9 +26,6 @@ module.exports = class EasterEggCommand extends Command {
|
||||
}
|
||||
|
||||
run(message, args) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const { tag } = args;
|
||||
return message.say(eastereggs[tag]);
|
||||
}
|
||||
|
||||
@@ -4,10 +4,6 @@ module.exports = class GiveFlowerCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'giveflower',
|
||||
aliases: [
|
||||
'present',
|
||||
'gift'
|
||||
],
|
||||
group: 'random',
|
||||
memberName: 'giveflower',
|
||||
description: 'Gives Xiao Pai a flower.'
|
||||
@@ -15,9 +11,6 @@ module.exports = class GiveFlowerCommand 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('Ooh, what a pretty flower. What, I may have it? Thanks! I like flowers, yes? ♪');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,9 +11,6 @@ module.exports = class LennyCommand 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('( ͡° ͜ʖ ͡°)');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -17,9 +17,6 @@ module.exports = class MathCommand extends Command {
|
||||
}
|
||||
|
||||
run(message, args) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const { expression } = args;
|
||||
try {
|
||||
const solved = math.eval(expression);
|
||||
|
||||
@@ -4,10 +4,6 @@ module.exports = class MotivateCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'motivate',
|
||||
aliases: [
|
||||
'encourage',
|
||||
'justdoit'
|
||||
],
|
||||
group: 'random',
|
||||
memberName: 'motivate',
|
||||
description: 'Motivates something/someone.',
|
||||
@@ -20,9 +16,6 @@ module.exports = class MotivateCommand extends Command {
|
||||
}
|
||||
|
||||
run(message, args) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const { thing } = args;
|
||||
return message.say(`${thing}, https://www.youtube.com/watch?v=ZXsQAXx_ao0`);
|
||||
}
|
||||
|
||||
@@ -12,10 +12,9 @@ module.exports = class NitroCommand 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('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 embed = new RichEmbed()
|
||||
.setAuthor('Discord Nitro')
|
||||
.setThumbnail('https://pbs.twimg.com/profile_images/814184180649197568/y2eZcVMq.jpg')
|
||||
|
||||
@@ -11,9 +11,6 @@ module.exports = class SlowClapCommand 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('*slow clap*');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,10 +11,9 @@ module.exports = class SpamCommand 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!');
|
||||
return message.channel.send({files: ['./images/Spam.jpg']});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5,9 +5,6 @@ module.exports = class StrawpollCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'strawpoll',
|
||||
aliases: [
|
||||
'poll'
|
||||
],
|
||||
group: 'random',
|
||||
memberName: 'strawpoll',
|
||||
description: 'Creates a Strawpoll with your options.',
|
||||
@@ -16,9 +13,8 @@ module.exports = class StrawpollCommand extends Command {
|
||||
prompt: 'What would you like the title of the Strawpoll to be?',
|
||||
type: 'string',
|
||||
validate: title => {
|
||||
if (title.length < 200) {
|
||||
if (title.length < 200)
|
||||
return true;
|
||||
}
|
||||
return `Please keep your title under 200 characters, you have ${title.length}.`;
|
||||
}
|
||||
}, {
|
||||
@@ -27,9 +23,8 @@ module.exports = class StrawpollCommand extends Command {
|
||||
type: 'string',
|
||||
infinite: true,
|
||||
validate: choice => {
|
||||
if (choice.length < 160) {
|
||||
if (choice.length < 160)
|
||||
return true;
|
||||
}
|
||||
return `Please keep your choices under 160 characters each, you have ${choice.length}.`;
|
||||
}
|
||||
}]
|
||||
@@ -37,12 +32,11 @@ module.exports = class StrawpollCommand extends Command {
|
||||
}
|
||||
|
||||
async run(message, args) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const { title, choices } = args;
|
||||
if (choices.length < 2) return message.say(':x: Error! You provided less than two choices!');
|
||||
if (choices.length > 31) return message.say(':x: Error! You provided more than thirty choices!');
|
||||
if (choices.length < 2)
|
||||
return message.say(':x: Error! You provided less than two choices!');
|
||||
if (choices.length > 31)
|
||||
return message.say(':x: Error! You provided more than thirty choices!');
|
||||
try {
|
||||
const { body } = await request
|
||||
.post('https://strawpoll.me/api/v2/polls')
|
||||
|
||||
@@ -6,9 +6,6 @@ module.exports = class TodayCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'today',
|
||||
aliases: [
|
||||
'history'
|
||||
],
|
||||
group: 'random',
|
||||
memberName: 'today',
|
||||
description: 'Tells you what happened today in history.'
|
||||
@@ -16,10 +13,9 @@ module.exports = class TodayCommand 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!');
|
||||
try {
|
||||
const { text } = await request
|
||||
.get('http://history.muffinlabs.com/date')
|
||||
|
||||
@@ -7,7 +7,6 @@ module.exports = class WouldYouRatherCommand extends Command {
|
||||
super(client, {
|
||||
name: 'wouldyourather',
|
||||
aliases: [
|
||||
'would-you-rather',
|
||||
'wyrather'
|
||||
],
|
||||
group: 'random',
|
||||
@@ -17,10 +16,9 @@ module.exports = class WouldYouRatherCommand 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!');
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('http://www.rrrather.com/botapi');
|
||||
|
||||
Reference in New Issue
Block a user