Waifu search is it's own command

pull/8/head
sgoudham 4 years ago
parent 76956f3e3f
commit ed031d689c

@ -14,8 +14,6 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
from typing import Optional
import aiohttp import aiohttp
from decouple import config from decouple import config
from discord import Embed from discord import Embed
@ -166,7 +164,7 @@ class Anime(Cog):
@group(name="waifu", invoke_without_command=True, case_insensitive=True) @group(name="waifu", invoke_without_command=True, case_insensitive=True)
@bot_has_permissions(embed_links=True, add_reactions=True) @bot_has_permissions(embed_links=True, add_reactions=True)
async def waifu(self, ctx, *, waifu2: Optional[str] = None): async def waifu(self, ctx, *, name: str):
""" """
Shows a Waifu (UNDER CONSTRUCTION) Shows a Waifu (UNDER CONSTRUCTION)
Waifu's are grabbed from mywaifulist.com Waifu's are grabbed from mywaifulist.com
@ -175,12 +173,9 @@ class Anime(Cog):
# Local Variable i to allow the index of the pages[] to be modified # Local Variable i to allow the index of the pages[] to be modified
i = 0 i = 0
# When a waifu has been specified, retrieve waifu(s) matching the user input
if waifu2:
waifus_dict = {} waifus_dict = {}
url = "https://mywaifulist.moe/api/v1/search/" url = "https://mywaifulist.moe/api/v1/search/"
data = {"term": waifu2, data = {"term": name,
'content-type': "application/json"} 'content-type': "application/json"}
# Searching API for waifu(s) # Searching API for waifu(s)
@ -204,11 +199,13 @@ class Anime(Cog):
waifus_dict[waifu["name"]] = {} waifus_dict[waifu["name"]] = {}
for value in waifu: for value in waifu:
store_waifus(waifus_dict, waifu, value) store_waifus(waifus_dict, waifu, value)
else: else:
break break
# When no waifu has been retrieved, send error message to the user # When no waifu has been retrieved, send error message to the user
else: else:
await self.bot.generate_embed(ctx, desc="**Waifu Not Found!**") await self.bot.generate_embed(ctx, desc="**Waifu Not Found!**")
# Get the instance of the bot # Get the instance of the bot

Loading…
Cancel
Save