|
|
@ -100,17 +100,12 @@ async def post_from_api(self, i, ctx, term, _dict, url):
|
|
|
|
|
|
|
|
|
|
|
|
# As long as data is returned
|
|
|
|
# As long as data is returned
|
|
|
|
# Store all data from the api in dict
|
|
|
|
# Store all data from the api in dict
|
|
|
|
if len(api_data["data"]) > 0:
|
|
|
|
if len(api_data["data"]) > 1:
|
|
|
|
for item in api_data["data"]:
|
|
|
|
for item in api_data["data"]:
|
|
|
|
_dict[item["name"]] = {}
|
|
|
|
_dict[item["name"]] = {}
|
|
|
|
for value in item:
|
|
|
|
for value in item:
|
|
|
|
store_dict(_dict, item, value)
|
|
|
|
store_dict(_dict, item, value)
|
|
|
|
|
|
|
|
|
|
|
|
# When no waifu has been retrieved, send error message to the user
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
await self.bot.generate_embed(ctx, desc="**Waifu/Anime Not Found!**")
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Get the instance of the bot
|
|
|
|
# Get the instance of the bot
|
|
|
|
bot = ctx.guild.get_member(self.bot.user.id)
|
|
|
|
bot = ctx.guild.get_member(self.bot.user.id)
|
|
|
|
# Get the permissions of the channel
|
|
|
|
# Get the permissions of the channel
|
|
|
@ -121,8 +116,25 @@ async def post_from_api(self, i, ctx, term, _dict, url):
|
|
|
|
|
|
|
|
|
|
|
|
return menu
|
|
|
|
return menu
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Don't bother with pagination if only 1 item is returned by the API
|
|
|
|
|
|
|
|
elif len(api_data["data"]) == 1:
|
|
|
|
|
|
|
|
if api_data["data"][0]["type"] in ["Waifu", "Husbando"]:
|
|
|
|
|
|
|
|
await ctx.send(embed=waifu_embed(self, api_data["data"][0], False))
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
await ctx.send(embed=anime_embed(self, api_data["data"][0], False))
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# When no waifu has been retrieved, send error message to the user
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
await self.bot.generate_embed(ctx, desc="**Waifu/Anime Not Found!\n"
|
|
|
|
|
|
|
|
"Tips for a good search:\n"
|
|
|
|
|
|
|
|
"- Use the full name!\n"
|
|
|
|
|
|
|
|
f"- Use `{ctx.prefix}bsearch` to try and get better results!**")
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def anime_embed(self, anime):
|
|
|
|
def anime_embed(self, anime, detailed):
|
|
|
|
"""Generate embed of single anime's"""
|
|
|
|
"""Generate embed of single anime's"""
|
|
|
|
|
|
|
|
|
|
|
|
# Get all the data to be displayed in the embed
|
|
|
|
# Get all the data to be displayed in the embed
|
|
|
@ -131,15 +143,27 @@ def anime_embed(self, anime):
|
|
|
|
og_name = anime["original_name"]
|
|
|
|
og_name = anime["original_name"]
|
|
|
|
picture = anime["display_picture"]
|
|
|
|
picture = anime["display_picture"]
|
|
|
|
url = anime["url"]
|
|
|
|
url = anime["url"]
|
|
|
|
|
|
|
|
_type = anime["type"]
|
|
|
|
romaji_name = anime["romaji_name"]
|
|
|
|
romaji_name = anime["romaji_name"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Only setting the description if original name is returned from the API
|
|
|
|
|
|
|
|
desc = og_name if og_name else Embed.Empty
|
|
|
|
|
|
|
|
embed = Embed(title=name, description=desc,
|
|
|
|
|
|
|
|
url=url,
|
|
|
|
|
|
|
|
colour=self.bot.random_colour())
|
|
|
|
|
|
|
|
embed.set_author(name=f"{_type} | ID: {anime_id}")
|
|
|
|
|
|
|
|
embed.set_image(url=picture)
|
|
|
|
|
|
|
|
if romaji_name:
|
|
|
|
|
|
|
|
embed.set_footer(text=f"{romaji_name} | Powered by MyWaifuList")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
embed.set_footer(text="Powered By MyWaifuList")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if detailed:
|
|
|
|
release_date = anime["release_date"]
|
|
|
|
release_date = anime["release_date"]
|
|
|
|
airing_start = anime["airing_start"]
|
|
|
|
airing_start = anime["airing_start"]
|
|
|
|
airing_end = anime["airing_end"]
|
|
|
|
airing_end = anime["airing_end"]
|
|
|
|
episode_count = anime["episode_count"]
|
|
|
|
episode_count = anime["episode_count"]
|
|
|
|
|
|
|
|
|
|
|
|
# Only setting the description if original name is returned from the API
|
|
|
|
|
|
|
|
desc = og_name if og_name else Embed.Empty
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Only setting the series date information if they exist
|
|
|
|
# Only setting the series date information if they exist
|
|
|
|
rel_date = release_date if release_date else self.bot.cross
|
|
|
|
rel_date = release_date if release_date else self.bot.cross
|
|
|
|
air_start = airing_start if airing_start else self.bot.cross
|
|
|
|
air_start = airing_start if airing_start else self.bot.cross
|
|
|
@ -153,16 +177,6 @@ def anime_embed(self, anime):
|
|
|
|
("Episode Count", ep_count, True),
|
|
|
|
("Episode Count", ep_count, True),
|
|
|
|
("\u200b", "\u200b", True)]
|
|
|
|
("\u200b", "\u200b", True)]
|
|
|
|
|
|
|
|
|
|
|
|
embed = Embed(title=name, description=desc,
|
|
|
|
|
|
|
|
url=url,
|
|
|
|
|
|
|
|
colour=self.bot.random_colour())
|
|
|
|
|
|
|
|
embed.set_author(name=f"ID: {anime_id}")
|
|
|
|
|
|
|
|
embed.set_image(url=picture)
|
|
|
|
|
|
|
|
if romaji_name:
|
|
|
|
|
|
|
|
embed.set_footer(text=f"{romaji_name} | Powered by MyWaifuList")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
embed.set_footer(text="Powered By MyWaifuList")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Add fields to the embed
|
|
|
|
# Add fields to the embed
|
|
|
|
for name, value, inline in fields:
|
|
|
|
for name, value, inline in fields:
|
|
|
|
embed.add_field(name=name, value=value, inline=inline)
|
|
|
|
embed.add_field(name=name, value=value, inline=inline)
|
|
|
@ -185,14 +199,17 @@ def waifu_embed(self, waifu, _type):
|
|
|
|
|
|
|
|
|
|
|
|
# Set different values for description based on the command
|
|
|
|
# Set different values for description based on the command
|
|
|
|
if _type == "random":
|
|
|
|
if _type == "random":
|
|
|
|
desc = f"{og_name} | Random {waifu_type}" if waifu["original_name"] else f"Random {waifu_type}"
|
|
|
|
author = f"Random {waifu_type} | ID: {waifu_id}"
|
|
|
|
elif _type == "daily":
|
|
|
|
elif _type == "daily":
|
|
|
|
desc = f"{og_name} | Daily {waifu_type}" if waifu["original_name"] else f"Daily {waifu_type}"
|
|
|
|
author = f"Daily {waifu_type} | ID: {waifu_id}"
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
author = f"{waifu_type} | ID: {waifu_id}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
desc = og_name if waifu["original_name"] else Embed.Empty
|
|
|
|
embed = Embed(title=name, description=desc,
|
|
|
|
embed = Embed(title=name, description=desc,
|
|
|
|
colour=self.bot.random_colour(),
|
|
|
|
colour=self.bot.random_colour(),
|
|
|
|
url=url)
|
|
|
|
url=url)
|
|
|
|
embed.set_author(name=f"ID: {waifu_id}")
|
|
|
|
embed.set_author(name=author)
|
|
|
|
embed.set_image(url=picture)
|
|
|
|
embed.set_image(url=picture)
|
|
|
|
embed.set_footer(text=f"❤️ {likes} 🗑️ {trash} | Powered by MyWaifuList")
|
|
|
|
embed.set_footer(text=f"❤️ {likes} 🗑️ {trash} | Powered by MyWaifuList")
|
|
|
|
|
|
|
|
|
|
|
@ -470,7 +487,7 @@ class Anime(Cog):
|
|
|
|
"""Returning information about a given series (MWL ID ONLY)"""
|
|
|
|
"""Returning information about a given series (MWL ID ONLY)"""
|
|
|
|
|
|
|
|
|
|
|
|
anime = await get_from_api(self, ctx, f"series/{term}")
|
|
|
|
anime = await get_from_api(self, ctx, f"series/{term}")
|
|
|
|
await ctx.send(embed=anime_embed(self, anime))
|
|
|
|
await ctx.send(embed=anime_embed(self, anime, True))
|
|
|
|
|
|
|
|
|
|
|
|
@anime.command(name="waifu", usage="`<MWLAnimeID>`")
|
|
|
|
@anime.command(name="waifu", usage="`<MWLAnimeID>`")
|
|
|
|
@bot_has_permissions(embed_links=True)
|
|
|
|
@bot_has_permissions(embed_links=True)
|
|
|
@ -481,6 +498,7 @@ class Anime(Cog):
|
|
|
|
anime_waifus = {}
|
|
|
|
anime_waifus = {}
|
|
|
|
waifus = await get_from_api(self, ctx, f"series/{term}/waifus")
|
|
|
|
waifus = await get_from_api(self, ctx, f"series/{term}/waifus")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(waifus) > 0:
|
|
|
|
for item in waifus:
|
|
|
|
for item in waifus:
|
|
|
|
# Don't bother storing Hentai's or Games (Not yet until I figure out what data they send)
|
|
|
|
# Don't bother storing Hentai's or Games (Not yet until I figure out what data they send)
|
|
|
|
if item["type"] in ["Waifu", "Husbando"]:
|
|
|
|
if item["type"] in ["Waifu", "Husbando"]:
|
|
|
@ -497,6 +515,9 @@ class Anime(Cog):
|
|
|
|
menu = MWLMenu(i, perms, anime_waifus, self.bot)
|
|
|
|
menu = MWLMenu(i, perms, anime_waifus, self.bot)
|
|
|
|
await menu.start(ctx)
|
|
|
|
await menu.start(ctx)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
await self.bot.generate_embed(ctx, desc="**No Waifu's/Husbando's To Be Displayed!**")
|
|
|
|
|
|
|
|
|
|
|
|
@command("detailedwaifu", aliases=["dwaifu"], usage="`<MWLWaifuID>`")
|
|
|
|
@command("detailedwaifu", aliases=["dwaifu"], usage="`<MWLWaifuID>`")
|
|
|
|
@bot_has_permissions(embed_links=True)
|
|
|
|
@bot_has_permissions(embed_links=True)
|
|
|
|
async def detailed_waifu(self, ctx, term: int):
|
|
|
|
async def detailed_waifu(self, ctx, term: int):
|
|
|
|