From f7f9ddef68de1c06f66efce79d45215482c3fa2d Mon Sep 17 00:00:00 2001 From: phixxy Date: Mon, 22 Jan 2024 15:08:07 -0800 Subject: [PATCH] fixed bug where command would not work in text channels --- extensions/waifu.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/extensions/waifu.py b/extensions/waifu.py index 3aab631..e4c9a09 100644 --- a/extensions/waifu.py +++ b/extensions/waifu.py @@ -18,12 +18,12 @@ class Waifu(commands.Cog): resp_data = await resp.json() try: image = resp_data['images'][0] - return image['url'], image['is_nsfw'] + return image['url'] except: if resp_data['detail'] == "No image found matching the criteria given.": - return "No image found matching the criteria given.", "False" + return "No image found matching the criteria given." else: - return "Something went wrong", "False" + return "Something went wrong" @commands.command() async def waifu(self, ctx, nsfw=""): @@ -31,15 +31,14 @@ class Waifu(commands.Cog): tag = random.choice(["ero", "ass", "hentai", "milf", "oral", "paizuri", "ecchi"]) else: tag = random.choice(["waifu", "maid", "selfies", "uniform"]) - image_url, nsfw = await self.get_waifu(tag) + image_url = await self.get_waifu(tag) if ctx.channel.type == discord.ChannelType["private"]: await ctx.send(image_url) - elif not ctx.channel.is_nsfw() and nsfw == "False": - await ctx.send(image_url) - elif ctx.channel.is_nsfw() and nsfw == "True": - await ctx.send(image_url) - else: + elif not ctx.channel.is_nsfw() and nsfw.lower() == "nsfw": await ctx.send("Cannot post NSFW images in this channel.") + else: + await ctx.send(image_url) + async def setup(bot): try: