-2

I want a Python discord bot to send a message to a discord user like "Sammie#2596" <- My discord id

How do I send a private message to such a user?

NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
  • 1
    Have you searched for that already? What did you find? – NoDataDumpNoContribution Apr 03 '21 at 19:48
  • About a 100 pages, but always sending with the idea of answering. Going slightly mad. – Dion Koens Apr 03 '21 at 19:51
  • 2
    [Python - DM a User Discord Bot](https://stackoverflow.com/a/52345385/15497888) and [How do I get a list of all members in a discord server using the new discord.py version?](https://stackoverflow.com/a/56533566/15497888) – Henry Ecker Apr 03 '21 at 20:50
  • That ain't helping. Can't be to difficult to send a discord user a message. I don't get it. – Dion Koens Apr 03 '21 at 21:36
  • "About a 100 pages.." What was on the 100 pages? Please always include a summary of your search findings in the question. – NoDataDumpNoContribution Apr 04 '21 at 08:29
  • The problem with this question is that it currently asks two questions which should be asked separately. I removed question 1 and voted to reopen because it seems to have been answered already in the linked questions. If not please ask it separately again. – NoDataDumpNoContribution Apr 04 '21 at 08:30
  • As @Trilarion updated your question and voted to reopen this question and If you want my vote to reopen this question then please respond to the answer given by 'Dominik' to let him know if his solution is working or not i.e you are getting your expected result or not – Anurag Dabas Apr 04 '21 at 10:30

1 Answers1

1

A simple command to send a direct message to a member could be:

@client.command() / @bot.command() / @commands.command()
async def dm(ctx, user: discord.Member, *, message):
    await user.send(f"{message}")
  • * is used in order to allow more than one word
  • discord.Member can either be the ID/Tag or you mention the user
  • Make sure to turn Intents on and import them into your code.

To get a list of all users check out other posts on StackOverflow: 1 or 2

Dominik
  • 3,612
  • 2
  • 11
  • 44