Skip to content

GroupDMChannel

classe · Source

Represents a Group DM Channel on Discord.

Extends: ChannelImplements: TextBasedChannel

Properties

messages

messages: MessageManager

A manager of the messages belonging to this channel Source

ownerId

nullable

ownerId: Snowflake

The user id of the owner of this Group DM Channel Source

lastMessageId

nullable

lastMessageId: Snowflake

The channel's last message id, if one was sent Source

lastPinTimestamp

nullable

lastPinTimestamp: number

The timestamp when the last pinned message was pinned, if there was one Source

name

nullable

name: string

The name of this Group DM Channel Source

icon

nullable

icon: string

The hash of the channel icon Source

recipients

readonly

recipients: Collection<Snowflake, User>

The recipients of this Group DM Channel. Source

owner

readonly · nullable

owner: User

The owner of this Group DM Channel Source

partial

readonly

partial: boolean

Whether this DMChannel is a partial Source

voiceUsers

readonly

voiceUsers: Collection<Snowflake, User>

The user in this voice-based channel Source

shard

readonly

shard: WebSocketShard

Get current shard Source

voiceAdapterCreator

readonly · nullable

voiceAdapterCreator: function

The voice state adapter for this client that can be used with @discordjs/voice to play audio in DM / Group DM channels. Source

lastMessage

readonly · nullable

lastMessage: Message

The Message object of the last message in the channel, if one was sent Source

lastPinAt

readonly · nullable

lastPinAt: Date

The date when the last pinned message was pinned, if there was one Source

type

type: ChannelType

The type of the channel Source

id

id: Snowflake

The channel's id Source

flags

nullable

flags: Readonly<ChannelFlags>

The flags that are applied to the channel. Source

createdTimestamp

readonly

createdTimestamp: number

The timestamp the channel was created at Source

createdAt

readonly

createdAt: Date

The time the channel was created at Source

deleted

deprecated

deleted: boolean

Whether or not the structure has been deleted Source

client

readonly

client: Client

The client that instantiated this Source

Methods

iconURL

iconURL(options?: StaticImageURLOptions): string

The URL to this channel's icon. Parameters

NameTypeDescription
options?StaticImageURLOptionsOptions for the Image URL Default: {}.

Returns: stringSource

delete

async

async delete(slient: boolean): Promise<GroupDMChannel>

Leave this Group DM Channel. Parameters

NameTypeDescription
slientbooleanLeave without notifying other members Default: false.

Returns: Promise<GroupDMChannel>

js
// Delete the channel
channel.delete()
  .then(console.log)
  .catch(console.error);

Source

toString

toString(): string

When concatenated with a string, this automatically returns the recipient's mention instead of the GroupDMChannel object. Returns: string

js
// Logs: Hello from Group Test!
console.log(`Hello from ${channel}!`);

Source

edit

async

async edit(data: GroupDMChannelEditData): Promise<GroupDMChannel>

Edit channel data Parameters

NameTypeDescription
dataGroupDMChannelEditDataData

Returns: Promise<GroupDMChannel>

js
// Set the channel name
channel.edit({
  name: 'Group Test',
})
  .then(updated => console.log(`New channel name ${updated}`))
  .catch(console.error);

Source

setName

setName(name: string): Promise<GroupDMChannel>

Renames this Group DM Channel. Parameters

NameTypeDescription
namestringName of the channel

Returns: Promise<GroupDMChannel>Source

setIcon

setIcon(icon: Base64Resolvable | BufferResolvable): Promise<GroupDMChannel>

Sets the icon of this Group DM Channel. Parameters

NameTypeDescription
iconBase64Resolvable | BufferResolvableIcon of the channel

Returns: Promise<GroupDMChannel>Source

setOwner

setOwner(user: UserResolvable): Promise<GroupDMChannel>

Changes the owner of this Group DM Channel. Parameters

NameTypeDescription
userUserResolvableUser to transfer ownership to

Returns: Promise<GroupDMChannel>Source

addUser

async

async addUser(user: UserResolvable): Promise<GroupDMChannel>

Adds a user to this Group DM Channel. Parameters

NameTypeDescription
userUserResolvableUser to add to the group

Returns: Promise<GroupDMChannel>Source

removeUser

async

async removeUser(user: UserResolvable): Promise<GroupDMChannel>

Removes a user from this Group DM Channel. Parameters

