pythondiscorddiscord.pydmsdm

How to get dm in discord.py


I want to know that to get the user who send dm, the idea is to stop people using the bot in dm and then ping them in #bot-lab so that they can use it there

i havn't tried anything yet, but would begreat if anyone tell me how to do

thank you


Solution

  • In discord.py you can use the isinstance(ctx.channel, discord.channel.DMChannel) to check if a message is a DM or not.

    @client.command()
    async def check(ctx, arg):
        if isinstance(ctx.channel, discord.channel.DMChannel):
            await ctx.send(arg)