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())
Asked By: FlamyIce

||

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.

Answered By: stijndcl
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.