Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in printing discord.Interaction #12

Open
Ibrahim2750mi opened this issue Aug 17, 2021 · 1 comment
Open

Bug in printing discord.Interaction #12

Ibrahim2750mi opened this issue Aug 17, 2021 · 1 comment
Labels
bug Something isn't working fixed in developer-branch This Issue is fixed in the developer branch

Comments

@Ibrahim2750mi
Copy link

When I am trying to print discord.Interaction object it throws this error

Ignoring exception in command test_command:
Traceback (most recent call last):
  File "/home/ibrahim/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 245, in test_command
    print(interaction, button)
  File "/home/ibrahim/.local/lib/python3.8/site-packages/discord/interactions.py", line 96, in __repr__
    return f'<Interaction {", ".join(["%s=%s" % (a, getattr(self, a)) for a in self.__slots__ if a[0] != "_"])}>'
AttributeError: 'Interaction' object has no attribute '__slots__'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ibrahim/.local/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 1062, in invoke
    await ctx.command.invoke(ctx)
  File "/home/ibrahim/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/ibrahim/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Interaction' object has no attribute '__slots__'

I think its caused because in the __init__ it doesn't defines __slots__ and in the __repr__ part, it inserted __slots__ in the return statement. So, it raised an AttributeError

This is the code that I ran to get the error

@commands.command(ignore_extra=True)
async def test_command(self, ctx, count:int):
    new_button = Button(label="test_button", custom_id = "009")
    message = await ctx.send("test", components = [[new_button]])

    def check_button(i: discord.Interaction, button):
        return i.author == ctx.author and i.message == message

    interaction, button = await bot.wait_for('button_click', check=check_button)

    print(interaction, button)

    await interaction.edit(content=count)
@mccoderpy
Copy link
Owner

mccoderpy commented Aug 17, 2021

Oh yea another peace of Code i forgot to change after removing the __slots__, will bee fixed with the next update (im working on Implementation for Slash-commands and context-menus.)

@mccoderpy mccoderpy added the bug Something isn't working label Aug 17, 2021
@mccoderpy mccoderpy added the fixed in developer-branch This Issue is fixed in the developer branch label May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in developer-branch This Issue is fixed in the developer branch
Projects
None yet
Development

No branches or pull requests

2 participants