diff --git a/commands/games/akinator.js b/commands/games/akinator.js index 74da5f32..1638397c 100644 --- a/commands/games/akinator.js +++ b/commands/games/akinator.js @@ -11,7 +11,7 @@ module.exports = class AkinatorCommand extends Command { aliases: ['the-web-genie', 'web-genie'], group: 'games', memberName: 'akinator', - description: 'Play a game of Akinator!', + description: 'Play a game of Akinator.', clientPermissions: ['EMBED_LINKS'] }); diff --git a/commands/games/battle.js b/commands/games/battle.js index c9a4f1e5..489fdb3f 100644 --- a/commands/games/battle.js +++ b/commands/games/battle.js @@ -88,14 +88,13 @@ module.exports = class BattleCommand extends Command { } else if (choice === 'special') { const hit = Math.floor(Math.random() * 4) + 1; if (hit === 1) { - const damage = Math.floor(Math.random() * ((guard ? 300 : 150) - 100 + 1)) + 100; + const damage = Math.floor(Math.random() * ((guard ? 150 : 300) - 100 + 1)) + 100; await msg.say(`${user} deals **${damage}** damage!`); dealDamage(damage); - reset(); } else { await msg.say(`${user}'s attack missed!`); - reset(); } + reset(); } else if (choice === 'run') { await msg.say(`${user} flees!`); forfeit(); @@ -105,10 +104,11 @@ module.exports = class BattleCommand extends Command { } } this.fighting.delete(msg.channel.id); + const userWin = userHP > oppoHP; return msg.say(stripIndents` The match is over! - **Winner**: ${userHP > oppoHP ? `${msg.author} (${userHP}HP)` : `${opponent} (${oppoHP}HP)`} - **Loser**: ${userHP > oppoHP ? `${opponent} (${oppoHP}HP)` : `${msg.author} (${userHP}HP)`} + **Winner**: ${userWin ? `${msg.author} (${userHP}HP)` : `${opponent} (${oppoHP}HP)`} + **Loser**: ${userWin ? `${opponent} (${oppoHP}HP)` : `${msg.author} (${userHP}HP)`} `); } catch (err) { this.fighting.delete(msg.channel.id); diff --git a/commands/games/emoji-emoji-revolution.js b/commands/games/emoji-emoji-revolution.js index e47b25f8..302a170a 100644 --- a/commands/games/emoji-emoji-revolution.js +++ b/commands/games/emoji-emoji-revolution.js @@ -63,7 +63,8 @@ module.exports = class EmojiEmojiRevolutionCommand extends Command { } this.playing.delete(msg.channel.id); if (aPts === oPts) return msg.say('It\'s a tie!'); - return msg.say(`You win ${aPts > oPts ? msg.author : opponent} with ${aPts > oPts ? aPts : oPts} points!`); + const userWin = aPts > oPts; + return msg.say(`You win ${userWin ? msg.author : opponent} with ${userWin ? aPts : oPts} points!`); } catch (err) { this.playing.delete(msg.channel.id); throw err; diff --git a/commands/games/gunfight.js b/commands/games/gunfight.js index 77d6f0e8..2f28838e 100644 --- a/commands/games/gunfight.js +++ b/commands/games/gunfight.js @@ -36,7 +36,7 @@ module.exports = class GunfightCommand extends Command { return msg.say('Looks like they declined...'); } await msg.say('Get Ready...'); - const length = Math.floor(Math.random() * ((30000 - 1000) + 1)) + 1000; + const length = Math.floor(Math.random() * (30000 - 1000 + 1)) + 1000; await wait(length); const word = words[Math.floor(Math.random() * words.length)]; await msg.say(`TYPE \`${word.toUpperCase()}\` NOW!`); @@ -47,7 +47,7 @@ module.exports = class GunfightCommand extends Command { }); this.fighting.delete(msg.channel.id); if (!winner.size) return msg.say('Oh... No one won.'); - return msg.say(`And the winner is ${winner.first().author.username}!`); + return msg.say(`The winner is ${winner.first().author}!`); } catch (err) { this.fighting.delete(msg.channel.id); throw err; diff --git a/commands/games/hangman.js b/commands/games/hangman.js index eefc135c..828885ff 100644 --- a/commands/games/hangman.js +++ b/commands/games/hangman.js @@ -49,7 +49,10 @@ module.exports = class HangmanCommand extends Command { } const choice = guess.first().content.toLowerCase(); if (choice === 'end') break; - if (confirmation.includes(choice) || incorrect.includes(choice)) { + if (choice.length > 1) { + if (word === choice) break; + else await msg.say('Nope, that\'s not the word, try again!'); + } else if (confirmation.includes(choice) || incorrect.includes(choice)) { await msg.say('You have already picked that letter!'); } else if (word.includes(choice)) { await msg.say('Nice job!'); diff --git a/commands/games/whos-that-pokemon.js b/commands/games/whos-that-pokemon.js index d6c04a44..484712eb 100644 --- a/commands/games/whos-that-pokemon.js +++ b/commands/games/whos-that-pokemon.js @@ -20,8 +20,7 @@ module.exports = class WhosThatPokemonCommand extends Command { { key: 'hide', prompt: 'Do you want to silhouette the Pokémon\'s image?', - type: 'boolean', - default: false + type: 'boolean' } ] }); diff --git a/commands/random-res/guess-my-looks.js b/commands/random-res/guess-my-looks.js index 06db681d..d9880b80 100644 --- a/commands/random-res/guess-my-looks.js +++ b/commands/random-res/guess-my-looks.js @@ -38,8 +38,8 @@ module.exports = class GuessMyLooksCommand extends Command { const extra = extras[Math.floor(Math.random() * extras.length)]; const prefix = user.id === msg.author.id ? 'You' : 'They'; return msg.reply(oneLine` - ${prefix} are, I think, a ${age} year old ${gender} with ${eyeColor} eyes and ${hairStyle} - ${hairColor} hair. ${prefix} are ${feet}'${inches}" and weigh ${weight} pounds. Don't forget the ${extra}! + ${prefix} are, I think, a ${age} year old ${gender} with ${eyeColor} eyes and ${hairStyle} ${hairColor} hair. + ${prefix} are ${feet}'${inches}" and weigh ${weight} pounds. Don't forget the ${extra}! `); } }; diff --git a/commands/search/bot-info.js b/commands/search/bot-info.js index 4ca0fbe1..c3bfc5bc 100644 --- a/commands/search/bot-info.js +++ b/commands/search/bot-info.js @@ -27,11 +27,6 @@ module.exports = class BotInfoCommand extends Command { const { body } = await snekfetch .get(`https://bots.discord.pw/api/bots/${bot.id}`) .set({ Authorization: DBOTS_KEY }); - const owners = []; - for (const owner of body.owner_ids) { - const user = await this.client.users.fetch(owner); - owners.push(user.tag); - } const embed = new MessageEmbed() .setColor(0x9797FF) .setAuthor('Discord Bots', 'https://i.imgur.com/tHTKaks.jpg') @@ -43,9 +38,7 @@ module.exports = class BotInfoCommand extends Command { .addField('❯ Invite', `[Here](${body.invite_url})`, true) .addField('❯ Prefix', - body.prefix, true) - .addField('❯ Owner(s)', - owners.join(', '), true); + body.prefix, true); return msg.embed(embed); } catch (err) { if (err.status === 404) return msg.say('Could not find any results.'); diff --git a/commands/search/bulbapedia.js b/commands/search/bulbapedia.js index 5755d9dd..5d8d3098 100644 --- a/commands/search/bulbapedia.js +++ b/commands/search/bulbapedia.js @@ -44,7 +44,7 @@ module.exports = class BulbapediaCommand extends Command { .setTitle(data.title) .setAuthor('Bulbapedia', 'https://i.imgur.com/ePpoeFA.png') .setThumbnail(data.thumbnail ? data.thumbnail.source : null) - .setURL(`https://bulbapedia.bulbagarden.net/wiki/${encodeURIComponent(query.replace(/\)/gi, '%29'))}`) + .setURL(`https://bulbapedia.bulbagarden.net/wiki/${encodeURIComponent(query.replace(/\)/g, '%29'))}`) .setDescription(shorten(data.extract.replace(/\n/g, '\n\n'))); return msg.embed(embed); } catch (err) { diff --git a/commands/search/github.js b/commands/search/github.js index c3c3ae5c..5d62f389 100644 --- a/commands/search/github.js +++ b/commands/search/github.js @@ -1,6 +1,7 @@ const { Command } = require('discord.js-commando'); const { MessageEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); +const { shorten } = require('../../util/Util'); const { GITHUB_LOGIN } = process.env; module.exports = class GitHubCommand extends Command { @@ -37,8 +38,8 @@ module.exports = class GitHubCommand extends Command { .setAuthor('GitHub', 'https://i.imgur.com/e4HunUm.png') .setTitle(body.full_name) .setURL(body.html_url) - .setDescription(body.description || 'No description.') - .setThumbnail(body.owner.avatar_url || null) + .setDescription(body.description ? shorten(body.description) : 'No description.') + .setThumbnail(body.owner.avatar_url) .addField('❯ Stars', body.stargazers_count, true) .addField('❯ Forks', diff --git a/commands/search/ip-info.js b/commands/search/ip-info.js deleted file mode 100644 index 263b1900..00000000 --- a/commands/search/ip-info.js +++ /dev/null @@ -1,52 +0,0 @@ -const { Command } = require('discord.js-commando'); -const { MessageEmbed } = require('discord.js'); -const snekfetch = require('snekfetch'); - -module.exports = class IPInfoCommand extends Command { - constructor(client) { - super(client, { - name: 'ip-info', - aliases: ['ip'], - group: 'search', - memberName: 'ip-info', - description: 'Gets data for an IP address.', - clientPermissions: ['EMBED_LINKS'], - args: [ - { - key: 'ip', - prompt: 'Which IP would you like to get information on?', - type: 'string', - parse: ip => encodeURIComponent(ip) - } - ] - }); - } - - async run(msg, { ip }) { - try { - const { body } = await snekfetch.get(`https://ipinfo.io/${ip}/json`); - const embed = new MessageEmbed() - .setColor(0x9797FF) - .setURL(`https://ipinfo.io/${ip}`) - .setTitle(body.ip) - .addField('❯ Hostname', - body.hostname || 'N/A') - .addField('❯ Location', - body.loc || 'N/A', true) - .addField('❯ Organization', - body.org || 'N/A', true) - .addField('❯ Zip', - body.postal || 'N/A', true) - .addField('❯ City', - body.city || 'N/A', true) - .addField('❯ Region', - body.region || 'N/A', true) - .addField('❯ Country', - body.country || 'N/A', true); - return msg.embed(embed); - } catch (err) { - if (err.status === 404) return msg.say('Could not find any results.'); - return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); - } - } -}; diff --git a/commands/search/kickstarter.js b/commands/search/kickstarter.js index 0143974a..31aaef8a 100644 --- a/commands/search/kickstarter.js +++ b/commands/search/kickstarter.js @@ -1,6 +1,7 @@ const { Command } = require('discord.js-commando'); const { MessageEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); +const { shorten } = require('../../util/Util'); module.exports = class KickstarterCommand extends Command { constructor(client) { @@ -36,12 +37,12 @@ module.exports = class KickstarterCommand extends Command { .setTitle(data.name) .setURL(data.urls.web.project) .setAuthor('Kickstarter', 'https://i.imgur.com/EHDlH5t.png') - .setDescription(data.blurb) + .setDescription(shorten(data.blurb)) .setThumbnail(data.photo ? data.photo.full : null) .addField('❯ Goal', - `${data.currency_symbol}${data.goal.toLocaleString()}`, true) + `${data.currency_symbol}${data.goal}`, true) .addField('❯ Pledged', - `${data.currency_symbol}${data.pledged.toLocaleString()}`, true) + `${data.currency_symbol}${data.pledged}`, true) .addField('❯ Backers', data.backers_count, true) .addField('❯ Creator', diff --git a/commands/search/mdn.js b/commands/search/mdn.js index e9c9f22b..bcb70e27 100644 --- a/commands/search/mdn.js +++ b/commands/search/mdn.js @@ -1,6 +1,7 @@ const { Command } = require('discord.js-commando'); const { MessageEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); +const { shorten } = require('../../util/Util'); module.exports = class MDNCommand extends Command { constructor(client) { @@ -33,7 +34,7 @@ module.exports = class MDNCommand extends Command { .setAuthor('MDN', 'https://i.imgur.com/DFGXabG.png') .setURL(data.url) .setTitle(data.title) - .setDescription(data.excerpt); + .setDescription(shorten(data.excerpt)); return msg.embed(embed); } catch (err) { return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); diff --git a/commands/search/new-york-times.js b/commands/search/new-york-times.js index 70d18c9c..90dd4350 100644 --- a/commands/search/new-york-times.js +++ b/commands/search/new-york-times.js @@ -1,6 +1,7 @@ const { Command } = require('discord.js-commando'); const { MessageEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); +const { shorten } = require('../../util/Util'); const { NYTIMES_KEY } = process.env; module.exports = class NewYorkTimesCommand extends Command { @@ -38,7 +39,7 @@ module.exports = class NewYorkTimesCommand extends Command { .setAuthor('New York Times', 'https://i.imgur.com/ZbuTWwO.png') .setURL(data.web_url) .setTitle(data.headline.main) - .setDescription(data.snippet) + .setDescription(shorten(data.snippet)) .addField('❯ Publish Date', new Date(data.pub_date).toDateString(), true); return msg.embed(embed); diff --git a/commands/search/npm.js b/commands/search/npm.js index dbd2af67..5c9069c4 100644 --- a/commands/search/npm.js +++ b/commands/search/npm.js @@ -31,7 +31,7 @@ module.exports = class NPMCommand extends Command { .setAuthor('NPM', 'https://i.imgur.com/ErKf5Y0.png') .setTitle(body.name) .setURL(`https://www.npmjs.com/package/${query}`) - .setDescription(body.description || 'No Description.') + .setDescription(body.description ? shorten(body.description) : 'No description.') .addField('❯ Version', body['dist-tags'].latest, true) .addField('❯ License', @@ -47,7 +47,7 @@ module.exports = class NPMCommand extends Command { .addField('❯ Keywords', body.keywords && body.keywords.length ? shorten(body.keywords.join(', '), 1000) : 'None') .addField('❯ Maintainers', - body.maintainers.map(user => user.name).join(', ')); + shorten(body.maintainers.map(user => user.name).join(', '), 1000)); return msg.embed(embed); } catch (err) { if (err.status === 404) return msg.say('Could not find any results.'); diff --git a/commands/search/pokedex.js b/commands/search/pokedex.js index b66df53b..d409599e 100644 --- a/commands/search/pokedex.js +++ b/commands/search/pokedex.js @@ -34,7 +34,7 @@ module.exports = class PokedexCommand extends Command { .setURL(`https://www.serebii.net/pokedex-sm/${id}.shtml`) .setDescription(stripIndents` **The ${filterPkmn(body.genera).genus} Pokémon** - ${filterPkmn(body.flavor_text_entries).flavor_text.replace(/(\n|\f|\r)/g, ' ')} + ${filterPkmn(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/studio-ghibli.js b/commands/search/studio-ghibli.js deleted file mode 100644 index 7a419954..00000000 --- a/commands/search/studio-ghibli.js +++ /dev/null @@ -1,48 +0,0 @@ -const { Command } = require('discord.js-commando'); -const { MessageEmbed } = require('discord.js'); -const snekfetch = require('snekfetch'); -const { shorten } = require('../../util/Util'); - -module.exports = class StudioGhibliCommand extends Command { - constructor(client) { - super(client, { - name: 'studio-ghibli', - aliases: ['ghibli', 'ghibli-film', 'studio-ghibli-film'], - group: 'search', - memberName: 'studio-ghibli', - description: 'Searches Studio Ghibli films for your query.', - clientPermissions: ['EMBED_LINKS'], - args: [ - { - key: 'query', - prompt: 'What film would you like to search for?', - type: 'string' - } - ] - }); - } - - async run(msg, { query }) { - try { - const { body } = await snekfetch - .get('http://ghibliapi.herokuapp.com/films') - .query({ title: query }); - if (!body.length) return msg.say('Could not find any results.'); - const data = body[0]; - const embed = new MessageEmbed() - .setColor(0xE7E7E7) - .setAuthor('Studio Ghibli', 'https://i.imgur.com/fQvw2B8.jpg') - .setTitle(data.title) - .setDescription(shorten(data.description)) - .addField('❯ Release Year', - data.release_date || 'N/A', true) - .addField('❯ Director', - data.director || 'N/A', true) - .addField('❯ Rotten Tomatoes Score', - data.rt_score ? `${data.rt_score}%` : 'N/A', true); - return msg.embed(embed); - } catch (err) { - return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); - } - } -}; diff --git a/commands/search/thesaurus.js b/commands/search/thesaurus.js index fb2d26e8..7e12926a 100644 --- a/commands/search/thesaurus.js +++ b/commands/search/thesaurus.js @@ -32,12 +32,12 @@ module.exports = class ThesaurusCommand extends Command { api_key: WORDNIK_KEY }); if (!body.length) return msg.say('Could not find any results.'); - const synonyms = body.find(i => i.relationshipType === 'synonym'); - const antonyms = body.find(i => i.relationshipType === 'antonym'); + const synonyms = body.filter(word => word.relationshipType === 'synonym'); + const antonyms = body.filter(word => word.relationshipType === 'antonym'); return msg.say(stripIndents` **${query}** - __Synonyms:__ ${synonyms ? synonyms.words.join(', ') : 'N/A'} - __Antonyms:__ ${antonyms ? antonyms.words.join(', ') : 'N/A'} + __Synonyms:__ ${synonyms.length ? synonyms.words.join(', ') : 'N/A'} + __Antonyms:__ ${antonyms.length ? antonyms.words.join(', ') : 'N/A'} `); } catch (err) { return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); diff --git a/commands/search/urban.js b/commands/search/urban.js index 09ff7dc0..03c19f75 100644 --- a/commands/search/urban.js +++ b/commands/search/urban.js @@ -28,7 +28,7 @@ module.exports = class UrbanCommand extends Command { .get('http://api.urbandictionary.com/v0/define') .query({ term: query }); if (!body.list.length) return msg.say('Could not find any results.'); - const data = body.list[0]; + const data = body.list[Math.floor(Math.random() * body.list.length)]; const embed = new MessageEmbed() .setColor(0x32A8F0) .setAuthor('Urban Dictionary', 'https://i.imgur.com/Fo0nRTe.png') @@ -36,7 +36,7 @@ module.exports = class UrbanCommand extends Command { .setTitle(data.word) .setDescription(shorten(data.definition)) .addField('❯ Example', - shorten(data.example, 1000) || 'None'); + data.example ? shorten(data.example, 1000) : 'None'); return msg.embed(embed); } catch (err) { return msg.say(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); diff --git a/commands/search/wikipedia.js b/commands/search/wikipedia.js index 8e02e36c..25ff1493 100644 --- a/commands/search/wikipedia.js +++ b/commands/search/wikipedia.js @@ -44,7 +44,7 @@ module.exports = class WikipediaCommand extends Command { .setTitle(data.title) .setAuthor('Wikipedia', 'https://i.imgur.com/Z7NJBK2.png') .setThumbnail(data.thumbnail ? data.thumbnail.source : null) - .setURL(`https://en.wikipedia.org/wiki/${encodeURIComponent(query.replace(/\)/gi, '%29'))}`) + .setURL(`https://en.wikipedia.org/wiki/${encodeURIComponent(query.replace(/\)/g, '%29'))}`) .setDescription(shorten(data.extract.replace(/\n/g, '\n\n'))); return msg.embed(embed); } catch (err) { diff --git a/commands/search/youtube.js b/commands/search/youtube.js index ca7678a3..e279ec57 100644 --- a/commands/search/youtube.js +++ b/commands/search/youtube.js @@ -1,6 +1,7 @@ const { Command } = require('discord.js-commando'); const { MessageEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); +const { shorten } = require('../../util/Util'); const { GOOGLE_KEY } = process.env; module.exports = class YouTubeCommand extends Command { @@ -38,7 +39,7 @@ module.exports = class YouTubeCommand extends Command { const embed = new MessageEmbed() .setColor(0xDD2825) .setTitle(data.snippet.title) - .setDescription(data.snippet.description) + .setDescription(shorten(data.snippet.description)) .setAuthor(`YouTube - ${data.snippet.channelTitle}`, 'https://i.imgur.com/kKHJg9Q.png') .setURL(`https://www.youtube.com/watch?v=${data.id.videoId}`) .setThumbnail(data.snippet.thumbnails.default.url); diff --git a/commands/search/yu-gi-oh.js b/commands/search/yu-gi-oh.js index 04e835d0..496c6474 100644 --- a/commands/search/yu-gi-oh.js +++ b/commands/search/yu-gi-oh.js @@ -1,6 +1,7 @@ const { Command } = require('discord.js-commando'); const { MessageEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); +const { shorten } = require('../../util/Util'); module.exports = class YuGiOhCommand extends Command { constructor(client) { @@ -31,7 +32,7 @@ module.exports = class YuGiOhCommand extends Command { const embed = new MessageEmbed() .setColor(0xBE5F1F) .setTitle(data.name) - .setDescription(data.text) + .setDescription(shorten(data.text)) .setAuthor('Yu-Gi-Oh!', 'https://i.imgur.com/AJNBflD.png') .setThumbnail(image.headers.location) .addField('❯ Card Type', diff --git a/commands/text-edit/b.js b/commands/text-edit/b.js index 1481d2b3..5630faea 100644 --- a/commands/text-edit/b.js +++ b/commands/text-edit/b.js @@ -14,7 +14,7 @@ module.exports = class BCommand extends Command { prompt: 'What text would you like to 🅱?', type: 'string', validate: text => { - if (text.replace(/(b|d|g|p|q)/gi, '🅱').length < 2000) return true; + if (text.replace(/b/gi, '🅱').length < 2000) return true; return 'Invalid text, your text is too long.'; } } @@ -23,6 +23,6 @@ module.exports = class BCommand extends Command { } run(msg, { text }) { - return msg.say(text.replace(/(b|d|g|p|q)/gi, '🅱')); + return msg.say(text.replace(/b/gi, '🅱')); } }; diff --git a/commands/util/upvote.js b/commands/util/upvote.js index f6a53a2f..baae3910 100644 --- a/commands/util/upvote.js +++ b/commands/util/upvote.js @@ -10,7 +10,7 @@ module.exports = class UpvoteCommand extends Command { aliases: ['upvoters', 'updoot'], group: 'util', memberName: 'upvote', - description: 'Responds with Xiao\'s upvoter link on Discord Bots.', + description: 'Responds with Xiao\'s upvoter link on discordbots.org.', guarded: true }); } diff --git a/package.json b/package.json index c9289546..4c9f2cd4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "48.1.1", + "version": "49.0.0", "description": "Your personal server companion.", "main": "Shard.js", "scripts": {