1

I would like to know how do I send private messages to someone with they'r ID

Help

Alexandre Maia
  • 29
  • 1
  • 1
  • 2
  • 4
    You have not mentioned anything about where you are stuck at and your work. – Huzo Jan 29 '19 at 10:07
  • 1
    Is the id in your code, or supplied by a user when the bot is running? For the former, use [`Client.get_user_info`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.get_user_info) and for the later use a converter [as shown here](https://stackoverflow.com/questions/52343245/python-dm-a-user-discord-bot) – Patrick Haugh Jan 29 '19 at 14:45

2 Answers2

8
@client.command(pass_context=True)
async def dm(ctx):
    user=await client.get_user_info("User's ID here")
    await client.send_message(user, "Your message goes here")
    # This works ^
  • 3
    Although I answered the question, this is s duplicate to [Python - DM a User Discord Bot](https://stackoverflow.com/questions/52343245/python-dm-a-user-discord-bot?). It's better to research first next time –  Jan 31 '19 at 16:42
1
async def msg(ctx,userid:str,*,msg):
       user = ctx.message.server.get_member(userid) or user = client.get_member(userid)
       await client.send_message(user,msg)

Hope this will helps you!.

Mahesh Mahi
  • 41
  • 1
  • 5