Use Discord API to send a private message given a user ID

nolanplatt

I have been attempting to use Discord's API to send a new private message to a user, given their user ID.

I am aware this is possible using libraries such as Discord.JS and Discord.py - please do not recommend me to use those, I am quite aware of what I am wanting to do. I've tried looking at the source for libraries like Discord.js but can't seem to find the endpoint needed to create a new DM with the specific user.

In addition, Discord's documentation are unclear on the topic and research online is broad.

Here is my current code(which obviously won't work as the endpoint isn't correct):

const discordToken = "some-token";
const discordID = "some-user-id";
const userURL = `https://discordapp.com/api/users/${discordID}`;
    fetch(userURL, {
        method: 'POST',
        body: JSON.stringify({
            recipent_id: discordID,
            embed: {
              title: `Testing - Title `,
              description: `Testing - Description`
            }
        }), 
        headers: {
            'Content-Type': 'application/json',
            'Authorization': 'Bot ' + discordToken
          },
    })

If anyone knows the proper endpoint or another way to achieve this(using purely POST requests, no external libraries), please let me know, thanks.

Harry Kruger

Note I have not used discord api directly, but from what I know, I believe this will work.

I think you send a dm like sending a message in a channel.

You first need to create the dm using https://discord.com/developers/docs/resources/user#create-dm

And then send to it like any normal channel https://discord.com/developers/docs/resources/channel#create-message

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Discord.JS Send message to tagged user

From Dev

How to send message with discord.js with ID

From Dev

Discord.py - Send message under different name or user

From Dev

Check if a user can send message in a specific channel discord.js

From Dev

discord py - Send a different message if a user replies to my bot

From Dev

How to programmatically send a text message after the user has given permission?

From Dev

Discord.py Send a DM to a Custom ID User

From Dev

How to send private message to member in on_member_join() discord.py?

From Dev

Given a user id, get all their channels with recipients and last message preview?

From Dev

Send private message with phpbb - Delphi

From Dev

send message from android telegram source to to specific user id

From Dev

How to make my Bot Private Message the user who has been kicked by the bot ? (Discord.js)

From Dev

Send message to a connected user

From Dev

How to use websockets to send message to specific user with Flask?

From Dev

Is it possible to send a message to a user's friend using the Bots for Messenger API?

From Dev

Await reply in private message discord.js

From Dev

jquery chat Trying to get user id from a user that i want to send a message

From Dev

How do I use discord.py to send a greeting message in the System Messages Channel

From Dev

Find out my own user ID for sending a message with Telegram API

From Dev

Why a UIButton could send message to a private method?

From Dev

Why a UIButton could send message to a private method?

From Dev

Send message to specific user in signalr

From Dev

Send broadcast message on user login

From Dev

Send message to multiple tagged user

From Dev

Python, capture OS output and send as a message in discord

From Dev

Send a message if there is a role Discord.js

From Dev

Discord.js -- make presenceUpdate send a message

From Dev

How to send a message to a different server | Discord Bot

From Dev

Private message Slack user via RTM

Related Related

  1. 1

    Discord.JS Send message to tagged user

  2. 2

    How to send message with discord.js with ID

  3. 3

    Discord.py - Send message under different name or user

  4. 4

    Check if a user can send message in a specific channel discord.js

  5. 5

    discord py - Send a different message if a user replies to my bot

  6. 6

    How to programmatically send a text message after the user has given permission?

  7. 7

    Discord.py Send a DM to a Custom ID User

  8. 8

    How to send private message to member in on_member_join() discord.py?

  9. 9

    Given a user id, get all their channels with recipients and last message preview?

  10. 10

    Send private message with phpbb - Delphi

  11. 11

    send message from android telegram source to to specific user id

  12. 12

    How to make my Bot Private Message the user who has been kicked by the bot ? (Discord.js)

  13. 13

    Send message to a connected user

  14. 14

    How to use websockets to send message to specific user with Flask?

  15. 15

    Is it possible to send a message to a user's friend using the Bots for Messenger API?

  16. 16

    Await reply in private message discord.js

  17. 17

    jquery chat Trying to get user id from a user that i want to send a message

  18. 18

    How do I use discord.py to send a greeting message in the System Messages Channel

  19. 19

    Find out my own user ID for sending a message with Telegram API

  20. 20

    Why a UIButton could send message to a private method?

  21. 21

    Why a UIButton could send message to a private method?

  22. 22

    Send message to specific user in signalr

  23. 23

    Send broadcast message on user login

  24. 24

    Send message to multiple tagged user

  25. 25

    Python, capture OS output and send as a message in discord

  26. 26

    Send a message if there is a role Discord.js

  27. 27

    Discord.js -- make presenceUpdate send a message

  28. 28

    How to send a message to a different server | Discord Bot

  29. 29

    Private message Slack user via RTM

HotTag

Archive