要编辑已发送的嵌入式机器人消息,您可以使用discord.Message.edit()
方法。以下是一个使用discord.py的代码示例:
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.typing = False
intents.presences = False
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.event
async def on_ready():
print('Bot is ready.')
@bot.command()
async def send_embed(ctx):
embed = discord.Embed(title="Test Embed", description="This is a test embed message.")
message = await ctx.send(embed=embed)
# Edit the embed message
new_embed = discord.Embed(title="Edited Embed", description="This is an edited embed message.")
await message.edit(embed=new_embed)
bot.run('YOUR_BOT_TOKEN')
在上面的示例中,我们定义了一个名为send_embed
的命令,该命令会发送一个带有嵌入式消息的文本消息。然后,我们使用discord.Message.edit()
方法编辑发送的消息,将其替换为一个新的嵌入式消息。
请确保替换为您自己的bot令牌,然后运行代码。当您在Discord服务器上使用!send_embed
命令时,您的机器人将发送一个带有嵌入式消息的文本消息,然后编辑该消息以显示新的嵌入式消息。
下一篇:编辑一个 .gz 文件的第一行