error handling if the ship isnt found

This commit is contained in:
Luke Robles 2023-04-27 08:29:30 -07:00
parent e8743f24da
commit f1f01428b4

View File

@ -9,8 +9,17 @@ async def get_ship(ship_name):
base_url = "https://robertspaceindustries.com"
wiki_url = "https://starcitizen.tools/"
try:
ship = await Ship(name=ship_name).get_ships_pages_async()
ship = ship[0]
except IndexError:
embed = discord.Embed(description="", color=discord.Color.red(), type="rich")
embed.add_field(
name="**Could not find that ship**", value="You gave me %s. Did you spell it right? (Its also possible my shitty code isnt working right)" % ship_name, inline=True
)
return embed
# prints for debug
# pp = pprint.PrettyPrinter(indent=4)
# pp.pprint(ship)