Send a dm in discord.py

157 Views Asked by At

I am trying to have it send a dm to a specified user using the on_message event. So far I've gotten it to get the snowflake id from the mentioned user but can't find a way to send a dm to that user. I've been looking for hours and haven't found an anwser please help.

1

There are 1 best solutions below

0
On

It depends on which version of discord.py you are using but assuming you are using a version newer than 1.0:

Use user.send(message).

To be more specific than that I'd need a code snippet or more in depth description of exactly what you are trying to do

To get a user id from a mention:

Use a converter to get the User object:

@bot.command(name="id")
async def id_(ctx, user: discord.User):
    await ctx.send(user.id)

from this post: How to get ID of a mentioned user (Discord.py)