好的,问题来了。我想创建一个命令,它通常只循环浏览一些数据和图像。所以我做了,但我遇到的一个问题是,当我尝试在嵌入中编辑图像时,它会抛出错误。 discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Object of type File is not JSON serializable
这是有道理的,但我找不到解决这个问题的方法。有没有办法让这个 JSON 可序列化?
@client.command()
async def test(ctx):
file = discord.File('image1.png', filename="card.png")
embed = discord.Embed(title='Random Embed')
embed.set_image(url="attachment://card.png")
msg = await ctx.send(file=file, embed=embed)
await asyncio.sleep(1)
file = discord.File('image2.png', filename="card.png")
embed = discord.Embed(title='Title goes here', description='Description goes here', color=0x35363B)
embed.set_image(url="attachment://card.png")
embed.add_field(name='Stats:', value='Stats go here')
await msg.edit(file=file, embed=embed)
答案 0 :(得分:0)
据我所知,文件一旦发送就无法编辑
您可以从 image_url
或 set_thumbail
的嵌入中编辑 set_image