diff --git a/commands/avataredit/3000years.js b/commands/avataredit/3000years.js index 929a3081..d7672757 100644 --- a/commands/avataredit/3000years.js +++ b/commands/avataredit/3000years.js @@ -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 = []; diff --git a/commands/avataredit/beautiful.js b/commands/avataredit/beautiful.js index f975e429..d2d1b331 100644 --- a/commands/avataredit/beautiful.js +++ b/commands/avataredit/beautiful.js @@ -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 = []; diff --git a/commands/avataredit/bobross.js b/commands/avataredit/bobross.js index 59419906..82f93266 100644 --- a/commands/avataredit/bobross.js +++ b/commands/avataredit/bobross.js @@ -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); diff --git a/commands/avataredit/rip.js b/commands/avataredit/rip.js index a6fe041d..842205c5 100644 --- a/commands/avataredit/rip.js +++ b/commands/avataredit/rip.js @@ -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 = []; diff --git a/commands/avataredit/steamcard.js b/commands/avataredit/steamcard.js index 0c6d2769..8aaec413 100644 --- a/commands/avataredit/steamcard.js +++ b/commands/avataredit/steamcard.js @@ -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'); diff --git a/commands/games/lottery.js b/commands/games/lottery.js index 9ce84f3f..52d41ef8 100644 --- a/commands/games/lottery.js +++ b/commands/games/lottery.js @@ -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!`); diff --git a/commands/games/mathgame.js b/commands/games/mathgame.js index c3a2d21a..09112837 100644 --- a/commands/games/mathgame.js +++ b/commands/games/mathgame.js @@ -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; diff --git a/commands/games/quiz.js b/commands/games/quiz.js index 9c090d99..b727c1e4 100644 --- a/commands/games/quiz.js +++ b/commands/games/quiz.js @@ -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'); diff --git a/commands/games/rockpaperscissors.js b/commands/games/rockpaperscissors.js index 318c102e..49327d9f 100644 --- a/commands/games/rockpaperscissors.js +++ b/commands/games/rockpaperscissors.js @@ -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!'); } } }; diff --git a/commands/games/slots.js b/commands/games/slots.js index c9a5f21e..bf69185f 100644 --- a/commands/games/slots.js +++ b/commands/games/slots.js @@ -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?`); } }; diff --git a/commands/games/typinggame.js b/commands/games/typinggame.js index f4adad56..55a71138 100644 --- a/commands/games/typinggame.js +++ b/commands/games/typinggame.js @@ -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:`) diff --git a/commands/guildinfo/emoji.js b/commands/guildinfo/emoji.js index adb926e1..f84e8d67 100644 --- a/commands/guildinfo/emoji.js +++ b/commands/guildinfo/emoji.js @@ -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?')); } }; diff --git a/commands/guildinfo/guildinfo.js b/commands/guildinfo/guildinfo.js index e526f393..6b39921e 100644 --- a/commands/guildinfo/guildinfo.js +++ b/commands/guildinfo/guildinfo.js @@ -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) diff --git a/commands/imageedit/meme.js b/commands/imageedit/meme.js index a23c5dc3..9f0e4d90 100644 --- a/commands/imageedit/meme.js +++ b/commands/imageedit/meme.js @@ -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`]}); } diff --git a/commands/moderation/ban.js b/commands/moderation/ban.js index 6e7afdda..8478037c 100644 --- a/commands/moderation/ban.js +++ b/commands/moderation/ban.js @@ -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!'); } diff --git a/commands/moderation/kick.js b/commands/moderation/kick.js index 08a2883e..c8472ed2 100644 --- a/commands/moderation/kick.js +++ b/commands/moderation/kick.js @@ -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!'); } diff --git a/commands/moderation/lockdown.js b/commands/moderation/lockdown.js index 3f249f25..5c3dfed7 100644 --- a/commands/moderation/lockdown.js +++ b/commands/moderation/lockdown.js @@ -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 diff --git a/commands/moderation/prune.js b/commands/moderation/prune.js index 9bfa98d1..e0d82cc7 100644 --- a/commands/moderation/prune.js +++ b/commands/moderation/prune.js @@ -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 { diff --git a/commands/moderation/unban.js b/commands/moderation/unban.js index 8fa2a408..26dd6e31 100644 --- a/commands/moderation/unban.js +++ b/commands/moderation/unban.js @@ -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!'); } diff --git a/commands/moderation/warn.js b/commands/moderation/warn.js index 312bdecc..68597694 100644 --- a/commands/moderation/warn.js +++ b/commands/moderation/warn.js @@ -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!'); } diff --git a/commands/random/canyounot.js b/commands/random/canyounot.js index 85995761..e918f4eb 100644 --- a/commands/random/canyounot.js +++ b/commands/random/canyounot.js @@ -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?'); } }; diff --git a/commands/random/easteregg.js b/commands/random/easteregg.js index 8c48af61..d62bb8af 100644 --- a/commands/random/easteregg.js +++ b/commands/random/easteregg.js @@ -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]); } diff --git a/commands/random/giveflower.js b/commands/random/giveflower.js index 7d0f1aa6..b9d0712a 100644 --- a/commands/random/giveflower.js +++ b/commands/random/giveflower.js @@ -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? ♪'); } }; diff --git a/commands/random/lenny.js b/commands/random/lenny.js index c56b0b33..d2882445 100644 --- a/commands/random/lenny.js +++ b/commands/random/lenny.js @@ -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('( ͡° ͜ʖ ͡°)'); } }; diff --git a/commands/random/math.js b/commands/random/math.js index 2849fae4..465132a7 100644 --- a/commands/random/math.js +++ b/commands/random/math.js @@ -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); diff --git a/commands/random/motivate.js b/commands/random/motivate.js index 3448848f..47401816 100644 --- a/commands/random/motivate.js +++ b/commands/random/motivate.js @@ -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`); } diff --git a/commands/random/nitro.js b/commands/random/nitro.js index 97972a4c..80e2c7fd 100644 --- a/commands/random/nitro.js +++ b/commands/random/nitro.js @@ -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') diff --git a/commands/random/slowclap.js b/commands/random/slowclap.js index 2cc612e9..ad257685 100644 --- a/commands/random/slowclap.js +++ b/commands/random/slowclap.js @@ -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*'); } }; diff --git a/commands/random/spam.js b/commands/random/spam.js index 744a1511..5781c4ce 100644 --- a/commands/random/spam.js +++ b/commands/random/spam.js @@ -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']}); } }; diff --git a/commands/random/strawpoll.js b/commands/random/strawpoll.js index fb2284ef..c4d9e37f 100644 --- a/commands/random/strawpoll.js +++ b/commands/random/strawpoll.js @@ -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') diff --git a/commands/random/today.js b/commands/random/today.js index b9d62e52..d34a5f45 100644 --- a/commands/random/today.js +++ b/commands/random/today.js @@ -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') diff --git a/commands/random/wouldyourather.js b/commands/random/wouldyourather.js index e493e66a..0b26639f 100644 --- a/commands/random/wouldyourather.js +++ b/commands/random/wouldyourather.js @@ -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'); diff --git a/commands/randomimg/cat.js b/commands/randomimg/cat.js index f254e105..a94bc776 100644 --- a/commands/randomimg/cat.js +++ b/commands/randomimg/cat.js @@ -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}`]}); } diff --git a/commands/randomimg/potato.js b/commands/randomimg/potato.js index a0039523..e813270c 100644 --- a/commands/randomimg/potato.js +++ b/commands/randomimg/potato.js @@ -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}`]}); } diff --git a/commands/randomimg/pun.js b/commands/randomimg/pun.js index 9cc1835d..206e115c 100644 --- a/commands/randomimg/pun.js +++ b/commands/randomimg/pun.js @@ -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}`]}); } diff --git a/commands/randomimg/vocaloid.js b/commands/randomimg/vocaloid.js index 404b6b71..9de9fe4a 100644 --- a/commands/randomimg/vocaloid.js +++ b/commands/randomimg/vocaloid.js @@ -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); } diff --git a/commands/randomimg/xiaopai.js b/commands/randomimg/xiaopai.js index 68b5fcbb..a65a43a9 100644 --- a/commands/randomimg/xiaopai.js +++ b/commands/randomimg/xiaopai.js @@ -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}`]}); } diff --git a/commands/response/8ball.js b/commands/response/8ball.js index 695cbc33..2294661a 100644 --- a/commands/response/8ball.js +++ b/commands/response/8ball.js @@ -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:`); diff --git a/commands/response/choose.js b/commands/response/choose.js index 20b37f1f..9a09bad5 100644 --- a/commands/response/choose.js +++ b/commands/response/choose.js @@ -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}!`); diff --git a/commands/response/coin.js b/commands/response/coin.js index d9dcc0a8..8d2088e4 100644 --- a/commands/response/coin.js +++ b/commands/response/coin.js @@ -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}!`); } diff --git a/commands/response/compliment.js b/commands/response/compliment.js index 9f50eeb2..b96e4f8a 100644 --- a/commands/response/compliment.js +++ b/commands/response/compliment.js @@ -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}`); diff --git a/commands/response/factcore.js b/commands/response/factcore.js index b8397f1b..05bd957b 100644 --- a/commands/response/factcore.js +++ b/commands/response/factcore.js @@ -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); } diff --git a/commands/response/fishy.js b/commands/response/fishy.js index f5f49b84..8bfa806b 100644 --- a/commands/response/fishy.js +++ b/commands/response/fishy.js @@ -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}`); } diff --git a/commands/response/fortune.js b/commands/response/fortune.js index 491a1ca4..01da63fa 100644 --- a/commands/response/fortune.js +++ b/commands/response/fortune.js @@ -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); } diff --git a/commands/response/name.js b/commands/response/name.js index b2e414c2..e052ca66 100644 --- a/commands/response/name.js +++ b/commands/response/name.js @@ -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') { diff --git a/commands/response/offspring.js b/commands/response/offspring.js index 3eed2de1..75e43bd1 100644 --- a/commands/response/offspring.js +++ b/commands/response/offspring.js @@ -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}!`); } diff --git a/commands/response/quantumcoin.js b/commands/response/quantumcoin.js index bdb6eb2e..ffaa0aa2 100644 --- a/commands/response/quantumcoin.js +++ b/commands/response/quantumcoin.js @@ -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}.`); } diff --git a/commands/response/ratewaifu.js b/commands/response/ratewaifu.js index 2983ce5a..c4b5f8a5 100644 --- a/commands/response/ratewaifu.js +++ b/commands/response/ratewaifu.js @@ -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!`); diff --git a/commands/response/roast.js b/commands/response/roast.js index 03da5371..97ba0d0a 100644 --- a/commands/response/roast.js +++ b/commands/response/roast.js @@ -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}`); diff --git a/commands/response/roll.js b/commands/response/roll.js index 497ee25d..c53fbcb3 100644 --- a/commands/response/roll.js +++ b/commands/response/roll.js @@ -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}.`); diff --git a/commands/response/roulette.js b/commands/response/roulette.js index 9ad83319..b4dd3eef 100644 --- a/commands/response/roulette.js +++ b/commands/response/roulette.js @@ -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}!`); } }; diff --git a/commands/response/ship.js b/commands/response/ship.js index 03459e31..a274182a 100644 --- a/commands/response/ship.js +++ b/commands/response/ship.js @@ -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}%!`); diff --git a/commands/roleplay/cuddle.js b/commands/roleplay/cuddle.js index 2b45f64e..02332114 100644 --- a/commands/roleplay/cuddle.js +++ b/commands/roleplay/cuddle.js @@ -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}`); } diff --git a/commands/roleplay/divorce.js b/commands/roleplay/divorce.js index 216283e9..e6cdf248 100644 --- a/commands/roleplay/divorce.js +++ b/commands/roleplay/divorce.js @@ -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}`); } diff --git a/commands/roleplay/eat.js b/commands/roleplay/eat.js index 10fef1f7..b7069347 100644 --- a/commands/roleplay/eat.js +++ b/commands/roleplay/eat.js @@ -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}`); } diff --git a/commands/roleplay/falconpunch.js b/commands/roleplay/falconpunch.js index 070c539e..f8f316c2 100644 --- a/commands/roleplay/falconpunch.js +++ b/commands/roleplay/falconpunch.js @@ -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}`); } diff --git a/commands/roleplay/fistbump.js b/commands/roleplay/fistbump.js index 845cc2c2..706286ac 100644 --- a/commands/roleplay/fistbump.js +++ b/commands/roleplay/fistbump.js @@ -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*`); } diff --git a/commands/roleplay/highfive.js b/commands/roleplay/highfive.js index 9da6f7e4..9f5003e7 100644 --- a/commands/roleplay/highfive.js +++ b/commands/roleplay/highfive.js @@ -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}`); } diff --git a/commands/roleplay/hitwithshovel.js b/commands/roleplay/hitwithshovel.js index 041ca2c8..0cb9be1f 100644 --- a/commands/roleplay/hitwithshovel.js +++ b/commands/roleplay/hitwithshovel.js @@ -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*`); } diff --git a/commands/roleplay/hug.js b/commands/roleplay/hug.js index 2524639f..79748bc4 100644 --- a/commands/roleplay/hug.js +++ b/commands/roleplay/hug.js @@ -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}`); } diff --git a/commands/roleplay/inhales.js b/commands/roleplay/inhales.js index 1e836395..2aac39d5 100644 --- a/commands/roleplay/inhales.js +++ b/commands/roleplay/inhales.js @@ -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...*`); } diff --git a/commands/roleplay/kill.js b/commands/roleplay/kill.js index 0e79c2fe..a72db6ef 100644 --- a/commands/roleplay/kill.js +++ b/commands/roleplay/kill.js @@ -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}`); } diff --git a/commands/roleplay/kiss.js b/commands/roleplay/kiss.js index 14f5e7f7..27055e84 100644 --- a/commands/roleplay/kiss.js +++ b/commands/roleplay/kiss.js @@ -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}`); } diff --git a/commands/roleplay/marries.js b/commands/roleplay/marries.js index e1f7a1a9..09886562 100644 --- a/commands/roleplay/marries.js +++ b/commands/roleplay/marries.js @@ -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}`); } diff --git a/commands/roleplay/pat.js b/commands/roleplay/pat.js index 1d32be93..9ed244cb 100644 --- a/commands/roleplay/pat.js +++ b/commands/roleplay/pat.js @@ -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}`); } diff --git a/commands/roleplay/poke.js b/commands/roleplay/poke.js index 2f5df626..8c30ff34 100644 --- a/commands/roleplay/poke.js +++ b/commands/roleplay/poke.js @@ -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}`); } diff --git a/commands/roleplay/punch.js b/commands/roleplay/punch.js index b0ce6e77..e1330eec 100644 --- a/commands/roleplay/punch.js +++ b/commands/roleplay/punch.js @@ -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}`); } diff --git a/commands/roleplay/slap.js b/commands/roleplay/slap.js index 8edc07d8..3191bb3d 100644 --- a/commands/roleplay/slap.js +++ b/commands/roleplay/slap.js @@ -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}`); } diff --git a/commands/search/botinfo.js b/commands/search/botinfo.js index d049ad51..a45f9fee 100644 --- a/commands/search/botinfo.js +++ b/commands/search/botinfo.js @@ -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 { diff --git a/commands/search/define.js b/commands/search/define.js index 28a0315b..93a84af1 100644 --- a/commands/search/define.js +++ b/commands/search/define.js @@ -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 diff --git a/commands/search/discrim.js b/commands/search/discrim.js index 6d254db0..69446d14 100644 --- a/commands/search/discrim.js +++ b/commands/search/discrim.js @@ -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() diff --git a/commands/search/forecast.js b/commands/search/forecast.js index da30dc10..239d71c9 100644 --- a/commands/search/forecast.js +++ b/commands/search/forecast.js @@ -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 diff --git a/commands/search/google.js b/commands/search/google.js index 37ea474c..760d7d80 100644 --- a/commands/search/google.js +++ b/commands/search/google.js @@ -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 { diff --git a/commands/search/imdb.js b/commands/search/imdb.js index 5cfabd6c..ebf6137e 100644 --- a/commands/search/imdb.js +++ b/commands/search/imdb.js @@ -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 diff --git a/commands/search/lmgtfy.js b/commands/search/lmgtfy.js index 3b0bc0fa..95aa5c96 100644 --- a/commands/search/lmgtfy.js +++ b/commands/search/lmgtfy.js @@ -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}`); } diff --git a/commands/search/map.js b/commands/search/map.js index 54c1b5ba..979c2266 100644 --- a/commands/search/map.js +++ b/commands/search/map.js @@ -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 diff --git a/commands/search/neopet.js b/commands/search/neopet.js index 5169d620..40ac5c63 100644 --- a/commands/search/neopet.js +++ b/commands/search/neopet.js @@ -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 diff --git a/commands/search/osu.js b/commands/search/osu.js index cc399e72..1546e4f5 100644 --- a/commands/search/osu.js +++ b/commands/search/osu.js @@ -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 diff --git a/commands/search/soundcloud.js b/commands/search/soundcloud.js index d888035e..61b0db5a 100644 --- a/commands/search/soundcloud.js +++ b/commands/search/soundcloud.js @@ -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 diff --git a/commands/search/urban.js b/commands/search/urban.js index 33bc222f..c613ff86 100644 --- a/commands/search/urban.js +++ b/commands/search/urban.js @@ -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 diff --git a/commands/search/wattpad.js b/commands/search/wattpad.js index 67d5e09c..490290af 100644 --- a/commands/search/wattpad.js +++ b/commands/search/wattpad.js @@ -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 diff --git a/commands/search/weather.js b/commands/search/weather.js index 84320011..21a6778e 100644 --- a/commands/search/weather.js +++ b/commands/search/weather.js @@ -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 diff --git a/commands/search/wikipedia.js b/commands/search/wikipedia.js index a0316197..e10633c9 100644 --- a/commands/search/wikipedia.js +++ b/commands/search/wikipedia.js @@ -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 diff --git a/commands/search/youtube.js b/commands/search/youtube.js index 44329d9b..f694d18b 100644 --- a/commands/search/youtube.js +++ b/commands/search/youtube.js @@ -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 diff --git a/commands/search/yugioh.js b/commands/search/yugioh.js index 17ac4d13..92b72e73 100644 --- a/commands/search/yugioh.js +++ b/commands/search/yugioh.js @@ -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 diff --git a/commands/textedit/binary.js b/commands/textedit/binary.js index 6ae9a726..f80ac531 100644 --- a/commands/textedit/binary.js +++ b/commands/textedit/binary.js @@ -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); } diff --git a/commands/textedit/cowsay.js b/commands/textedit/cowsay.js index 46e0522a..a08ebc3f 100644 --- a/commands/textedit/cowsay.js +++ b/commands/textedit/cowsay.js @@ -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 || ||`); } diff --git a/commands/textedit/embed.js b/commands/textedit/embed.js index 883772bf..71c22ab2 100644 --- a/commands/textedit/embed.js +++ b/commands/textedit/embed.js @@ -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); } }; diff --git a/commands/textedit/morse.js b/commands/textedit/morse.js index 7fa0e0d7..00c4e5dd 100644 --- a/commands/textedit/morse.js +++ b/commands/textedit/morse.js @@ -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); } diff --git a/commands/textedit/pirate.js b/commands/textedit/pirate.js index 17e94202..66ca3071 100644 --- a/commands/textedit/pirate.js +++ b/commands/textedit/pirate.js @@ -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}`); } diff --git a/commands/textedit/reverse.js b/commands/textedit/reverse.js index d4a3aa44..d863b4e2 100644 --- a/commands/textedit/reverse.js +++ b/commands/textedit/reverse.js @@ -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}`); } diff --git a/commands/textedit/say.js b/commands/textedit/say.js index eaa30011..297ad2f4 100644 --- a/commands/textedit/say.js +++ b/commands/textedit/say.js @@ -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}`); } }; diff --git a/commands/textedit/temmie.js b/commands/textedit/temmie.js index 71ee2f6d..625a153e 100644 --- a/commands/textedit/temmie.js +++ b/commands/textedit/temmie.js @@ -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}`); } diff --git a/commands/textedit/upsidedown.js b/commands/textedit/upsidedown.js index 4d45e596..dc41130a 100644 --- a/commands/textedit/upsidedown.js +++ b/commands/textedit/upsidedown.js @@ -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); } diff --git a/commands/textedit/webhook.js b/commands/textedit/webhook.js index 810a004a..3f8e35f2 100644 --- a/commands/textedit/webhook.js +++ b/commands/textedit/webhook.js @@ -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(); diff --git a/commands/textedit/zalgo.js b/commands/textedit/zalgo.js index c6b8b0a0..438cf1fe 100644 --- a/commands/textedit/zalgo.js +++ b/commands/textedit/zalgo.js @@ -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}`); } diff --git a/commands/userinfo/avatar.js b/commands/userinfo/avatar.js index 8011fc85..c8556bb0 100644 --- a/commands/userinfo/avatar.js +++ b/commands/userinfo/avatar.js @@ -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); } diff --git a/commands/userinfo/userinfo.js b/commands/userinfo/userinfo.js index 71310a86..367afe5a 100644 --- a/commands/userinfo/userinfo.js +++ b/commands/userinfo/userinfo.js @@ -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; diff --git a/commands/util/info.js b/commands/util/info.js index f205bc6a..cc9ce6c5 100644 --- a/commands/util/info.js +++ b/commands/util/info.js @@ -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) diff --git a/commands/util/invite.js b/commands/util/invite.js index 0e251f31..e98a5c9a 100644 --- a/commands/util/invite.js +++ b/commands/util/invite.js @@ -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}`); } diff --git a/commands/util/shardinfo.js b/commands/util/shardinfo.js index 7eb2296e..8e82fc41 100644 --- a/commands/util/shardinfo.js +++ b/commands/util/shardinfo.js @@ -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,9 +9,6 @@ module.exports = class ShardInfoCommand extends Command { super(client, { name: 'shardinfo', aliases: [ - 'shard-info', - 'shard-data', - 'sharddata', 'shard' ], group: 'util', @@ -26,12 +23,12 @@ module.exports = class ShardInfoCommand 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 { shardID } = args; - if (shardID > this.client.options.shardCount - 1 || shardID < 0) return message.say(':x: Error! Invalid Shard!'); + if (shardID > this.client.options.shardCount - 1 || shardID < 0) + return message.say(':x: Error! Invalid Shard!'); const memory = await this.client.shard.broadcastEval('Math.round(process.memoryUsage().heapUsed / 1024 / 1024)'); const uptime = await this.client.shard.fetchClientValues('uptime'); const guilds = await this.client.shard.fetchClientValues('guilds.size'); diff --git a/commands/util/uptime.js b/commands/util/uptime.js index 62a40929..72bd1771 100644 --- a/commands/util/uptime.js +++ b/commands/util/uptime.js @@ -13,9 +13,6 @@ module.exports = class UptimeCommand 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've been active on this shard for: **${moment.duration(this.client.uptime).format('d[ days], h[ hours], m[ minutes, and ]s[ seconds]')}**!`); } }; diff --git a/index.js b/index.js index e8054fd0..53f5d12a 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ const { CommandoClient } = require('discord.js-commando'); -const { discordBots, carbon } = require('./poststats.js'); +const { discordBots, carbon } = require('./poststats'); const path = require('path'); const client = new CommandoClient({ commandPrefix: 'x;', diff --git a/package.json b/package.json index 6458f3a4..0ef67659 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "31.10.0", + "version": "32.0.0", "description": "A Discord Bot", "main": "shardingmanager.js", "scripts": { diff --git a/shardingmanager.js b/shardingmanager.js index 9865d613..5e868277 100644 --- a/shardingmanager.js +++ b/shardingmanager.js @@ -1,5 +1,7 @@ const { ShardingManager } = require('discord.js'); -const Manager = new ShardingManager('./index.js'); -Manager.spawn(1); +const Manager = new ShardingManager('./index.js', { + token: process.env.TOKEN +}); +Manager.spawn(); process.on('unhandledRejection', console.error);