Search code examples
pythondiscorddiscord.pybotsmessageid

Get the message content into a command [discord.py]


I'm searching to create a bot which create private text channels and then delete them. But with my actual code everyone can delete and rename other peolple's rooms. So, I'd like to create a message that contains the author ID when the bot create the room, and then when someone try to delete or rename the room, the bot goes to search the message and checks if the message author is the same who created the room.

In a few words, I'd like to know what there's in a past message, read and compare it with the message author.

For now I have this:

@client.command()
async def getmsg(ctx):
    guild = ctx.guild
    channel = ctx.channel
    bot = client.user

    msg = get(await channel.history(limit=100).flatten(), author=bot)

This isn't convincing me because I'd like to have directly the message content (if it's possible).

Thanks in advance.


Solution

  • You can get the message content with ctx.message.content. If you got the rest then this would be the solution