NameTypeDescription
userUserResolvableUser to remove from the group

Returns: Promise<GroupDMChannel>Source

getInvite

async

async getInvite(): Promise<Invite>

Gets the invite for this Group DM Channel. Returns: Promise<Invite>Source

fetchAllInvite

async

async fetchAllInvite(): Promise<Collection<string, Invite>>

Get all the invites for this Group DM Channel. Returns: Promise<Collection<string, Invite>>Source

removeInvite

async

async removeInvite(invite: InviteResolvable): Promise<GroupDMChannel>

Delete invites from this Group DM Channel. Parameters

NameTypeDescription
inviteInviteResolvableInvite to add to the channel

Returns: Promise<GroupDMChannel>Source

ring

ring(recipients?: Array<UserResolvable>): Promise<void>

Ring the user's phone / PC (call) Parameters

NameTypeDescription
recipients?Array<UserResolvable>Array of recipients

Returns: Promise<void>Source

sync

sync(): undefined

Sync VoiceState of this Group DMChannel. Returns: undefinedSource

send

async

async send(options: string | MessagePayload | MessageOptions): Promise<Message>

Sends a message to this channel. Parameters

NameTypeDescription
optionsstring | MessagePayload | MessageOptionsThe options to provide

Returns: Promise<Message>

js
// Send a basic message
channel.send('hello!')
  .then(message => console.log(`Sent message: ${message.content}`))
  .catch(console.error);
js
// Send a remote file
channel.send({
  files: ['https://cdn.discordapp.com/icons/222078108977594368/6e1019b3179d71046e463a75915e7244.png?size=2048']
})
  .then(console.log)
  .catch(console.error);
js
// Send a local file
channel.send({
  files: [{
    attachment: 'entire/path/to/file.jpg',
    name: 'file.jpg',
    description: 'A description of the file'
  }]
})
  .then(console.log)
  .catch(console.error);

Source

sendTyping

sendTyping(): Promise<({message_send_cooldown_ms: number, thread_create_cooldown_ms: number}|void)>

Sends a typing indicator in the channel. Returns: Promise<({message_send_cooldown_ms: number, thread_create_cooldown_ms: number}\|void)> — Resolves upon the typing status being sent

js
// Start typing in a channel
channel.sendTyping();

Source

createMessageCollector

createMessageCollector(options?: MessageCollectorOptions): MessageCollector

Creates a Message Collector. Parameters

NameTypeDescription
options?MessageCollectorOptionsThe options to pass to the collector Default: {}.

Returns: MessageCollector

js
// Create a message collector
const filter = m => m.content.includes('discord');
const collector = channel.createMessageCollector({ filter, time: 15_000 });
collector.on('collect', m => console.log(`Collected ${m.content}`));
collector.on('end', collected => console.log(`Collected ${collected.size} items`));

Source

awaitMessages

awaitMessages(options?: AwaitMessagesOptions): Promise<Collection<Snowflake, Message>>

Similar to createMessageCollector but in promise form. Resolves with a collection of messages that pass the specified filter. Parameters

NameTypeDescription
options?AwaitMessagesOptionsOptional options to pass to the internal collector Default: {}.

Returns: Promise<Collection<Snowflake, Message>>

js
// Await !vote messages
const filter = m => m.content.startsWith('!vote');
// Errors: ['time'] treats ending because of the time limit as an error
channel.awaitMessages({ filter, max: 4, time: 60_000, errors: ['time'] })
  .then(collected => console.log(collected.size))
  .catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`));

Source

fetch

fetch(force?: boolean): Promise<Channel>

Fetches this channel. Parameters

NameTypeDescription
force?booleanWhether to skip the cache check and request the API Default: true.

Returns: Promise<Channel>Source

isText

isText(): boolean

Indicates whether this channel is text-based. Returns: booleanSource

isVoice

isVoice(): boolean

Indicates whether this channel is voice-based. Returns: booleanSource

isThread

isThread(): boolean

Indicates whether this channel is a ThreadChannel. Returns: booleanSource

isThreadOnly

isThreadOnly(): boolean

Indicates whether this channel is ThreadOnlyChannel. Returns: booleanSource

isDirectory

isDirectory(): boolean

Indicates whether this channel is a DirectoryChannelReturns: booleanSource

Unofficial software. Not affiliated with or supported by Discord.