Skip to content Skip to sidebar Skip to footer

Discord.py | How Do I Check If The Message Being Sent Is Being Sent Directly To The Bot (dm) Or In A Chat?

I want to check to see if the message being sent (on_message()) is in a DM sent to the bot or just sent in any other place like a chat in a guild. Any help would be greatly appreci

Solution 1:

You can check message.guild.

@client.event
async def on_message(message):
    if message.guild: # message is not DM
        # do stuff
    else: # message is DM
        # do something else```

Post a Comment for "Discord.py | How Do I Check If The Message Being Sent Is Being Sent Directly To The Bot (dm) Or In A Chat?"