【发布时间】:2021-01-13 08:44:53
【问题描述】:
我正在尝试从用户那里获取消息,然后将其发送到特定的文本频道。消息应嵌入。但是我不喜欢当你有一堆字段时它的样子,我希望discord.Embed() 中的描述来保存文本内容。但这给了我一个错误
TypeError: Object of type Message is not JSON serializable
这是我的代码:
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))
【问题讨论】:
-
您确定在显示的代码中出现此错误吗?
标签: discord.py discord.py-rewrite