简体   繁体   English

如何将 discord 消息 object 转换为字符串?

[英]How to convert a discord message object into a string?

I'm using the method kernel.respond(message) from the module aiml .我正在使用模块aiml中的方法kernel.respond(message)

the message variable here is of type discord.message.Message but the method kernel.respond(message) can only have a string argument.这里的消息变量是discord.message.Message类型,但方法kernel.respond(message)只能有一个字符串参数。

How can I convert the discord.message.Message object into string?如何将discord.message.Message object 转换为字符串?

You most likely want to get the actual message string rather than convert the Message object into a string representation.您很可能想要获取实际的消息字符串,而不是将消息 object 转换为字符串表示形式。 You should look at the documentation to find how to do it.您应该查看文档以了解如何操作。 Specifically, the documentation of the Message class has some good information.具体来说,消息 class的文档有一些很好的信息。

If you have a discord.Message instance, then you can use content to get the string representation of the message body如果你有一个discord.Message实例,那么你可以使用content来获取消息体的字符串表示

content = message.content

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM