Skip to content

VoiceChannel

classe · Source

Represents a guild voice channel on Discord.

Extends: BaseGuildVoiceChannel

Properties

editable

readonly · deprecated

editable: boolean

Whether the channel is editable by the client user Source

joinable

readonly

joinable: boolean

Whether the channel is joinable by the client user Source

speakable

readonly

speakable: boolean

Checks if the client has permission to send audio to the voice channel Source

messages

messages: MessageManager

A manager of the messages sent to this channel Source

nsfw

nsfw: boolean

If the guild considers this channel NSFW Source

bitrate

bitrate: number

The bitrate of this voice-based channel Source

rtcRegion

nullable

rtcRegion: string

The RTC region for this voice-based channel. This region is automatically selected if null. Source

userLimit

userLimit: number

The maximum amount of users allowed in this channel. Source

videoQualityMode

nullable

videoQualityMode: VideoQualityMode

The camera video quality mode of the channel. Source

lastMessageId

nullable

lastMessageId: Snowflake

The last message id sent in the channel, if one was sent Source

rateLimitPerUser

rateLimitPerUser: number

The rate limit per user (slowmode) for this channel in seconds Source

status

nullable

status: string

The status of the voice channel (max 500 characters) Source

voiceStartTimestamp

nullable

voiceStartTimestamp: number

The timestamp when the current voice session started. Source

voiceStartAt

readonly · nullable

voiceStartAt: Date

The time when the current voice session started. Source

members

readonly

members: Collection<Snowflake, GuildMember>

The members in this voice-based channel Source

full

readonly

full: boolean

Checks if the voice-based channel is full Source

lastMessage

readonly · nullable

lastMessage: Message

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

guild

guild: Guild

The guild the channel is in Source

guildId

guildId: Snowflake

The id of the guild the channel is in Source

permissionOverwrites

permissionOverwrites: PermissionOverwriteManager

A manager of permission overwrites that belong to this channel Source

name

name: string

The name of the guild channel Source

rawPosition

rawPosition: number

The raw position of the channel from Discord Source

parentId

nullable

parentId: Snowflake

The id of the category parent of this channel Source

parent

readonly · nullable

parent: CategoryChannel

The category parent of this channel Source

permissionsLocked

readonly · nullable

permissionsLocked: boolean

If the permissionOverwrites match the parent channel, null if no parent Source

position

readonly

position: number

The position of the channel Source

deletable

readonly

deletable: boolean

Whether the channel is deletable by the client user Source

manageable

readonly

manageable: boolean

Whether the channel is manageable by the client user Source

viewable

readonly

viewable: boolean

Whether the channel is viewable by the client user 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

partial

readonly

partial: boolean

Whether this Channel is a partial This is always false outside of DM channels. Source

client

readonly

client: Client

The client that instantiated this Source

Methods

createInvite

createInvite(options?: CreateInviteOptions): Promise<Invite>

Creates an invite to this guild channel. Parameters

NameTypeDescription
options?CreateInviteOptionsThe options for creating the invite Default: {}.

Returns: Promise<Invite>

js
// Create an invite to a channel
channel.createInvite()
  .then(invite => console.log(`Created an invite with a code of ${invite.code}`))
  .catch(console.error);

Source

fetchInvites

fetchInvites(cache?: boolean): Promise<Collection<string, Invite>>

Fetches a collection of invites to this guild channel. Resolves with a collection mapping invites by their codes. Parameters

NameTypeDescription
cache?booleanWhether or not to cache the fetched invites Default: true.

Returns: Promise<Collection<string, Invite>>Source

setBitrate

setBitrate(bitrate: number, reason?: string): Promise<BaseGuildVoiceChannel>

Sets the bitrate of the channel. Parameters

NameTypeDescription
bitratenumberThe new bitrate
reason?stringReason for changing the channel's bitrate

Returns: Promise<BaseGuildVoiceChannel>

js
// 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);

Source

setRTCRegion

setRTCRegion(rtcRegion: string, reason?: string): Promise<BaseGuildVoiceChannel>

Sets the RTC region of the channel. Parameters

NameTypeDescription
rtcRegionstringThe new region of the channel. Set to null to remove a specific region for the channel
reason?stringThe reason for modifying this region.

Returns: Promise<BaseGuildVoiceChannel>

js
// Set the RTC region to sydney
channel.setRTCRegion('sydney');
js
// Remove a fixed region for this channel - let Discord decide automatically
channel.setRTCRegion(null, 'We want to let Discord decide.');

Source

setUserLimit

setUserLimit(userLimit: number, reason?: string): Promise<BaseGuildVoiceChannel>

Sets the user limit of the channel. Parameters

NameTypeDescription
userLimitnumberThe new user limit
reason?stringReason for changing the user limit

Returns: Promise<BaseGuildVoiceChannel>

js
// 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);

Source

setVideoQualityMode

setVideoQualityMode(videoQualityMode: VideoQualityMode | number, reason?: string): Promise<BaseGuildVoiceChannel>

Sets the camera video quality mode of the channel. Parameters

NameTypeDescription
videoQualityModeVideoQualityMode | numberThe new camera video quality mode.
reason?stringReason for changing the camera video quality mode.

Returns: Promise<BaseGuildVoiceChannel>Source

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

