error handling if the ship isnt found
This commit is contained in:
parent
e8743f24da
commit
f1f01428b4
@ -9,8 +9,17 @@ async def get_ship(ship_name):
|
|||||||
base_url = "https://robertspaceindustries.com"
|
base_url = "https://robertspaceindustries.com"
|
||||||
wiki_url = "https://starcitizen.tools/"
|
wiki_url = "https://starcitizen.tools/"
|
||||||
|
|
||||||
ship = await Ship(name=ship_name).get_ships_pages_async()
|
try:
|
||||||
ship = ship[0]
|
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.PrettyPrinter(indent=4)
|
||||||
# pp.pprint(ship)
|
# pp.pprint(ship)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user