If image can't be found, display an error 404 image

pull/8/head
sgoudham 4 years ago
parent 0e3bf7e44c
commit 9008d221e9

@ -73,16 +73,20 @@ def store_dict(dict_, key, value):
def search(self, bot): def search(self, bot):
"""Method to generate embed of multiple waifu's""" """Method to generate embed of multiple waifu's"""
not_found = "https://media.discordapp.net/attachments/741072426984538122/748586578074664980/DzEZ4UsXgAAcFjN.png?width=423&height=658"
embeds = [] embeds = []
for key in self._dict.values(): for key in self._dict.values():
# Only setting up description if waifu og_name has a value # Only setting up description if waifu og_name has a value
desc = f"{key['original_name']}" if key["original_name"] else Embed.Empty desc = f"{key['original_name']}" if key["original_name"] else Embed.Empty
# Only using image if it can be displayed, else display 404 image
url = key["display_picture"] if key["display_picture"].endswith((".jpeg", ".png", ".jpg")) else not_found
embed = Embed(title=key["name"], description=desc, embed = Embed(title=key["name"], description=desc,
colour=bot.random_colour(), colour=bot.random_colour(),
url=key["url"]) url=key["url"])
embed.set_image(url=key["display_picture"]) embed.set_image(url=url)
if key["type"] in ["Waifu", "Husbando"]: if key["type"] in ["Waifu", "Husbando"]:
embed.set_author(name=key["type"]) embed.set_author(name=key["type"])
@ -92,7 +96,7 @@ def search(self, bot):
if key['romaji_name']: if key['romaji_name']:
embed.set_footer(text=f"{key['romaji_name']} | Powered by MyWaifuList") embed.set_footer(text=f"{key['romaji_name']} | Powered by MyWaifuList")
else: else:
embed.set_footer(text="- | Powered by MyWaifuList") embed.set_footer(text="Powered by MyWaifuList")
embeds.append(embed) embeds.append(embed)
@ -322,6 +326,7 @@ class Anime(Cog):
Display airing shows and waifu's in those shows Display airing shows and waifu's in those shows
(UNDER CONSTRUCTION) (UNDER CONSTRUCTION)
""" """
error = WaifuCommandNotFound(ctx.command, ctx) error = WaifuCommandNotFound(ctx.command, ctx)
await self.bot.generate_embed(ctx, desc=error.message) await self.bot.generate_embed(ctx, desc=error.message)

Loading…
Cancel
Save