Cache Pokemon Trainer Card IDs

This commit is contained in:
Dragon Fire
2021-02-11 14:25:20 -05:00
parent 19b5d6f926
commit 742bf51ddf
2 changed files with 15 additions and 10 deletions
+1 -10
View File
@@ -91,7 +91,7 @@ module.exports = class TrainerCardCommand extends Command {
try {
const pokemonUsed = [];
for (const pkmn of pokemon) {
const id = await this.fetchPokemonID(pkmn);
const id = await pokemon.fetchCardID();
pokemonUsed.push(id);
}
const card = await this.createCard(style, name, character, badgeChoice, pokemonUsed);
@@ -114,13 +114,4 @@ module.exports = class TrainerCardCommand extends Command {
.attach('_xfResponseType', 'json');
return Buffer.from(body.trainerCard, 'base64');
}
async fetchPokemonID(pokemon) {
const { body } = await request
.post('https://pokecharms.com/trainer-card-maker/pokemon-panels')
.attach('number', pokemon.id)
.attach('_xfResponseType', 'json');
const $ = cheerio.load(body.templateHtml);
return $('li[class="Panel"]').first().attr('data-id');
}
};