Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

bot sending message information instead of message

So i am currently making a chat channel, where you can chat in the channel and the bot sends into an another server that has the channel named chat-chan,

here is my code:

async def on_message(message):
    if message.channel.name == 'chat-chan' and message.author.bot == False:
        await message.channel.send(f"{message.author.name}:  {message}")

instead it sends the information of the message instead of the message itself

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Mini: <Message id=12345678910 channel= type=<MessageType.default: 0> author=<Member id=12345678910 name=’Mini’ discriminator=’4140′ bot=False nick=None guild=> flags=>

>Solution :

You are sending the object of the message. To access message itself you need to replace it with message.content

async def on_message(message):
    if message.channel.name == 'chat-chan' and message.author.bot == False:
        await message.channel.send(f"{message.author.name}:  {message.content}")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading