DMChannel

DMChannel

Represents a DM channel. See Channel for more properties

Constructor

new DMChannel()

Properties:
Name Type Attributes Description
lastMessageID String <nullable>

The ID of the last message in the channel. This can be null if there has never been a message in the channel

lastPinTimestamp Number <nullable>

The timestamp of the last pinned message

messages Collection.<Message>

Collection of Messages in this channel

recipients Collection.<User>

The recipient in this private channel (this should always contain one entry)

Source:

Extends

Methods

addMessageReaction(messageID, reaction) → {Promise}

Add a reaction to a message

Source:
Parameters:
Name Type Description
messageID String

The ID of the message

reaction String

The reaction (Unicode string if Unicode emoji, emojiName:emojiID if custom emoji)

Returns:
Type:
Promise

createMessage(content, fileopt) → {Promise.<Message>}

Create a message in the channel

Source:
Parameters:
Name Type Attributes Description
content String | Object

A string or object. If an object is passed:

Name Type Attributes Description
allowedMentions Object <optional>

A list of mentions to allow (overrides default)

Name Type Attributes Description
everyone Boolean <optional>

Whether or not to allow @everyone/@here

repliedUser Boolean <optional>

Whether or not to mention the author of the message being replied to

roles Boolean | Array.<String> <optional>

Whether or not to allow all role mentions, or an array of specific role mentions to allow

users Boolean | Array.<String> <optional>

Whether or not to allow all user mentions, or an array of specific user mentions to allow

attachments Array.<Object> <optional>

An array of attachment objects with the filename and description

Name Type Attributes Description
description String <optional>

The description of the file

filename String <optional>

The name of the file

id Number

The index of the file

components Array.<Object> <optional>

An array of component objects

Name Type Attributes Description
custom_id String <optional>

The ID of the component (type 2 style 0-4 and type 3,5,6,7,8 only)

disabled Boolean <optional>

Whether the component is disabled (type 2 and 3,5,6,7,8 only)

emoji Object <optional>

The emoji to be displayed in the component (type 2)

label String <optional>

The label to be displayed in the component (type 2)

default_values Array.<Object> <optional>

default values for the component (type 5,6,7,8 only)

Name Type Attributes Description
id String <optional>

id of a user, role, or channel

type String <optional>

type of value that id represents (user, role, or channel)

max_values Number <optional>

The maximum number of items that can be chosen (1-25, default 1)

min_values Number <optional>

The minimum number of items that must be chosen (0-25, default 1)

options Array.<Object> <optional>

The options for this component (type 3 only)

Name Type Attributes Description
default Boolean <optional>

Whether this option should be the default value selected

description String <optional>

The description for this option

emoji Object <optional>

The emoji to be displayed in this option

label String

The label for this option

value Number | String

The value for this option

placeholder String <optional>

The placeholder text for the component when no option is selected (type 3,5,6,7,8 only)

style Number <optional>

The style of the component (type 2 only) - If 0-4, custom_id is required; if 5, url is required

type Number

The type of component - If 1, it is a collection and a components array (nested) is required; if 2, it is a button; if 3, it is a string select; if 5, it is a user select; if 6, it is a role select; if 7, it is a mentionable select; if 8, it is a channel select

url String <optional>

The URL that the component should open for users (type 2 style 5 only)

content String <optional>

A content string

embed Object <optional>

[DEPRECATED] An embed object. See the official Discord API documentation entry for object structure

embeds Array.<Object> <optional>

An array of embed objects. See the official Discord API documentation entry for object structure

enforceNonce Boolean <optional>

If true and content.nonce is present, if multiple messages are sent with the same nonce within a few minutes of each other, that message will be returned and no new message created

messageReference Object <optional>

The message reference, used when replying to or forwarding messages

Name Type Attributes Default Description
channelID String <optional>

The channel ID of the referenced message. Required when forwarding messages

failIfNotExists Boolean <optional>
true

Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message

guildID String <optional>

The guild ID of the referenced message

messageID String

The message ID of the referenced message. This cannot reference a system message

type String <optional>
0

The type of reference. Either 0 (REPLY) or 1 (FORWARDED). Will become required in the future

messageReferenceID String <optional>

[DEPRECATED] The ID of the message should be replied to. Use messageReference instead

poll Object <optional>

A poll object. See the official Discord API documentation entry for object structure

stickerIDs Array.<String> <optional>

An array of IDs corresponding to stickers to send

tts Boolean <optional>

Set the message TTS flag

file Object | Array.<Object> <optional>

A file object (or an Array of them)

Name Type Description
file Buffer

A buffer containing file data

name String

What to name the file

Returns:
Type:
Promise.<Message>

delete() → {Promise.<DMChannel>}

Close the DM Channel. This doesn't really concern bots with DMs.

Source:
Returns:
Type:
Promise.<DMChannel>

deleteMessage(messageID) → {Promise}

Delete a message

Source:
Parameters:
Name Type Description
messageID String

The ID of the message

Returns:
Type:
Promise

editMessage(messageID, content) → {Promise.<Message>}

Edit a message

Source:
Parameters:
Name Type Description
messageID String

The ID of the message

content String | Array | Object

A string, array of strings, or object. If an object is passed:

Name Type Attributes Description
allowedMentions Object <optional>

A list of mentions to allow (overrides default)

Name Type Attributes Description
everyone Boolean <optional>

Whether or not to allow @everyone/@here

roles Boolean | Array.<String> <optional>

Whether or not to allow all role mentions, or an array of specific role mentions to allow

users Boolean | Array.<String> <optional>

Whether or not to allow all user mentions, or an array of specific user mentions to allow

attachments Array.<Object> <optional>

An array of attachment objects that will be appended to the message, including new files. Only the provided files will be appended

Name Type Attributes Description
description String <optional>

