Message
List Messages
GetAPIChannelMessages
Retrieves the messages in a channel.
import { listMessages } from "dressed";
const messages = await listMessages(channelId, params?);- If operating on a guild channel, this endpoint requires the current user to have the
VIEW_CHANNELpermission. If the channel is a voice channel, they must also have theCONNECTpermission. - If the current user is missing the
READ_MESSAGE_HISTORYpermission in the channel, then no messages will be returned. - The
before,after, andaroundparameters are mutually exclusive, only one may be passed at a time.
Get Message
GetAPIChannelMessage
Retrieves a specific message in the channel.
import { getMessage } from "dressed";
const message = await getMessage(channelId, messageId);If operating on a guild channel, this endpoint requires the current user to have the VIEW_CHANNEL and READ_MESSAGE_HISTORY permissions. If the channel is a voice channel, they must also have the CONNECT permission.
Create Message
PostAPIChannelMessage
Post a message to a guild text or DM channel.
import { createMessage } from "dressed";
await createMessage(channelId, data);To create a message as a reply or forward of another message, apps can include a message_reference.
Discord may strip certain characters from message content, like invalid unicode characters or characters which cause unexpected message formatting. If you are passing user-generated strings into message content, consider sanitizing the data to prevent unexpected behavior and using allowed_mentions to prevent unexpected mentions.
Crosspost Message
PostAPIChannelMessageCrosspost
Crosspost a message in an Announcement Channel to following channels.
import { crosspostMessage } from "dressed";
await crosspostMessage(channelId, messageId);This endpoint requires the SEND_MESSAGES permission, if the current user sent the message, or additionally the MANAGE_MESSAGES permission, for all other messages, to be present for the current user.
Create Reaction
PutAPIChannelMessageOwnReaction
Create a reaction for the message.
import { createReaction } from "dressed";
await createReaction(channelId, messageId, emoji);This endpoint requires the READ_MESSAGE_HISTORY permission to be present on the current user. Additionally, if nobody else has reacted to the message using this emoji, this endpoint requires the ADD_REACTIONS permission to be present on the current user.
Delete Reaction
DeleteAPIChannelMessageUserReaction
Delete a user's reaction, defaults to removing the current user's reaction for a message.
import { deleteReaction } from "dressed";
await deleteReaction(channelId, messageId, emoji, userId?);List Reactions
GetAPIChannelMessageReactionUsers
Get a list of users that reacted with this emoji.
import { listReactions } from "dressed";
const reactions = await listReactions(channelId, messageId, emoji, params?);Delete All Reactions
DeleteAPIChannelAllMessageReactions
Deletes all reactions on a message.
import { deleteAllReactions } from "dressed";
await deleteAllReactions(channelId, messageId);This endpoint requires the MANAGE_MESSAGES permission to be present on the current user.
Delete All Emoji Reactions
DeleteAPIChannelMessageReactionUsers
Deletes all the reactions for a given emoji on a message.
import { deleteAllEmojiReactions } from "dressed";
await deleteAllEmojiReactions(channelId, messageId, emoji);This endpoint requires the MANAGE_MESSAGES permission to be present on the current user.
Edit Message
PatchAPIChannelMessage
Edit a previously sent message.
import { editMessage } from "dressed";
await editMessage(channelId, messageId, data);- The fields
content,embeds,flagsandcomponentscan be edited by the original message author. Other users can only editflagsand only if they have theMANAGE_MESSAGESpermission in the corresponding channel. - When specifying flags, ensure to include all previously set flags/bits in addition to ones that you are modifying.
- When the
contentfield is edited, the arraysmentionsandmention_rolesand the booleanmention_everyonein the message object will be reconstructed from scratch based on the new content. - When the message flag
IS_COMPONENTS_V2is set, the reconstructed arrays and boolean are based on the edited content in thecomponentsarray. Theallowed_mentionsfield of the edit request controls how this happens. If there is no explicitallowed_mentionsin the edit request, the content will be parsed with default allowances, that is, without regard to whether or not anallowed_mentionswas present in the request that originally created the message.
Starting with API v10, the attachments array must contain all attachments that should be present after edit, including retained and new attachments provided in the request body.
Delete Message
DeleteAPIChannelMessage
Delete a message.
import { deleteMessage } from "dressed";
await deleteMessage(channelId, messageId);If operating on a guild channel and trying to delete a message that was not sent by the current user, this endpoint requires the MANAGE_MESSAGES permission.
Bulk Delete
PostAPIChannelMessagesBulkDelete
Delete multiple messages in a single request.
import { bulkDelete } from "dressed";
await bulkDelete(channelId, data);This endpoint can only be used on guild channels and requires the MANAGE_MESSAGES permission.
This endpoint will not delete messages older than 2 weeks, and will fail with a 400 BAD REQUEST if any message provided is older than that or if any duplicate message IDs are provided.
List Pins
GetAPIChannelPins
Gets the first 50 pinned messages in a channel, returning an array of message objects on success.
import { listPins } from "dressed";
const pins = await listPins(channelId);Requires the VIEW_CHANNEL permission. If the user is missing the READ_MESSAGE_HISTORY permission in the channel, then no pins will be returned.
List Channel Pins
GetAPIChannelMessagesPins
Retrieves the list of pins in a channel.
import { listChannelPins } from "dressed";
const channelPins = await listChannelPins(channelId, params?);Requires the VIEW_CHANNEL permission. If the user is missing the READ_MESSAGE_HISTORY permission in the channel, then no pins will be returned.
Create Pin
PutAPIChannelMessagesPin
Pin a message in a channel.
import { createPin } from "dressed";
await createPin(channelId, messageId);Requires the PIN_MESSAGES permission.
Delete Pin
DeleteAPIChannelMessagesPin
Unpin a message in a channel.
import { deletePin } from "dressed";
await deletePin(channelId, messageId);Requires the PIN_MESSAGES permission.