I am attempting to make a menu in a Discord.py bot using buttons in a slash command.
My code:
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
The problem It returns the following error:
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
My question: I checked the error code meaning, why does it return a webhook error? How can I get the original embed I sent in the command output to be edited with another embed when a button is pressed?
I'm quite unfamiliar with the discord wrapper you are using, as it has a rather odd order of callback parameter. I usually see button come before the interaction parameter but anyway try deferring the interaction before doing edit_original_message
in each callback.