The description of the file

filename String <optional>

The name of the file. This is not required if you are attaching a new file

id Number | String

The ID of the file. If you are attaching a new file, this would be the index of the file

components Array.<Object> <optional>

An array of component objects

Name Type Attributes Description
custom_id String <optional>

The ID of the component (type 2 style 0-4 and type 3,5,6,7,8 only)

disabled Boolean <optional>

Whether the component is disabled (type 2 and 3,5,6,7,8 only)

emoji Object <optional>

The emoji to be displayed in the component (type 2)

label String <optional>

The label to be displayed in the component (type 2)

default_values Array.<Object> <optional>

default values for the component (type 5,6,7,8 only)

Name Type Attributes Description
id String <optional>

id of a user, role, or channel

type String <optional>

type of value that id represents (user, role, or channel)

max_values Number <optional>

The maximum number of items that can be chosen (1-25, default 1)

min_values Number <optional>

The minimum number of items that must be chosen (0-25, default 1)

options Array.<Object> <optional>

The options for this component (type 3 only)

Name Type Attributes Description
default Boolean <optional>

Whether this option should be the default value selected

description String <optional>

The description for this option

emoji Object <optional>

The emoji to be displayed in this option

label String

The label for this option

value Number | String

The value for this option

placeholder String <optional>

The placeholder text for the component when no option is selected (type 3,5,6,7,8 only)

style Number <optional>

The style of the component (type 2 only) - If 0-4, custom_id is required; if 5, url is required

type Number

The type of component - If 1, it is a collection and a components array (nested) is required; if 2, it is a button; if 3, it is a string select; if 5, it is a user select; if 6, it is a role select; if 7, it is a mentionable select; if 8, it is a channel select

url String <optional>

The URL that the component should open for users (type 2 style 5 only)

content String <optional>

A content string

embed Object <optional>

[DEPRECATED] An embed object. See the official Discord API documentation entry for object structure

embeds Array.<Object> <optional>

An array of embed objects. See the official Discord API documentation entry for object structure

file Object | Array.<Object> <optional>

A file object (or an Array of them)

Name Type Description
file Buffer

A buffer containing file data

name String

What to name the file

flags Number <optional>

A number representing the flags to apply to the message. See the official Discord API documentation entry for flags reference

Returns:
Type:
Promise.<Message>

getMessage(messageID) → {Promise.<Message>}

Get a previous message in the channel

Source:
Parameters:
Name Type Description
messageID String

The ID of the message

Returns:
Type:
Promise.<Message>

getMessageReaction(messageID, reaction, optionsopt, beforeopt, afteropt) → {Promise.<Array.<User>>}

Get a list of users who reacted with a specific reaction

Source:
Parameters:
Name Type Attributes Description
messageID String

The ID of the message

reaction String

The reaction (Unicode string if Unicode emoji, emojiName:emojiID if custom emoji)

options Object <optional>

Options for the request. If this is a number, it is treated as options.limit ([DEPRECATED] behavior)

Name Type Attributes Default Description
after String <optional>

Get users after this user ID

limit Number <optional>
100

The maximum number of users to get

type Number <optional>
0

The type of reaction (0 for normal, 1 for burst)

before String <optional>

[DEPRECATED] Get users before this user ID. Discord no longer supports this parameter

after String <optional>

[DEPRECATED] Get users after this user ID

Returns:
Type:
Promise.<Array.<User>>

getMessages(optionsopt, beforeopt, afteropt, aroundopt) → {Promise.<Array.<Message>>}

Get previous messages in the channel

Source:
Parameters:
Name Type Attributes Description
options Object <optional>

Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as options.limit

Name Type Attributes Default Description
after String <optional>

Get messages after this message ID

around String <optional>

Get messages around this message ID (does not work with limit > 100)

before String <optional>

Get messages before this message ID

limit Number <optional>
50

The max number of messages to get

before String <optional>

[DEPRECATED] Get messages before this message ID

after String <optional>

[DEPRECATED] Get messages after this message ID

around String <optional>

[DEPRECATED] Get messages around this message ID (does not work with limit > 100)

Returns:
Type:
Promise.<Array.<Message>>

getPins(optionsopt) → {Promise.<{hasMore: Boolean, items: Array.<{pinnedAt: Number, message: Message}>}>}

Get pinned messages in the channel

Source:
Parameters:
Name Type Attributes Description
options Object <optional>

The options to use to get pinned messages

Name Type Attributes Default Description
before Date <optional>

Get pinned messages before this date

limit Number <optional>
50

The max number of pinned messages to get (1-50, default 50)

Returns:
Type:
Promise.<{hasMore: Boolean, items: Array.<{pinnedAt: Number, message: Message}>}>

pinMessage(messageID) → {Promise}

Pin a message

Source:
Parameters:
Name Type Description
messageID String

The ID of the message

Returns:
Type:
Promise

removeMessageReaction(messageID, reaction, userIDopt) → {Promise}

Remove a reaction from a message

Source:
Parameters:
Name Type Attributes Default Description
messageID String

The ID of the message

reaction String

The reaction (Unicode string if Unicode emoji, emojiName:emojiID if custom emoji)

userID String <optional>
"@me"

The ID of the user to remove the reaction for. Passing this parameter is deprecated and will not be supported in future versions.

Returns:
Type:
Promise

sendTyping() → {Promise}

Send typing status in the channel

Source:
Returns:
Type:
Promise

unpinMessage(messageID) → {Promise}

Unpin a message

Source:
Parameters:
Name Type Description
messageID String

The ID of the message

Returns:
Type:
Promise

unsendMessage(messageID) → {Promise}

Un-send a message. You're welcome Programmix

Source:
Parameters:
Name Type Description
messageID String

The ID of the message

Returns:
Type:
Promise