fetchWebhooks

fetchWebhooks(): Promise<Collection<Snowflake, Webhook>>

Fetches all webhooks for the channel. Returns: Promise<Collection<Snowflake, Webhook>>

js
// Fetch webhooks
channel.fetchWebhooks()
  .then(hooks => console.log(`This channel has ${hooks.size} hooks`))
  .catch(console.error);

Source

createWebhook

createWebhook(name: string, options?: ChannelWebhookCreateOptions): Promise<Webhook>

Creates a webhook for the channel. Parameters

NameTypeDescription
namestringThe name of the webhook
options?ChannelWebhookCreateOptionsOptions for creating the webhook

Returns: Promise<Webhook> — Returns the created Webhook

js
// 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)

Source

setRateLimitPerUser

setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise<this>

Sets the rate limit per user (slowmode) for this channel. Parameters

NameTypeDescription
rateLimitPerUsernumberThe new rate limit in seconds
reason?stringReason for changing the channel's rate limit

Returns: Promise<this>Source

setNSFW

setNSFW(nsfw?: boolean, reason?: string): Promise<this>

Sets whether this channel is flagged as NSFW. Parameters

NameTypeDescription
nsfw?booleanWhether the channel should be considered NSFW Default: true.
reason?stringReason for changing the channel's NSFW flag

Returns: Promise<this>Source

permissionsFor

permissionsFor(memberOrRole: GuildMemberResolvable | RoleResolvable, checkAdmin?: boolean): Readonly<Permissions>

Gets the overall set of permissions for a member or role in this channel, taking into account channel overwrites. Parameters

NameTypeDescription
memberOrRoleGuildMemberResolvable | RoleResolvableThe member or role to obtain the overall permissions for
checkAdmin?booleanWhether having ADMINISTRATOR will return all permissions Default: true.

Returns: Readonly<Permissions>Source

memberPermissions

private

memberPermissions(member: GuildMember, checkAdmin: boolean): Readonly<Permissions>

Gets the overall set of permissions for a member in this channel, taking into account channel overwrites. Parameters

NameTypeDescription
memberGuildMemberThe member to obtain the overall permissions for
checkAdminbooleanWhether having ADMINISTRATOR will return all permissions Default: true.

Returns: Readonly<Permissions>Source

rolePermissions

private

rolePermissions(role: Role, checkAdmin: boolean): Readonly<Permissions>

Gets the overall set of permissions for a role in this channel, taking into account channel overwrites. Parameters

NameTypeDescription
roleRoleThe role to obtain the overall permissions for
checkAdminbooleanWhether having ADMINISTRATOR will return all permissions

Returns: Readonly<Permissions>Source

lockPermissions

async

async lockPermissions(): Promise<GuildChannel>

Locks in the permission overwrites from the parent channel. Returns: Promise<GuildChannel>Source

edit

edit(data: ChannelData, reason?: string): Promise<GuildChannel>

Edits the channel. Parameters

NameTypeDescription
dataChannelDataThe new data for the channel
reason?stringReason for editing this channel

Returns: Promise<GuildChannel>

js
// Edit a channel
channel.edit({ name: 'new-channel' })
  .then(console.log)
  .catch(console.error);

Source

setName

setName(name: string, reason?: string): Promise<GuildChannel>

Sets a new name for the guild channel. Parameters

NameTypeDescription
namestringThe new name for the guild channel
reason?stringReason for changing the guild channel's name

Returns: Promise<GuildChannel>

js
// Set a new channel name
channel.setName('not_general')
  .then(newChannel => console.log(`Channel's new name is ${newChannel.name}`))
  .catch(console.error);

Source

setParent

setParent(channel: CategoryChannelResolvable, options?: SetParentOptions): Promise<GuildChannel>

Sets the parent of this channel. Parameters

NameTypeDescription
channelCategoryChannelResolvableThe category channel to set as the parent
options?SetParentOptionsThe options for setting the parent Default: {}.

Returns: Promise<GuildChannel>

js
// 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);

Source

setPosition

setPosition(position: number, options?: SetChannelPositionOptions): Promise<GuildChannel>

Sets a new position for the guild channel. Parameters

NameTypeDescription
positionnumberThe new position for the guild channel
options?SetChannelPositionOptionsOptions for setting position

Returns: Promise<GuildChannel>

js
// Set a new channel position
channel.setPosition(2)
  .then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
  .catch(console.error);

Source

clone

clone(options?: GuildChannelCloneOptions): Promise<GuildChannel>

Clones this channel. Parameters

NameTypeDescription
options?GuildChannelCloneOptionsThe options for cloning this channel

Returns: Promise<GuildChannel>Source

equals

equals(channel: GuildChannel): boolean

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

NameTypeDescription
channelGuildChannelChannel to compare with

Returns: booleanSource

delete

async

async delete(reason?: string): Promise<GuildChannel>

Deletes this channel. Parameters

NameTypeDescription
reason?stringReason for deleting this channel

Returns: Promise<GuildChannel>

js
// Delete the channel
channel.delete('making room for new channels')
  .then(console.log)
  .catch(console.error);

Source

toString

toString(): string

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

js
// Logs: Hello from <#123456789012345678>!
console.log(`Hello from ${channel}!`);

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.