added shiny lookups to pokedex

This commit is contained in:
phixxy 2024-01-07 13:25:21 -08:00
parent dcf347e392
commit a6e00b439a

View file

@ -1702,14 +1702,18 @@ async def pokemon(ctx, pokemon):
hidden=False
)
async def pokedex(ctx, pokemon):
pokemon = pokemon.lower()
pokemon = ctx.message.content.split(" ", maxsplit=1)[1]
shiny = False
if 'shiny ' in pokemon:
shiny = True
pokemon = pokemon.replace('shiny ', '')
url = "https://pokeapi.co/api/v2/pokemon/" + pokemon
dex_url = "https://pokeapi.co/api/v2/pokemon-species/" + pokemon
#try:
data = await get_json(url)
name = data['name']
height = data['height']
weight = data['weight']
height_str = str(int(data['height'])/10) + 'm'
weight_str = str(int(data['weight'])/10) + 'kg'
type1 = data['types'][0]['type']['name']
try:
type2 = data['types'][1]['type']['name']
@ -1718,6 +1722,8 @@ async def pokedex(ctx, pokemon):
type2 = "None"
type_str = type1.capitalize()
sprite = data["sprites"]["front_default"]
if shiny:
sprite = data["sprites"]["front_shiny"]
dex_data = await get_json(dex_url)
for entry in dex_data['flavor_text_entries']:
print(type(entry))
@ -1733,16 +1739,11 @@ async def pokedex(ctx, pokemon):
embed=discord.Embed(title=name.capitalize())
embed.set_image(url=sprite)
embed.add_field(name=genus, value=dex_desc, inline=False)
embed.add_field(name="Weight", value=weight, inline=True)
embed.add_field(name="Height", value=height, inline=True)
embed.add_field(name="Weight", value=weight_str , inline=True)
embed.add_field(name="Height", value=height_str, inline=True)
embed.add_field(name="Types", value=type_str, inline=True)
await ctx.send(embed=embed)
#message = name + ' ' + str(height) + ' ' + str(weight) + ' ' + type1 + ' ' + type2 + ' ' + sprite
#await ctx.send(message)
@bot.command(
description="Kill",
help="Kills the bot in event of an emergency. Only special users can do this! Usage: !kill",