我试图在www.example.com机器人中使用斜线命令中的按钮来创建菜单。Discord.py bot using buttons in a slash command.
- 我的密码:**
class helpbclass(discord.ui.View):
def __init__(self):
super().__init__()
self.value = None
@discord.ui.button(label="General",
style=discord.ButtonStyle.blurple,
emoji="📜")
async def general(self, interaction: discord.Interaction,
button: discord.ui.Button):
await interaction.response.edit_original_response('general')
@discord.ui.button(label="Moderation",
style=discord.ButtonStyle.blurple,
emoji="📜")
async def moderation(self, interaction: discord.Interaction,
button: discord.ui.Button):
await interaction.edit_original_response(content='moderation')
@discord.ui.button(label="QUIT", style=discord.ButtonStyle.red, emoji="📜")
async def quit(self, interaction: discord.Interaction,
button: discord.ui.Button):
await interaction.edit_original_response(content='quit')
self.value = False
self.stop()
@client.tree.command(name="test",
description="Menu testing",
guild=discord.Object(id=123456789))
async def test(interaction: discord.Interaction):
await interaction.response.defer()
#code for embed
view = helpbclass()
await interaction.followup.send(embed=embed, view=view)
# i also tried interaction.response.send_message, without the response.defer() at top
- 问题**返回以下错误:
Traceback (most recent call last):
File "/home/runner/AtlaReboot/venv/lib/python3.10/site-packages/discord/ui/view.py", line 425, in _scheduled_task
await item.callback(interaction)
File "main.py", line 61, in moderation
await interaction.edit_original_response(content='moderation')
File "/home/runner/AtlaReboot/venv/lib/python3.10/site-packages/discord/interactions.py", line 462, in edit_original_response
data = await adapter.edit_original_interaction_response(
File "/home/runner/AtlaReboot/venv/lib/python3.10/site-packages/discord/webhook/async_.py", line 218, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook
- 我的问题:**我检查了错误代码的含义,为什么它会返回一个webhook错误?当按下一个按钮时,我如何让我在命令输出中发送的原始嵌入内容被另一个嵌入内容编辑?
1条答案
按热度按时间iezvtpos1#
我对你使用的discord Package 器很不熟悉,因为它的回调参数的顺序很奇怪,我通常看到button在interaction参数之前,但是无论如何,在每次回调中执行
edit_original_message
之前,尝试推迟交互。