How Can I Get My Bot To DM A Specific User ID Without A Command Given?

- 1 answer

When someone DM's my bot, I have it print to the console who messaged, what the message was, and the time the message was sent. I would like the bot to then DM me to either notify me someone messaged it, and/or who and what and when.

I've seen many issues about this with different solutions. A lot of them were outdated therefore do not work with my code. I use Python 3.7 on Spyder.

I can get the bot to DM a user on bot command but cannot get it to DM a specific user ID which would be mine.

Here's the code that prints DM messages received to the console. Again, no issues with this part. Just need this info private messaged to me.

if isinstance(, discord.DMChannel):
        print("DM Recieved by: " +
        print("Time:", str(
        print("Message: " + message.content)

Updated Code:

if client.user.mentioned_in(message) and message.mention_everyone is False:
        await message.delete()
        channel =
        await channel.trigger_typing()
        await channel.send("{0.mention} Please don't tag me.".format(
        print("Mentioned By: " +
        print("Time:", str(
        print("Message: " + message.clean_content)
        print("Channel: " + str(

        #DM me when bot get's mentioned.
        await user.send("Test")


It seems to me that you're using the old async version of - I highly recommend moving to the newer rewrite branch as support for the async version has now ceased.

Migrating to v1.0 (rewrite)

client.get_user(ID) is a rewrite method and doesn't exist in the async version of You can use client.get_user_info(ID) in this case.

Hope this helps - happy coding!

EDIT: Here's the code you need to use:

user = client.get_user(305508822485827584)
await user.send("Test")