mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-22 18:29:14 +02:00
Rewrite Permission Checks and Validators
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const answers = require('./8ballanswers.json');
|
||||
const answers = require('./8ballanswers');
|
||||
|
||||
module.exports = class MagicBallCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -17,9 +17,6 @@ module.exports = class MagicBallCommand extends Command {
|
||||
}
|
||||
|
||||
run(message, args) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const { question } = args;
|
||||
const answer = answers[Math.floor(Math.random() * answers.length)];
|
||||
return message.say(`Question: ${question}\n:8ball: ${answer} :8ball:`);
|
||||
|
||||
@@ -4,9 +4,6 @@ module.exports = class ChooseCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'choose',
|
||||
aliases: [
|
||||
'pick'
|
||||
],
|
||||
group: 'response',
|
||||
memberName: 'choose',
|
||||
description: 'Chooses between things.',
|
||||
@@ -20,9 +17,6 @@ module.exports = class ChooseCommand extends Command {
|
||||
}
|
||||
|
||||
run(message, args) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const { choices } = args;
|
||||
const choice = choices[Math.floor(Math.random() * choices.length)];
|
||||
return message.say(`I choose ${choice}!`);
|
||||
|
||||
@@ -16,9 +16,6 @@ module.exports = class CoinFlipCommand extends Command {
|
||||
}
|
||||
|
||||
run(message) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const coin = sides[Math.floor(Math.random() * sides.length)];
|
||||
return message.say(`It landed on ${coin}!`);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const compliments = require('./compliments.json');
|
||||
const compliments = require('./compliments');
|
||||
|
||||
module.exports = class ComplimentCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -17,9 +17,6 @@ module.exports = class ComplimentCommand 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;
|
||||
const compliment = compliments[Math.floor(Math.random() * compliments.length)];
|
||||
return message.say(`${thing}, ${compliment}`);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const facts = require('./facts.json');
|
||||
const facts = require('./facts');
|
||||
|
||||
module.exports = class FactCoreCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -12,9 +12,6 @@ module.exports = class FactCoreCommand extends Command {
|
||||
}
|
||||
|
||||
run(message) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const fact = facts[Math.floor(Math.random() * facts.length)];
|
||||
return message.say(fact);
|
||||
}
|
||||
|
||||
@@ -5,10 +5,6 @@ module.exports = class FishyCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'fishy',
|
||||
aliases: [
|
||||
'fishing',
|
||||
'fish'
|
||||
],
|
||||
group: 'response',
|
||||
memberName: 'fishy',
|
||||
description: 'Catches a fish.'
|
||||
@@ -16,10 +12,6 @@ module.exports = class FishyCommand extends Command {
|
||||
}
|
||||
|
||||
run(message) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
|
||||
const fish = fishes[Math.floor(Math.random() * fishes.length)];
|
||||
return message.say(`You caught a: ${fish}`);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const fortunes = require('./fortunes.json');
|
||||
const fortunes = require('./fortunes');
|
||||
|
||||
module.exports = class FortuneCookieCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'fortune',
|
||||
aliases: [
|
||||
'fortunecookie'
|
||||
],
|
||||
group: 'response',
|
||||
memberName: 'fortune',
|
||||
description: 'Fortune Cookie.'
|
||||
@@ -15,9 +12,6 @@ module.exports = class FortuneCookieCommand extends Command {
|
||||
}
|
||||
|
||||
run(message) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const fortune = fortunes[Math.floor(Math.random() * fortunes.length)];
|
||||
return message.say(fortune);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { lastNames, maleNames, femaleNames } = require('./names.json');
|
||||
const { lastNames, maleNames, femaleNames } = require('./names');
|
||||
|
||||
module.exports = class RandomNameCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'name',
|
||||
aliases: [
|
||||
'namegen',
|
||||
'randomname'
|
||||
],
|
||||
group: 'response',
|
||||
memberName: 'name',
|
||||
description: 'Generates a random name.',
|
||||
@@ -17,9 +13,8 @@ module.exports = class RandomNameCommand extends Command {
|
||||
prompt: 'Which gender do you want to generate a name for?',
|
||||
type: 'string',
|
||||
validate: gender => {
|
||||
if (gender.toLowerCase() === 'male' || gender.toLowerCase() === 'female') {
|
||||
if (['male', 'female'].includes(gender.toLowerCase()))
|
||||
return true;
|
||||
}
|
||||
return 'Please enter either `male` or `female`.';
|
||||
},
|
||||
parse: text => text.toLowerCase()
|
||||
@@ -28,9 +23,6 @@ module.exports = class RandomNameCommand extends Command {
|
||||
}
|
||||
|
||||
run(message, args) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const { gender } = args;
|
||||
const lastName = lastNames[Math.floor(Math.random() * lastNames.length)];
|
||||
if (gender === 'male') {
|
||||
|
||||
@@ -5,10 +5,6 @@ module.exports = class OffspringCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'offspring',
|
||||
aliases: [
|
||||
'child',
|
||||
'baby'
|
||||
],
|
||||
group: 'response',
|
||||
memberName: 'offspring',
|
||||
description: 'Tells you if your new child is a boy or a girl.'
|
||||
@@ -16,9 +12,6 @@ module.exports = class OffspringCommand extends Command {
|
||||
}
|
||||
|
||||
run(message) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const gender = genders[Math.floor(Math.random() * genders.length)];
|
||||
return message.say(`It's a ${gender}!`);
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ module.exports = class QuantumCoinCommand extends Command {
|
||||
super(client, {
|
||||
name: 'quantumcoin',
|
||||
aliases: [
|
||||
'oddcoin',
|
||||
'brokencoin',
|
||||
'qcoin'
|
||||
],
|
||||
group: 'response',
|
||||
@@ -17,9 +15,6 @@ module.exports = class QuantumCoinCommand extends Command {
|
||||
}
|
||||
|
||||
run(message) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const qcoin = sides[Math.floor(Math.random() * sides.length)];
|
||||
return message.say(`It landed ${qcoin}.`);
|
||||
}
|
||||
|
||||
@@ -19,9 +19,6 @@ module.exports = class RateWaifuCommand extends Command {
|
||||
}
|
||||
|
||||
run(message, args) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const { waifu } = args;
|
||||
const rating = Math.floor(Math.random() * 10) + 1;
|
||||
return message.say(`I'd give ${waifu} a ${rating}/10!`);
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const roasts = require('./roasts.json');
|
||||
const roasts = require('./roasts');
|
||||
|
||||
module.exports = class RoastCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'roast',
|
||||
aliases: [
|
||||
'burn'
|
||||
],
|
||||
group: 'response',
|
||||
memberName: 'roast',
|
||||
description: 'Roasts something/someone.',
|
||||
@@ -20,9 +17,6 @@ module.exports = class RoastCommand 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;
|
||||
const roast = roasts[Math.floor(Math.random() * roasts.length)];
|
||||
return message.say(`${thing}, ${roast}`);
|
||||
|
||||
@@ -5,7 +5,6 @@ module.exports = class RollCommand extends Command {
|
||||
super(client, {
|
||||
name: 'roll',
|
||||
aliases: [
|
||||
'randomnumber',
|
||||
'dice'
|
||||
],
|
||||
group: 'response',
|
||||
@@ -20,9 +19,6 @@ module.exports = class RollCommand extends Command {
|
||||
}
|
||||
|
||||
run(message, args) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const { value } = args;
|
||||
const roll = Math.floor(Math.random() * value) + 1;
|
||||
return message.say(`You rolled a ${roll}.`);
|
||||
|
||||
@@ -4,12 +4,6 @@ module.exports = class RouletteCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'roulette',
|
||||
aliases: [
|
||||
'randommember',
|
||||
'randomuser',
|
||||
'pickmember',
|
||||
'pickuser'
|
||||
],
|
||||
group: 'response',
|
||||
memberName: 'roulette',
|
||||
description: 'Chooses a random member in the server.',
|
||||
@@ -18,9 +12,6 @@ module.exports = class RouletteCommand 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 choose ${message.guild.members.random().displayName}!`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,9 +19,6 @@ module.exports = class ShipCommand extends Command {
|
||||
}
|
||||
|
||||
run(message, args) {
|
||||
if (message.channel.type !== 'dm') {
|
||||
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
|
||||
}
|
||||
const { things } = args;
|
||||
const percentage = Math.floor(Math.random() * 100) + 1;
|
||||
return message.say(`I'd give ${things} a ${percentage}%!`);
|
||||
|
||||
Reference in New Issue
Block a user