Skip to content

Commit

Permalink
Catch some more identical forms
Browse files Browse the repository at this point in the history
  • Loading branch information
Glazelf committed May 14, 2024
1 parent af4af85 commit 7ff58e2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion util/pokemon/getWhosThatPokemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ module.exports = async ({ pokemonList, censor }) => {
serebiiRender = `https://www.serebii.net/pokemon/art/${pokemonID}.png`;
doesRenderExist = await imageExists(serebiiRender);
};
// Catch identical forms
let correctAnswer = pokemon.name;
let totemFormString = "-Totem";
if (correctAnswer.endsWith(totemFormString)) correctAnswer = correctAnswer.replace(totemFormString, "");
if (correctAnswer.startsWith("Arceus") || correctAnswer.startsWith("Silvally")) correctAnswer = correctAnswer.split("-")[0];
// Initiate image context
let img = await Canvas.loadImage(serebiiRender);
let canvas = Canvas.createCanvas(img.width, img.height); // Serebii renders seem to always be 475x475
Expand All @@ -30,6 +32,6 @@ module.exports = async ({ pokemonList, censor }) => {
};
pokemonFiles = new Discord.AttachmentBuilder(canvas.toBuffer());
returnString = `# Who's That Pokémon?`;
pokemonButtons.addComponents(new Discord.ButtonBuilder({ customId: `pkmQuiz|${pokemon.name}`, label: "Guess!", style: Discord.ButtonStyle.Primary }));
pokemonButtons.addComponents(new Discord.ButtonBuilder({ customId: `pkmQuiz|${correctAnswer}`, label: "Guess!", style: Discord.ButtonStyle.Primary }));
return { content: returnString, files: [pokemonFiles], components: [pokemonButtons] };
};

0 comments on commit 7ff58e2

Please sign in to comment.