[英]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.我正在使用 discord.py 制作 discord 机器人,并想编辑我的机器人发送的消息,它是文本,并用图像替换文本。 Most of the thing I have tried give me an error and I couldn't find this anywhere else.
我尝试过的大部分事情都给了我一个错误,我在其他任何地方都找不到。
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.查看下面的代码,执行命令它是
?test
并将编辑该消息。
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.