Reputation:
Is there a way to have a bot edit its own message? I've tried to look for an answer but couldn't find one.
Upvotes: 4
Views: 25884
Reputation: 1
I tried it with another method and it works. I am using nextcord.py library.
You can do something like this:
@bot.event:
async def on_message(message):
if message.content == "Test!":
ctx = await message.reply("Processing!")
await ctx.edit("Test Successful!")
Upvotes: 0
Reputation: 111
This will be done through code. You need to just somehow execute it in your bot program. For example, make a command for it that executes it and later you can delete that.
channel = bot.get_channel(id_of_the_channel)
message = await channel.fetch_message(id_of_the_message)
# make sure that you change "id_of_the_channel" for the id of the channel (as an integer)
# and make sure to change "id_of_the_message" for the id of the message (as an integer)
# you can get those by enabling Developer Mode in the Appearance settings in discord
# and right-clicking on the channel to get its id, and right-clicking on the message to get
# its id as well.
await message.edit(content="the new content of the message")
And that's basically it. Execute those three lines of code through your bot, and it will edit the message.
Upvotes: 7