From 218c8aa0faf798ed53aa4854b9ae7067880a9192 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Wed, 16 Aug 2017 16:06:06 +0000 Subject: [PATCH] Clean-ups --- XiaoBot.js | 10 +++++++- assets/json/name.json | 6 ++--- commands/guild-info/emoji.js | 5 ++-- commands/num-edit/currency.js | 2 +- commands/num-edit/temperature.js | 2 +- commands/random-img/xiao.js | 3 +-- commands/random-res/8-ball.js | 3 +-- commands/random-res/choose.js | 3 +-- commands/random-res/coin.js | 3 +-- commands/random-res/compliment.js | 3 +-- commands/random-res/fact-core.js | 3 +-- commands/random-res/fortune.js | 3 +-- commands/random-res/magic-conch.js | 3 +-- commands/random-res/name.js | 21 ++++++---------- commands/random-res/offspring.js | 3 +-- commands/random-res/quantum-coin.js | 3 +-- commands/random-res/rate-waifu.js | 3 +-- commands/random-res/roast.js | 3 +-- commands/random-res/roll.js | 3 +-- commands/random-res/ship.js | 3 +-- commands/search/bulbapedia.js | 2 +- commands/search/giphy.js | 3 +-- commands/search/pokedex.js | 9 +++---- commands/search/reddit.js | 19 +++++++------- commands/search/wikia.js | 3 +-- commands/search/wikipedia.js | 2 +- commands/text-edit/binary.js | 3 +-- commands/text-edit/mocking.js | 2 +- commands/text-edit/morse.js | 5 ++-- commands/text-edit/organization-xiii-name.js | 6 ++--- commands/text-edit/pirate.js | 5 ++-- commands/text-edit/repeat.js | 9 ++++--- commands/text-edit/reverse.js | 3 +-- commands/text-edit/say.js | 5 ++-- commands/text-edit/shuffle.js | 3 +-- commands/text-edit/temmie.js | 5 ++-- commands/text-edit/upside-down.js | 3 +-- commands/text-edit/zalgo.js | 3 +-- commands/user-info/user-info.js | 3 +-- commands/util/info.js | 2 +- package.json | 2 +- structures/Command.js | 14 ++++------- structures/Util.js | 26 ++++++++++---------- 43 files changed, 98 insertions(+), 127 deletions(-) diff --git a/XiaoBot.js b/XiaoBot.js index ba0fb743..2eec965b 100644 --- a/XiaoBot.js +++ b/XiaoBot.js @@ -109,7 +109,15 @@ client.on('guildDelete', async guild => { dBotsOrg(count, client.user.id); }); -client.setTimeout(() => { +const { wait } = require('./structures/Util'); +client.setTimeout(async () => { + const battle = client.registry.resolveCommand('games:battle').fighting.size; + const hangman = client.registry.resolveCommand('games:hangman').playing.size; + const gunfight = client.registry.resolveCommand('games:gunfight').fighting.size; + while (battle && hangman && gunfight) { // eslint-disable-line no-unmodified-loop-condition + console.log('[RESTART] A game is going on, delaying...'); + await wait(5000); + } console.log(`[RESTART] Shard ${client.shard.id} Restarted.`); process.exit(0); }, 7.2e+6); diff --git a/assets/json/name.json b/assets/json/name.json index 8ad8bfff..57bc49f7 100644 --- a/assets/json/name.json +++ b/assets/json/name.json @@ -1,5 +1,5 @@ { - "lastNames": [ + "last": [ "Walker", "Tworni", "Ross", @@ -72,7 +72,7 @@ "Galusha", "Alston" ], - "maleNames": [ + "male": [ "Bob", "Daniel", "Logan", @@ -145,7 +145,7 @@ "Larry", "Victor" ], - "femaleNames": [ + "female": [ "Elizabeth", "Chelsey", "Rachel", diff --git a/commands/guild-info/emoji.js b/commands/guild-info/emoji.js index 7f9b2f9a..c8eb39c6 100644 --- a/commands/guild-info/emoji.js +++ b/commands/guild-info/emoji.js @@ -12,8 +12,7 @@ module.exports = class EmojiCommand extends Command { } run(msg) { - const emoji = msg.guild.emojis; - if (!emoji.size) return msg.say('You have no custom emoji.'); - return msg.say(emoji.map(e => e).join('')); + if (!msg.guild.emojis.size) return msg.say('This server has no custom emoji.'); + return msg.say(msg.guild.emojis.map(e => e).join('')); } }; diff --git a/commands/num-edit/currency.js b/commands/num-edit/currency.js index 7a2e7160..18607170 100644 --- a/commands/num-edit/currency.js +++ b/commands/num-edit/currency.js @@ -34,7 +34,7 @@ module.exports = class CurrencyCommand extends Command { { key: 'amount', prompt: 'How much money should be converted? Do not use symbols.', - type: 'integer' + type: 'float' } ] }); diff --git a/commands/num-edit/temperature.js b/commands/num-edit/temperature.js index 10b537f5..36aa24f8 100644 --- a/commands/num-edit/temperature.js +++ b/commands/num-edit/temperature.js @@ -31,7 +31,7 @@ module.exports = class TemperatureCommand extends Command { { key: 'amount', prompt: 'What temperature should be converted?', - type: 'integer' + type: 'float' } ] }); diff --git a/commands/random-img/xiao.js b/commands/random-img/xiao.js index a708fe5f..c89d1f64 100644 --- a/commands/random-img/xiao.js +++ b/commands/random-img/xiao.js @@ -14,7 +14,6 @@ module.exports = class XiaoCommand extends Command { } run(msg) { - const xiao = xiaos[Math.floor(Math.random() * xiaos.length)]; - return msg.say({ files: [xiao] }); + return msg.say({ files: [xiaos[Math.floor(Math.random() * xiaos.length)]] }); } }; diff --git a/commands/random-res/8-ball.js b/commands/random-res/8-ball.js index 6961e5ee..e3640900 100644 --- a/commands/random-res/8-ball.js +++ b/commands/random-res/8-ball.js @@ -21,10 +21,9 @@ module.exports = class MagicBallCommand extends Command { run(msg, args) { const { question } = args; - const answer = answers[Math.floor(Math.random() * answers.length)]; return msg.say(stripIndents` Question: ${question} - :8ball: ${answer} :8ball: + :8ball: ${answers[Math.floor(Math.random() * answers.length)]} :8ball: `); } }; diff --git a/commands/random-res/choose.js b/commands/random-res/choose.js index 40c53062..4cc69638 100644 --- a/commands/random-res/choose.js +++ b/commands/random-res/choose.js @@ -20,7 +20,6 @@ module.exports = class ChooseCommand extends Command { run(msg, args) { const { choices } = args; - const choice = choices[Math.floor(Math.random() * choices.length)]; - return msg.say(`I choose ${choice}!`); + return msg.say(`I choose ${choices[Math.floor(Math.random() * choices.length)]}!`); } }; diff --git a/commands/random-res/coin.js b/commands/random-res/coin.js index ceed7e6a..79eaa01d 100644 --- a/commands/random-res/coin.js +++ b/commands/random-res/coin.js @@ -13,7 +13,6 @@ module.exports = class CoinFlipCommand extends Command { } run(msg) { - const side = sides[Math.floor(Math.random() * sides.length)]; - return msg.say(`It landed on ${side}!`); + return msg.say(`It landed on ${sides[Math.floor(Math.random() * sides.length)]}!`); } }; diff --git a/commands/random-res/compliment.js b/commands/random-res/compliment.js index 70b30f81..de2013f9 100644 --- a/commands/random-res/compliment.js +++ b/commands/random-res/compliment.js @@ -21,7 +21,6 @@ module.exports = class ComplimentCommand extends Command { run(msg, args) { const user = args.user || msg.author; - const compliment = compliments[Math.floor(Math.random() * compliments.length)]; - return msg.say(`${user.username}, ${compliment}`); + return msg.say(`${user.username}, ${compliments[Math.floor(Math.random() * compliments.length)]}`); } }; diff --git a/commands/random-res/fact-core.js b/commands/random-res/fact-core.js index f155f193..0a9611ac 100644 --- a/commands/random-res/fact-core.js +++ b/commands/random-res/fact-core.js @@ -12,7 +12,6 @@ module.exports = class FactCoreCommand extends Command { } run(msg) { - const fact = facts[Math.floor(Math.random() * facts.length)]; - return msg.say(fact); + return msg.say(facts[Math.floor(Math.random() * facts.length)]); } }; diff --git a/commands/random-res/fortune.js b/commands/random-res/fortune.js index cb563bce..b364d25c 100644 --- a/commands/random-res/fortune.js +++ b/commands/random-res/fortune.js @@ -13,7 +13,6 @@ module.exports = class FortuneCommand extends Command { } run(msg) { - const fortune = fortunes[Math.floor(Math.random() * fortunes.length)]; - return msg.say(fortune); + return msg.say(fortunes[Math.floor(Math.random() * fortunes.length)]); } }; diff --git a/commands/random-res/magic-conch.js b/commands/random-res/magic-conch.js index 279883fa..9cc7076f 100644 --- a/commands/random-res/magic-conch.js +++ b/commands/random-res/magic-conch.js @@ -21,10 +21,9 @@ module.exports = class MagicConchCommand extends Command { run(msg, args) { const { question } = args; - const answer = answers[Math.floor(Math.random() * answers.length)]; return msg.say(stripIndents` Question: ${question} - :shell: ${answer} :shell: + :shell: ${answers[Math.floor(Math.random() * answers.length)]} :shell: `); } }; diff --git a/commands/random-res/name.js b/commands/random-res/name.js index 35190271..c0f98d2d 100644 --- a/commands/random-res/name.js +++ b/commands/random-res/name.js @@ -1,5 +1,5 @@ const Command = require('../../structures/Command'); -const { lastNames, maleNames, femaleNames } = require('../../assets/json/name'); +const { last, male, female } = require('../../assets/json/name'); module.exports = class RandomNameCommand extends Command { constructor(client) { @@ -26,23 +26,16 @@ module.exports = class RandomNameCommand extends Command { run(msg, args) { // eslint-disable-line consistent-return const { gender } = args; - const lastName = lastNames[Math.floor(Math.random() * lastNames.length)]; + const lastName = last[Math.floor(Math.random() * last.length)]; if (gender === 'male') { - const name = maleNames[Math.floor(Math.random() * maleNames.length)]; - return msg.say(`${name} ${lastName}`); + return msg.say(`${male[Math.floor(Math.random() * male.length)]} ${lastName}`); } else if (gender === 'female') { - const name = femaleNames[Math.floor(Math.random() * femaleNames.length)]; - return msg.say(`${name} ${lastName}`); + return msg.say(`${female[Math.floor(Math.random() * female.length)]} ${lastName}`); } else if (gender === 'both') { const genders = ['male', 'female']; - const randomGender = genders[Math.floor(Math.random() * genders.length)]; - if (randomGender === 'male') { - const name = maleNames[Math.floor(Math.random() * maleNames.length)]; - return msg.say(`${name} ${lastName}`); - } else if (randomGender === 'female') { - const name = femaleNames[Math.floor(Math.random() * femaleNames.length)]; - return msg.say(`${name} ${lastName}`); - } + const rGender = genders[Math.floor(Math.random() * genders.length)]; + if (gender === 'male') return msg.say(`${male[Math.floor(Math.random() * male.length)]} ${lastName}`); + else if (rGender === 'female') return msg.say(`${female[Math.floor(Math.random() * female.length)]} ${lastName}`); } } }; diff --git a/commands/random-res/offspring.js b/commands/random-res/offspring.js index fed15cad..f6a2676f 100644 --- a/commands/random-res/offspring.js +++ b/commands/random-res/offspring.js @@ -12,7 +12,6 @@ module.exports = class OffspringCommand extends Command { } run(msg) { - const gender = genders[Math.floor(Math.random() * genders.length)]; - return msg.say(`It's a ${gender}!`); + return msg.say(`It's a ${genders[Math.floor(Math.random() * genders.length)]}!`); } }; diff --git a/commands/random-res/quantum-coin.js b/commands/random-res/quantum-coin.js index c5ed241f..4ff9436b 100644 --- a/commands/random-res/quantum-coin.js +++ b/commands/random-res/quantum-coin.js @@ -13,7 +13,6 @@ module.exports = class QuantumCoinCommand extends Command { } run(msg) { - const side = sides[Math.floor(Math.random() * sides.length)]; - return msg.say(`It landed ${side}.`); + return msg.say(`It landed ${sides[Math.floor(Math.random() * sides.length)]}.`); } }; diff --git a/commands/random-res/rate-waifu.js b/commands/random-res/rate-waifu.js index c0878d8f..ef3a7467 100644 --- a/commands/random-res/rate-waifu.js +++ b/commands/random-res/rate-waifu.js @@ -20,7 +20,6 @@ module.exports = class RateWaifuCommand extends Command { run(msg, args) { const { waifu } = args; - const rating = Math.floor(Math.random() * 10) + 1; - return msg.say(`I'd give ${waifu} a ${rating}/10!`); + return msg.say(`I'd give ${waifu} a ${Math.floor(Math.random() * 10) + 1}/10!`); } }; diff --git a/commands/random-res/roast.js b/commands/random-res/roast.js index d1cc703b..9efc2505 100644 --- a/commands/random-res/roast.js +++ b/commands/random-res/roast.js @@ -21,7 +21,6 @@ module.exports = class RoastCommand extends Command { run(msg, args) { const user = args.user || msg.author; - const roast = roasts[Math.floor(Math.random() * roasts.length)]; - return msg.say(`${user.username}, ${roast}`); + return msg.say(`${user.username}, ${roasts[Math.floor(Math.random() * roasts.length)]}`); } }; diff --git a/commands/random-res/roll.js b/commands/random-res/roll.js index f23b7674..09b6dbbf 100644 --- a/commands/random-res/roll.js +++ b/commands/random-res/roll.js @@ -22,7 +22,6 @@ module.exports = class RollCommand extends Command { run(msg, args) { const { value } = args; - const roll = Math.floor(Math.random() * value) + 1; - return msg.say(`You rolled a ${roll}.`); + return msg.say(`You rolled a ${Math.floor(Math.random() * value) + 1}.`); } }; diff --git a/commands/random-res/ship.js b/commands/random-res/ship.js index 529f92d9..f5bf7ff7 100644 --- a/commands/random-res/ship.js +++ b/commands/random-res/ship.js @@ -20,8 +20,7 @@ module.exports = class ShipCommand extends Command { run(msg, args) { const { things } = args; - const rating = Math.floor(Math.random() * 100) + 1; const list = `${things.slice(0, -1).join(', ')}${things.length > 1 ? ' and ' : ''}${things.slice(-1)}`; - return msg.say(`I'd give ${list} a ${rating}%!`); + return msg.say(`I'd give ${list} a ${Math.floor(Math.random() * 100) + 1}%!`); } }; diff --git a/commands/search/bulbapedia.js b/commands/search/bulbapedia.js index 13a8538a..2836e6a7 100644 --- a/commands/search/bulbapedia.js +++ b/commands/search/bulbapedia.js @@ -40,7 +40,7 @@ module.exports = class BulbapediaCommand extends Command { .setColor(0x3E7614) .setTitle(body.query.pages[0].title) .setAuthor('Bulbapedia', 'https://i.imgur.com/09eYo5T.png') - .setDescription(body.query.pages[0].extract.replace(/[\n]/g, '\n\n').substr(0, 2048)); + .setDescription(body.query.pages[0].extract.replace(/\n/g, '\n\n').substr(0, 2048)); return msg.embed(embed); } }; diff --git a/commands/search/giphy.js b/commands/search/giphy.js index 8cd6866f..36dd50f2 100644 --- a/commands/search/giphy.js +++ b/commands/search/giphy.js @@ -29,7 +29,6 @@ module.exports = class GiphyCommand extends Command { rating: msg.channel.nsfw ? 'r' : 'pg' }); if (!body.data.length) return msg.say('No Results.'); - const random = Math.floor(Math.random() * body.data.length); - return msg.say(body.data[random].images.original.url); + return msg.say(body.data[Math.floor(Math.random() * body.data.length)].images.original.url); } }; diff --git a/commands/search/pokedex.js b/commands/search/pokedex.js index 2e336aed..fd433031 100644 --- a/commands/search/pokedex.js +++ b/commands/search/pokedex.js @@ -29,16 +29,13 @@ module.exports = class PokedexCommand extends Command { const { body } = await snekfetch .get(`https://pokeapi.co/api/v2/pokemon-species/${pokemon}`); const id = `${'000'.slice(body.id.toString().length)}${body.id}`; - const name = this.filter(body.names).name; - const flavor = this.filter(body.flavor_text_entries).flavor_text.replace(/(\n|\f|\r)/g, ' '); - const species = this.filter(body.genera).genus; const embed = new MessageEmbed() .setColor(0xED1C24) - .setAuthor(`#${id} - ${name}`, `https://www.serebii.net/pokedex-sm/icon/${id}.png`) + .setAuthor(`#${id} - ${this.filter(body.names).name}`, `https://www.serebii.net/pokedex-sm/icon/${id}.png`) .setURL(`https://www.serebii.net/pokedex-sm/${id}.shtml`) .setDescription(stripIndents` - **The ${species} Pokémon** - ${flavor} + **The ${this.filter(body.genera).genus} Pokémon** + ${this.filter(body.flavor_text_entries).flavor_text.replace(/(\n|\f|\r)/g, ' ')} `) .setThumbnail(`https://www.serebii.net/sunmoon/pokemon/${id}.png`); return msg.embed(embed); diff --git a/commands/search/reddit.js b/commands/search/reddit.js index 577304bf..6d32e1e8 100644 --- a/commands/search/reddit.js +++ b/commands/search/reddit.js @@ -26,21 +26,22 @@ module.exports = class RedditCommand extends Command { const { body } = await snekfetch .get(`https://www.reddit.com/r/${subreddit}/new.json`) .query({ sort: 'new' }); - const post = body.data.children[Math.floor(Math.random() * body.data.children.length)].data; - if (!msg.channel.nsfw && post.over_18) return msg.say('This post is only viewable in NSFW Channels.'); + const post = body.data.children[Math.floor(Math.random() * body.data.children.length)]; + if (!post.data) return msg.say('This post has no data, try again!'); + if (!msg.channel.nsfw && post.data.over_18) return msg.say('This post is only viewable in NSFW Channels.'); const embed = new MessageEmbed() .setColor(0xFF4500) .setAuthor('Reddit', 'https://i.imgur.com/V6hXniU.png') - .setURL(`https://www.reddit.com${post.permalink}`) - .setTitle(post.title) - .setDescription(`[View URL Here](${post.url})`) - .setThumbnail(post.thumbnail !== 'self' ? post.thumbnail : null) + .setURL(`https://www.reddit.com${post.data.permalink}`) + .setTitle(post.data.title) + .setDescription(`[View URL Here](${post.data.url})`) + .setThumbnail(post.data.thumbnail !== 'self' ? post.data.thumbnail : null) .addField('❯ Upvotes', - post.ups, true) + post.data.ups, true) .addField('❯ Downvotes', - post.downs, true) + post.data.downs, true) .addField('❯ Score', - post.score, true); + post.data.score, true); return msg.embed(embed); } catch (err) { if (err.status === 404) return msg.say('Subreddit Not Found.'); diff --git a/commands/search/wikia.js b/commands/search/wikia.js index 23224634..b7579f04 100644 --- a/commands/search/wikia.js +++ b/commands/search/wikia.js @@ -36,10 +36,9 @@ module.exports = class WikiaCommand extends Command { limit: 1, namespaces: 0 }); - const id = search.body.items[0].id; const { body } = await snekfetch .get(`http://${wiki}.wikia.com/api/v1/Articles/AsSimpleJson/`) - .query({ id }); + .query({ id: search.body.items[0].id }); const embed = new MessageEmbed() .setColor(0x002D54) .setTitle(body.sections[0].title) diff --git a/commands/search/wikipedia.js b/commands/search/wikipedia.js index d0f61e60..6d2728ba 100644 --- a/commands/search/wikipedia.js +++ b/commands/search/wikipedia.js @@ -39,7 +39,7 @@ module.exports = class WikipediaCommand extends Command { .setColor(0xE7E7E7) .setTitle(body.query.pages[0].title) .setAuthor('Wikipedia', 'https://i.imgur.com/a4eeEhh.png') - .setDescription(body.query.pages[0].extract.replace(/[\n]/g, '\n\n').substr(0, 2048)); + .setDescription(body.query.pages[0].extract.replace(/\n/g, '\n\n').substr(0, 2048)); return msg.embed(embed); } }; diff --git a/commands/text-edit/binary.js b/commands/text-edit/binary.js index 16305bc9..03775815 100644 --- a/commands/text-edit/binary.js +++ b/commands/text-edit/binary.js @@ -23,8 +23,7 @@ module.exports = class BinaryCommand extends Command { run(msg, args) { const { text } = args; - const converted = this.binary(text); - return msg.say(converted); + return msg.say(this.binary(text)); } binary(text) { diff --git a/commands/text-edit/mocking.js b/commands/text-edit/mocking.js index 276df025..65ae1ce3 100644 --- a/commands/text-edit/mocking.js +++ b/commands/text-edit/mocking.js @@ -27,7 +27,7 @@ module.exports = class MockingCommand extends Command { run(msg, args) { const { text } = args; for (let i = 0; i < text.length; i += Math.floor(Math.random() * 4)) text[i] = text[i].toUpperCase(); - return msg.say(`\u180E${text.join('')} <:sponge:318612443398144000>`); + return msg.say(`${text.join('')} <:sponge:318612443398144000>`); } }; diff --git a/commands/text-edit/morse.js b/commands/text-edit/morse.js index a3b7c0c3..7dff5e01 100644 --- a/commands/text-edit/morse.js +++ b/commands/text-edit/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) return true; + if (letterTrans(text, dictionary, ' ').length < 2000) return true; return 'Your text is too long.'; } } @@ -25,7 +25,6 @@ module.exports = class MorseCommand extends Command { run(msg, args) { const { text } = args; - const converted = letterTrans(text.toLowerCase(), dictionary, ' '); - return msg.say(converted); + return msg.say(letterTrans(text.toLowerCase(), dictionary, ' ')); } }; diff --git a/commands/text-edit/organization-xiii-name.js b/commands/text-edit/organization-xiii-name.js index fa94cf21..f2c1c312 100644 --- a/commands/text-edit/organization-xiii-name.js +++ b/commands/text-edit/organization-xiii-name.js @@ -23,8 +23,8 @@ module.exports = class OrganizationXIIINameCommand extends Command { run(msg, args) { const { text } = args; text.push('x'); - const converted = shuffle(text); - converted[0] = converted[0].toUpperCase(); - return msg.say(`\u180E${converted.join('')}`); + const shuffled = shuffle(text); + shuffled[0] = shuffled[0].toUpperCase(); + return msg.say(shuffled.join('')); } }; diff --git a/commands/text-edit/pirate.js b/commands/text-edit/pirate.js index 568cad4e..15af26cb 100644 --- a/commands/text-edit/pirate.js +++ b/commands/text-edit/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) return true; + if (wordTrans(text, dictionary).length < 2000) return true; return 'Your text is too long.'; } } @@ -25,7 +25,6 @@ module.exports = class PirateCommand extends Command { run(msg, args) { const { text } = args; - const converted = wordTrans(text, dictionary); - return msg.say(`\u180E${converted}`); + return msg.say(wordTrans(text, dictionary)); } }; diff --git a/commands/text-edit/repeat.js b/commands/text-edit/repeat.js index 57902192..91ca3ef8 100644 --- a/commands/text-edit/repeat.js +++ b/commands/text-edit/repeat.js @@ -11,7 +11,11 @@ module.exports = class RepeatCommand extends Command { { key: 'text', prompt: 'What text would you like to repeat over and over and over and over?', - type: 'string' + type: 'string', + validate: text => { + if (!text.includes('@everyone') && !text.includes('@here')) return true; + return 'Please do not repeat everyone or here mentions.'; + } } ] }); @@ -19,7 +23,6 @@ module.exports = class RepeatCommand extends Command { run(msg, args) { const { text } = args; - const converted = text.repeat(2000).substr(0, 1999); - return msg.say(`\u180E${converted}`); + return msg.say(text.repeat(2000).substr(0, 2000)); } }; diff --git a/commands/text-edit/reverse.js b/commands/text-edit/reverse.js index c261a216..bdfec04c 100644 --- a/commands/text-edit/reverse.js +++ b/commands/text-edit/reverse.js @@ -19,7 +19,6 @@ module.exports = class ReverseCommand extends Command { run(msg, args) { const { text } = args; - const converted = text.split('').reverse().join(''); - return msg.say(`\u180E${converted}`); + return msg.say(text.split('').reverse().join('')); } }; diff --git a/commands/text-edit/say.js b/commands/text-edit/say.js index c3a28299..232dfcaf 100644 --- a/commands/text-edit/say.js +++ b/commands/text-edit/say.js @@ -9,7 +9,6 @@ module.exports = class SayCommand extends Command { memberName: 'say', description: 'Make XiaoBot say what you wish.', guildOnly: true, - clientPermissions: ['MANAGE_MESSAGES'], args: [ { key: 'text', @@ -22,7 +21,7 @@ module.exports = class SayCommand extends Command { run(msg, args) { const { text } = args; - msg.delete(); - return msg.say(`\u180E${text}`); + if (msg.channel.permissionsFor(this.client.user).has('MANAGE_MESSAGES')) msg.delete(); + return msg.say(text); } }; diff --git a/commands/text-edit/shuffle.js b/commands/text-edit/shuffle.js index bf5cc237..4a80a55f 100644 --- a/commands/text-edit/shuffle.js +++ b/commands/text-edit/shuffle.js @@ -20,7 +20,6 @@ module.exports = class ShuffleCommand extends Command { run(msg, args) { const { text } = args; - const converted = shuffle(text.split('')).join(''); - return msg.say(`\u180E${converted}`); + return msg.say(shuffle(text.split('')).join('')); } }; diff --git a/commands/text-edit/temmie.js b/commands/text-edit/temmie.js index 1112381f..73b8d1f1 100644 --- a/commands/text-edit/temmie.js +++ b/commands/text-edit/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) return true; + if (wordTrans(text, dictionary).length < 2000) return true; return 'Your text is too long.'; } } @@ -25,7 +25,6 @@ module.exports = class TemmieCommand extends Command { run(msg, args) { const { text } = args; - const converted = wordTrans(text, dictionary); - return msg.say(`\u180E${converted}`); + return msg.say(wordTrans(text, dictionary)); } }; diff --git a/commands/text-edit/upside-down.js b/commands/text-edit/upside-down.js index 16b601c0..380eac28 100644 --- a/commands/text-edit/upside-down.js +++ b/commands/text-edit/upside-down.js @@ -22,7 +22,6 @@ module.exports = class UpsideDownCommand extends Command { run(msg, args) { const { text } = args; - const converted = letterTrans(text, dictionary); - return msg.say(converted); + return msg.say(letterTrans(text, dictionary)); } }; diff --git a/commands/text-edit/zalgo.js b/commands/text-edit/zalgo.js index 601a5195..742ee378 100644 --- a/commands/text-edit/zalgo.js +++ b/commands/text-edit/zalgo.js @@ -24,7 +24,6 @@ module.exports = class ZalgoCommand extends Command { run(msg, args) { const { text } = args; - const converted = zalgo(text); - return msg.say(`\u180E${converted}`); + return msg.say(zalgo(text)); } }; diff --git a/commands/user-info/user-info.js b/commands/user-info/user-info.js index ee9eaa62..574e189a 100644 --- a/commands/user-info/user-info.js +++ b/commands/user-info/user-info.js @@ -26,7 +26,6 @@ module.exports = class UserInfoCommand extends Command { run(msg, args) { const member = args.member || msg.member; - const status = member.user.presence.status; const embed = new MessageEmbed() .setColor(member.displayHexColor) .setThumbnail(member.user.displayAvatarURL()) @@ -39,7 +38,7 @@ module.exports = class UserInfoCommand extends Command { .addField('❯ Server Join Date', moment(member.joinedTimestamp).format('MMMM Do YYYY'), true) .addField('❯ Status', - statuses[status], true) + statuses[member.user.presence.status], true) .addField('❯ Playing', member.user.presence.game ? member.user.presence.game.name : 'N/A', true) .addField('❯ Highest Role', diff --git a/commands/util/info.js b/commands/util/info.js index efffdff7..f7f29fe0 100644 --- a/commands/util/info.js +++ b/commands/util/info.js @@ -40,7 +40,7 @@ module.exports = class InfoCommand extends Command { .addField('❯ Node Version', process.version, true) .addField('❯ Library', - '[discord.js](https://discord.js.org)[-commando](https://github.com/Gawdl3y/discord.js-commando)', true); // eslint-disable-line max-len + '[discord.js](https://discord.js.org)[-commando](https://github.com/Gawdl3y/discord.js-commando)', true); return msg.embed(embed); } }; diff --git a/package.json b/package.json index 674cb93e..e5356bc5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "30.3.0", + "version": "30.3.2", "description": "Your personal server companion.", "main": "Shard.js", "scripts": { diff --git a/structures/Command.js b/structures/Command.js index ca94076f..9eb0096c 100644 --- a/structures/Command.js +++ b/structures/Command.js @@ -16,24 +16,20 @@ class XiaoCommand extends Command { } hasPermission(msg) { - if (this.ownerOnly && !this.client.isOwner(msg.author)) { - return 'This Command can only be used by the bot owner.'; - } - if (this.nsfw && !msg.channel.nsfw) { - return 'This Command can only be used in NSFW Channels.'; - } - if (msg.channel.type !== 'dm') { + if (this.ownerOnly && !this.client.isOwner(msg.author)) return 'This Command can only be used by the bot owner.'; + if (this.nsfw && !msg.channel.nsfw) return 'This Command can only be used in NSFW Channels.'; + if (msg.channel.type === 'text') { if (this.clientPermissions) { for (const permission of this.clientPermissions) { if (!msg.channel.permissionsFor(this.client.user).has(permission)) { - return `This Command requires the \`${perms[permission]}\` Permission.`; + return `This Command requires me to have the \`${perms[permission]}\` Permission.`; } } } if (this.userPermissions) { for (const permission of this.userPermissions) { if (!msg.channel.permissionsFor(msg.author).has(permission)) { - return `You do not have the \`${perms[permission]}\` Permission.`; + return `This Command requires you to have the \`${perms[permission]}\` Permission.`; } } } diff --git a/structures/Util.js b/structures/Util.js index bb379f4b..19e7a674 100644 --- a/structures/Util.js +++ b/structures/Util.js @@ -5,11 +5,11 @@ const { CARBON_KEY, DBOTS_KEY, DBOTSORG_KEY } = process.env; class Util { static cleanXML(str) { return str - .replace(/(
)/g, '') - .replace(/(')/g, '\'') - .replace(/(—)/g, '—') + .replace(/
/g, '') + .replace(/'/g, '\'') + .replace(/—/g, '—') .replace(/("|")/g, '"') - .replace(/(&)/g, '&') + .replace(/&/g, '&') .replace(/(\[i\]|\[\/i\])/g, '*'); } @@ -44,8 +44,8 @@ class Util { static filterTopics(channels, setting) { return channels.filter(c => { - if (c.type !== 'text' || !c.topic) return false; - if (c.topic.includes(`<${setting}>`) && c.permissionsFor(c.client.user).has('SEND_MESSAGES')) return true; + if (c.type !== 'text' || !c.topic || !c.permissionsFor(c.client.user).has('SEND_MESSAGES')) return false; + if (c.topic.includes(`<${setting}>`)) return true; return false; }); } @@ -63,13 +63,13 @@ class Util { } static shuffle(arr) { - for (let i = arr.length - 1; i > 0; i--) { - const j = Math.floor(Math.random() * (i + 1)); - const temp = arr[i]; - arr[i] = arr[j]; - arr[j] = temp; - } - return arr; + for (let i = arr.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + const temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + return arr; } }