如何将不和谐消息对象转换为字符串?

时间:2020-08-17 19:56:41

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

我正在使用模块 aiml 中的方法 kernel.respond(message)

此处的message变量的类型为 discord.message.Message 但是方法 kernel.respond(message)只能有一个字符串参数。

如何将 discord.message.Message 对象转换为字符串?

2 个答案:

答案 0 :(得分:1)

您很可能希望获取实际的消息字符串,而不是将Message对象转换为字符串表示形式。您应该查看the documentation来找到方法。具体来说,Message class的文档提供了一些很好的信息。

答案 1 :(得分:1)

如果您有discord.Message实例,则可以使用content获取消息正文的字符串表示形式

content = message.content