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
+3 -4
View File
@@ -20,10 +20,9 @@ module.exports = class YearsCommand 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('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 { user } = args;
const userAvatar = user.displayAvatarURL.replace('.jpg', '.png').replace('.gif', '.png');
let images = [];
+3 -4
View File
@@ -20,10 +20,9 @@ module.exports = class BeautifulCommand 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('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 { user } = args;
const userAvatar = user.displayAvatarURL.replace('.jpg', '.png').replace('.gif', '.png');
let images = [];
+3 -5
View File
@@ -6,7 +6,6 @@ module.exports = class BobRossCommand extends Command {
super(client, {
name: 'bobross',
aliases: [
'bob',
'ross'
],
group: 'avataredit',
@@ -21,10 +20,9 @@ module.exports = class BobRossCommand 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('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 { user } = args;
const userAvatar = user.displayAvatarURL.replace('.jpg', '.png').replace('.gif', '.png');
const blank = new Jimp(600, 775, 0xFFFFFF);
+3 -4
View File
@@ -21,10 +21,9 @@ module.exports = class RIPCommand 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('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 { user } = args;
const userAvatar = user.displayAvatarURL.replace('.jpg', '.png').replace('.gif', '.png');
let images = [];
+6 -4
View File
@@ -5,6 +5,9 @@ module.exports = class SteamCardCommand extends Command {
constructor(client) {
super(client, {
name: 'steamcard',
aliases: [
'card'
],
group: 'avataredit',
memberName: 'steamcard',
description: 'Put an avatar on a Steam Card.',
@@ -17,10 +20,9 @@ module.exports = class SteamCardCommand 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('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 { user } = args;
const username = message.guild ? message.guild.member(user).displayName : user.username;
const userAvatar = user.displayAvatarURL.replace('.jpg', '.png').replace('.gif', '.png');
-3
View File
@@ -11,9 +11,6 @@ module.exports = class LotteryCommand extends Command {
}
run(message) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
const lottery = Math.floor(Math.random() * 100) + 1;
if (lottery < 99) return message.say(`Nope, sorry ${message.author.username}, you lost.`);
return message.say(`Wow ${message.author.username}! You actually won! Great job!`);
+9 -8
View File
@@ -12,13 +12,12 @@ module.exports = class MathGameCommand extends Command {
description: 'See how fast you can answer a math problem in a given time limit.',
args: [{
key: 'difficulty',
prompt: 'What difficulty should the math game be? easy, medium, hard, or extreme?',
prompt: 'What should the difficulty of the math game be? Easy, Medium, Hard, Extreme, or Impossible?',
type: 'string',
validate: difficulty => {
if (difficulty.toLowerCase() === 'easy' || difficulty.toLowerCase() === 'medium' || difficulty.toLowerCase() === 'hard' || difficulty.toLowerCase() === 'extreme') {
if (['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase()))
return true;
}
return 'Please set the difficulty to either `easy`, `medium`, `hard`, or `extreme`.';
return 'Please set the difficulty to either `easy`, `medium`, `hard`, `extreme`, or `impossible`.';
},
parse: text => text.toLowerCase()
}]
@@ -26,10 +25,9 @@ module.exports = class MathGameCommand 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 { difficulty } = args;
const operation = operations[Math.floor(Math.random() * operations.length)];
let value;
@@ -46,6 +44,9 @@ module.exports = class MathGameCommand extends Command {
case 'extreme':
value = 1000;
break;
case 'impossible':
value = 10000;
break;
}
const value1 = Math.floor(Math.random() * value) + 1;
const value2 = Math.floor(Math.random() * value) + 1;
+3 -4
View File
@@ -16,10 +16,9 @@ module.exports = class QuizCommand 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://jservice.io/api/random?count=1');
+20 -16
View File
@@ -6,8 +6,7 @@ module.exports = class RockPaperScissorsCommand extends Command {
super(client, {
name: 'rps',
aliases: [
'rockpaperscissors',
'rock-paper-scissors'
'rockpaperscissors'
],
group: 'games',
memberName: 'rps',
@@ -17,9 +16,8 @@ module.exports = class RockPaperScissorsCommand extends Command {
prompt: 'Rock, Paper, or Scissors?',
type: 'string',
validate: rps => {
if (rps.toLowerCase() === 'rock' || rps.toLowerCase() === 'paper' || rps.toLowerCase() === 'scissors') {
if (['rock', 'paper', 'scissors'].includes(rps.toLowerCase()))
return true;
}
return 'Please enter either `rock`, `paper`, or `scissors`.';
},
parse: text => text.toLowerCase()
@@ -28,23 +26,29 @@ module.exports = class RockPaperScissorsCommand extends Command {
}
run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
const { choice } = args;
const response = responses[Math.floor(Math.random() * responses.length)];
if (choice === 'rock') {
if (response === 'Rock') return message.say('Rock! Aw, it\'s a tie!');
if (response === 'Paper') return message.say('Paper! Yes! I win!');
if (response === 'Scissors') return message.say('Scissors! Aw... I lose...');
if (response === 'Rock')
return message.say('Rock! Aw, it\'s a tie!');
if (response === 'Paper')
return message.say('Paper! Yes! I win!');
if (response === 'Scissors')
return message.say('Scissors! Aw... I lose...');
} else if (choice === 'paper') {
if (response === 'Rock') return message.say('Rock! Aw... I lose...');
if (response === 'Paper') return message.say('Paper! Aw, it\'s a tie!');
if (response === 'Scissors') return message.say('Scissors! Yes! I win!');
if (response === 'Rock')
return message.say('Rock! Aw... I lose...');
if (response === 'Paper')
return message.say('Paper! Aw, it\'s a tie!');
if (response === 'Scissors')
return message.say('Scissors! Yes! I win!');
} else if (choice === 'scissors') {
if (response === 'Rock') return message.say('Rock! Yes! I win!');
if (response === 'Paper') return message.say('Paper! Aw... I lose...');
if (response === 'Scissors') return message.say('Scissors! Aw, it\'s a tie!');
if (response === 'Rock')
return message.say('Rock! Yes! I win!');
if (response === 'Paper')
return message.say('Paper! Aw... I lose...');
if (response === 'Scissors')
return message.say('Scissors! Aw, it\'s a tie!');
}
}
};
+1 -5
View File
@@ -12,15 +12,11 @@ module.exports = class SlotsCommand extends Command {
}
run(message) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
const slotOne = slotThing[Math.floor(Math.random() * slotThing.length)];
const slotTwo = slotThing[Math.floor(Math.random() * slotThing.length)];
const slotThree = slotThing[Math.floor(Math.random() * slotThing.length)];
if (slotOne === slotTwo && slotOne === slotThree) {
if (slotOne === slotTwo && slotOne === slotThree)
return message.say(`${slotOne}|${slotTwo}|${slotThree}\nWow! You won! Great job... er... luck!`);
}
return message.say(`${slotOne}|${slotTwo}|${slotThree}\nAww... You lost... Guess it's just bad luck, huh?`);
}
};
+11 -9
View File
@@ -1,6 +1,6 @@
const { Command } = require('discord.js-commando');
const { RichEmbed } = require('discord.js');
const sentences = require('./sentences.json');
const sentences = require('./sentences');
module.exports = class TypingGameCommand extends Command {
constructor(client) {
@@ -11,13 +11,12 @@ module.exports = class TypingGameCommand extends Command {
description: 'See how fast you can type a sentence in a given time limit.',
args: [{
key: 'difficulty',
prompt: 'What difficulty should the typing game be? Easy, Medium, Hard, or Extreme?',
prompt: 'What should the difficulty of the typing game be? Easy, Medium, Hard, Extreme, or Impossible?',
type: 'string',
validate: difficulty => {
if (difficulty.toLowerCase() === 'easy' || difficulty.toLowerCase() === 'medium' || difficulty.toLowerCase() === 'hard' || difficulty.toLowerCase() === 'extreme') {
if (['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase()))
return true;
}
return 'Please set the difficulty to either `easy`, `medium`, `hard`, or `extreme`.';
return 'Please set the difficulty to either `easy`, `medium`, `hard`, `extreme`, or `impossible`.';
},
parse: text => text.toLowerCase()
}]
@@ -25,10 +24,9 @@ module.exports = class TypingGameCommand 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 { difficulty } = args;
const sentence = sentences[Math.floor(Math.random() * sentences.length)];
let time;
@@ -50,6 +48,10 @@ module.exports = class TypingGameCommand extends Command {
time = 10000;
levelWord = 'ten';
break;
case 'impossible':
time = 5000;
levelWord = 'five';
break;
}
const embed = new RichEmbed()
.setTitle(`You have **${levelWord}** seconds to type:`)
-8
View File
@@ -4,11 +4,6 @@ module.exports = class EmojiCommand extends Command {
constructor(client) {
super(client, {
name: 'emoji',
aliases: [
'emoticons',
'emojilist',
'emoticonlist'
],
group: 'guildinfo',
memberName: 'emoji',
description: 'Gives a list of the current server\'s custom emoji.',
@@ -17,9 +12,6 @@ module.exports = class EmojiCommand 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(message.guild.emojis.map(e => e).join('')).catch(() => message.say(':x: Error! Perhaps you have no custom emoji?'));
}
};
+2 -4
View File
@@ -20,10 +20,8 @@ module.exports = class GuildInfoCommand 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.permissionsFor(this.client.user).hasPermission('EMBED_LINKS'))
return message.say(':x: Error! I don\'t have the Embed Links Permission!');
const embed = new RichEmbed()
.setColor(0x00AE86)
.setThumbnail(message.guild.iconURL)
+9 -15
View File
@@ -1,13 +1,10 @@
const { Command } = require('discord.js-commando');
const memecodes = require('./memecodes.json');
const memecodes = require('./memecodes');
module.exports = class MemeCommand extends Command {
constructor(client) {
super(client, {
name: 'meme',
aliases: [
'memegen'
],
group: 'imageedit',
memberName: 'meme',
description: 'Sends a Meme with text of your choice, and a background of your choice.',
@@ -17,9 +14,8 @@ module.exports = class MemeCommand extends Command {
prompt: 'What meme type do you want to use?',
type: 'string',
validate: type => {
if (memecodes.includes(type.toLowerCase())) {
if (memecodes.includes(type.toLowerCase()))
return true;
}
return `${type.toLowerCase()} is not a valid meme type. Use \`x;help meme\` to view a list of types.`;
},
parse: text => text.toLowerCase()
@@ -28,10 +24,9 @@ module.exports = class MemeCommand extends Command {
prompt: 'What should the top row of the meme to be?',
type: 'string',
validate: toprow => {
if (toprow.match(/^[a-zA-Z0-9.,!?'\s]+$/) && toprow.length < 100) {
if (/[a-zA-Z0-9.,!?'\s]+$/g.test(toprow) && toprow.length < 100)
return true;
}
return `Please do not use special characters and keep the rows under 100 characters each, you have ${toprow.length}.`;
return `Please do not use special characters and keep the rows under 100 characters each, top row has ${toprow.length}.`;
},
parse: text => text.replace(/[ ]/g, '-').replace(/[?]/g, '~q')
}, {
@@ -39,10 +34,9 @@ module.exports = class MemeCommand extends Command {
prompt: 'What should the bottom row of the meme to be?',
type: 'string',
validate: bottomrow => {
if (bottomrow.match(/^[a-zA-Z0-9.,!?'\s]+$/) && bottomrow.length < 100) {
if (/[a-zA-Z0-9.,!?'\s]+$/g.test(bottomrow) && bottomrow.length < 100)
return true;
}
return `Please do not use special characters and keep the rows under 100 characters each, you have ${bottomrow.length}.`;
return `Please do not use special characters and keep the rows under 100 characters each, bottom row has ${bottomrow.length}.`;
},
parse: text => text.replace(/[ ]/g, '-').replace(/[?]/g, '~q')
}]
@@ -50,9 +44,9 @@ module.exports = class MemeCommand extends Command {
}
run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
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 { type, toprow, bottomrow } = args;
return message.channel.send({files: [`https://memegen.link/${type}/${toprow}/${bottomrow}.jpg`]});
}
+10 -8
View File
@@ -35,14 +35,16 @@ module.exports = class BanCommand 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.permissionsFor(this.client.user).hasPermission('BAN_MEMBERS')) return message.say(':x: Error! I don\'t have the Ban Members Permission!');
}
if (!message.guild.channels.exists('name', 'mod_logs')) return message.say(':x: Error! Could not find the mod_logs channel! Please create it!');
if (!message.channel.permissionsFor(this.client.user).hasPermission('BAN_MEMBERS'))
return message.say(':x: Error! I don\'t have the Ban Members Permission!');
const modlogs = message.guild.channels.find('name', 'mod_logs');
if (!modlogs)
return message.say(':x: Error! Could not find the mod_logs channel! Please create it!');
if (!modlogs.permissionsFor(this.client.user).hasPermission('EMBED_LINKS'))
return message.say(':x: Error! I don\'t have the Embed Links Permission!');
const { member, reason } = args;
if (!member.bannable) return message.say(':x: Error! This member cannot be banned! Perhaps they have a higher role than me?');
if (!member.bannable)
return message.say(':x: Error! This member cannot be banned! Perhaps they have a higher role than me?');
try {
await member.ban(7);
await message.say(':ok_hand:');
@@ -51,7 +53,7 @@ module.exports = class BanCommand extends Command {
.setColor(0xFF0000)
.setTimestamp()
.setDescription(`**Member:** ${member.user.tag} (${member.id})\n**Action:** Ban\n**Reason:** ${reason}`);
return message.guild.channels.find('name', 'mod_logs').send({embed});
return modlogs.send({embed});
} catch (err) {
return message.say(':x: Error! Something went wrong!');
}
+10 -8
View File
@@ -32,14 +32,16 @@ module.exports = class KickCommand 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.permissionsFor(this.client.user).hasPermission('KICK_MEMBERS')) return message.say(':x: Error! I don\'t have the Kick Members Permission!');
}
if (!message.guild.channels.exists('name', 'mod_logs')) return message.say(':x: Error! Could not find the mod_logs channel! Please create it!');
if (!message.channel.permissionsFor(this.client.user).hasPermission('BAN_MEMBERS'))
return message.say(':x: Error! I don\'t have the Ban Members Permission!');
const modlogs = message.guild.channels.find('name', 'mod_logs');
if (!modlogs)
return message.say(':x: Error! Could not find the mod_logs channel! Please create it!');
if (!modlogs.permissionsFor(this.client.user).hasPermission('EMBED_LINKS'))
return message.say(':x: Error! I don\'t have the Embed Links Permission!');
const { member, reason } = args;
if (!member.bannable) return message.say(':x: Error! This member cannot be kicked! Perhaps they have a higher role than me?');
if (!member.bannable)
return message.say(':x: Error! This member cannot be kicked! Perhaps they have a higher role than me?');
try {
await member.kick();
await message.say(':ok_hand:');
@@ -48,7 +50,7 @@ module.exports = class KickCommand extends Command {
.setColor(0xFFA500)
.setTimestamp()
.setDescription(`**Member:** ${member.user.tag} (${member.id})\n**Action:** Kick\n**Reason:** ${reason}`);
return message.guild.channels.find('name', 'mod_logs').send({embed});
return modlogs.send({embed});
} catch (err) {
return message.say(':x: Error! Something went wrong!');
}
+4 -8
View File
@@ -13,9 +13,8 @@ module.exports = class LockdownCommand extends Command {
prompt: 'Please enter either start or stop.',
type: 'string',
validate: type => {
if (type.toLowerCase() === 'start' || type.toLowerCase() === 'stop') {
if (['start', 'stop'].includes(type.toLowerCase()))
return true;
}
return 'Please enter either `start` or `stop`.';
},
parse: text => text.toLowerCase()
@@ -28,10 +27,8 @@ module.exports = class LockdownCommand extends Command {
}
async run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['READ_MESSAGES', 'SEND_MESSAGES'])) return;
if (!message.channel.permissionsFor(this.client.user).hasPermission('ADMINISTRATOR')) return message.say(':x: Error! I don\'t have the Administrator permission! This is not given by default, as that\'s quite bad practice. Please give it to me to use the lockdown command!');
}
if (!message.channel.permissionsFor(this.client.user).hasPermission('ADMINISTRATOR'))
return message.say(':x: Error! I don\'t have the Administrator Permission!');
const { type } = args;
if (type === 'start') {
try {
@@ -42,8 +39,7 @@ module.exports = class LockdownCommand extends Command {
} catch (err) {
return message.say(':x: Error! Something went wrong!');
}
}
if (type === 'stop') {
} else if (type === 'stop') {
try {
await message.channel.overwritePermissions(message.guild.defaultRole, {
SEND_MESSAGES: true
+5 -11
View File
@@ -4,10 +4,6 @@ module.exports = class PruneCommand extends Command {
constructor(client) {
super(client, {
name: 'prune',
aliases: [
'clean',
'bulkdelete'
],
group: 'moderation',
memberName: 'prune',
description: 'Deletes a specified number of messages from the current channel, up to 99.',
@@ -21,9 +17,8 @@ module.exports = class PruneCommand extends Command {
prompt: 'How many messages do you want to delete? Limit of up to 99.',
type: 'integer',
validate: count => {
if (count < 100 && count > 0) {
if (count < 100 && count > 0)
return true;
}
return `${count} is not a valid amount of messages. Limit 1-99.`;
}
}]
@@ -35,11 +30,10 @@ module.exports = class PruneCommand 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('READ_MESSAGE_HISTORY')) return message.say(':x: Error! I don\'t have the Read Message History Permission!');
if (!message.channel.permissionsFor(this.client.user).hasPermission('MANAGE_MESSAGES')) return message.say(':x: Error! I don\'t have the Manage Messages Permission!');
}
if (!message.channel.permissionsFor(this.client.user).hasPermission('READ_MESSAGE_HISTORY'))
return message.say(':x: Error! I don\'t have the Read Message History Permission!');
if (!message.channel.permissionsFor(this.client.user).hasPermission('MANAGE_MESSAGES'))
return message.say(':x: Error! I don\'t have the Manage Messages Permission!');
let { count } = args;
count = count + 1;
try {
+12 -12
View File
@@ -17,9 +17,8 @@ module.exports = class UnbanCommand extends Command {
prompt: 'What member do you want to unban? Please enter the ID of the user.',
type: 'string',
validate: userID => {
if (userID.length === 18) {
if (userID.length === 18)
return true;
}
return `${userID} is not a valid ID. Please enter the user you wish to unban's ID.`;
}
}, {
@@ -27,9 +26,8 @@ module.exports = class UnbanCommand extends Command {
prompt: 'What do you want to set the reason as?',
type: 'string',
validate: reason => {
if (reason.length < 140) {
if (reason.length < 140)
return true;
}
return `Please keep your reason under 140 characters, you have ${reason.length}.`;
}
}]
@@ -41,15 +39,17 @@ module.exports = class UnbanCommand 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.permissionsFor(this.client.user).hasPermission('BAN_MEMBERS')) return message.say(':x: Error! I don\'t have the Ban Members Permission!');
}
if (!message.guild.channels.exists('name', 'mod_logs')) return message.say(':x: Error! Could not find the mod_logs channel! Please create it!');
if (!message.channel.permissionsFor(this.client.user).hasPermission('BAN_MEMBERS'))
return message.say(':x: Error! I don\'t have the Ban Members Permission!');
const modlogs = message.guild.channels.find('name', 'mod_logs');
if (!modlogs)
return message.say(':x: Error! Could not find the mod_logs channel! Please create it!');
if (!modlogs.permissionsFor(this.client.user).hasPermission('EMBED_LINKS'))
return message.say(':x: Error! I don\'t have the Embed Links Permission!');
const { memberID, reason } = args;
const bans = await message.guild.fetchBans();
if (!bans.has(memberID)) return message.say(':x: Error! Could not find this user in the bans.');
if (!bans.has(memberID))
return message.say(':x: Error! Could not find this user in the bans.');
const unbanUser = await bans.get(memberID);
try {
await message.guild.unban(unbanUser);
@@ -59,7 +59,7 @@ module.exports = class UnbanCommand extends Command {
.setColor(0x00AE86)
.setTimestamp()
.setDescription(`**Member:** ${unbanUser.tag} (${unbanUser.id})\n**Action:** Unban\n**Reason:** ${reason}`);
return message.guild.channels.find('name', 'mod_logs').send({embed});
return modlogs.send({embed});
} catch (err) {
return message.say(':x: Error! Something went wrong!');
}
+9 -8
View File
@@ -18,9 +18,8 @@ module.exports = class WarnCommand extends Command {
prompt: 'What do you want to set the reason as?',
type: 'string',
validate: reason => {
if (reason.length < 140) {
if (reason.length < 140)
return true;
}
return `Please keep your reason under 140 characters, you have ${reason.length}.`;
}
}]
@@ -32,12 +31,14 @@ module.exports = class WarnCommand 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.permissionsFor(this.client.user).hasPermission('BAN_MEMBERS'))
return message.say(':x: Error! I don\'t have the Ban Members Permission!');
const modlogs = message.guild.channels.find('name', 'mod_logs');
if (!modlogs)
return message.say(':x: Error! Could not find the mod_logs channel! Please create it!');
if (!modlogs.permissionsFor(this.client.user).hasPermission('EMBED_LINKS'))
return message.say(':x: Error! I don\'t have the Embed Links Permission!');
const { member, reason } = args;
if (!message.guild.channels.exists('name', 'mod_logs')) return message.say(':x: Error! Could not find the mod_logs channel! Please create it!');
try {
await message.say(':ok_hand:');
const embed = new RichEmbed()
@@ -45,7 +46,7 @@ module.exports = class WarnCommand extends Command {
.setColor(0xFFFF00)
.setTimestamp()
.setDescription(`**Member:** ${member.user.tag} (${member.id})\n**Action:** Warn\n**Reason:** ${reason}`);
return message.guild.channels.find('name', 'mod_logs').send({embed});
return modlogs.send({embed});
} catch (err) {
return message.say(':x: Error! Something went wrong!');
}
-3
View File
@@ -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?');
}
};
+3 -8
View File
@@ -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]);
}
-7
View File
@@ -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? ♪');
}
};
-3
View File
@@ -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('( ͡° ͜ʖ ͡°)');
}
};
-3
View File
@@ -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);
-7
View File
@@ -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`);
}
+3 -4
View File
@@ -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')
-3
View File
@@ -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*');
}
};
+3 -4
View File
@@ -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']});
}
};
+6 -12
View File
@@ -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')
+3 -7
View File
@@ -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')
+3 -5
View File
@@ -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');
+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}`]});
}
+1 -4
View File
@@ -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:`);
-6
View File
@@ -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}!`);
-3
View File
@@ -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 -4
View File
@@ -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 -4
View File
@@ -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);
}
-8
View File
@@ -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 -7
View File
@@ -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);
}
+2 -10
View File
@@ -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') {
-7
View File
@@ -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}!`);
}
-5
View File
@@ -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}.`);
}
-3
View File
@@ -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 -7
View File
@@ -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}`);
-4
View File
@@ -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}.`);
-9
View File
@@ -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}!`);
}
};
-3
View File
@@ -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}%!`);
-3
View File
@@ -16,9 +16,6 @@ module.exports = class CuddleCommand 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(`${message.author} *cuddles* ${thing}`);
}
-3
View File
@@ -16,9 +16,6 @@ module.exports = class DivorceCommand 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(`${message.author} *divorces* ${thing}`);
}
-3
View File
@@ -16,9 +16,6 @@ module.exports = class EatCommand 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(`${message.author} *eats* ${thing}`);
}
-3
View File
@@ -16,9 +16,6 @@ module.exports = class FalconPunchCommand 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(`${message.author} *falcon punches* ${thing}`);
}
-3
View File
@@ -16,9 +16,6 @@ module.exports = class FistBumpCommand 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(`${message.author} *fist-bumps* ${thing} *badalalala*`);
}
-3
View File
@@ -16,9 +16,6 @@ module.exports = class HighFivesCommand 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(`${message.author} *high-fives* ${thing}`);
}
-3
View File
@@ -16,9 +16,6 @@ module.exports = class HitwithShovelCommand 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(`${message.author} *hits* ${thing} *with a shovel*`);
}
-3
View File
@@ -16,9 +16,6 @@ module.exports = class HugCommand 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(`${message.author} *hugs* ${thing}`);
}
-3
View File
@@ -16,9 +16,6 @@ module.exports = class InhaleCommand 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(`${message.author} *inhales* ${thing} *but gained no ability...*`);
}
-3
View File
@@ -16,9 +16,6 @@ module.exports = class KillCommand 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(`${message.author} *kills* ${thing}`);
}
-3
View File
@@ -16,9 +16,6 @@ module.exports = class KissCommand 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(`${message.author} *kisses* ${thing}`);
}
-3
View File
@@ -16,9 +16,6 @@ module.exports = class MarryCommand 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(`${message.author} *marries* ${thing}`);
}
-3
View File
@@ -16,9 +16,6 @@ module.exports = class PatCommand 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(`${message.author} *pats* ${thing}`);
}
-3
View File
@@ -16,9 +16,6 @@ module.exports = class PokeCommand 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(`${message.author} *pokes* ${thing}`);
}
-3
View File
@@ -16,9 +16,6 @@ module.exports = class PunchCommand 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(`${message.author} *punches* ${thing}`);
}
-3
View File
@@ -16,9 +16,6 @@ module.exports = class SlapCommand 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(`${message.author} *slaps* ${thing}`);
}
+3 -8
View File
@@ -6,10 +6,6 @@ module.exports = class BotSearchCommand extends Command {
constructor(client) {
super(client, {
name: 'botinfo',
aliases: [
'bot',
'botdata'
],
group: 'search',
memberName: 'botinfo',
description: 'Searches Discord Bots for info on a bot.',
@@ -22,10 +18,9 @@ module.exports = class BotSearchCommand 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!');
let { bot } = args;
bot = bot.id;
try {
+3 -10
View File
@@ -6,12 +6,6 @@ module.exports = class DefineCommand extends Command {
constructor(client) {
super(client, {
name: 'define',
aliases: [
'definition',
'defineword',
'dictionary',
'wordnik'
],
group: 'search',
memberName: 'define',
description: 'Defines a word.',
@@ -25,10 +19,9 @@ module.exports = class DefineCommand 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 { word } = args;
try {
const { body } = await request
+4 -6
View File
@@ -17,9 +17,8 @@ module.exports = class DiscrimCommand extends Command {
prompt: 'Which discriminator would you like to search for?',
type: 'string',
validate: discrim => {
if (discrim.match(/^[0-9]+$/) && discrim.length === 4) {
if (/[0-9]+$/g.test(discrim) && discrim.length === 4)
return true;
}
return `${discrim} is not a valid discriminator.`;
}
}]
@@ -27,10 +26,9 @@ module.exports = class DiscrimCommand 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 { discrim } = args;
const users = await this.client.users.filter(u => u.discriminator === discrim).map(u => u.username).sort();
const embed = new RichEmbed()
+3 -7
View File
@@ -6,9 +6,6 @@ module.exports = class ForecastCommand extends Command {
constructor(client) {
super(client, {
name: 'forecast',
aliases: [
'weatherforecast'
],
group: 'search',
memberName: 'forecast',
description: 'Gets the seven-day forecast for a specified location.',
@@ -21,10 +18,9 @@ module.exports = class ForecastCommand 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 { location } = args;
try {
const { body } = await request
-6
View File
@@ -7,9 +7,6 @@ module.exports = class GoogleCommand extends Command {
constructor(client) {
super(client, {
name: 'google',
aliases: [
'search'
],
group: 'search',
memberName: 'google',
description: 'Searches Google.',
@@ -23,9 +20,6 @@ module.exports = class GoogleCommand 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 { query } = args;
const msg = await message.say('Searching...');
try {
+3 -10
View File
@@ -6,12 +6,6 @@ module.exports = class IMDBCommand extends Command {
constructor(client) {
super(client, {
name: 'imdb',
aliases: [
'movie',
'tvshow',
'film',
'omdb'
],
group: 'search',
memberName: 'imdb',
description: 'Searches IMDB for a specified movie.',
@@ -25,10 +19,9 @@ module.exports = class IMDBCommand 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 { movie } = args;
try {
const { body } = await request
-3
View File
@@ -17,9 +17,6 @@ module.exports = class LMGTFYCommand extends Command {
}
run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
const { query } = args;
return message.say(`http://lmgtfy.com/?iie=1&q=${query}`);
}
+4 -9
View File
@@ -5,9 +5,6 @@ module.exports = class MapCommand extends Command {
constructor(client) {
super(client, {
name: 'map',
aliases: [
'location'
],
group: 'search',
memberName: 'map',
description: 'Gets a map image for the location you define with the zoom level you define (1-20).',
@@ -16,9 +13,8 @@ module.exports = class MapCommand extends Command {
prompt: 'What would you like the zoom level for the map to be? Limit 1-20.',
type: 'integer',
validate: zoom => {
if (zoom < 21 && zoom > 0) {
if (zoom < 21 && zoom > 0)
return true;
}
return 'Please enter a zoom value from 1-20';
}
}, {
@@ -31,10 +27,9 @@ module.exports = class MapCommand 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('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 { zoom, location } = args;
try {
const { body } = await request
+3 -4
View File
@@ -19,10 +19,9 @@ module.exports = class NeopetCommand 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('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 { pet } = args;
try {
const { text } = await request
+3 -9
View File
@@ -6,11 +6,6 @@ module.exports = class OsuCommand extends Command {
constructor(client) {
super(client, {
name: 'osu',
aliases: [
'osuuser',
'osudata',
'osuinfo'
],
group: 'search',
memberName: 'osu',
description: 'Searches Osu! user data.',
@@ -24,10 +19,9 @@ module.exports = class OsuCommand 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 { username } = args;
try {
const { body } = await request
+3 -8
View File
@@ -6,10 +6,6 @@ module.exports = class SoundCloudCommand extends Command {
constructor(client) {
super(client, {
name: 'soundcloud',
aliases: [
'cloudsound',
'scloud'
],
group: 'search',
memberName: 'soundcloud',
description: 'Searches SoundCloud for a song.',
@@ -23,10 +19,9 @@ module.exports = class SoundCloudCommand 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 { query } = args;
try {
const { body } = await request
+3 -9
View File
@@ -6,11 +6,6 @@ module.exports = class UrbanCommand extends Command {
constructor(client) {
super(client, {
name: 'urban',
aliases: [
'urbandictionary',
'urbandefine',
'urbandefinition'
],
group: 'search',
memberName: 'urban',
description: 'Searches Urban Dictionary for a word.',
@@ -24,10 +19,9 @@ module.exports = class UrbanCommand 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 { word } = args;
try {
const { body } = await request
+3 -4
View File
@@ -19,10 +19,9 @@ module.exports = class WattpadCommand 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 { book } = args;
try {
const { body } = await request
+3 -4
View File
@@ -18,10 +18,9 @@ module.exports = class WeatherCommand 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 { location } = args;
try {
const { body } = await request
+3 -4
View File
@@ -19,10 +19,9 @@ module.exports = class WikipediaCommand 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 { query } = args;
try {
const { body } = await request
+3 -7
View File
@@ -6,9 +6,6 @@ module.exports = class YouTubeCommand extends Command {
constructor(client) {
super(client, {
name: 'youtube',
aliases: [
'video'
],
group: 'search',
memberName: 'youtube',
description: 'Searches YouTube for a video.',
@@ -22,10 +19,9 @@ module.exports = class YouTubeCommand 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 { video } = args;
try {
const { body } = await request
+3 -4
View File
@@ -19,10 +19,9 @@ module.exports = class YuGiOhCommand 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 { card } = args;
try {
const { body } = await request
+1 -5
View File
@@ -20,9 +20,8 @@ module.exports = class BinaryCommand extends Command {
prompt: 'What text would you like to convert to binary?',
type: 'string',
validate: content => {
if (stringToBinary(content).length < 2000) {
if (stringToBinary(content).length < 2000)
return true;
}
return 'Your message content is too long.';
},
parse: text => stringToBinary(text)
@@ -31,9 +30,6 @@ module.exports = class BinaryCommand extends Command {
}
run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
const { text } = args;
return message.say(text);
}
+1 -5
View File
@@ -12,9 +12,8 @@ module.exports = class CowsayCommand extends Command {
prompt: 'What text would you like the cow to say?',
type: 'string',
validate: text => {
if (text.length < 1500) {
if (text.length < 1500)
return true;
}
return `Please keep your content under 1500 characters, you have ${text.length}.`;
}
}]
@@ -22,9 +21,6 @@ module.exports = class CowsayCommand extends Command {
}
run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
const { text } = args;
return message.code(null, `< ${text} >\n \\ ^__^\n \\ (oO)\\_______\n (__)\\ )\\/\\\n U ||----w |\n || ||`);
}
+3 -7
View File
@@ -8,7 +8,6 @@ module.exports = class EmbedCommand extends Command {
group: 'textedit',
memberName: 'embed',
description: 'Sends a message in an embed.',
guildOnly: true,
args: [{
key: 'text',
prompt: 'What text would you like to embed?',
@@ -18,18 +17,15 @@ module.exports = class EmbedCommand extends Command {
}
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.permissionsFor(this.client.user).hasPermission('MANAGE_MESSAGES')) return message.say(':x: Error! I don\'t have the Manage Messages 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 { text } = args;
const embed = new RichEmbed()
.setAuthor(message.author.username, message.author.avatarURL)
.setColor(0x00AE86)
.setTimestamp()
.setDescription(text);
message.delete();
return message.embed(embed);
}
};
+2 -9
View File
@@ -1,14 +1,11 @@
const { Command } = require('discord.js-commando');
const { letterTrans } = require('custom-translate');
const dictionary = require('./morsemappings.json');
const dictionary = require('./morsemappings');
module.exports = class MorseCommand extends Command {
constructor(client) {
super(client, {
name: 'morse',
aliases: [
'morsecode'
],
group: 'textedit',
memberName: 'morse',
description: 'Translates text to morse code.',
@@ -17,9 +14,8 @@ module.exports = class MorseCommand extends Command {
prompt: 'What text would you like to convert to morse?',
type: 'string',
validate: content => {
if (letterTrans(content, dictionary, ' ').length < 1999) {
if (letterTrans(content, dictionary, ' ').length < 1999)
return true;
}
return 'Your message content is too long.';
},
parse: text => letterTrans(text.toLowerCase(), dictionary, ' ')
@@ -28,9 +24,6 @@ module.exports = class MorseCommand extends Command {
}
run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
const { text } = args;
return message.say(text);
}
+2 -10
View File
@@ -1,15 +1,11 @@
const { Command } = require('discord.js-commando');
const { wordTrans } = require('custom-translate');
const dictionary = require('./piratewords.json');
const dictionary = require('./piratewords');
module.exports = class PirateCommand extends Command {
constructor(client) {
super(client, {
name: 'pirate',
aliases: [
'piratespeak',
'yarr'
],
group: 'textedit',
memberName: 'pirate',
description: 'Talk like a pirate!',
@@ -18,9 +14,8 @@ module.exports = class PirateCommand extends Command {
prompt: 'What text would you like to convert to pirate?',
type: 'string',
validate: content => {
if (wordTrans(content, dictionary).length < 1999) {
if (wordTrans(content, dictionary).length < 1999)
return true;
}
return 'Your message content is too long.';
},
parse: text => wordTrans(text, dictionary)
@@ -29,9 +24,6 @@ module.exports = class PirateCommand extends Command {
}
run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
const { text } = args;
return message.say(`\u180E${text}`);
}
-3
View File
@@ -17,9 +17,6 @@ module.exports = class ReverseCommand extends Command {
}
run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
const { text } = args;
return message.say(`\u180E${text}`);
}
-7
View File
@@ -7,13 +7,11 @@ module.exports = class SayCommand extends Command {
aliases: [
'copy',
'repeat',
'parrot',
'echo'
],
group: 'textedit',
memberName: 'say',
description: 'Make XiaoBot say what you wish.',
guildOnly: true,
args: [{
key: 'text',
prompt: 'What text would you like XiaoBot to say?',
@@ -23,12 +21,7 @@ module.exports = class SayCommand extends Command {
}
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('MANAGE_MESSAGES')) return message.say(':x: Error! I don\'t have the Manage Messages Permission!');
}
const { text } = args;
message.delete();
return message.say(`\u180E${text}`);
}
};
+2 -6
View File
@@ -1,6 +1,6 @@
const { Command } = require('discord.js-commando');
const { wordTrans } = require('custom-translate');
const dictionary = require('./temmiewords.json');
const dictionary = require('./temmiewords');
module.exports = class TemmieCommand extends Command {
constructor(client) {
@@ -14,9 +14,8 @@ module.exports = class TemmieCommand extends Command {
prompt: 'What text would you like to convert to Temmie speak?',
type: 'string',
validate: content => {
if (wordTrans(content, dictionary).length < 1999) {
if (wordTrans(content, dictionary).length < 1999)
return true;
}
return 'Your message content is too long.';
},
parse: text => wordTrans(text, dictionary)
@@ -25,9 +24,6 @@ module.exports = class TemmieCommand extends Command {
}
run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
const { text } = args;
return message.say(`\u180E${text}`);
}
+1 -5
View File
@@ -1,13 +1,12 @@
const { Command } = require('discord.js-commando');
const { letterTrans } = require('custom-translate');
const dictionary = require('./udmappings.json');
const dictionary = require('./udmappings');
module.exports = class UpsideDownCommand extends Command {
constructor(client) {
super(client, {
name: 'upsidedown',
aliases: [
'upside-down',
'udown'
],
group: 'textedit',
@@ -23,9 +22,6 @@ module.exports = class UpsideDownCommand extends Command {
}
run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
const { text } = args;
return message.say(text);
}
+2 -4
View File
@@ -26,10 +26,8 @@ module.exports = class WebhookCommand 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('MANAGE_MESSAGES')) return message.say(':x: Error! I don\'t have the Manage Messages Permission!');
}
if (!message.channel.permissionsFor(this.client.user).hasPermission('MANAGE_MESSAGES'))
return message.say(':x: Error! I don\'t have the Manage Messages Permission!');
const { text } = args;
try {
message.delete();
-3
View File
@@ -24,9 +24,6 @@ module.exports = class ZalgoCommand extends Command {
}
run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
const { text } = args;
return message.say(`\u180E${text}`);
}
-3
View File
@@ -16,9 +16,6 @@ module.exports = class AvatarCommand extends Command {
}
run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
}
const { user } = args;
return message.say(user.displayAvatarURL);
}
+3 -4
View File
@@ -25,10 +25,9 @@ module.exports = class UserInfoCommand 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 { user } = args;
const member = await message.guild.fetchMember(user);
let stat;
+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}`);
}

Some files were not shown because too many files have changed in this diff Show More