简体   繁体   中英

How to convert a discord message object into a string?

I'm using the method kernel.respond(message) from the module aiml .

the message variable here is of type discord.message.Message but the method kernel.respond(message) can only have a string argument.

How can I convert the discord.message.Message object into string?

You most likely want to get the actual message string rather than convert the Message object into a string representation. You should look at the documentation to find how to do it. Specifically, the documentation of the Message class has some good information.

If you have a discord.Message instance, then you can use content to get the string representation of the message body

content = message.content

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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