How i can edit message with button?
Question:
I am trying to do button, that editing message, but this button doesn’t work.
class Buttons(discord.ui.View):
def __init__(self, *, timeout=180):
super().__init__(timeout=timeout)
@discord.ui.button(label="Button",style=discord.ButtonStyle.gray)
async def blurple_button(self,button:discord.ui.Button,interaction:discord.Interaction):
button.style=discord.ButtonStyle.green
await interaction.response.edit_message(content="This is an edited button response!")
class test(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def test(self, ctx):
await ctx.send("This message has buttons!",view=Buttons())
Answers:
Your callback’s arguments are the wrong way around. The first one is supposed to be the Interaction
, and the second the Button
.
Your error message should also tell you this, though. You may not have configured logging properly.
I am trying to do button, that editing message, but this button doesn’t work.
class Buttons(discord.ui.View):
def __init__(self, *, timeout=180):
super().__init__(timeout=timeout)
@discord.ui.button(label="Button",style=discord.ButtonStyle.gray)
async def blurple_button(self,button:discord.ui.Button,interaction:discord.Interaction):
button.style=discord.ButtonStyle.green
await interaction.response.edit_message(content="This is an edited button response!")
class test(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def test(self, ctx):
await ctx.send("This message has buttons!",view=Buttons())
Your callback’s arguments are the wrong way around. The first one is supposed to be the Interaction
, and the second the Button
.
Your error message should also tell you this, though. You may not have configured logging properly.