Support More Pokemon

This commit is contained in:
Dragon Fire
2020-11-26 08:40:44 -05:00
parent a22af5768e
commit 4df75d669a
6 changed files with 26 additions and 18 deletions
+2 -3
View File
@@ -1,6 +1,5 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const { reactIfAble } = require('../../util/Util'); const { reactIfAble } = require('../../util/Util');
const pokemonCount = 893;
module.exports = class WhosThatPokemonCryCommand extends Command { module.exports = class WhosThatPokemonCryCommand extends Command {
constructor(client) { constructor(client) {
@@ -70,9 +69,9 @@ module.exports = class WhosThatPokemonCryCommand extends Command {
key: 'pokemon', key: 'pokemon',
prompt: 'What Pokémon do you want to use?', prompt: 'What Pokémon do you want to use?',
type: 'integer', type: 'integer',
max: pokemonCount, max: client.pokemon.pokemonCountWithCry,
min: 0, min: 0,
default: () => Math.floor(Math.random() * (pokemonCount + 1)) default: () => Math.floor(Math.random() * (client.pokemon.pokemonCountWithCry + 1))
} }
] ]
}); });
+3 -5
View File
@@ -5,7 +5,6 @@ const { reactIfAble } = require('../../util/Util');
const { silhouette } = require('../../util/Canvas'); const { silhouette } = require('../../util/Canvas');
const path = require('path'); const path = require('path');
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Pokemon Solid.ttf'), { family: 'Pokemon' }); registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Pokemon Solid.ttf'), { family: 'Pokemon' });
const pokemonCount = 893;
module.exports = class WhosThatPokemonCommand extends Command { module.exports = class WhosThatPokemonCommand extends Command {
constructor(client) { constructor(client) {
@@ -73,9 +72,9 @@ module.exports = class WhosThatPokemonCommand extends Command {
key: 'pokemon', key: 'pokemon',
prompt: 'What Pokémon do you want to use?', prompt: 'What Pokémon do you want to use?',
type: 'integer', type: 'integer',
max: pokemonCount, max: client.pokemon.pokemonCount,
min: 0, min: 0,
default: () => Math.floor(Math.random() * (pokemonCount + 1)) default: () => Math.floor(Math.random() * (client.pokemon.pokemonCount + 1))
} }
] ]
}); });
@@ -100,10 +99,9 @@ module.exports = class WhosThatPokemonCommand extends Command {
max: 1, max: 1,
time: 15000 time: 15000
}); });
if (connection) { if (connection && data.cry) {
if (connection.dispatcher) connection.dispatcher.end(); if (connection.dispatcher) connection.dispatcher.end();
connection.play(data.cry); connection.play(data.cry);
await reactIfAble(msg, this.client.user, '🔉');
} }
this.client.games.delete(msg.channel.id); this.client.games.delete(msg.channel.id);
if (!msgs.size) return msg.reply(`Time! It's **${data.name}**!`, { files: [answerAttachment] }); if (!msgs.size) return msg.reply(`Time! It's **${data.name}**!`, { files: [answerAttachment] });
+9 -7
View File
@@ -88,13 +88,15 @@ module.exports = class PokedexCommand extends Command {
if (found.id === data.id) return `**${found.name}**`; if (found.id === data.id) return `**${found.name}**`;
return found.name; return found.name;
}).join(' -> ')); }).join(' -> '));
const connection = msg.guild ? this.client.voice.connections.get(msg.guild.id) : null; if (data.cry) {
if (connection) { const connection = msg.guild ? this.client.voice.connections.get(msg.guild.id) : null;
connection.play(data.cry); if (connection) {
await reactIfAble(msg, this.client.user, '🔉'); connection.play(data.cry);
} else { await reactIfAble(msg, this.client.user, '🔉');
const usage = this.client.registry.commands.get('join').usage(); } else {
embed.setFooter(`Join a voice channel and use ${usage} to hear the Pokémon's cry.`); 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.`);
}
} }
return msg.embed(embed); return msg.embed(embed);
} catch (err) { } catch (err) {
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "xiao", "name": "xiao",
"version": "121.2.1", "version": "121.2.2",
"description": "Your personal server companion.", "description": "Your personal server companion.",
"main": "Xiao.js", "main": "Xiao.js",
"scripts": { "scripts": {
+4 -2
View File
@@ -19,7 +19,7 @@ module.exports = class Pokemon {
: [{ name: slugName, language: 'en' }]; : [{ name: slugName, language: 'en' }];
this.genus = data.genera.length this.genus = data.genera.length
? `The ${data.genera.filter(entry => entry.language.name === 'en')[0].genus}` ? `The ${data.genera.filter(entry => entry.language.name === 'en')[0].genus}`
: 'Galar Native'; : 'Undiscovered Pokémon';
this.varieties = data.varieties.map(variety => { this.varieties = data.varieties.map(variety => {
const name = firstUpperCase(variety.pokemon.name const name = firstUpperCase(variety.pokemon.name
.replace(new RegExp(`${this.slug}-?`, 'i'), '') .replace(new RegExp(`${this.slug}-?`, 'i'), '')
@@ -38,7 +38,9 @@ module.exports = class Pokemon {
}; };
this.typesCached = data.missingno || false; this.typesCached = data.missingno || false;
this.missingno = data.missingno || false; this.missingno = data.missingno || false;
this.cry = path.join(__dirname, '..', '..', 'assets', 'sounds', 'pokedex', `${data.id}.wav`); this.cry = data.id > store.pokemonCountWithCry
? null
: path.join(__dirname, '..', '..', 'assets', 'sounds', 'pokedex', `${data.id}.wav`);
} }
get displayID() { get displayID() {
+7
View File
@@ -4,6 +4,13 @@ const Pokemon = require('./Pokemon');
const missingno = require('../../assets/json/missingno'); const missingno = require('../../assets/json/missingno');
module.exports = class PokemonStore extends Collection { module.exports = class PokemonStore extends Collection {
constructor(options) {
super(options);
this.pokemonCount = 897;
this.pokemonCountWithCry = 893;
}
async fetch(query) { async fetch(query) {
query = this.makeSlug(query); query = this.makeSlug(query);
if (!query) return null; if (!query) return null;