#error, expected 2 arguments, got 4. while trying to seperate my commands

1 messages · Page 1 of 1 (latest)

stark harness
#
    async def filter(self, ctx, img, usr, op):
        msg = (op == "bw" and 'turn black and white') or (op == "invert" and "invert the colors of")
        if img is None and usr is None:
            embed = discord.Embed(title=f"No Image!!",
                                  description=f"I need something to {msg}... like an image... or a user...",
                                  color=0xff5733)
            embed.set_footer(text=randomMsg())
            await ctx.respond(embed=embed)
        else:
            with open('input.png', 'wb') as f:
                if usr is not None:
                    f.write(await usr.display_avatar.with_size(512).with_static_format("png").read())

                else:
                    f.write(await img.read())
                image = Image.open('input.png')
                return image
#

and I'm using it like:

@discord.slash_command(guild_ids=config['main_guilds'],description="turns an image to black & white.")
    async def bw(self, ctx, image: discord.message.Attachment = None, user: discord.Member = None):
        image = await filter(ctx, image, user, "bw")
        output = image.convert("L")
        output.save("output.png")
        file = discord.File("output.png")
        embed = discord.Embed(title="I turned your image BW", color=color)
        embed.set_image(url="attachment://output.png")
        embed.set_footer(text=randomMsg())

        await ctx.respond(embed=embed, file=file)
#

In my head this works but I get this error, which if I expected any, wouldn't be this:

discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: filter expected 2 arguments, got 4
iron ledge
#

.tag solved

astral haloBOT
#

Done with your help thread?

Please close your own help thread by using </close:1009144375709814897> with @cyan osprey.