diff --git a/commands/avataredit/3000years.js b/commands/avataredit/3000years.js index ab39bc79..d18d76a7 100644 --- a/commands/avataredit/3000years.js +++ b/commands/avataredit/3000years.js @@ -22,12 +22,12 @@ module.exports = class YearsCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return msg.say('This Command requires the `Attach Files` Permission.'); const { user } = args; const avatarURL = user.avatarURL('png', 2048); - if (!avatarURL) return msg.say('This user has no avatar.'); + if(!avatarURL) return msg.say('This user has no avatar.'); let images = []; images.push(Jimp.read(avatarURL)); images.push(Jimp.read('https://i.imgur.com/eScwGFS.png')); @@ -35,8 +35,8 @@ module.exports = class YearsCommand extends Command { avatar.resize(200, 200); az.composite(avatar, 461, 127); az.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if (err) return msg.say('An Unknown Error Occurred.'); - return msg.channel.send({files: [{attachment: buff}]}) + if(err) return msg.say('An Unknown Error Occurred.'); + return msg.channel.send({ files: [{ attachment: buff, name: 'az.png' }] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); }); } diff --git a/commands/avataredit/beautiful.js b/commands/avataredit/beautiful.js index 07700e70..1b2c17e6 100644 --- a/commands/avataredit/beautiful.js +++ b/commands/avataredit/beautiful.js @@ -22,12 +22,12 @@ module.exports = class BeautifulCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return msg.say('This Command requires the `Attach Files` Permission.'); const { user } = args; const avatarURL = user.avatarURL('png', 2048); - if (!avatarURL) return msg.say('This user has no avatar.'); + if(!avatarURL) return msg.say('This user has no avatar.'); let images = []; images.push(Jimp.read(avatarURL)); images.push(Jimp.read('https://i.imgur.com/71qLwPf.png')); @@ -36,8 +36,8 @@ module.exports = class BeautifulCommand extends Command { grunkle.composite(avatar, 341, 35); grunkle.composite(avatar, 342, 301); grunkle.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if (err) return msg.say('An Unknown Error Occurred.'); - return msg.channel.send({files: [{attachment: buff}]}) + if(err) return msg.say('An Unknown Error Occurred.'); + return msg.channel.send({ files: [{ attachment: buff, name: 'beautiful.png' }] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); }); } diff --git a/commands/avataredit/bobross.js b/commands/avataredit/bobross.js index 1eba330e..ecc64172 100644 --- a/commands/avataredit/bobross.js +++ b/commands/avataredit/bobross.js @@ -22,12 +22,12 @@ module.exports = class BobRossCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return msg.say('This Command requires the `Attach Files` Permission.'); const { user } = args; const avatarURL = user.avatarURL('png', 2048); - if (!avatarURL) return msg.say('This user has no avatar.'); + if(!avatarURL) return msg.say('This user has no avatar.'); const blank = new Jimp(600, 775, 0xFFFFFFFF); let images = []; images.push(Jimp.read(avatarURL)); @@ -38,8 +38,8 @@ module.exports = class BobRossCommand extends Command { blank.composite(avatar, 44, 85); blank.composite(bob, 0, 0); blank.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if (err) return msg.say('An Unknown Error Occurred.'); - return msg.channel.send({files: [{attachment: buff}]}) + if(err) return msg.say('An Unknown Error Occurred.'); + return msg.channel.send({ files: [{ attachment: buff, name: 'bobross.png' }] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); }); } diff --git a/commands/avataredit/greyscale.js b/commands/avataredit/greyscale.js index 88948750..a598ba5f 100644 --- a/commands/avataredit/greyscale.js +++ b/commands/avataredit/greyscale.js @@ -19,17 +19,17 @@ module.exports = class GreyscaleCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return msg.say('This Command requires the `Attach Files` Permission.'); const { user } = args; const avatarURL = user.avatarURL('png', 2048); - if (!avatarURL) return msg.say('This user has no avatar.'); + if(!avatarURL) return msg.say('This user has no avatar.'); const avatar = await Jimp.read(avatarURL); avatar.greyscale(); avatar.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if (err) return msg.say('An Unknown Error Occurred.'); - return msg.channel.send({files: [{attachment: buff}]}) + if(err) return msg.say('An Unknown Error Occurred.'); + return msg.channel.send({ files: [{ attachment: buff, name: 'greyscale.png' }] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); }); } diff --git a/commands/avataredit/invert.js b/commands/avataredit/invert.js index 90282a29..d38b981d 100644 --- a/commands/avataredit/invert.js +++ b/commands/avataredit/invert.js @@ -19,17 +19,17 @@ module.exports = class InvertCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return msg.say('This Command requires the `Attach Files` Permission.'); const { user } = args; const avatarURL = user.avatarURL('png', 2048); - if (!avatarURL) return msg.say('This user has no avatar.'); + if(!avatarURL) return msg.say('This user has no avatar.'); const avatar = await Jimp.read(avatarURL); avatar.invert(); avatar.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if (err) return msg.say('An Unknown Error Occurred.'); - return msg.channel.send({files: [{attachment: buff}]}) + if(err) return msg.say('An Unknown Error Occurred.'); + return msg.channel.send({ files: [{ attachment: buff, name: 'invert.png' }] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); }); } diff --git a/commands/avataredit/rip.js b/commands/avataredit/rip.js index 6611b7ce..bb5a15b1 100644 --- a/commands/avataredit/rip.js +++ b/commands/avataredit/rip.js @@ -23,12 +23,12 @@ module.exports = class RIPCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return msg.say('This Command requires the `Attach Files` Permission.'); const { user } = args; const avatarURL = user.avatarURL('png', 2048); - if (!avatarURL) return msg.say('This user has no avatar.'); + if(!avatarURL) return msg.say('This user has no avatar.'); let images = []; images.push(Jimp.read(avatarURL)); images.push(Jimp.read('https://i.imgur.com/KriteWm.jpg')); @@ -37,8 +37,8 @@ module.exports = class RIPCommand extends Command { avatar.resize(200, 200); grave.composite(avatar, 158, 51); grave.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if (err) return msg.say('An Unknown Error Occurred.'); - return msg.channel.send({files: [{attachment: buff}]}) + if(err) return msg.say('An Unknown Error Occurred.'); + return msg.channel.send({ files: [{ attachment: buff, name: 'rip.png' }] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); }); } diff --git a/commands/avataredit/steamcard.js b/commands/avataredit/steamcard.js index 7053a656..1d1e933e 100644 --- a/commands/avataredit/steamcard.js +++ b/commands/avataredit/steamcard.js @@ -22,13 +22,13 @@ module.exports = class SteamCardCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return msg.say('This Command requires the `Attach Files` Permission.'); const { user } = args; const username = msg.guild ? msg.guild.member(user).displayName : user.username; const avatarURL = user.avatarURL('png', 2048); - if (!avatarURL) return msg.say('This user has no avatar.'); + if(!avatarURL) return msg.say('This user has no avatar.'); const blank = new Jimp(494, 568, 0xFFFFFFFF); let images = []; images.push(Jimp.read(avatarURL)); @@ -40,8 +40,8 @@ module.exports = class SteamCardCommand extends Command { blank.composite(card, 0, 0); blank.print(font, 38, 20, username); blank.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if (err) return msg.say('An Unknown Error Occurred.'); - return msg.channel.send({files: [{attachment: buff}]}) + if(err) return msg.say('An Unknown Error Occurred.'); + return msg.channel.send({ files: [{ attachment: buff, name: 'steamcard.png' }] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); }); } diff --git a/commands/avataredit/triggered.js b/commands/avataredit/triggered.js index 8900d226..19d345b0 100644 --- a/commands/avataredit/triggered.js +++ b/commands/avataredit/triggered.js @@ -19,12 +19,12 @@ module.exports = class TriggeredCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return msg.say('This Command requires the `Attach Files` Permission.'); const { user } = args; const avatarURL = user.avatarURL('png', 2048); - if (!avatarURL) return msg.say('This user has no avatar.'); + if(!avatarURL) return msg.say('This user has no avatar.'); const blank = new Jimp(320, 371, 0xFFFFFFFF); let images = []; images.push(Jimp.read(avatarURL)); @@ -34,8 +34,8 @@ module.exports = class TriggeredCommand extends Command { blank.composite(avatar, 0, 0); blank.composite(triggered, 0, 0); blank.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if (err) return msg.say('An Unknown Error Occurred.'); - return msg.channel.send({files: [{attachment: buff}]}) + if(err) return msg.say('An Unknown Error Occurred.'); + return msg.channel.send({ files: [{ attachment: buff, name: 'triggered.png' }] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); }); } diff --git a/commands/avataredit/wanted.js b/commands/avataredit/wanted.js index a7914807..637eedbb 100644 --- a/commands/avataredit/wanted.js +++ b/commands/avataredit/wanted.js @@ -19,12 +19,12 @@ module.exports = class WantedCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return msg.say('This Command requires the `Attach Files` Permission.'); const { user } = args; const avatarURL = user.avatarURL('png', 2048); - if (!avatarURL) return msg.say('This user has no avatar.'); + if(!avatarURL) return msg.say('This user has no avatar.'); let images = []; images.push(Jimp.read(avatarURL)); images.push(Jimp.read('https://i.imgur.com/ca09TG5.jpg')); @@ -32,8 +32,8 @@ module.exports = class WantedCommand extends Command { avatar.resize(500, 500); wanted.composite(avatar, 189, 438); wanted.getBuffer(Jimp.MIME_PNG, (err, buff) => { - if (err) return msg.say('An Unknown Error Occurred.'); - return msg.channel.send({files: [{attachment: buff}]}) + if(err) return msg.say('An Unknown Error Occurred.'); + return msg.channel.send({ files: [{ attachment: buff, name: 'wanted.png' }] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); }); } diff --git a/commands/games/lottery.js b/commands/games/lottery.js index 69ac987d..0be99a1c 100644 --- a/commands/games/lottery.js +++ b/commands/games/lottery.js @@ -12,8 +12,7 @@ module.exports = class LotteryCommand extends Command { run(msg) { const lottery = Math.floor(Math.random() * 100) + 1; - if (lottery < 99) - return msg.say(`Nope, sorry ${msg.author.username}, you lost.`); + if(lottery < 99) return msg.say(`Nope, sorry ${msg.author.username}, you lost.`); return msg.say(`Wow ${msg.author.username}! You actually won! Great job!`); } }; diff --git a/commands/games/mathgame.js b/commands/games/mathgame.js index 8aca0191..1d464834 100644 --- a/commands/games/mathgame.js +++ b/commands/games/mathgame.js @@ -17,7 +17,7 @@ module.exports = class MathGameCommand extends Command { prompt: 'What should the difficulty of the math game be? `Easy`, `Medium`, `Hard`, `Extreme`, or `Impossible`?', type: 'string', validate: difficulty => { - if (['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase())) + if(['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase())) return true; return 'Please set the difficulty to either `easy`, `medium`, `hard`, `extreme`, or `impossible`.'; }, @@ -28,13 +28,13 @@ module.exports = class MathGameCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { difficulty } = args; const operation = operations[Math.floor(Math.random() * operations.length)]; let value; - switch (difficulty) { + switch(difficulty) { case 'easy': value = 10; break; @@ -63,13 +63,13 @@ module.exports = class MathGameCommand extends Command { time: 10000, errors: ['time'] }); - if (collected.first().content !== solved) + if(collected.first().content !== solved) return msg.say(stripIndents` Aw... Too bad, try again next time! The correct answer is: ${solved} `); return msg.say(`Good Job! You won! ${solved} is the correct answer!`); - } catch (err) { + } catch(err) { return msg.say(stripIndents` Aw... Too bad, try again next time! The correct answer is: ${solved} diff --git a/commands/games/quiz.js b/commands/games/quiz.js index 2bfcaff2..517d64dc 100644 --- a/commands/games/quiz.js +++ b/commands/games/quiz.js @@ -17,8 +17,8 @@ module.exports = class QuizCommand extends Command { } async run(msg) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); try { const { body } = await request @@ -37,16 +37,16 @@ module.exports = class QuizCommand extends Command { time: 15000, errors: ['time'] }); - if (collected.first().content.toLowerCase() !== answer) + if(collected.first().content.toLowerCase() !== answer) return msg.say(`The correct answer is: ${answer}`); return msg.say(`Perfect! The correct answer is: ${answer}`); - } catch (err) { + } catch(err) { return msg.say(stripIndents` Aw... Too bad, try again next time! The Correct Answer was: ${answer} `); } - } catch (err) { + } catch(err) { return msg.say('An Unknown Error Occurred.'); } } diff --git a/commands/games/rockpaperscissors.js b/commands/games/rockpaperscissors.js index 98cdf3dd..60a87312 100644 --- a/commands/games/rockpaperscissors.js +++ b/commands/games/rockpaperscissors.js @@ -17,7 +17,7 @@ module.exports = class RockPaperScissorsCommand extends Command { prompt: '`Rock`, `Paper`, or `Scissors`?', type: 'string', validate: choice => { - if (['rock', 'paper', 'scissors'].includes(choice.toLowerCase())) + if(['rock', 'paper', 'scissors'].includes(choice.toLowerCase())) return true; return 'Please enter either `rock`, `paper`, or `scissors`.'; }, @@ -30,26 +30,26 @@ module.exports = class RockPaperScissorsCommand extends Command { run(msg, args) { const { choice } = args; const response = responses[Math.floor(Math.random() * responses.length)]; - if (choice === 'rock') { - if (response === 'Rock') + if(choice === 'rock') { + if(response === 'Rock') return msg.say('Rock! Aw, it\'s a tie!'); - if (response === 'Paper') + if(response === 'Paper') return msg.say('Paper! Yes! I win!'); - if (response === 'Scissors') + if(response === 'Scissors') return msg.say('Scissors! Aw... I lose...'); - } else if (choice === 'paper') { - if (response === 'Rock') + } else if(choice === 'paper') { + if(response === 'Rock') return msg.say('Rock! Aw... I lose...'); - if (response === 'Paper') + if(response === 'Paper') return msg.say('Paper! Aw, it\'s a tie!'); - if (response === 'Scissors') + if(response === 'Scissors') return msg.say('Scissors! Yes! I win!'); - } else if (choice === 'scissors') { - if (response === 'Rock') + } else if(choice === 'scissors') { + if(response === 'Rock') return msg.say('Rock! Yes! I win!'); - if (response === 'Paper') + if(response === 'Paper') return msg.say('Paper! Aw... I lose...'); - if (response === 'Scissors') + if(response === 'Scissors') return msg.say('Scissors! Aw, it\'s a tie!'); } } diff --git a/commands/games/slots.js b/commands/games/slots.js index 62fe0184..5aa88e78 100644 --- a/commands/games/slots.js +++ b/commands/games/slots.js @@ -16,7 +16,7 @@ module.exports = class SlotsCommand extends Command { 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 msg.say(stripIndents` ${slotOne}|${slotTwo}|${slotThree} Wow! You won! Great job... er... luck! diff --git a/commands/games/typinggame.js b/commands/games/typinggame.js index 2b266c9e..f821930c 100644 --- a/commands/games/typinggame.js +++ b/commands/games/typinggame.js @@ -15,7 +15,7 @@ module.exports = class TypingGameCommand extends Command { prompt: 'What should the difficulty of the typing game be? `Easy`, `Medium`, `Hard`, `Extreme`, or `Impossible`?', type: 'string', validate: difficulty => { - if (['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase())) + if(['easy', 'medium', 'hard', 'extreme', 'impossible'].includes(difficulty.toLowerCase())) return true; return 'Please set the difficulty to either `easy`, `medium`, `hard`, `extreme`, or `impossible`.'; }, @@ -26,13 +26,13 @@ module.exports = class TypingGameCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { difficulty } = args; const sentence = sentences[Math.floor(Math.random() * sentences.length)]; let time; - switch (difficulty) { + switch(difficulty) { case 'easy': time = 25000; break; @@ -59,10 +59,10 @@ module.exports = class TypingGameCommand extends Command { time: time, errors: ['time'] }); - if (collected.first().content !== sentence) + if(collected.first().content !== sentence) return msg.say('Nope, your sentence does not match the original. Try again next time!'); return msg.say(`Good Job! You won!`); - } catch (err) { + } catch(err) { return msg.say('Aw... Too bad, try again next time!'); } } diff --git a/commands/guildinfo/guildinfo.js b/commands/guildinfo/guildinfo.js index 1c8746d1..4d42e172 100644 --- a/commands/guildinfo/guildinfo.js +++ b/commands/guildinfo/guildinfo.js @@ -21,7 +21,7 @@ module.exports = class GuildInfoCommand extends Command { } run(msg) { - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const embed = new RichEmbed() .setColor(0x00AE86) diff --git a/commands/imageedit/meme.js b/commands/imageedit/meme.js index 64c91d5f..5457a8f9 100644 --- a/commands/imageedit/meme.js +++ b/commands/imageedit/meme.js @@ -15,7 +15,7 @@ module.exports = class MemeCommand extends Command { prompt: 'What meme type do you want to use?', type: 'string', validate: type => { - if (codes.includes(type.toLowerCase())) + if(codes.includes(type.toLowerCase())) return true; return `${type.toLowerCase()} is not a valid meme type. Use \`help meme\` to view a list of types.`; }, @@ -26,7 +26,7 @@ module.exports = class MemeCommand extends Command { prompt: 'What should the top row of the meme to be?', type: 'string', validate: top => { - if (/[a-zA-Z0-9.,!?'\s]+$/g.test(top) && top.length < 100) + if(/[a-zA-Z0-9.,!?'\s]+$/g.test(top) && top.length < 100) return true; return `Please do not use special characters and keep the rows under 100 characters each, top row has ${top.length}.`; }, @@ -37,7 +37,7 @@ module.exports = class MemeCommand extends Command { prompt: 'What should the bottom row of the meme to be?', type: 'string', validate: bottom => { - if (/[a-zA-Z0-9.,!?'\s]+$/g.test(bottom) && bottom.length < 100) + if(/[a-zA-Z0-9.,!?'\s]+$/g.test(bottom) && bottom.length < 100) return true; return `Please do not use special characters and keep the rows under 100 characters each, bottom row has ${bottom.length}.`; }, @@ -48,11 +48,11 @@ module.exports = class MemeCommand extends Command { } run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return msg.say('This Command requires the `Attach Files` Permission.'); const { type, top, bottom } = args; - return msg.channel.send({files: [`https://memegen.link/${type}/${top}/${bottom}.jpg`]}) + return msg.channel.send({ files: [`https://memegen.link/${type}/${top}/${bottom}.jpg`] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); } }; diff --git a/commands/moderation/ban.js b/commands/moderation/ban.js index 0704890f..43863e92 100644 --- a/commands/moderation/ban.js +++ b/commands/moderation/ban.js @@ -24,7 +24,7 @@ module.exports = class BanCommand 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}.`; @@ -39,15 +39,15 @@ module.exports = class BanCommand extends Command { } async run(msg, args) { - if (!msg.channel.permissionsFor(this.client.user).has('BAN_MEMBERS')) + if(!msg.channel.permissionsFor(this.client.user).has('BAN_MEMBERS')) return msg.say('This Command requires the `Ban Members` Permission.'); const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog')); - if (!modlogs) + if(!modlogs) return msg.say('This Command requires a channel set with the `modchannel` command.'); - if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { member, reason } = args; - if (!member.bannable) + if(!member.bannable) return msg.say('This member is not bannable. Perhaps they have a higher role than me?'); try { try { @@ -55,13 +55,10 @@ module.exports = class BanCommand extends Command { You were banned from ${msg.guild.name}! Reason: ${reason}. `); - } catch (err) { + } catch(err) { await msg.say('Failed to send DM to user.'); } - await member.ban({ - days: 7, - reason - }); + await member.ban({ days: 7, reason }); await msg.say(':ok_hand:'); const embed = new RichEmbed() .setAuthor(msg.author.tag, msg.author.displayAvatarURL) @@ -72,8 +69,8 @@ module.exports = class BanCommand extends Command { **Action:** Ban **Reason:** ${reason} `); - return modlogs.send({embed}); - } catch (err) { + return modlogs.send({ embed }); + } catch(err) { return msg.say('An Unknown Error Occurred.'); } } diff --git a/commands/moderation/kick.js b/commands/moderation/kick.js index 1e38b87e..d0b22ad3 100644 --- a/commands/moderation/kick.js +++ b/commands/moderation/kick.js @@ -21,7 +21,7 @@ module.exports = class KickCommand 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}.`; @@ -36,15 +36,15 @@ module.exports = class KickCommand extends Command { } async run(msg, args) { - if (!msg.channel.permissionsFor(this.client.user).has('KICK_MEMBERS')) + if(!msg.channel.permissionsFor(this.client.user).has('KICK_MEMBERS')) return msg.say('This Command requires the `Kick Members` Permission.'); const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog')); - if (!modlogs) + if(!modlogs) return msg.say('This Command requires a channel set with the `modchannel` command.'); - if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { member, reason } = args; - if (!member.kickable) + if(!member.kickable) return msg.say('This member is not kickable. Perhaps they have a higher role than me?'); try { try { @@ -52,12 +52,10 @@ module.exports = class KickCommand extends Command { You were kicked from ${msg.guild.name}! Reason: ${reason}. `); - } catch (err) { + } catch(err) { await msg.say('Failed to send DM.'); } - await member.kick({ - reason - }); + await member.kick({ reason }); await msg.say(':ok_hand:'); const embed = new RichEmbed() .setAuthor(msg.author.tag, msg.author.displayAvatarURL) @@ -68,8 +66,8 @@ module.exports = class KickCommand extends Command { **Action:** Kick **Reason:** ${reason} `); - return modlogs.send({embed}); - } catch (err) { + return modlogs.send({ embed }); + } catch(err) { return msg.say('An Unknown Error Occurred.'); } } diff --git a/commands/moderation/lockdown.js b/commands/moderation/lockdown.js index d3396380..c4a85e4b 100644 --- a/commands/moderation/lockdown.js +++ b/commands/moderation/lockdown.js @@ -1,4 +1,5 @@ const { Command } = require('discord.js-commando'); +const { stripIndents } = require('common-tags'); module.exports = class LockdownCommand extends Command { constructor(client) { @@ -14,7 +15,7 @@ module.exports = class LockdownCommand extends Command { prompt: 'Please enter either `start` or `stop`.', type: 'string', validate: type => { - if (['start', 'stop'].includes(type.toLowerCase())) + if(['start', 'stop'].includes(type.toLowerCase())) return true; return 'Please enter either `start` or `stop`.'; }, @@ -29,25 +30,24 @@ module.exports = class LockdownCommand extends Command { } async run(msg, args) { - if (!msg.channel.permissionsFor(this.client.user).has('ADMINISTRATOR')) + if(!msg.channel.permissionsFor(this.client.user).has('ADMINISTRATOR')) return msg.say('This Command requires the `Administrator` Permission.'); const { type } = args; - if (type === 'start') { + if(type === 'start') { try { - await msg.channel.overwritePermissions(msg.guild.defaultRole, { - SEND_MESSAGES: false - }); - return msg.say('Lockdown Started, users without Administrator can no longer post messages. Please use `;lockdown stop` to end the lockdown.'); - } catch (err) { + await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: false }); + return msg.say(stripIndents` + Lockdown Started, users without Administrator can no longer post messages. + Please use \`;lockdown stop\` to end the lockdown. + `); + } catch(err) { return msg.say('Something went wrong!'); } - } else if (type === 'stop') { + } else if(type === 'stop') { try { - await msg.channel.overwritePermissions(msg.guild.defaultRole, { - SEND_MESSAGES: true - }); + await msg.channel.overwritePermissions(msg.guild.defaultRole, { SEND_MESSAGES: true }); return msg.say('Lockdown Ended, users without Administrator can now post messages.'); - } catch (err) { + } catch(err) { return msg.say('An Unknown Error Occurred.'); } } diff --git a/commands/moderation/prune.js b/commands/moderation/prune.js index b9c2f6d9..43c8062b 100644 --- a/commands/moderation/prune.js +++ b/commands/moderation/prune.js @@ -19,7 +19,7 @@ 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.`; } @@ -33,18 +33,16 @@ module.exports = class PruneCommand extends Command { } async run(msg, args) { - if (!msg.channel.permissionsFor(this.client.user).has('READ_MESSAGE_HISTORY')) + if(!msg.channel.permissionsFor(this.client.user).has('READ_MESSAGE_HISTORY')) return msg.say('This Command requires the `Read Message History` Permission.'); - if (!msg.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES')) + if(!msg.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES')) return msg.say('This Command requires the `Manage Messages` Permission.'); const { count } = args; try { - const messages = await msg.channel.fetchMessages({ - limit: count + 1 - }); + const messages = await msg.channel.fetchMessages({ limit: count + 1 }); await msg.channel.bulkDelete(messages, true); return null; - } catch (err) { + } catch(err) { return msg.say('There are no messages younger than two weeks that can be deleted.'); } } diff --git a/commands/moderation/softban.js b/commands/moderation/softban.js index 91d143aa..ffb93967 100644 --- a/commands/moderation/softban.js +++ b/commands/moderation/softban.js @@ -21,7 +21,7 @@ module.exports = class SoftbanCommand 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}.`; @@ -36,17 +36,17 @@ module.exports = class SoftbanCommand extends Command { } async run(msg, args) { - if (!msg.channel.permissionsFor(this.client.user).has('BAN_MEMBERS')) + if(!msg.channel.permissionsFor(this.client.user).has('BAN_MEMBERS')) return msg.say('This Command requires the `Ban Members` Permission.'); - if (!msg.channel.permissionsFor(this.client.user).has('KICK_MEMBERS')) + if(!msg.channel.permissionsFor(this.client.user).has('KICK_MEMBERS')) return msg.say('This Command requires the `Kick Members` Permission.'); const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog')); - if (!modlogs) + if(!modlogs) return msg.say('This Command requires a channel set with the `modchannel` command.'); - if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { member, reason } = args; - if (!member.bannable) + if(!member.bannable) return msg.say('This member is not bannable. Perhaps they have a higher role than me?'); try { try { @@ -54,13 +54,10 @@ module.exports = class SoftbanCommand extends Command { You were softbanned from ${msg.guild.name}! Reason: ${reason}. `); - } catch (err) { + } catch(err) { await msg.say('Failed to send DM to user.'); } - await member.ban({ - days: 7, - reason - }); + await member.ban({ days: 7, reason }); await msg.guild.unban(member.user); await msg.say(':ok_hand:'); const embed = new RichEmbed() @@ -72,8 +69,8 @@ module.exports = class SoftbanCommand extends Command { **Action:** Softban **Reason:** ${reason} `); - return modlogs.send({embed}); - } catch (err) { + return modlogs.send({ embed }); + } catch(err) { return msg.say('An Unknown Error Occurred.'); } } diff --git a/commands/moderation/unban.js b/commands/moderation/unban.js index d637702e..e3191b36 100644 --- a/commands/moderation/unban.js +++ b/commands/moderation/unban.js @@ -19,7 +19,7 @@ module.exports = class UnbanCommand extends Command { prompt: 'What member do you want to unban? Please enter the ID of the user.', type: 'string', validate: id => { - if (id.length === 18) + if(id.length === 18) return true; return `${id} is not a valid ID. Please enter the user you wish to unban's ID.`; } @@ -29,7 +29,7 @@ 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}.`; } @@ -43,16 +43,16 @@ module.exports = class UnbanCommand extends Command { } async run(msg, args) { - if (!msg.channel.permissionsFor(this.client.user).has('BAN_MEMBERS')) + if(!msg.channel.permissionsFor(this.client.user).has('BAN_MEMBERS')) return msg.say('This Command requires the `Ban Members` Permission.'); const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog', 'mod_logs')); - if (!modlogs) + if(!modlogs) return msg.say('This Command requires a channel set with the `modchannel` command.'); - if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { id, reason } = args; const bans = await msg.guild.fetchBans(); - if (!bans.has(id)) + if(!bans.has(id)) return msg.say('This ID is not in the Guild Banlist.'); const member = bans.get(id); try { @@ -67,8 +67,8 @@ module.exports = class UnbanCommand extends Command { **Action:** Unban **Reason:** ${reason} `); - return modlogs.send({embed}); - } catch (err) { + return modlogs.send({ embed }); + } catch(err) { return msg.say('An Unknown Error Occurred.'); } } diff --git a/commands/moderation/warn.js b/commands/moderation/warn.js index 70b3c7d9..4b809cbd 100644 --- a/commands/moderation/warn.js +++ b/commands/moderation/warn.js @@ -21,7 +21,7 @@ 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}.`; } @@ -36,9 +36,9 @@ module.exports = class WarnCommand extends Command { async run(msg, args) { const modlogs = msg.guild.channels.get(msg.guild.settings.get('modLog', 'mod_logs')); - if (!modlogs) + if(!modlogs) return msg.say('This Command requires a channel set with the `modchannel` command.'); - if (!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(!modlogs.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { member, reason } = args; try { @@ -52,8 +52,8 @@ module.exports = class WarnCommand extends Command { **Action:** Warn **Reason:** ${reason} `); - return modlogs.send({embed}); - } catch (err) { + return modlogs.send({ embed }); + } catch(err) { return msg.say('An Unknown Error Occurred.'); } } diff --git a/commands/random/easteregg.js b/commands/random/easteregg.js index 61cb95f0..af554829 100644 --- a/commands/random/easteregg.js +++ b/commands/random/easteregg.js @@ -17,7 +17,7 @@ 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!'; }, diff --git a/commands/random/math.js b/commands/random/math.js index 8927e1f1..600419eb 100644 --- a/commands/random/math.js +++ b/commands/random/math.js @@ -24,7 +24,7 @@ module.exports = class MathCommand extends Command { const solved = math.eval(expression); return msg.say(solved) .catch(() => msg.say('Invalid statement.')); - } catch (err) { + } catch(err) { return msg.say('Invalid statement.'); } } diff --git a/commands/random/nitro.js b/commands/random/nitro.js index 8b34b5ee..22b1327a 100644 --- a/commands/random/nitro.js +++ b/commands/random/nitro.js @@ -13,12 +13,12 @@ module.exports = class NitroCommand extends Command { } run(msg) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const embed = new RichEmbed() .setAuthor('Discord Nitro') - .setThumbnail('https://pbs.twimg.com/profile_images/814184180649197568/y2eZcVMq.jpg') + .setThumbnail('https://i.imgur.com/wzhMMnl.jpg') .setColor(0x748BD9) .setURL('https://discordapp.com/nitro') .setDescription(stripIndents` diff --git a/commands/random/spam.js b/commands/random/spam.js index 4ec519b7..6364823f 100644 --- a/commands/random/spam.js +++ b/commands/random/spam.js @@ -11,10 +11,10 @@ module.exports = class SpamCommand extends Command { } run(msg) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return msg.say('This Command requires the `Attach Files` Permission.'); - return msg.channel.send({files: ['https://i.imgur.com/2JFu5xE.jpg']}) + return msg.channel.send({ files: ['https://i.imgur.com/2JFu5xE.jpg'] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); } }; diff --git a/commands/random/strawpoll.js b/commands/random/strawpoll.js index d2729ae3..7993ebf1 100644 --- a/commands/random/strawpoll.js +++ b/commands/random/strawpoll.js @@ -15,7 +15,7 @@ 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}.`; } @@ -26,7 +26,7 @@ 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 options under 160 characters each, you have ${choice.length}.`; } @@ -37,22 +37,19 @@ module.exports = class StrawpollCommand extends Command { async run(msg, args) { const { title, options } = args; - if (options.length < 2) + if(options.length < 2) return msg.say('You provided less than two choices.'); - if (options.length > 31) + if(options.length > 31) return msg.say('You provided more than thirty choices.'); try { const { body } = await request .post('https://strawpoll.me/api/v2/polls') - .send({ - title, - options - }); + .send({ title, options }); return msg.say(stripIndents` ${body.title} http://strawpoll.me/${body.id} `); - } catch (err) { + } catch(err) { return msg.say('An Unknown Error Occurred.'); } } diff --git a/commands/random/today.js b/commands/random/today.js index ba8365e5..0aa565ea 100644 --- a/commands/random/today.js +++ b/commands/random/today.js @@ -13,8 +13,8 @@ module.exports = class TodayCommand extends Command { } async run(msg) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); try { const { text } = await request @@ -30,7 +30,7 @@ module.exports = class TodayCommand extends Command { .setTimestamp() .setDescription(`${events[random].year}: ${events[random].text}`); return msg.embed(embed); - } catch (err) { + } catch(err) { return msg.say('An Unknown Error Occurred.'); } } diff --git a/commands/random/wouldyourather.js b/commands/random/wouldyourather.js index cd382375..4338939d 100644 --- a/commands/random/wouldyourather.js +++ b/commands/random/wouldyourather.js @@ -16,8 +16,8 @@ module.exports = class WouldYouRatherCommand extends Command { } async run(msg) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); try { const { body } = await request @@ -28,7 +28,7 @@ module.exports = class WouldYouRatherCommand extends Command { .setColor(0x9797FF) .setDescription(`${body.choicea} OR ${body.choiceb}?`); return msg.embed(embed); - } catch (err) { + } catch(err) { return msg.say('An Unknown Error Occurred.'); } } diff --git a/commands/randomimg/cat.js b/commands/randomimg/cat.js index ad76bf3f..c3c0302f 100644 --- a/commands/randomimg/cat.js +++ b/commands/randomimg/cat.js @@ -15,15 +15,15 @@ module.exports = class CatCommand extends Command { } async run(msg) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return msg.say('This Command requires the `Attach Files` Permission.'); try { const { body } = await request .get('http://random.cat/meow'); - return msg.channel.send({files: [body.file]}) + return msg.channel.send({ files: [body.file] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); - } catch (err) { + } catch(err) { return msg.say('An Unknown Error Occurred.'); } } diff --git a/commands/randomimg/dog.js b/commands/randomimg/dog.js index c8817b78..21905ef3 100644 --- a/commands/randomimg/dog.js +++ b/commands/randomimg/dog.js @@ -12,15 +12,15 @@ module.exports = class DogCommand extends Command { } async run(msg) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return msg.say('This Command requires the `Attach Files` Permission.'); try { const { body } = await request .get('https://random.dog/woof.json'); - return msg.channel.send({files: [body.url]}) + return msg.channel.send({ files: [body.url] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); - } catch (err) { + } catch(err) { return msg.say('An Unknown Error Occurred.'); } } diff --git a/commands/randomimg/xiaopai.js b/commands/randomimg/xiaopai.js index 2ac71c56..95ffb42f 100644 --- a/commands/randomimg/xiaopai.js +++ b/commands/randomimg/xiaopai.js @@ -15,11 +15,11 @@ module.exports = class XiaoCommand extends Command { } run(msg) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return msg.say('This Command requires the `Attach Files` Permission.'); const xiao = xiaos[Math.floor(Math.random() * xiaos.length)]; - return msg.channel.send({files: [xiao]}) + return msg.channel.send({ files: [xiao] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); } }; diff --git a/commands/response/name.js b/commands/response/name.js index 4be82c4f..e2d3eeb0 100644 --- a/commands/response/name.js +++ b/commands/response/name.js @@ -14,7 +14,7 @@ module.exports = class RandomNameCommand extends Command { prompt: 'Which gender do you want to generate a name for?', type: 'string', validate: gender => { - if (['male', 'female'].includes(gender.toLowerCase())) + if(['male', 'female'].includes(gender.toLowerCase())) return true; return 'Please enter either `male` or `female`.'; }, @@ -27,10 +27,10 @@ module.exports = class RandomNameCommand extends Command { run(msg, args) { const { gender } = args; const lastName = lastNames[Math.floor(Math.random() * lastNames.length)]; - if (gender === 'male') { + if(gender === 'male') { const name = maleNames[Math.floor(Math.random() * maleNames.length)]; return msg.say(`${name} ${lastName}`); - } else if (gender === 'female') { + } else if(gender === 'female') { const name = femaleNames[Math.floor(Math.random() * femaleNames.length)]; return msg.say(`${name} ${lastName}`); } diff --git a/commands/search/botinfo.js b/commands/search/botinfo.js index 97d2c85a..7b6fef0f 100644 --- a/commands/search/botinfo.js +++ b/commands/search/botinfo.js @@ -20,21 +20,19 @@ module.exports = class BotSearchCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { bot } = args; try { const { body } = await request .get(`https://bots.discord.pw/api/bots/${bot.id}`) - .set({ - 'Authorization': process.env.DISCORD_BOTS_KEY - }); + .set({ 'Authorization': process.env.DISCORD_BOTS_KEY }); const embed = new RichEmbed() .setColor(0x9797FF) - .setAuthor('Discord Bots', 'https://cdn.discordapp.com/icons/110373943822540800/47336ad0631ac7aac0a48a2ba6246c65.jpg') + .setAuthor('Discord Bots', 'https://i.imgur.com/lrKYBQi.jpg') .setTitle(body.name) - .setURL('https://bots.discord.pw/') + .setURL(`https://bots.discord.pw/bots/${bot.id}`) .setDescription(body.description) .addField('**Library:**', body.library, true) @@ -43,7 +41,7 @@ module.exports = class BotSearchCommand extends Command { .addField('**Prefix:**', body.prefix, true); return msg.embed(embed); - } catch (err) { + } catch(err) { return msg.say('An Error Occurred. The bot may not have been found.'); } } diff --git a/commands/search/define.js b/commands/search/define.js index 41f44146..3d7dee59 100644 --- a/commands/search/define.js +++ b/commands/search/define.js @@ -21,8 +21,8 @@ module.exports = class DefineCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { query } = args; try { @@ -33,7 +33,7 @@ module.exports = class DefineCommand extends Command { .setTitle(body[0].word) .setDescription(body[0].text); return msg.embed(embed); - } catch (err) { + } catch(err) { return msg.say('An Error Occurred. The word may not have been found.'); } } diff --git a/commands/search/discrim.js b/commands/search/discrim.js index 83c89c63..c670e496 100644 --- a/commands/search/discrim.js +++ b/commands/search/discrim.js @@ -18,7 +18,7 @@ module.exports = class DiscrimCommand extends Command { prompt: 'Which discriminator would you like to search for?', type: 'string', validate: discrim => { - if (/[0-9]+$/g.test(discrim) && discrim.length === 4) + if(/[0-9]+$/g.test(discrim) && discrim.length === 4) return true; return `${discrim} is not a valid discriminator.`; } @@ -28,8 +28,8 @@ module.exports = class DiscrimCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { discrim } = args; const users = await this.client.users.filter(u => u.discriminator === discrim).map(u => u.username).sort(); diff --git a/commands/search/forecast.js b/commands/search/forecast.js index 716a1ee8..d2a6f608 100644 --- a/commands/search/forecast.js +++ b/commands/search/forecast.js @@ -20,8 +20,8 @@ module.exports = class ForecastCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { query } = args; try { @@ -48,7 +48,7 @@ module.exports = class ForecastCommand extends Command { .addField(`**${forecasts[6].day} - ${forecasts[6].date}:**`, `**High:** ${forecasts[6].high}°F, **Low:** ${forecasts[6].low}°F, **Condition:** ${forecasts[6].text}`); return msg.embed(embed); - } catch (err) { + } catch(err) { return msg.say('An Error Occurred. The location may not have been found.'); } } diff --git a/commands/search/google.js b/commands/search/google.js index d7f67dfd..b15b2f1d 100644 --- a/commands/search/google.js +++ b/commands/search/google.js @@ -29,10 +29,10 @@ module.exports = class GoogleCommand extends Command { .get(`https://www.google.com/search?q=${query}`); const $ = cheerio.load(text); let href = $('.r').first().find('a').first().attr('href'); - if (!href) throw new Error('No Results'); + if(!href) throw new Error('No Results'); href = querystring.parse(href.replace('/url?', '')); return message.edit(href.q); - } catch (err) { + } catch(err) { return message.edit('No Results Found.'); } } diff --git a/commands/search/imdb.js b/commands/search/imdb.js index d90e8acc..84b0b8ae 100644 --- a/commands/search/imdb.js +++ b/commands/search/imdb.js @@ -21,8 +21,8 @@ module.exports = class IMDBCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { query } = args; try { @@ -30,7 +30,7 @@ module.exports = class IMDBCommand extends Command { .get(`http://www.omdbapi.com/?t=${query}&plot=full`); const embed = new RichEmbed() .setColor(0xDBA628) - .setAuthor('IMDB', 'http://static.wixstatic.com/media/c65cbf_31901b544fe24f1890134553bf40c8be.png') + .setAuthor('IMDB', 'https://i.imgur.com/sXwwIQs.png') .setURL(`http://www.imdb.com/title/${body.imdbID}`) .setTitle(`${body.Title} (${body.imdbRating} Score)`) .setDescription(body.Plot.substr(0, 2000)) @@ -49,7 +49,7 @@ module.exports = class IMDBCommand extends Command { .addField('**Actors:**', body.Actors); return msg.embed(embed); - } catch (err) { + } catch(err) { return msg.say('An Error Occurred. The film may not have been found.'); } } diff --git a/commands/search/map.js b/commands/search/map.js index acec8170..c88e0d8b 100644 --- a/commands/search/map.js +++ b/commands/search/map.js @@ -15,7 +15,7 @@ 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,16 +31,16 @@ module.exports = class MapCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) return msg.say('This Command requires the `Attach Files` Permission.'); const { zoom, query } = args; try { const { body } = await request .get(`https://maps.googleapis.com/maps/api/staticmap?center=${query}&zoom=${zoom}&size=500x500&key=${process.env.GOOGLE_KEY}`); - return msg.channel.send({files: [{attachment: body}]}) + return msg.channel.send({ files: [{attachment: body}] }) .catch(err => msg.say(`An Error Occurred: ${err}`)); - } catch (err) { + } catch(err) { return msg.say('An Error Occurred. The location may not have been found.'); } } diff --git a/commands/search/neopet.js b/commands/search/neopet.js index 6c9d7e98..85f3a38c 100644 --- a/commands/search/neopet.js +++ b/commands/search/neopet.js @@ -27,10 +27,10 @@ module.exports = class NeopetCommand extends Command { .get(`http://www.sunnyneo.com/petimagefinder.php?name=${query}&size=5&mood=1`); const $ = cheerio.load(text); const link = $('textarea').first().text(); - if (!link.includes('cp')) + if(!link.includes('cp')) return msg.say('This is not a valid pet name.'); return msg.say(link); - } catch (err) { + } catch(err) { return msg.say('An Unknown Error Occurred.'); } } diff --git a/commands/search/osu.js b/commands/search/osu.js index a1d9ea28..7e307544 100644 --- a/commands/search/osu.js +++ b/commands/search/osu.js @@ -21,8 +21,8 @@ module.exports = class OsuCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { query } = args; try { @@ -30,7 +30,7 @@ module.exports = class OsuCommand extends Command { .get(`https://osu.ppy.sh/api/get_user?k=${process.env.OSU_KEY}&u=${query}&type=string`); const embed = new RichEmbed() .setColor(0xFF66AA) - .setAuthor('osu!', 'http://vignette3.wikia.nocookie.net/osugame/images/c/c9/Logo.png/revision/latest?cb=20151219073209') + .setAuthor('osu!', 'https://i.imgur.com/EmnUp00.png') .setURL('https://osu.ppy.sh/') .addField('**Username:**', body[0].username, true) @@ -57,7 +57,7 @@ module.exports = class OsuCommand extends Command { .addField('**A:**', body[0].count_rank_a, true); return msg.embed(embed); - } catch (err) { + } catch(err) { return msg.say('An Error Occurred. The user may not have been found.'); } } diff --git a/commands/search/soundcloud.js b/commands/search/soundcloud.js index 09bcb6df..c296def7 100644 --- a/commands/search/soundcloud.js +++ b/commands/search/soundcloud.js @@ -21,8 +21,8 @@ module.exports = class SoundCloudCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { query } = args; try { @@ -30,7 +30,7 @@ module.exports = class SoundCloudCommand extends Command { .get(`https://api.soundcloud.com/tracks?q=${query}&client_id=${process.env.SOUNDCLOUD_KEY}`); const embed = new RichEmbed() .setColor(0xF15A22) - .setAuthor(body[0].title, 'http://icons.iconarchive.com/icons/danleech/simple/1024/soundcloud-icon.png') + .setAuthor(body[0].title, 'https://i.imgur.com/lFIz7RU.png') .setURL(body[0].permalink_url) .setThumbnail(body[0].artwork_url) .addField('**Artist:**', @@ -44,7 +44,7 @@ module.exports = class SoundCloudCommand extends Command { .addField('**Favorited Count:**', body[0].favoritings_count, true); return msg.embed(embed); - } catch (err) { + } catch(err) { return msg.say('An Error Occurred. The song may not have been found.'); } } diff --git a/commands/search/urban.js b/commands/search/urban.js index 6c4c75b5..16950d81 100644 --- a/commands/search/urban.js +++ b/commands/search/urban.js @@ -21,8 +21,8 @@ module.exports = class UrbanCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { query } = args; try { @@ -30,14 +30,14 @@ module.exports = class UrbanCommand extends Command { .get(`http://api.urbandictionary.com/v0/define?term=${query}`); const embed = new RichEmbed() .setColor(0x32a8f0) - .setAuthor('Urban Dictionary', 'http://a1.mzstatic.com/eu/r30/Purple71/v4/66/54/68/6654683f-cacd-4a55-1784-f14257f77874/icon175x175.png') + .setAuthor('Urban Dictionary', 'https://i.imgur.com/fzFuuL7.png') .setURL(body.list[0].permalink) .setTitle(body.list[0].word) .setDescription(body.list[0].definition.substr(0, 2000)) .addField('**Example:**', body.list[0].example.substr(0, 2000) || 'None'); return msg.embed(embed); - } catch (err) { + } catch(err) { return msg.say('An Error Occurred. The word may not have been found.'); } } diff --git a/commands/search/wattpad.js b/commands/search/wattpad.js index e9a5b056..b91d14ef 100644 --- a/commands/search/wattpad.js +++ b/commands/search/wattpad.js @@ -21,19 +21,17 @@ module.exports = class WattpadCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { query } = args; try { const { body } = await request .get(`https://api.wattpad.com:443/v4/stories?query=${query}&limit=1`) - .set({ - 'Authorization': `Basic ${process.env.WATTPAD_KEY}` - }); + .set({ 'Authorization': `Basic ${process.env.WATTPAD_KEY}` }); const embed = new RichEmbed() .setColor(0xF89C34) - .setAuthor('Wattpad', 'http://www.selfpubtoolbox.com/wp-content/uploads/2015/05/a6044fd3a88acd5043860484db972ca6.png') + .setAuthor('Wattpad', 'https://i.imgur.com/Rw9vRQB.png') .setURL(body.stories[0].url) .setTitle(body.stories[0].title) .setDescription(body.stories[0].description.substr(0, 2000)) @@ -50,7 +48,7 @@ module.exports = class WattpadCommand extends Command { .addField('**Comments:**', body.stories[0].commentCount, true); return msg.embed(embed); - } catch (err) { + } catch(err) { return msg.say('An Error Occurred. The book may not have been found.'); } } diff --git a/commands/search/weather.js b/commands/search/weather.js index 76879b24..99f1b4ed 100644 --- a/commands/search/weather.js +++ b/commands/search/weather.js @@ -20,8 +20,8 @@ module.exports = class WeatherCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { query } = args; try { @@ -57,7 +57,7 @@ module.exports = class WeatherCommand extends Command { .addField('**Wind Speed:**', body.query.results.channel.wind.speed, true); return msg.embed(embed); - } catch (err) { + } catch(err) { return msg.say('An Error Occurred. The location may not have been found.'); } } diff --git a/commands/search/wikipedia.js b/commands/search/wikipedia.js index ed9f078e..0e4c04db 100644 --- a/commands/search/wikipedia.js +++ b/commands/search/wikipedia.js @@ -21,8 +21,8 @@ module.exports = class WikipediaCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { query } = args; try { @@ -32,10 +32,10 @@ module.exports = class WikipediaCommand extends Command { .setColor(0xE7E7E7) .setTitle(body.query.pages[0].title) .setURL(`https://en.wikipedia.org/wiki/${query}`) - .setAuthor('Wikipedia', 'https://upload.wikimedia.org/wikipedia/en/thumb/8/80/Wikipedia-logo-v2.svg/1122px-Wikipedia-logo-v2.svg.png') + .setAuthor('Wikipedia', 'https://i.imgur.com/a4eeEhh.png') .setDescription(body.query.pages[0].extract.substr(0, 2000).replace(/[\n]/g, '\n\n')); return msg.embed(embed); - } catch (err) { + } catch(err) { return msg.say('An Error Occurred. The page may not have been found.'); } } diff --git a/commands/search/youtube.js b/commands/search/youtube.js index cd2a7724..47e6e7a0 100644 --- a/commands/search/youtube.js +++ b/commands/search/youtube.js @@ -21,8 +21,8 @@ module.exports = class YouTubeCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { query } = args; try { @@ -32,11 +32,11 @@ module.exports = class YouTubeCommand extends Command { .setColor(0xDD2825) .setTitle(body.items[0].snippet.title) .setDescription(body.items[0].snippet.description) - .setAuthor(`YouTube - ${body.items[0].snippet.channelTitle}`, 'https://cdn3.iconfinder.com/data/icons/social-icons-5/607/YouTube_Play.png') + .setAuthor(`YouTube - ${body.items[0].snippet.channelTitle}`, 'https://i.imgur.com/hkUafwu.png') .setURL(`https://www.youtube.com/watch?v=${body.items[0].id.videoId}`) .setThumbnail(body.items[0].snippet.thumbnails.default.url); return msg.embed(embed); - } catch (err) { + } catch(err) { return msg.say('An Error Occurred. The video may not have been found.'); } } diff --git a/commands/search/yugioh.js b/commands/search/yugioh.js index 3bffa850..420d73f3 100644 --- a/commands/search/yugioh.js +++ b/commands/search/yugioh.js @@ -21,19 +21,19 @@ module.exports = class YuGiOhCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { query } = args; try { const { body } = await request .get(`http://yugiohprices.com/api/card_data/${query}`); - if (body.data.card_type === 'monster') { + if(body.data.card_type === 'monster') { const embed = new RichEmbed() .setColor(0xBE5F1F) .setTitle(body.data.name) .setDescription(body.data.text) - .setAuthor('Yu-Gi-Oh!', 'http://vignette3.wikia.nocookie.net/yugioh/images/1/10/Back-TF-EN-VG.png/revision/latest?cb=20120824043558') + .setAuthor('Yu-Gi-Oh!', 'https://i.imgur.com/7gPm9Rr.png') .addField('**Card Type:**', 'Monster', true) .addField('**Type:**', @@ -52,11 +52,11 @@ module.exports = class YuGiOhCommand extends Command { .setColor(0xBE5F1F) .setTitle(body.data.name) .setDescription(body.data.text) - .setAuthor('Yu-Gi-Oh!', 'http://vignette3.wikia.nocookie.net/yugioh/images/1/10/Back-TF-EN-VG.png/revision/latest?cb=20120824043558') + .setAuthor('Yu-Gi-Oh!', 'https://i.imgur.com/7gPm9Rr.png') .addField('**Card Type:**', body.data.card_type, true); return msg.embed(embed); - } catch (err) { + } catch(err) { return msg.say('An Error Occurred. The card may not have been found.'); } } diff --git a/commands/textedit/binary.js b/commands/textedit/binary.js index 0eedda57..9f6d9651 100644 --- a/commands/textedit/binary.js +++ b/commands/textedit/binary.js @@ -20,7 +20,7 @@ module.exports = class BinaryCommand extends Command { prompt: 'What text would you like to convert to binary?', type: 'string', validate: text => { - if (binary(text).length < 2000) + if(binary(text).length < 2000) return true; return 'Your message content is too long.'; }, diff --git a/commands/textedit/cowsay.js b/commands/textedit/cowsay.js index 03f92d4f..2bded6b9 100644 --- a/commands/textedit/cowsay.js +++ b/commands/textedit/cowsay.js @@ -14,7 +14,7 @@ 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}.`; } diff --git a/commands/textedit/embed.js b/commands/textedit/embed.js index c3bd0dee..b21bfa6f 100644 --- a/commands/textedit/embed.js +++ b/commands/textedit/embed.js @@ -19,8 +19,8 @@ module.exports = class EmbedCommand extends Command { } run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { text } = args; const embed = new RichEmbed() diff --git a/commands/textedit/morse.js b/commands/textedit/morse.js index f7269632..646d6ea9 100644 --- a/commands/textedit/morse.js +++ b/commands/textedit/morse.js @@ -15,7 +15,7 @@ module.exports = class MorseCommand extends Command { prompt: 'What text would you like to convert to morse?', type: 'string', validate: text => { - if (letterTrans(text, dictionary, ' ').length < 1999) + if(letterTrans(text, dictionary, ' ').length < 1999) return true; return 'Your message content is too long.'; }, diff --git a/commands/textedit/pirate.js b/commands/textedit/pirate.js index b8726bbb..67af5c91 100644 --- a/commands/textedit/pirate.js +++ b/commands/textedit/pirate.js @@ -15,7 +15,7 @@ module.exports = class PirateCommand extends Command { prompt: 'What text would you like to convert to pirate?', type: 'string', validate: text => { - if (wordTrans(text, dictionary).length < 1999) + if(wordTrans(text, dictionary).length < 1999) return true; return 'Your message content is too long.'; }, diff --git a/commands/textedit/say.js b/commands/textedit/say.js index e9b94e96..d24ee177 100644 --- a/commands/textedit/say.js +++ b/commands/textedit/say.js @@ -24,7 +24,7 @@ module.exports = class SayCommand extends Command { } run(msg, args) { - if (!msg.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES')) + if(!msg.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES')) return msg.say('This Command requires the `Manage Messages` Permission.'); const { text } = args; msg.delete(); diff --git a/commands/textedit/temmie.js b/commands/textedit/temmie.js index c0dc7c83..ba1e43a9 100644 --- a/commands/textedit/temmie.js +++ b/commands/textedit/temmie.js @@ -15,7 +15,7 @@ module.exports = class TemmieCommand extends Command { prompt: 'What text would you like to convert to Temmie speak?', type: 'string', validate: text => { - if (wordTrans(text, dictionary).length < 1999) + if(wordTrans(text, dictionary).length < 1999) return true; return 'Your message content is too long.'; }, diff --git a/commands/textedit/webhook.js b/commands/textedit/webhook.js index 79b8748c..3809d3b6 100644 --- a/commands/textedit/webhook.js +++ b/commands/textedit/webhook.js @@ -28,16 +28,16 @@ module.exports = class WebhookCommand extends Command { } async run(msg, args) { - if (!msg.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES')) + if(!msg.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES')) return msg.say('This Command requires the `Manage Messages` Permission.'); const { content } = args; try { msg.delete(); await request .post(process.env.WEBHOOK_URL) - .send({content}); + .send({ content }); return null; - } catch (err) { + } catch(err) { return msg.say('An Unknown Error Occurred.'); } } diff --git a/commands/textedit/zalgo.js b/commands/textedit/zalgo.js index d103b6d2..e0f50a08 100644 --- a/commands/textedit/zalgo.js +++ b/commands/textedit/zalgo.js @@ -14,7 +14,7 @@ module.exports = class ZalgoCommand extends Command { prompt: 'What text would you like to convert to zalgo?', type: 'string', validate: text => { - if (text.length < 500) { + if(text.length < 500) { return true; } return `Please keep your text under 500 characters, you have ${text.length}.`; diff --git a/commands/userinfo/userinfo.js b/commands/userinfo/userinfo.js index 2ebe6ff0..8c045e80 100644 --- a/commands/userinfo/userinfo.js +++ b/commands/userinfo/userinfo.js @@ -28,14 +28,14 @@ module.exports = class UserInfoCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { user } = args; - const member = await msg.guild.fetchMember(user); + const member = msg.guild.member(user); let stat; let color; - switch (user.presence.status) { + switch(user.presence.status) { case 'online': stat = '<:vpOnline:212789758110334977> Online'; color = 0x00AE86; diff --git a/commands/util/clearsetting.js b/commands/util/clearsetting.js index 29b8a184..4f6c9aa8 100644 --- a/commands/util/clearsetting.js +++ b/commands/util/clearsetting.js @@ -14,7 +14,7 @@ module.exports = class ClearSettingCommand extends Command { prompt: 'What setting do you want to clear? `modLog`, `memberLog`, or `staffRole`?', type: 'string', validate: setting => { - if (['modLog', 'memberLog', 'staffRole'].includes(setting)) + if(['modLog', 'memberLog', 'staffRole'].includes(setting)) return true; return 'Please enter either `modLog`, `memberLog`, or `staffRole`.'; } diff --git a/commands/util/help.js b/commands/util/help.js index 40df700e..7b42e2f6 100644 --- a/commands/util/help.js +++ b/commands/util/help.js @@ -28,8 +28,8 @@ module.exports = class HelpCommand extends Command { const { command } = args; const commands = this.client.registry.findCommands(command, false, msg); const showAll = command && command.toLowerCase() === 'all'; - if (command && !showAll) { - if (commands.length === 1) { + if(command && !showAll) { + if(commands.length === 1) { return msg.say(stripIndents` __Command **${commands[0].name}**:__ *${commands[0].description}* ${commands[0].guildOnly ? 'Usable Only in Servers' : 'Usable in Servers and DM'} @@ -38,17 +38,15 @@ module.exports = class HelpCommand extends Command { **Group:** ${commands[0].group.name} ${commands[0].details || ''} `); - } else if (commands.length > 1) { + } else if(commands.length > 1) { return msg.say('Multiple Commands Found. Please be more specific.'); } else { - return msg.say(`Could not identify command. Use ${msg.usage( - null, msg.channel.type === 'dm' ? null : undefined, msg.channel.type === 'dm' ? null : undefined - )} to view a list of commands you can use.`); + return msg.say(`Could not identify command. Use ${msg.usage(null)} to view a list of commands you can use.`); } } else { const embed = new RichEmbed() .setTitle(!showAll ? `Commands Available in ${msg.guild ? msg.guild.name : 'this DM'}` : 'All Commands') - .setDescription(`Use ${this.usage('', null, null)} to view detailed information about a specific command.`) + .setDescription(`Use ${msg.usage('')} to view detailed information about a specific command.`) .setColor(0x00AE86); for (const group of this.client.registry.groups.array()) { embed.addField(group.name, @@ -57,9 +55,9 @@ module.exports = class HelpCommand extends Command { group.commands.map(c => `\`${c.name}\``).join(', ')); } try { - await msg.author.send({embed}); + await msg.author.send({ embed }); return msg.say(':mailbox_with_mail: Sent you a DM with information.'); - } catch (err) { + } catch(err) { return msg.say('Failed to send DM. You probably have DMs disabled.'); } } diff --git a/commands/util/info.js b/commands/util/info.js index a5fbb07b..f3f26d76 100644 --- a/commands/util/info.js +++ b/commands/util/info.js @@ -1,5 +1,6 @@ const { Command } = require('discord.js-commando'); const { RichEmbed } = require('discord.js'); +const { oneLine } = require('common-tags'); const { version } = require('../../package'); const moment = require('moment'); require('moment-duration-format'); @@ -18,14 +19,18 @@ module.exports = class InfoCommand extends Command { } async run(msg) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const guilds = await this.client.shard.fetchClientValues('guilds.size'); const memory = await this.client.shard.broadcastEval('Math.round(process.memoryUsage().heapUsed / 1024 / 1024)'); const embed = new RichEmbed() .setColor(0x00AE86) - .setFooter(`©2017 dragonfire535 | Version ${version} | Created ${moment.duration(Date.now() - this.client.user.createdTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago!`) + .setFooter(oneLine` + ©2017 dragonfire535 | + Version ${version} | + Created ${moment.duration(Date.now() - this.client.user.createdTimestamp).format('y[ years], M[ months], w[ weeks, and ]d[ days]')} ago! + `) .addField('Servers', `${this.client.guilds.size} / ${guilds.reduce((prev, val) => prev + val, 0)}`, true) .addField('Shards', @@ -45,9 +50,42 @@ module.exports = class InfoCommand extends Command { .addField('Library', '[discord.js](https://discord.js.org/#/)', true) .addField('Modules', - '[commando](https://github.com/Gawdl3y/discord.js-commando), [zalgoize](https://github.com/clux/zalgolize), [superagent](https://github.com/visionmedia/superagent), [mathjs](http://mathjs.org/), [moment](http://momentjs.com), [moment-duration-format](https://github.com/jsmreese/moment-duration-format), [jimp](https://github.com/oliver-moran/jimp), [cheerio](https://cheerio.js.org/), [sequelize](http://docs.sequelizejs.com/en/v3/), [pg](https://github.com/brianc/node-postgres)') + oneLine` + [commando](https://github.com/Gawdl3y/discord.js-commando), + [zalgoize](https://github.com/clux/zalgolize), + [superagent](https://github.com/visionmedia/superagent), + [mathjs](http://mathjs.org/), + [moment](http://momentjs.com), + [moment-duration-format](https://github.com/jsmreese/moment-duration-format), + [jimp](https://github.com/oliver-moran/jimp), + [cheerio](https://cheerio.js.org/), + [sequelize](http://docs.sequelizejs.com/en/v3/), + [pg](https://github.com/brianc/node-postgres) + ` + ) .addField('APIs', - '[Wattpad](https://developer.wattpad.com/docs/api), [Wordnik](http://developer.wordnik.com/docs.html), [osu!](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link/), [Yugioh Prices](http://docs.yugiohprices.apiary.io/#), [YouTube Data](https://developers.google.com/youtube/v3/), [Discord Bots](https://bots.discord.pw/api), [Today in History](http://history.muffinlabs.com/#api), [jService](http://jservice.io/), [Urban Dictionary](https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation), [OMDB](http://www.omdbapi.com/), [Yahoo Weather](https://developer.yahoo.com/weather/), [Wikipedia](https://en.wikipedia.org/w/api.php), [Google Static Maps](https://developers.google.com/maps/documentation/static-maps/), [Strawpoll](https://github.com/strawpoll/strawpoll/wiki/API), [rrrather](http://www.rrrather.com/botapi), [SoundCloud](https://developers.soundcloud.com/), [random.cat](http://random.cat/), [random.dog](https://random.dog/)'); + oneLine` + [Wattpad](https://developer.wattpad.com/docs/api), + [Wordnik](http://developer.wordnik.com/docs.html), + [osu!](https://osu.ppy.sh/p/api), + [memegen.link](https://memegen.link/), + [Yugioh Prices](http://docs.yugiohprices.apiary.io/#), + [YouTube Data](https://developers.google.com/youtube/v3/), + [Discord Bots](https://bots.discord.pw/api), + [Today in History](http://history.muffinlabs.com/#api), + [jService](http://jservice.io/), + [Urban Dictionary](https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation), + [OMDB](http://www.omdbapi.com/), + [Yahoo Weather](https://developer.yahoo.com/weather/), + [Wikipedia](https://en.wikipedia.org/w/api.php), + [Google Static Maps](https://developers.google.com/maps/documentation/static-maps/), + [Strawpoll](https://github.com/strawpoll/strawpoll/wiki/API), + [rrrather](http://www.rrrather.com/botapi), + [SoundCloud](https://developers.soundcloud.com/), + [random.cat](http://random.cat/), + [random.dog](https://random.dog/) + ` + ); return msg.embed(embed); } }; diff --git a/commands/util/shardinfo.js b/commands/util/shardinfo.js index 446d57c3..fd26dad1 100644 --- a/commands/util/shardinfo.js +++ b/commands/util/shardinfo.js @@ -24,11 +24,11 @@ module.exports = class ShardInfoCommand extends Command { } async run(msg, args) { - if (msg.channel.type !== 'dm') - if (!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) + if(msg.channel.type !== 'dm') + if(!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return msg.say('This Command requires the `Embed Links` Permission.'); const { shard } = args; - if (shard > this.client.options.shardCount - 1 || shard < 0) + if(shard > this.client.options.shardCount - 1 || shard < 0) return msg.say('The Shard ID is not valid.'); const memory = await this.client.shard.broadcastEval('Math.round(process.memoryUsage().heapUsed / 1024 / 1024)'); const uptime = await this.client.shard.fetchClientValues('uptime'); diff --git a/index.js b/index.js index 63c91d8a..ea40ceb0 100644 --- a/index.js +++ b/index.js @@ -32,22 +32,20 @@ client.registry ['roleplay', 'Roleplay'] ]) .registerDefaultGroups() - .registerDefaultCommands({ - help: false - }) + .registerDefaultCommands({ help: false }) .registerCommandsIn(path.join(__dirname, 'commands')); client.on('guildMemberAdd', (member) => { const channel = member.guild.channels.get(member.guild.settings.get('memberLog')); - if (!channel) return; - if (!channel.permissionsFor(client.user).has('SEND_MESSAGES')) return; + if(!channel) return; + if(!channel.permissionsFor(client.user).has('SEND_MESSAGES')) return; channel.send(`Welcome ${member.user.username}!`); }); client.on('guildMemberRemove', (member) => { const channel = member.guild.channels.get(member.guild.settings.get('memberLog')); - if (!channel) return; - if (!channel.permissionsFor(client.user).has('SEND_MESSAGES')) return; + if(!channel) return; + if(!channel.permissionsFor(client.user).has('SEND_MESSAGES')) return; channel.send(`Bye ${member.user.username}...`); }); @@ -59,13 +57,13 @@ client.on('guildCreate', async(guild) => { try { await carbon(count); console.log(`[Carbon] Successfully posted to Carbon.`); - } catch (err) { + } catch(err) { console.log(`[Carbon] Failed to post to Carbon. ${err}`); } try { await discordBots(count, client.user.id); console.log(`[Discord Bots] Successfully posted to Discord Bots.`); - } catch (err) { + } catch(err) { console.log(`[Discord Bots] Failed to post to Discord Bots. ${err}`); } }); @@ -78,13 +76,13 @@ client.on('guildDelete', async(guild) => { try { await carbon(count); console.log(`[Carbon] Successfully posted to Carbon.`); - } catch (err) { + } catch(err) { console.log(`[Carbon] Failed to post to Carbon. ${err}`); } try { await discordBots(count, client.user.id); console.log(`[Discord Bots] Successfully posted to Discord Bots.`); - } catch (err) { + } catch(err) { console.log(`[Discord Bots] Failed to post to Discord Bots. ${err}`); } }); diff --git a/package.json b/package.json index 402c1b02..f01e38c6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "18.0.0", + "version": "18.0.1", "description": "A Discord Bot", "main": "shardingmanager.js", "scripts": { @@ -35,7 +35,7 @@ "cheerio": "^0.22.0", "custom-translate": "dragonfire535/custom-translate", "discord.js": "hydrabolt/discord.js", - "discord.js-commando": "dragonfire535/discord.js-commando", + "discord.js-commando": "gawdl3y/discord.js-commando", "jimp": "^0.2.27", "mathjs": "^3.12.2", "moment": "^2.18.1", diff --git a/providers/Sequelize.js b/providers/Sequelize.js index c3ecb675..2a8f835f 100644 --- a/providers/Sequelize.js +++ b/providers/Sequelize.js @@ -76,7 +76,7 @@ class SequelizeProvider extends SettingProvider { let settings; try { settings = JSON.parse(row.dataValues.settings); - } catch (err) { + } catch(err) { client.emit('warn', `PostgreSQLProvider couldn't parse the settings stored for guild ${row.dataValues.guild}.`); continue; } @@ -84,7 +84,7 @@ class SequelizeProvider extends SettingProvider { const guild = row.dataValues.guild !== '0' ? row.dataValues.guild : 'global'; this.settings.set(guild, settings); - if (guild !== 'global' && !client.guilds.has(row.dataValues.guild)) continue; + if(guild !== 'global' && !client.guilds.has(row.dataValues.guild)) continue; this.setupGuild(guild, settings); } @@ -95,18 +95,18 @@ class SequelizeProvider extends SettingProvider { .set('groupStatusChange', (guild, group, enabled) => this.set(guild, `grp-${group.id}`, enabled)) .set('guildCreate', guild => { const settings = this.settings.get(guild.id); - if (!settings) return; + if(!settings) return; this.setupGuild(guild.id, settings); }) .set('commandRegister', command => { for (const [guild, settings] of this.settings) { - if (guild !== 'global' && !client.guilds.has(guild)) continue; + if(guild !== 'global' && !client.guilds.has(guild)) continue; this.setupGuildCommand(client.guilds.get(guild), command, settings); } }) .set('groupRegister', group => { for (const [guild, settings] of this.settings) { - if (guild !== 'global' && !client.guilds.has(guild)) continue; + if(guild !== 'global' && !client.guilds.has(guild)) continue; this.setupGuildGroup(client.guilds.get(guild), group, settings); } }); @@ -127,32 +127,32 @@ class SequelizeProvider extends SettingProvider { async set(guild, key, val) { guild = this.constructor.getGuildID(guild); let settings = this.settings.get(guild); - if (!settings) { + if(!settings) { settings = {}; this.settings.set(guild, settings); } settings[key] = val; await this.model.upsert({ guild: guild !== 'global' ? guild : '0', settings: JSON.stringify(settings) }, { where: { guild: guild !== 'global' ? guild : '0' } }); // eslint-disable-line max-len - if (guild === 'global') this.updateOtherShards(key, val); + if(guild === 'global') this.updateOtherShards(key, val); return val; } async remove(guild, key) { guild = this.constructor.getGuildID(guild); const settings = this.settings.get(guild); - if (!settings || typeof settings[key] === 'undefined') return undefined; + if(!settings || typeof settings[key] === 'undefined') return undefined; const val = settings[key]; settings[key] = undefined; await this.model.upsert({ guild: guild !== 'global' ? guild : '0', settings: JSON.stringify(settings) }, { where: { guild: guild !== 'global' ? guild : '0' } }); // eslint-disable-line max-len - if (guild === 'global') this.updateOtherShards(key, undefined); + if(guild === 'global') this.updateOtherShards(key, undefined); return val; } async clear(guild) { guild = this.constructor.getGuildID(guild); - if (!this.settings.has(guild)) return; + if(!this.settings.has(guild)) return; this.settings.delete(guild); await this.model.destroy({ where: { guild: guild !== 'global' ? guild : '0' } }); } @@ -164,12 +164,12 @@ class SequelizeProvider extends SettingProvider { * @private */ setupGuild(guild, settings) { - if (typeof guild !== 'string') throw new TypeError('The guild must be a guild ID or "global".'); + if(typeof guild !== 'string') throw new TypeError('The guild must be a guild ID or "global".'); guild = this.client.guilds.get(guild) || null; // Load the command prefix - if (typeof settings.prefix !== 'undefined') { - if (guild) guild._commandPrefix = settings.prefix; + if(typeof settings.prefix !== 'undefined') { + if(guild) guild._commandPrefix = settings.prefix; else this.client._commandPrefix = settings.prefix; } @@ -186,9 +186,9 @@ class SequelizeProvider extends SettingProvider { * @private */ setupGuildCommand(guild, command, settings) { - if (typeof settings[`cmd-${command.name}`] === 'undefined') return; - if (guild) { - if (!guild._commandsEnabled) guild._commandsEnabled = {}; + if(typeof settings[`cmd-${command.name}`] === 'undefined') return; + if(guild) { + if(!guild._commandsEnabled) guild._commandsEnabled = {}; guild._commandsEnabled[command.name] = settings[`cmd-${command.name}`]; } else { command._globalEnabled = settings[`cmd-${command.name}`]; @@ -203,9 +203,9 @@ class SequelizeProvider extends SettingProvider { * @private */ setupGuildGroup(guild, group, settings) { - if (typeof settings[`grp-${group.id}`] === 'undefined') return; - if (guild) { - if (!guild._groupsEnabled) guild._groupsEnabled = {}; + if(typeof settings[`grp-${group.id}`] === 'undefined') return; + if(guild) { + if(!guild._groupsEnabled) guild._groupsEnabled = {}; guild._groupsEnabled[group.id] = settings[`grp-${group.id}`]; } else { group._globalEnabled = settings[`grp-${group.id}`]; @@ -219,7 +219,7 @@ class SequelizeProvider extends SettingProvider { * @private */ updateOtherShards(key, val) { - if (!this.client.shard) return; + if(!this.client.shard) return; key = JSON.stringify(key); val = typeof val !== 'undefined' ? JSON.stringify(val) : 'undefined'; this.client.shard.broadcastEval(` diff --git a/shardingmanager.js b/shardingmanager.js index 5e868277..2a14e586 100644 --- a/shardingmanager.js +++ b/shardingmanager.js @@ -1,7 +1,5 @@ const { ShardingManager } = require('discord.js'); -const Manager = new ShardingManager('./index.js', { - token: process.env.TOKEN -}); +const Manager = new ShardingManager('./index.js', { token: process.env.TOKEN }); Manager.spawn(); process.on('unhandledRejection', console.error); diff --git a/structures/PostgreSQL.js b/structures/PostgreSQL.js index 79b342e7..a8565829 100644 --- a/structures/PostgreSQL.js +++ b/structures/PostgreSQL.js @@ -1,7 +1,7 @@ const Sequelize = require('sequelize'); const database = new Sequelize(process.env.DATABASE_URL, { logging: false }); -module.exports = class Database { +class Database { static get db() { return database; } @@ -17,4 +17,6 @@ module.exports = class Database { .then(() => console.log('[Database] Ready!')) .catch(err => console.error(`[Database] Unable to connect: ${err}`)); } -}; +} + +module.exports = Database; diff --git a/structures/Stats.js b/structures/Stats.js index 75c70417..d241eedb 100644 --- a/structures/Stats.js +++ b/structures/Stats.js @@ -1,27 +1,22 @@ const request = require('superagent'); -module.exports = class Stats { +class Stats { constructor() { throw new Error(`The ${this.constructor.name} class may not be instantiated.`); } - static discordBots(count, userID) { + static discordBots(server_count, userID) { return request .post(`https://bots.discord.pw/api/bots/${userID}/stats`) - .set({ - 'Authorization': process.env.DISCORD_BOTS_KEY - }) - .send({ - server_count: count - }); + .set({ 'Authorization': process.env.DISCORD_BOTS_KEY }) + .send({ server_count }); } - static carbon(count) { + static carbon(servercount) { return request .post('https://www.carbonitex.net/discord/data/botdata.php') - .send({ - key: process.env.CARBON_KEY, - servercount: count - }); + .send({ key: process.env.CARBON_KEY, servercount }); } -}; +} + +module.exports = Stats;