mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-23 18:05:01 +02:00
Blacklist Pokemon without cries
This commit is contained in:
@@ -2,6 +2,7 @@ const Command = require('../../structures/Command');
|
||||
const { Readable } = require('stream');
|
||||
const { reactIfAble } = require('../../util/Util');
|
||||
const pokemonCount = 893;
|
||||
const blacklist = [0, 803, 804, 805, 806, 807, 808, 809, 890, 891, 892, 893];
|
||||
|
||||
module.exports = class WhosThatPokemonCryCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -59,7 +60,15 @@ module.exports = class WhosThatPokemonCryCommand extends Command {
|
||||
type: 'integer',
|
||||
max: pokemonCount,
|
||||
min: 0,
|
||||
default: () => Math.floor(Math.random() * (pokemonCount + 1))
|
||||
default: () => {
|
||||
let num;
|
||||
while (!num) {
|
||||
const chosen = Math.floor(Math.random() * (pokemonCount + 1));
|
||||
if (blacklist.includes(chosen)) continue;
|
||||
num = chosen;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -112,6 +112,7 @@ module.exports = class Pokemon {
|
||||
|
||||
async fetchCry() {
|
||||
if (this.cry) return this.cry;
|
||||
if (this.missingno) return null;
|
||||
try {
|
||||
const { body } = await request.get(`https://pokemoncries.com/cries/${this.id}.mp3`);
|
||||
this.cry = body;
|
||||
|
||||
Reference in New Issue
Block a user