BaseGuildVoiceChannel
classe · Source
Represents a voice-based guild channel on Discord.
Extends: GuildChannelImplements: TextBasedChannel
Properties
messages
A manager of the messages sent to this channel Source
nsfw
If the guild considers this channel NSFW Source
bitrate
The bitrate of this voice-based channel Source
rtcRegion
The RTC region for this voice-based channel. This region is automatically selected if null. Source
userLimit
The maximum amount of users allowed in this channel. Source
videoQualityMode
The camera video quality mode of the channel. Source
lastMessageId
The last message id sent in the channel, if one was sent Source
rateLimitPerUser
The rate limit per user (slowmode) for this channel in seconds Source
status
The status of the voice channel (max 500 characters) Source
voiceStartTimestamp
The timestamp when the current voice session started. Source
voiceStartAt
The time when the current voice session started. Source
members
The members in this voice-based channel Source
full
Checks if the voice-based channel is full Source
joinable
Whether the channel is joinable by the client user Source
lastMessage
The Message object of the last message in the channel, if one was sent Source
guild
The guild the channel is in Source
guildId
The id of the guild the channel is in Source
permissionOverwrites
A manager of permission overwrites that belong to this channel Source
name
The name of the guild channel Source
rawPosition
The raw position of the channel from Discord Source
parentId
The id of the category parent of this channel Source
parent
The category parent of this channel Source
permissionsLocked
If the permissionOverwrites match the parent channel, null if no parent Source
position
The position of the channel Source
deletable
Whether the channel is deletable by the client user Source
manageable
Whether the channel is manageable by the client user Source
viewable
Whether the channel is viewable by the client user 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
partial
Whether this Channel is a partial This is always false outside of DM channels. Source
client
The client that instantiated this Source
Methods
createInvite
Creates an invite to this guild channel. Parameters
| Name | Type | Description |
|---|---|---|
options? | CreateInviteOptions | The options for creating the invite Default: {}. |
Returns: Promise<Invite>
// Create an invite to a channel
channel.createInvite()
.then(invite => console.log(`Created an invite with a code of ${invite.code}`))
.catch(console.error);fetchInvites
Fetches a collection of invites to this guild channel. Resolves with a collection mapping invites by their codes. Parameters
| Name | Type | Description |
|---|---|---|
cache? | boolean | Whether or not to cache the fetched invites Default: true. |
Returns: Promise<Collection<string, Invite>>Source
setBitrate
Sets the bitrate of the channel. Parameters
| Name | Type | Description |
|---|---|---|
bitrate | number | The new bitrate |
reason? | string | Reason for changing the channel's bitrate |
Returns: Promise<BaseGuildVoiceChannel>
// Set the bitrate of a voice channel
channel.setBitrate(48_000)
.then(channel => console.log(`Set bitrate to ${channel.bitrate}bps for ${channel.name}`))
.catch(console.error);setRTCRegion
Sets the RTC region of the channel. Parameters
| Name | Type | Description |
|---|---|---|
rtcRegion | string | The new region of the channel. Set to null to remove a specific region for the channel |
reason? | string | The reason for modifying this region. |
Returns: Promise<BaseGuildVoiceChannel>
// Set the RTC region to sydney
channel.setRTCRegion('sydney');// Remove a fixed region for this channel - let Discord decide automatically
channel.setRTCRegion(null, 'We want to let Discord decide.');setUserLimit
Sets the user limit of the channel. Parameters
| Name | Type | Description |
|---|---|---|
userLimit | number | The new user limit |
reason? | string | Reason for changing the user limit |
Returns: Promise<BaseGuildVoiceChannel>
// Set the user limit of a voice channel
channel.setUserLimit(42)
.then(channel => console.log(`Set user limit to ${channel.userLimit} for ${channel.name}`))
.catch(console.error);setVideoQualityMode
Sets the camera video quality mode of the channel. Parameters
| Name | Type | Description |
|---|---|---|
videoQualityMode | VideoQualityMode | number | The new camera video quality mode. |
reason? | string | Reason for changing the camera video quality mode. |
Returns: Promise<BaseGuildVoiceChannel>Source
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.`));fetchWebhooks
Fetches all webhooks for the channel. Returns: Promise<Collection<Snowflake, Webhook>>
// Fetch webhooks
channel.fetchWebhooks()
.then(hooks => console.log(`This channel has ${hooks.size} hooks`))
.catch(console.error);createWebhook
Creates a webhook for the channel. Parameters
| Name | Type | Description |
|---|---|---|
name | string | The name of the webhook |
options? | ChannelWebhookCreateOptions | Options for creating the webhook |
Returns: Promise<Webhook> — Returns the created Webhook
// Create a webhook for the current channel
channel.createWebhook('Snek', {
avatar: 'https://i.imgur.com/mI8XcpG.jpg',
reason: 'Needed a cool new Webhook'
})
.then(console.log)
.catch(console.error)setRateLimitPerUser
Sets the rate limit per user (slowmode) for this channel. Parameters
| Name | Type | Description |
|---|---|---|
rateLimitPerUser | number | The new rate limit in seconds |
reason? | string | Reason for changing the channel's rate limit |
Returns: Promise<this>Source
setNSFW
Sets whether this channel is flagged as NSFW. Parameters
| Name | Type | Description |
|---|---|---|
nsfw? | boolean | Whether the channel should be considered NSFW Default: true. |
reason? | string | Reason for changing the channel's NSFW flag |
Returns: Promise<this>Source
permissionsFor
Gets the overall set of permissions for a member or role in this channel, taking into account channel overwrites. Parameters
| Name | Type | Description |
|---|---|---|
memberOrRole | GuildMemberResolvable | RoleResolvable | The member or role to obtain the overall permissions for |
checkAdmin? | boolean | Whether having ADMINISTRATOR will return all permissions Default: true. |
Returns: Readonly<Permissions>Source
memberPermissions
Gets the overall set of permissions for a member in this channel, taking into account channel overwrites. Parameters
| Name | Type | Description |
|---|---|---|
member | GuildMember | The member to obtain the overall permissions for |
checkAdmin | boolean | Whether having ADMINISTRATOR will return all permissions Default: true. |
Returns: Readonly<Permissions>Source
rolePermissions
Gets the overall set of permissions for a role in this channel, taking into account channel overwrites. Parameters
| Name | Type | Description |
|---|---|---|
role | Role | The role to obtain the overall permissions for |
checkAdmin | boolean | Whether having ADMINISTRATOR will return all permissions |
Returns: Readonly<Permissions>Source
lockPermissions
Locks in the permission overwrites from the parent channel. Returns: Promise<GuildChannel>Source
edit
Edits the channel. Parameters
| Name | Type | Description |
|---|---|---|
data | ChannelData | The new data for the channel |
reason? | string | Reason for editing this channel |
Returns: Promise<GuildChannel>
// Edit a channel
channel.edit({ name: 'new-channel' })
.then(console.log)
.catch(console.error);setName
Sets a new name for the guild channel. Parameters
| Name | Type | Description |
|---|---|---|
name | string | The new name for the guild channel |
reason? | string | Reason for changing the guild channel's name |
Returns: Promise<GuildChannel>
// Set a new channel name
channel.setName('not_general')
.then(newChannel => console.log(`Channel's new name is ${newChannel.name}`))
.catch(console.error);setParent
Sets the parent of this channel. Parameters
| Name | Type | Description |
|---|---|---|
channel | CategoryChannelResolvable | The category channel to set as the parent |
options? | SetParentOptions | The options for setting the parent Default: {}. |
Returns: Promise<GuildChannel>
// Add a parent to a channel
message.channel.setParent('355908108431917066', { lockPermissions: false })
.then(channel => console.log(`New parent of ${message.channel.name}: ${channel.name}`))
.catch(console.error);setPosition
Sets a new position for the guild channel. Parameters
| Name | Type | Description |
|---|---|---|
position | number | The new position for the guild channel |
options? | SetChannelPositionOptions | Options for setting position |
Returns: Promise<GuildChannel>
// Set a new channel position
channel.setPosition(2)
.then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
.catch(console.error);clone
Clones this channel. Parameters
| Name | Type | Description |
|---|---|---|
options? | GuildChannelCloneOptions | The options for cloning this channel |
Returns: Promise<GuildChannel>Source
equals
Checks if this channel has the same type, topic, position, name, overwrites, and id as another channel. In most cases, a simple channel.id === channel2.id will do, and is much faster too. Parameters
| Name | Type | Description |
|---|---|---|
channel | GuildChannel | Channel to compare with |
Returns: booleanSource
delete
Deletes this channel. Parameters
| Name | Type | Description |
|---|---|---|
reason? | string | Reason for deleting this channel |
Returns: Promise<GuildChannel>
// Delete the channel
channel.delete('making room for new channels')
.then(console.log)
.catch(console.error);toString
When concatenated with a string, this automatically returns the channel's mention instead of the Channel object. Returns: string
// Logs: Hello from <#123456789012345678>!
console.log(`Hello from ${channel}!`);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