mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 22:34:46 +02:00
Pokemon Moveset Command
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { stripIndents } = require('common-tags');
|
||||
|
||||
module.exports = class PokedexMovesetCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'pokedex-moveset',
|
||||
aliases: [
|
||||
'pokemon-moveset',
|
||||
'pokémon-moveset',
|
||||
'pokédex-moveset',
|
||||
'pkmn-moveset',
|
||||
'pokedex-moves',
|
||||
'pokémon-moves',
|
||||
'pokemon-moves',
|
||||
'pokédex-moves',
|
||||
'pkmn-moves'
|
||||
],
|
||||
group: 'search',
|
||||
memberName: 'pokedex-moveset',
|
||||
description: 'Responds with the moveset for a Pokémon.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
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'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
{
|
||||
key: 'pokemon',
|
||||
prompt: 'What Pokémon would you like to get information on?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { pokemon }) {
|
||||
try {
|
||||
const data = await this.client.pokemon.fetch(pokemon);
|
||||
if (!data) return msg.say('Could not find any results.');
|
||||
if (!data.gameDataCached) await data.fetchGameData();
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xED1C24)
|
||||
.setAuthor(`#${data.displayID} - ${data.name}`, data.boxImageURL, data.serebiiURL)
|
||||
.setDescription(data.moveSet.map(move => `**Level ${move.level}:** ${move.name}`).join('\n'))
|
||||
.setThumbnail(data.spriteImageURL);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -126,12 +126,17 @@ module.exports = class PokedexCommand extends Command {
|
||||
data.genderRate.genderless ? 'Genderless' : `♂️ ${data.genderRate.male}% ♀️ ${data.genderRate.female}%`);
|
||||
if (data.cry) {
|
||||
const connection = msg.guild ? this.client.voice.connections.get(msg.guild.id) : null;
|
||||
const moveUsage = this.client.registry.commands.get('pokedex-moveset').usage();
|
||||
if (connection) {
|
||||
embed.setFooter(`Use ${moveUsage} to get the Pokémon's moveset.`);
|
||||
connection.play(data.cry);
|
||||
await reactIfAble(msg, this.client.user, '🔉');
|
||||
} else {
|
||||
const usage = this.client.registry.commands.get('join').usage();
|
||||
embed.setFooter(`Join a voice channel and use ${usage} to hear the Pokémon's cry.`);
|
||||
embed.setFooter(stripIndents`
|
||||
Join a voice channel and use ${usage} to hear the Pokémon's cry.
|
||||
Use ${moveUsage} to get the Pokémon's moveset.
|
||||
`);
|
||||
}
|
||||
}
|
||||
return msg.embed(embed);
|
||||
|
||||
Reference in New Issue
Block a user