App Logo
discord.com

send_dm

Send a direct message to a Discord user, addressed by their username. Opens (or reuses) the one-to-one DM conversation and posts the message there. Returns sent, the created message's messageId, the DM channelId, timestamp, and the content as Discord stored it, plus the recipient's resolved handle so the message is provably not sent to a near-name match. This is a write and the recipient is notified: confirm the exact recipient and text with the user before running, and note that approval for one message does not carry over to another.

Input

userId required

The recipient's Discord user id, e.g. from discord.com/find_member_id or the author.id of discord.com/search_messages.

message required

The message text. Discord's own limit is 2000 characters.

expectedUsername required

The recipient's username, asserted against the handle on their profile before the message is typed. A mismatch aborts without sending, so a stale or wrong id cannot message the wrong person.

Output

sent required
channelId required

The one-to-one DM channel the message went to.

recipient required

The handle read from the recipient's own profile, not echoed from the input.

content optional

The content as Discord stored it.

messageId optional
timestamp optional

Start building not clicking