GroupDMChannel
classe · Source
Represents a Group DM Channel on Discord.
Extends: ChannelImplements: TextBasedChannel
Properties
messages
A manager of the messages belonging to this channel Source
ownerId
The user id of the owner of this Group DM Channel Source
lastMessageId
The channel's last message id, if one was sent Source
lastPinTimestamp
The timestamp when the last pinned message was pinned, if there was one Source
name
The name of this Group DM Channel Source
icon
The hash of the channel icon Source
recipients
The recipients of this Group DM Channel. Source
owner
The owner of this Group DM Channel Source
partial
Whether this DMChannel is a partial Source
voiceUsers
The user in this voice-based channel Source
shard
Get current shard Source
voiceAdapterCreator
The voice state adapter for this client that can be used with @discordjs/voice to play audio in DM / Group DM channels. Source
lastMessage
The Message object of the last message in the channel, if one was sent Source
lastPinAt
The date when the last pinned message was pinned, if there was one Source
type
The type of the channel Source
id
The channel's id Source
flags
The flags that are applied to the channel. Source
createdTimestamp
The timestamp the channel was created at Source
createdAt
The time the channel was created at Source
deleted
Whether or not the structure has been deleted Source
client
The client that instantiated this Source
Methods
iconURL
The URL to this channel's icon. Parameters
| Name | Type | Description |
|---|---|---|
options? | StaticImageURLOptions | Options for the Image URL Default: {}. |
Returns: stringSource
delete
Leave this Group DM Channel. Parameters
| Name | Type | Description |
|---|---|---|
slient | boolean | Leave without notifying other members Default: false. |
Returns: Promise<GroupDMChannel>
// Delete the channel
channel.delete()
.then(console.log)
.catch(console.error);toString
When concatenated with a string, this automatically returns the recipient's mention instead of the GroupDMChannel object. Returns: string
// Logs: Hello from Group Test!
console.log(`Hello from ${channel}!`);edit
Edit channel data Parameters
| Name | Type | Description |
|---|---|---|
data | GroupDMChannelEditData | Data |
Returns: Promise<GroupDMChannel>
// Set the channel name
channel.edit({
name: 'Group Test',
})
.then(updated => console.log(`New channel name ${updated}`))
.catch(console.error);setName
Renames this Group DM Channel. Parameters
| Name | Type | Description |
|---|---|---|
name | string | Name of the channel |
Returns: Promise<GroupDMChannel>Source
setIcon
Sets the icon of this Group DM Channel. Parameters
| Name | Type | Description |
|---|---|---|
icon | Base64Resolvable | BufferResolvable | Icon of the channel |
Returns: Promise<GroupDMChannel>Source
setOwner
Changes the owner of this Group DM Channel. Parameters
| Name | Type | Description |
|---|---|---|
user | UserResolvable | User to transfer ownership to |
Returns: Promise<GroupDMChannel>Source
addUser
Adds a user to this Group DM Channel. Parameters
| Name | Type | Description |
|---|---|---|
user | UserResolvable | User to add to the group |
Returns: Promise<GroupDMChannel>Source
removeUser
Removes a user from this Group DM Channel. Parameters
| Name | Type | Description |
|---|---|---|
user | UserResolvable | User to remove from the group |
Returns: Promise<GroupDMChannel>Source
getInvite
Gets the invite for this Group DM Channel. Returns: Promise<Invite>Source
fetchAllInvite
Get all the invites for this Group DM Channel. Returns: Promise<Collection<string, Invite>>Source
removeInvite
Delete invites from this Group DM Channel. Parameters
| Name | Type | Description |
|---|---|---|
invite | InviteResolvable | Invite to add to the channel |
Returns: Promise<GroupDMChannel>Source
ring
Ring the user's phone / PC (call) Parameters
| Name | Type | Description |
|---|---|---|
recipients? | Array<UserResolvable> | Array of recipients |
Returns: Promise<void>Source
sync
Sync VoiceState of this Group DMChannel. Returns: undefinedSource
send
Sends a message to this channel. Parameters
| Name | Type | Description |
|---|---|---|
options | string | MessagePayload | MessageOptions | The options to provide |
Returns: Promise<Message>
// Send a basic message
channel.send('hello!')
.then(message => console.log(`Sent message: ${message.content}`))
.catch(console.error);// Send a remote file
channel.send({
files: ['https://cdn.discordapp.com/icons/222078108977594368/6e1019b3179d71046e463a75915e7244.png?size=2048']
})
.then(console.log)
.catch(console.error);// 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);sendTyping
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
// Start typing in a channel
channel.sendTyping();createMessageCollector
Creates a Message Collector. Parameters
| Name | Type | Description |
|---|---|---|
options? | MessageCollectorOptions | The options to pass to the collector Default: {}. |
Returns: MessageCollector
// 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`));awaitMessages
Similar to createMessageCollector but in promise form. Resolves with a collection of messages that pass the specified filter. Parameters
| Name | Type | Description |
|---|---|---|
options? | AwaitMessagesOptions | Optional options to pass to the internal collector Default: {}. |
Returns: Promise<Collection<Snowflake, Message>>
// 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.`));fetch
Fetches this channel. Parameters
| Name | Type | Description |
|---|---|---|
force? | boolean | Whether to skip the cache check and request the API Default: true. |
Returns: Promise<Channel>Source
isText
Indicates whether this channel is text-based. Returns: booleanSource
isVoice
Indicates whether this channel is voice-based. Returns: booleanSource
isThread
Indicates whether this channel is a ThreadChannel. Returns: booleanSource
isThreadOnly
Indicates whether this channel is ThreadOnlyChannel. Returns: booleanSource
isDirectory
Indicates whether this channel is a DirectoryChannelReturns: booleanSource