How to make a dm user command (discord.py)

I’m new to discord.py (and general programming) I want to make a command which dms mentioned user with specified text. Can you please explain how to make it?

1 Like

Hi @Lemon553311-dev , can you tell me what version of python and discord.py are you using?
sorry for my bad english, i’m spanish xD

1 Like

I would help, but it was around 2 years ago I tried python bots. They are harder than JavaScript in my opinion.

1 Like

xD maybe. I program bots in python since 2 months and i have a masterpiece.

1 Like


This may help a bit.

2 Likes

unactualized version of discord. The version of discord used in that link is old and for example bot.get_userinfo doesn’t exist
@RiversideRocks

1 Like

That sucks. Sorry, I’m not very familiar with python! :grin:

2 Likes

no problem, we are for help.
sorry for my bad english, i’m spanish xD

2 Likes

im using python 3.7.7
discord.py = 1.2.3

1 Like

i have found a way to make bot say provided message but now i need to figure out how to make bot DM a specified user.

1 Like

creating a dm channel in discord.py is explained here: https://discordpy.readthedocs.io/en/latest/api.html#discord.User.dm_channel

so you can simply get a message object, then use await message.author.dm_channel.send("message") to send a message to a user via dms.

2 Likes

@Lemon553311-dev you can?

1 Like

Instead of ctx.send("message") its ctx.author.send("message") (basically user.send("message"))

2 Likes

this helped me out so much. hours of looking for a simple way without having to retrieve a discord.Member object to send a message. Thank you so much for your help

4 Likes