mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-06 22:44:32 +02:00
Pokemon Moveset Command
This commit is contained in:
@@ -258,7 +258,7 @@ in the appropriate channel's topic to use it.
|
||||
|
||||
## Commands
|
||||
|
||||
Total: 568
|
||||
Total: 569
|
||||
|
||||
### Utility:
|
||||
|
||||
@@ -503,6 +503,7 @@ Total: 568
|
||||
* **paladins:** Responds with information on a Paladins player.
|
||||
* **periodic-table:** Finds an element on the periodic table.
|
||||
* **poem:** Searches for poems by a specific author.
|
||||
* **pokedex-moveset:** Responds with the moveset for a Pokémon.
|
||||
* **pokedex:** Searches the Pokédex for a Pokémon.
|
||||
* **pornhub:** Searches Pornhub for your query. (NSFW)
|
||||
* **recipe:** Searches for recipes based on your query.
|
||||
@@ -1544,6 +1545,7 @@ here.
|
||||
- [Pokemon Fusion](https://pokemon.alexonsager.net/)
|
||||
* pokemon-fusion (Images)
|
||||
- [PokéAPI](https://pokeapi.co/)
|
||||
* pokemon-moveset (API)
|
||||
* pokedex (API)
|
||||
* pokemon-cry (API)
|
||||
* whos-that-pokemon (API)
|
||||
@@ -1552,6 +1554,7 @@ here.
|
||||
* 3000-years (Image, Original Game)
|
||||
* dexter (Image, Original Anime)
|
||||
* hat (Ash Hat Original Anime)
|
||||
* pokedex-moveset (Images, Original Game)
|
||||
* pokedex (Images, Original Game)
|
||||
* pokemon-cry (Original Game)
|
||||
* pokemon-fusion (Original Game)
|
||||
@@ -1628,6 +1631,7 @@ here.
|
||||
- [SEGA](https://www.sega.com/)
|
||||
* sonic-says ([Image, Original "Sonic the Hedgehog" Game](https://www.sonicthehedgehog.com/))
|
||||
- [Serebii.net](https://www.serebii.net/index2.shtml)
|
||||
* pokedex-moveset (Images)
|
||||
* pokedex (Images)
|
||||
* whos-that-pokemon (Images)
|
||||
* whos-that-pokemon-cry (Images)
|
||||
|
||||
@@ -72,6 +72,20 @@
|
||||
},
|
||||
"height": 120,
|
||||
"weight": 3507.2,
|
||||
"moveSet": [
|
||||
{
|
||||
"name": "Water Gun",
|
||||
"level": 1
|
||||
},
|
||||
{
|
||||
"name": "Water Gun",
|
||||
"level": 1
|
||||
},
|
||||
{
|
||||
"name": "Sky Attack",
|
||||
"level": 1
|
||||
}
|
||||
],
|
||||
"chain": [0],
|
||||
"missingno": true,
|
||||
"sprite": "https://cdn.bulbagarden.net/upload/9/98/Missingno_RB.png",
|
||||
|
||||
@@ -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);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "123.3.2",
|
||||
"version": "123.4.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -47,6 +47,7 @@ module.exports = class Pokemon {
|
||||
this.stats = data.missingno ? data.stats : null;
|
||||
this.height = data.missingno ? data.height : null;
|
||||
this.weight = data.missingno ? data.weight : null;
|
||||
this.moveSet = data.missingno ? data.moveSet : [];
|
||||
this.gameDataCached = data.missingno || false;
|
||||
this.missingno = data.missingno || false;
|
||||
this.cry = data.id > store.pokemonCountWithCry
|
||||
@@ -109,6 +110,14 @@ module.exports = class Pokemon {
|
||||
sDef: defaultBody.stats.find(stat => stat.stat.name === 'special-defense').base_stat,
|
||||
spd: defaultBody.stats.find(stat => stat.stat.name === 'speed').base_stat
|
||||
};
|
||||
for (const move of defaultBody.moves) {
|
||||
if (!move.version_group_details.some(mve => mve.move_learn_method.name === 'level-up')) continue;
|
||||
const { body: moveBody } = await request.get(move.url);
|
||||
this.moveSet.push({
|
||||
name: moveBody.names.find(name => name.language.name === 'en').name,
|
||||
level: move.version_group_details[move.version_group_details.length - 1].level_learned_at
|
||||
});
|
||||
}
|
||||
for (const variety of this.varieties) {
|
||||
if (variety.id === defaultVariety.id) continue;
|
||||
const { body } = await request.get(`https://pokeapi.co/api/v2/pokemon/${variety.id}`);
|
||||
|
||||
Reference in New Issue
Block a user