首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >打印discord.Interaction引发错误discord.py

打印discord.Interaction引发错误discord.py
EN

Stack Overflow用户
提问于 2021-08-16 17:05:45
回答 1查看 382关注 0票数 0

不和谐最近添加了按钮来与按钮交互,我用python3 -m pip install -U discord.py-message-components安装了它们,就像discord.py按钮中给出的那样。

现在,当我试图打印Intercation对象并获得此错误时

代码语言:javascript
复制
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__'

这是我的密码

代码语言:javascript
复制
@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)

这些是我进口的东西

代码语言:javascript
复制
import discord
from discord import Button, ButtonStyle, SelectMenu, SelectOption
from discord.ext import commands
from discord.ext.commands import check, Context, MemberConverter

我尝试过的事情:

代码语言:javascript
复制
from discord import Interaction

为什么会发生此错误,以及如何修复此错误?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-08-17 02:13:45

我想这是个虫子。我看到了它的源代码,它没有定义__slots__

这是指向GitHub中的交互类的链接

__init__部分中,它没有定义__slots__

__repr__部分中,它将__slots__插入到return语句中。因此,它提出了一个AttributeError

帮不了你。

您可以打印一些属性,例如作者、按钮标签、消息等…。打印一些信息。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68806682

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档