Blacklist Pokemon without cries

This commit is contained in:
Dragon Fire
2020-10-30 13:32:44 -04:00
parent 124451839b
commit f5f7427cf2
2 changed files with 11 additions and 1 deletions
+10 -1
View File
@@ -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;
}
}
]
});
+1
View File
@@ -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;