如何多次编辑嵌入的消息?到目前为止,我已经能够编辑一次嵌入的消息,但它不会再次编辑。
代码如下:
# IMPORTING
import discord
from discord import Embed
from discord.ext import commands
TOKEN = ""
BOT_PREFIX = "!"
bot = commands.Bot(command_prefix=BOT_PREFIX)
from discord import Embed
#commands
@bot.command()
async def test(ctx):
first_embed = Embed(title='embed 1')
second_embed = Embed(title='embed 2')
third_embed = Embed(title='embed 3')
msg = await ctx.send(embed=first_embed)
msg = await msg.edit(embed=second_embed)
await msg.edit(embed=third_embed)
#running the bot
bot.run(TOKEN)
结果:(嵌入标题,“嵌入 2”)和错误:discord.ext.commands.errors.CommandInvokeError:命令引发异常:AttributeError:'NoneType'对象没有属性'edit'
如何让它将消息编辑为 embed 3?
答案 0 :(得分:0)
Message.edit
不返回任何内容,您不应再次分配 msg
,
first_embed = Embed(title='embed 1')
second_embed = Embed(title='embed 2')
third_embed = Embed(title='embed 3')
msg = await ctx.send(embed=first_embed)
await msg.edit(embed=second_embed)
await msg.edit(embed=third_embed)