From feae21147d84441e9dab218a290cc5390b7e12cf Mon Sep 17 00:00:00 2001 From: sgoudham Date: Tue, 8 Sep 2020 17:21:56 +0100 Subject: [PATCH] Switching to ID so that the dicts are truly unique --- cogs/anime.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cogs/anime.py b/cogs/anime.py index 0daa4d3b..200668b0 100644 --- a/cogs/anime.py +++ b/cogs/anime.py @@ -49,7 +49,7 @@ def store_in_dict(_dict, api): # Store all the shows with the name as the key for item in api: - _dict[item["name"]] = {} + _dict[item["id"]] = {} for value in item: store_dict(_dict, item, value) @@ -57,7 +57,7 @@ def store_in_dict(_dict, api): def store_dict(dict_, key, value): """Method to store waifu's in the new dict""" - dict_[key["name"]][value] = key[value] + dict_[key["id"]][value] = key[value] async def get_from_api(self, ctx, url): @@ -102,7 +102,7 @@ async def post_from_api(self, i, ctx, term, _dict, url): # Store all data from the api in dict if len(api_data["data"]) > 1: for item in api_data["data"]: - _dict[item["name"]] = {} + _dict[item["id"]] = {} for value in item: store_dict(_dict, item, value) @@ -223,6 +223,7 @@ async def detailed_waifu_embed(self, waifu, author, ctx): # Get all the data to be displayed in the embed name = waifu["name"] + _type = waifu["type"] waifu_id = waifu["id"] url = waifu["url"] picture = waifu["display_picture"] @@ -281,7 +282,7 @@ async def detailed_waifu_embed(self, waifu, author, ctx): # Only using image if it can be displayed, else display 404 image picture_url = picture if picture.endswith((".jpeg", ".png", ".jpg")) else not_found # Different titles depending on if author was given or not - title = f"True Love | {name}" if author else f"Detailed Waifu | {name}" + title = f"True Love | {name}" if author else f"Detailed {_type} | {name}" detailed = Embed(title=title, description=desc, colour=self.bot.random_colour(), @@ -502,7 +503,7 @@ class Anime(Cog): for item in waifus: # Don't bother storing Hentai's or Games (Not yet until I figure out what data they send) if item["type"] in ["Waifu", "Husbando"]: - anime_waifus[item["name"]] = {} + anime_waifus[item["id"]] = {} for value in item: store_dict(anime_waifus, item, value)