Discord.py在不使用添加字段的情况下发送嵌入
我试图从用户那里获取消息,然后将其发送到特定的文本频道。该信息应嵌入到嵌入式系统中。但是我不喜欢有一堆字段时的外观,我希望Discord.py在不使用添加字段的情况下发送嵌入,discord.py,discord.py-rewrite,Discord.py,Discord.py Rewrite,我试图从用户那里获取消息,然后将其发送到特定的文本频道。该信息应嵌入到嵌入式系统中。但是我不喜欢有一堆字段时的外观,我希望discord.Embed()中的描述保存文本内容。但这给了我一个错误 TypeError:Message类型的对象不可JSON序列化 这是我的代码: class Changelog(commands.Cog): def __init__(self, client): self.client = client @commands.Cog.l
discord.Embed()
中的描述保存文本内容。但这给了我一个错误
TypeError:Message类型的对象不可JSON序列化
这是我的代码:
class Changelog(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print('Changelog is loaded')
@commands.command()
async def changelog(self, ctx):
changelog_channel = self.client.get_channel(759547196433104956)
await ctx.send("`Message: `")
message = await self.client.wait_for('message', check=lambda message: message.author == ctx.author, timeout=300)
embed = discord.Embed(title="Changelog", description=message, color=0)
await changelog_channel.send(embed=embed)
def setup(client):
client.add_cog(Changelog(client))
您没有收到此错误,因为您没有添加字段,而是因为您试图在描述中放置一个
消息
实例,而您应该将该消息的内容
放在那里。描述只能将字符串作为其值
embed = discord.Embed(title="Changelog", description=message.content, color=0)
wait_for(“message”)
返回一个discord.message
实例。消息
包含该消息的内容、id、作者、频道和更多内容。如果只想获取用户发送的文本,则需要content
属性
有关消息
可以做什么的更多信息,请参见。您没有收到此错误,因为您没有添加字段,而是因为您试图在描述中放置消息
实例,而您应该将该消息的内容
放在其中。描述只能将字符串作为其值
embed = discord.Embed(title="Changelog", description=message.content, color=0)
wait_for(“message”)
返回一个discord.message
实例。消息
包含该消息的内容、id、作者、频道和更多内容。如果只想获取用户发送的文本,则需要content
属性
有关消息
可以做什么的更多信息,请参见。您确定在显示的代码中出现此错误吗?您确定在显示的代码中出现此错误吗?