Reed Heit
Reed Heit

Reputation: 1

Send a dm in discord.py

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.

Upvotes: -1

Views: 160

Answers (1)

charlie scott
charlie scott

Reputation: 146

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)

Upvotes: 1

Related Questions