【问题标题】:How can I edit an embed message multiple times?如何多次编辑嵌入消息?
【发布时间】:2021-05-14 09:26:05
【问题描述】:

如何多次编辑嵌入消息?到目前为止,我已经能够编辑一次嵌入消息,但它不会再这样做了。

代码如下:


# 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'

如何让它将消息编辑为嵌入 3?

【问题讨论】:

    标签: python python-3.x discord discord.py


    【解决方案1】:

    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)
    

    【讨论】:

      猜你喜欢
      • 2020-03-17
      • 2019-10-15
      • 2021-07-06
      • 2020-09-08
      • 2021-11-01
      • 2021-08-31
      • 2021-05-09
      • 2021-10-30
      • 1970-01-01
      相关资源
      最近更新 更多