How to convert a message id from discord in the actually text that is written?

5.6k views Asked by At

So I'm coding a discord bot in Python and I want to get the message content of the message I defined before... With my code I'm only getting this:

<Message id=1234567890 channel=<TextChannel id=1234567890 name='tests' position=6 nsfw=False news=False category_id=1234567890> type=<MessageType.default: 0> author=<Member id=1234567890 name='example' discriminator='1234' bot=False nick='name' guild=<Guild id=1234567890 name='name2' shard_id=None chunked=True member_count=5>> flags=<MessageFlags value=0>>

This is the code:

       await message.channel.send('Please work:')
    try:
        beschreibung = await client.wait_for('message', check=definitionidefinedbefore, timeout=85.0)
    except asyncio.TimeoutError:
        return await message.channel.send('Too slow.')

And I only want the text that is written in message, not the other stuff.

I can't find anything in the internet and I'm almost despairing Would be very grateful if anyone could help me :)

1

There are 1 answers

0
Rafid Aslam On

The string that's printed looks like the result of printing an object from its __repr__ function.

From discord.py docs, I found Message object there, you can simply access the message content by accessing its content attribute like beschreibung.content.

Docs: https://discordpy.readthedocs.io/en/latest/api.html?highlight=message#discord.Message.content