Skip to content
This repository has been archived by the owner on Dec 26, 2021. It is now read-only.

TypeError: emoji() takes 1 positional argument but 2 were given #64

Closed
eltaylor1104 opened this issue Sep 10, 2021 · 2 comments
Closed

Comments

@eltaylor1104
Copy link

eltaylor1104 commented Sep 10, 2021

    @inter_client.slash_command(guild_ids=bonbot_support)
    async def emoji(ctx):
        pass
    @emoji.sub_command(description="steal an emoji with an option to lock it to a role", options=[Option("emoji", "an emoji to steal", OptionType.STRING, required=True),
    Option("role", "A role to lock this emoji to. (User must have this role to use emoji)", OptionType.ROLE)], guild_ids=bonbot_support)
    @slash_commands.guild_only()
    @slash_commands.has_permissions(manage_emojis=True)
    async def steal(self, ctx, emoji, role):
        c = commands.EmojiConverter() # create instance
        emoji_final = await c.convert(emoji) 
        # fetch the emoji asset and read it as bytes.
        emoji_bytes = await emoji_final.read()

        emoji_roles = [role]
        await ctx.guild.create_custom_emoji(name=emoji_final.name, image=emoji_bytes, roles=emoji_roles)
        await ctx.send("Created emoji!", ephemeral=True)

I get this error when I run this code, I even added print("number") after every step and it doesn't print anything. Not sure what is happening, I have asked for help in several servers and nobody can figure it out. When I run the same code as a regular command, (removing the components parts) it works flawlessly. Full error: https://mystb.in/UrwPutsGarlic.apache

@EQUENOS
Copy link
Owner

EQUENOS commented Sep 10, 2021

You forgot self in async def emoji
Also, I suspect that you forgot to pass ctx to c.convert
Let me know if it works

@eltaylor1104
Copy link
Author

thanks so much, that worked. I can't believe I missed something so simple, here I was thinking it was something super big.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants