Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can edit followUp message (discord.py)?

I have this code, however I don't understand how it is possible to edit the followup message. Thanks!

@bot.command()
async def button(ctx):
    view=View()
    button_create = Button(label="CREATE", style=discord.ButtonStyle.green)
    view.add_item(button_create)
    await ctx.send(view=view)
    async def button_callback(interaction):
        await interaction.response.defer()
        await asyncio.sleep(delay=1)
        await interaction.followup.send("Hi", ephemeral=True) # How can i edit this message? -_-

    button_create.callback = button_callback

I tried to use "interaction.followup.edit_message("Something")", but i got error:

discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body In message_id: Value "Something" is not snowflake.

like image 297
ArtyoM Avatar asked Nov 01 '25 09:11

ArtyoM


1 Answers

You can use the built in functions for it:

asd:discord.Message = await interaction.followup.send("Hi!")
await interaction.followup.edit_message(message_id=asd.id,content="Not Hello!")

This is just a basic edit. It requires a message id and a content.

like image 131
Rexy Avatar answered Nov 04 '25 11:11

Rexy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!