【发布时间】:2021-03-07 10:12:45
【问题描述】:
首先,很抱歉让标题家伙感到困惑,但我不知道如何更准确地称呼它。
所以这是我的问题:我有用于从上一条消息中获取 discord.Embed 对象的代码:
创建嵌入:
channel = bot.get_channel(780735930579288115)
embed = discord.Embed(title="December 2020", color=0x6687ff)
embed.set_author(name="New theme voting")
embed.add_field(name="\u200b", value="Nothing Interesting atm", inline=False)
sent = await channel.send("@.everyone We're starting new voting", embed=embed)
config[str(ctx.message.guild.id)]['quiz'] = str(ctx.sent.id)
with open('config.ini', 'w') as configfile:
config.write(configfile)
获取嵌入对象:
config.read("config.ini")
uzenet = await ctx.fetch_message(int(config[str(ctx.message.guild.id)]['quiz']))
embed = uzenet.embeds[0]
await ctx.send(embed=embed)
错误:
还有一个奇怪的错误说discord.Embed对象不是discord.Embed对象(我猜?)
Traceback (most recent call last):
File "C:\Users\user\PycharmProjects\CoronaBot\venv\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:/Users/user/PycharmProjects/CoronaBot/bot.py", line 476, in newOption
await ctx.send(embed=embed)
AttributeError: type object 'Embed' has no attribute 'from_data'
而且我不知道我还能做些什么来让 python 像对待 discord.Embed 对象一样对待它
【问题讨论】:
标签: python discord discord.py embed