【发布时间】:2025-11-26 10:45:01
【问题描述】:
这是我的代码。 当我第二次使用该命令时,它会引发以下异常。 discord.ext.commands.errors.CommandInvokeError: Command raise an exception: NotFound: 404 Not Found (error code: 0): 交互未知(你已经响应了交互或者响应时间过长)
例如,首先如果我使用“button hi”命令并单击它返回 hi。第二次,当我使用相同的命令“button hello”并单击按钮时,这一次它会抛出上述异常并返回“hi”而不是“hello”。
@bot.command()
async def button(ctx, *, args):
await ctx.send("hello", components=[
[Button(label="Hi", style="3", custom_id="button1")]
])
while True:
interaction = await bot.wait_for("button_click", check=lambda i: i.custom_id == "button1")
await interaction.send(content=args, ephemeral=True)
我正在使用 discord_components 库。 抱歉解释不好。任何帮助将不胜感激。
【问题讨论】:
-
你必须为此构建一个监听器。如果您执行一次命令,您也可以只单击一次按钮。 (如果我理解正确的话)
-
@Dominik,你能试着用一个例子来解释一下吗?
-
您是使用同一个按钮两次还是执行命令两次然后单击按钮一次?
-
我在帖子中的意思是,第二次使用相同的命令,内容没有得到更新。它只是返回我第一次使用的参数。
-
如果我删除 while 循环,每次我使用该命令时内容都会更新。但是我不能点击按钮两次,因为它显示交互失败。
标签: python-3.x discord.py discord-interactions