From 3a54cfb7f7d729f45428768cc8b7392816f1bfa9 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Fri, 30 Oct 2020 13:01:42 -0400 Subject: [PATCH] Who's That Pokemon Cry Command --- README.md | 11 ++- commands/games-sp/whos-that-pokemon-cry.js | 98 ++++++++++++++++++++++ commands/games-sp/whos-that-pokemon.js | 2 +- package.json | 2 +- 4 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 commands/games-sp/whos-that-pokemon-cry.js diff --git a/README.md b/README.md index 8ddc3347..2d177f5e 100644 --- a/README.md +++ b/README.md @@ -258,7 +258,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 552 +Total: 553 ### Utility: @@ -571,7 +571,8 @@ Total: 552 * **true-or-false:** Answer a true or false question. * **typing-test:** See how fast you can type a sentence in a given time limit. * **waldo:** Try to find Waldo with spoiler tags! -* **whos-that-pokemon:** Guess who that Pokémon is. +* **whos-that-pokemon:** Guess who that Pokémon is, based on their silhouette. +* **whos-that-pokemon-cry:** Guess who that Pokémon is, based on their cry. * **will-you-press-the-button:** Responds with a random "Will You Press The Button?" dilemma. ### Multi-Player Games: @@ -1027,6 +1028,7 @@ here. * yu-gi-oh-gen ([Card Base Template](https://www.deviantart.com/cylgom/art/Yu-GI-Oh-ultra-faithful-monster-card-template-728814822)) - [DaFont](https://www.dafont.com/) * whos-that-pokemon ([Pokemon Solid Font](https://www.dafont.com/pokemon.font)) + * whos-that-pokemon-cry ([Pokemon Solid Font](https://www.dafont.com/pokemon.font)) - [Danbooru](https://danbooru.donmai.us/) * danbooru (API) - [Dance Dance Revolution](https://www.ddrgame.com/) @@ -1506,9 +1508,11 @@ here. - [Pokemoncries.com](https://pokemoncries.com/) * pokedex (Cry Sound Effects) * whos-that-pokemon (Cry Sound Effects) + * whos-that-pokemon-cry (Cry Sound Effects) - [PokéAPI](https://pokeapi.co/) * pokedex (API) * whos-that-pokemon (API) + * whos-that-pokemon-cry (API) - [Pokémon](https://www.pokemon.com/us/) * 3000-years (Image, Original Game) * dexter (Image, Original Anime) @@ -1517,6 +1521,7 @@ here. * pokemon-fusion (Original Game) * soundboard (Pikachu Sound) * whos-that-pokemon (Images, Original Game) + * whos-that-pokemon-cry (Images, Original Game) * wild-pokemon (Image, Original Game) * wynaut (Image, Original Anime) - [Pornhub](https://www.pornhub.com/) @@ -1585,6 +1590,7 @@ here. - [Serebii.net](https://www.serebii.net/index2.shtml) * pokedex (Images) * whos-that-pokemon (Images) + * whos-that-pokemon-cry (Images) - [ShareFonts.net](https://www.wfonts.com/) * illegal ([Impact Font](https://www.wfonts.com/font/impact)) * meme-gen-classic ([Impact Font](https://www.wfonts.com/font/impact)) @@ -1696,6 +1702,7 @@ here. * dark-light ([Image](https://www.reddit.com/r/discordapp/comments/9krnhr/preach_the_message_of_the_möth_with_this_magi)) - [u/CaptainRako](https://www.reddit.com/user/CaptainRako/) * whos-that-pokemon ([Background Image](https://www.reddit.com/r/pokemon/comments/420xiv/whos_that_pokemon_1920x1080_hd_template_i_just/)) + * whos-that-pokemon-cry ([Background Image](https://www.reddit.com/r/pokemon/comments/420xiv/whos_that_pokemon_1920x1080_hd_template_i_just/)) - [u/guschuma](https://www.reddit.com/user/guschuma/) * waldo ([Concept](https://www.reddit.com/r/copypasta/comments/gkk7z1/wheres_waldo_game_created_by_me/)) - [u/LennyMcLennington](https://www.reddit.com/user/LennyMcLennington) diff --git a/commands/games-sp/whos-that-pokemon-cry.js b/commands/games-sp/whos-that-pokemon-cry.js new file mode 100644 index 00000000..03ada534 --- /dev/null +++ b/commands/games-sp/whos-that-pokemon-cry.js @@ -0,0 +1,98 @@ +const Command = require('../../structures/Command'); +const { Readable } = require('stream'); +const { reactIfAble } = require('../../util/Util'); +const path = require('path'); +const pokemonCount = 893; + +module.exports = class WhosThatPokemonCryCommand extends Command { + constructor(client) { + super(client, { + name: 'whos-that-pokemon-cry', + aliases: ['who-pokemon-cry', 'whos-that-pokémon-cry', 'who-pokémon-cry'], + group: 'games-sp', + memberName: 'whos-that-pokemon-cry', + description: 'Guess who that Pokémon is, based on their cry.', + throttling: { + usages: 1, + duration: 10 + }, + guildOnly: true, + userPermissions: ['CONNECT', 'SPEAK', 'ATTACH_FILES'], + credit: [ + { + name: 'Pokémon', + url: 'https://www.pokemon.com/us/', + reason: 'Images, Original Game' + }, + { + name: 'PokéAPI', + url: 'https://pokeapi.co/', + reason: 'API' + }, + { + name: 'Serebii.net', + url: 'https://www.serebii.net/index2.shtml', + reason: 'Images' + }, + { + name: 'u/CaptainRako', + url: 'https://www.reddit.com/user/CaptainRako/', + reason: 'Background Image', + // eslint-disable-next-line max-len + reasonURL: 'https://www.reddit.com/r/pokemon/comments/420xiv/whos_that_pokemon_1920x1080_hd_template_i_just/' + }, + { + name: 'DaFont', + url: 'https://www.dafont.com/', + reason: 'Pokemon Solid Font', + reasonURL: 'https://www.dafont.com/pokemon.font' + }, + { + name: 'Pokemoncries.com', + url: 'https://pokemoncries.com/', + reason: 'Cry Sound Effects' + } + ], + args: [ + { + key: 'pokemon', + prompt: 'What Pokémon do you want to use?', + type: 'integer', + max: pokemonCount, + min: 0, + default: () => Math.floor(Math.random() * (pokemonCount + 1)) + } + ] + }); + } + + async run(msg, { pokemon }) { + const connection = this.client.voice.connections.get(msg.guild.id); + if (!connection) { + const usage = this.client.registry.commands.get('join').usage(); + return msg.reply(`I am not in a voice channel. Use ${usage} to fix that!`); + } + try { + const data = await this.client.pokemon.fetch(pokemon.toString()); + const names = data.names.map(name => name.name.toLowerCase()); + const attachment = await this.client.registry.command.get('whos-that-pokemon').createImage(data, false); + await data.fetchCry(); + connection.play(Readable.from([data.cry])); + await reactIfAble(msg, this.client.user, '🔉'); + await msg.reply('**You have 15 seconds, who\'s that Pokémon?**'); + const msgs = await msg.channel.awaitMessages(res => res.author.id === msg.author.id, { + max: 1, + time: 15000 + }); + if (!msgs.size) return msg.reply(`Time! It's **${data.name}**!`, { files: [attachment] }); + const guess = msgs.first().content.toLowerCase(); + const slug = this.client.pokemon.makeSlug(guess); + if (!names.includes(guess) && data.slug !== slug) { + return msg.reply(`Nope! It's **${data.name}**!`, { files: [attachment] }); + } + return msg.reply(`Nice! It's **${data.name}**!`, { files: [attachment] }); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/commands/games-sp/whos-that-pokemon.js b/commands/games-sp/whos-that-pokemon.js index 47e2cb28..3f0cb6e2 100644 --- a/commands/games-sp/whos-that-pokemon.js +++ b/commands/games-sp/whos-that-pokemon.js @@ -15,7 +15,7 @@ module.exports = class WhosThatPokemonCommand extends Command { aliases: ['who-pokemon', 'whos-that-pokémon', 'who-pokémon'], group: 'games-sp', memberName: 'whos-that-pokemon', - description: 'Guess who that Pokémon is.', + description: 'Guess who that Pokémon is, based on their silhouette.', throttling: { usages: 1, duration: 10 diff --git a/package.json b/package.json index 538ce652..d0e7dedb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "119.34.9", + "version": "119.35.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {