AniketW
AniketW

Reputation: 11

How do I edit a message using an image in discord.py?

I am making a discord bot using discord.py and want to edit a message that my bot sent and is text and replace the text with an image. Most of the thing I have tried give me an error and I couldn't find this anywhere else.

Upvotes: 0

Views: 553

Answers (1)

Axisnix
Axisnix

Reputation: 2907

This is an example of what you would use to edit a message. You must save the message to a variable then you may edit it later. Look at the code below, to execute the command it's ?test and will edit that message.

import asyncio
from discord.ext import commands

bot = commands.Bot(command_prefix="?", case_insensitive=True)

@bot.command()
async def test(ctx):
    message = await ctx.send("I'm message 1")
    await asyncio.sleep(5)
    await message.edit(content="I'm message 2")


bot.run(token)

Upvotes: 0

Related Questions