discord rest api how to send dm ?

Hello, I am using discord-api-types and discordjs/rest for my worker based discord bot. According to docs,
rest.post(Routes.channelMessages(env.LOGS_CHANNEL_ID), ...));
rest.post(Routes.channelMessages(env.LOGS_CHANNEL_ID), ...));
is for sending messages to any discord server's channel. But I want to send message to a user's DM, how do I do that?
9 Replies
d.js toolkit
d.js toolkit3mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Octoboomer
Octoboomer3mo ago
Use the dm channel id There is an endpoint for opening user dms
Ren Hiyama
Ren HiyamaOP3mo ago
No description
Ren Hiyama
Ren HiyamaOP3mo ago
Routes.<what??>
d.js docs
d.js docs3mo ago
:discord: Users Resource - Create DM POST /users/@me/channels Create a new DM channel with a user. Returns a DM channel object (if one already exists, it will be returned instead). read more
Octoboomer
Octoboomer3mo ago
Idk what it’s called in the dapi-types package
Ren Hiyama
Ren HiyamaOP3mo ago
I found this
No description
Octoboomer
Octoboomer3mo ago
Yea Use that with the proper body to get a dm channel
Ren Hiyama
Ren HiyamaOP3mo ago
ah ok, thanks.

Did you find this page helpful?