class VoiceChannel
extends
BaseGuildVoiceChannelexport class VoiceChannel extends BaseGuildVoiceChannelRepresents a guild voice channel on Discord.
appPermissions : Readonly<PermissionsBitField> | null
The computed permissions of the application in this channel, including overwrites. This is only present on channels received through an interaction's resolved data, and only when the application's bot user is in the guild.
Inherited from: BaseChannel
readonlycreatedTimestamp : number
The timestamp the channel was created at
Inherited from: GuildChannel
readonlydeletable : boolean
Whether the channel is deletable by the client user
Inherited from: GuildChannel
flags : Readonly<ChannelFlagsBitField>
The flags that are applied to the channel. This is only null in a PartialGroupDMChannel. In all other cases, it is not null.
Inherited from: GuildChannel
readonlyfull : boolean
Checks if the voice-based channel is full
Inherited from: BaseGuildVoiceChannel
readonlyjoinable : boolean
Whether the channel is joinable by the client user
Inherited from: BaseGuildVoiceChannel
readonlyoptionallastMessage? : Message
The Message object of the last message in the channel, if one was sent
Inherited from: BaseGuildVoiceChannel
optionallastMessageId? : Snowflake
The last message id sent in the channel, if one was sent
Inherited from: BaseGuildVoiceChannel
readonlymanageable : boolean
Whether the channel is manageable by the client user
Inherited from: GuildChannel
readonlymembers : Collection<Snowflake, GuildMember>
The members in this voice-based channel
Inherited from: BaseGuildVoiceChannel
messages : GuildMessageManager
A manager of the messages sent to this channel
Inherited from: BaseGuildVoiceChannel
readonlyparent : CategoryChannel | null
The category parent of this channel
Inherited from: GuildChannel
The id of the category parent of this channel
Inherited from: GuildChannel
Whether this Channel is a partial This is always false outside of DM channels.
Inherited from: BaseChannel
permissionOverwrites : PermissionOverwriteManager
A manager of permission overwrites that belong to this channel
Inherited from: GuildChannel
permissions : Readonly<PermissionsBitField> | null
The computed permissions of the user who invoked the interaction in this channel, including overwrites. This is only present on channels received through an interaction's resolved data.
Inherited from: BaseChannel
If the permissionOverwrites match the parent channel, null if no parent
Inherited from: GuildChannel
The rate limit per user (slowmode) for this channel in seconds
Inherited from: BaseGuildVoiceChannel
The RTC region for this voice-based channel. This region is automatically selected if null.
Inherited from: BaseGuildVoiceChannel
readonlyspeakable : boolean
Checks if the client has permission to send audio to the voice channel
type : ChannelType.GuildVoice
The type of the channel
userLimit : number
The maximum amount of users allowed in this channel.
Inherited from: BaseGuildVoiceChannel
videoQualityMode : VideoQualityMode | null
The camera video quality mode of the channel.
Inherited from: BaseGuildVoiceChannel
readonlyviewable : boolean
Whether the channel is viewable by the client user
Inherited from: GuildChannel
awaitMessageComponent(options?: AwaitMessageComponentOptions = {}) : Promise<MessageComponentInteraction>
Collects a single component interaction that passes the filter. The Promise will reject if the time expires.
// Collect a message component interaction
const filter = (interaction) => interaction.customId === 'button' && interaction.user.id === 'someId';
channel.awaitMessageComponent({ filter, time: 15_000 })
.then(interaction => console.log(`${interaction.customId} was clicked!`))
.catch(console.error);Inherited from: BaseGuildVoiceChannel
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.
// 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.`));Inherited from: BaseGuildVoiceChannel
bulkDelete(messages: Collection<Snowflake, Message> | Array<MessageResolvable> | numberfilterOld?: boolean = false) : Promise<Array<Snowflake>>
Bulk deletes given messages up to 2 weeks old.
// Bulk delete messages
channel.bulkDelete(5)
.then(messages => console.log(`Bulk deleted ${messages.length} messages`))
.catch(console.error);Returns: Returns the deleted messages ids *
Inherited from: BaseGuildVoiceChannel
clone(options?: GuildChannelCloneOptions) : Promise<this>
Clones this channel.
Inherited from: GuildChannel
createInvite(options?: InviteCreateOptions = {}) : Promise<GuildInvite>
Creates an invite to this guild channel.
// Create an invite to a channel
channel.createInvite()
.then(invite => console.log(`Created an invite with a code of ${invite.code}`))
.catch(console.error);Inherited from: BaseGuildVoiceChannel
createMessageCollector(options?: MessageCollectorOptions = {}) : MessageCollector
Creates a Message Collector.
// Create a message collector
const filter = message => message.content.includes('discord');
const collector = channel.createMessageCollector({ filter, time: 15_000 });
collector.on('collect', message => console.log(`Collected ${message.content}`));
collector.on('end', collected => console.log(`Collected ${collected.size} items`));Inherited from: BaseGuildVoiceChannel
createMessageComponentCollector(options?: MessageComponentCollectorOptions = {}) : InteractionCollector
Creates a component interaction collector.
// Create a button interaction collector
const filter = (interaction) => interaction.customId === 'button' && interaction.user.id === 'someId';
const collector = channel.createMessageComponentCollector({ filter, time: 15_000 });
collector.on('collect', interaction => console.log(`Collected ${interaction.customId}`));
collector.on('end', collected => console.log(`Collected ${collected.size} items`));Inherited from: BaseGuildVoiceChannel
createWebhook(options?: ChannelWebhookCreateOptions) : Promise<Webhook>
Creates a webhook for the channel.
// Create a webhook for the current channel
channel.createWebhook({
name: 'Snek',
avatar: 'https://i.imgur.com/mI8XcpG.jpg',
reason: 'Needed a cool new Webhook'
})
.then(console.log)
.catch(console.error)Returns: Returns the created Webhook *
Inherited from: BaseGuildVoiceChannel
Deletes this channel.
// Delete the channel
channel.delete('making room for new channels')
.then(console.log)
.catch(console.error);Inherited from: GuildChannel
edit(options: GuildChannelEditOptions) : Promise<this>
Edits the channel.
// Edit a channel
channel.edit({ name: 'new-channel' })
.then(console.log)
.catch(console.error);Inherited from: GuildChannel
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.
Inherited from: GuildChannel
fetchInvites(cache?: boolean = true) : Promise<Collection<string, GuildInvite>>
Fetches a collection of invites to this guild channel.
Inherited from: BaseGuildVoiceChannel
fetchWebhooks() : Promise<Collection<Snowflake, Webhook>>
Fetches all webhooks for the channel.
// Fetch webhooks
channel.fetchWebhooks()
.then(hooks => console.log(`This channel has ${hooks.size} hooks`))
.catch(console.error);Inherited from: BaseGuildVoiceChannel
isDMBased() : this is DMChannel | PartialDMChannel | PartialGroupDMChannel
Indicates whether this channel is DM-based (either a DMChannel or a PartialGroupDMChannel).
Inherited from: BaseChannel
isSendable() : this is SendableChannels
Indicates whether this channel is sendable.
Inherited from: BaseChannel
isTextBased() : this is GuildBasedChannel & TextBasedChannel
Indicates whether this channel is text-based.
Inherited from: GuildChannel
isThread() : this is AnyThreadChannel
Indicates whether this channel is a ThreadChannel.
Inherited from: BaseChannel
isThreadOnly() : this is ThreadOnlyChannel
Indicates whether this channel is thread-only.
Inherited from: BaseChannel
isVoiceBased() : this is VoiceBasedChannel
Indicates whether this channel is voice-based.
Inherited from: BaseChannel
lockPermissions() : Promise<this>
Locks in the permission overwrites from the parent channel.
Inherited from: GuildChannel
permissionsFor(memberOrRole: GuildMember | RolecheckAdmin?: boolean = true) : Readonly<PermissionsBitField>
Gets the overall set of permissions for a member or role in this channel, taking into account channel overwrites.
Sends a message to this channel.
// 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://github.com/discordjs.png']
})
.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);Inherited from: BaseGuildVoiceChannel
Send a soundboard sound to a voice channel the user is connected to.
Sends a typing indicator in the channel.
// Start typing in a channel
channel.sendTyping();Returns: Resolves upon the typing status being sent *
Inherited from: BaseGuildVoiceChannel
setBitrate() : Promise<VoiceChannel>
Sets the bitrate of the channel.
// Set the bitrate of a voice channel
voiceChannel.setBitrate(48_000)
.then(channel => console.log(`Set bitrate to ${channel.bitrate}bps for ${channel.name}`))
.catch(console.error);Sets a new name for the guild channel.
// Set a new channel name
channel.setName('not_general')
.then(newChannel => console.log(`Channel's new name is ${newChannel.name}`))
.catch(console.error);Inherited from: GuildChannel
Sets whether this channel is flagged as NSFW.
Inherited from: BaseGuildVoiceChannel
setParent(channel: CategoryChannelResolvable | nulloptions?: SetParentOptions = {}) : Promise<this>
Sets the parent of this channel.
// Add a parent to a channel
message.channel.setParent('355908108431917066')
.then(channel => console.log(`New parent of ${channel.name}: ${channel.parent.name}`))
.catch(console.error);// Move a channel and sync its permissions with the parent
message.channel.setParent('355908108431917066', { lockPermissions: true })
.then(channel => console.log(`Moved ${message.channel.name} to ${channel.parent.name}`))
.catch(console.error);Inherited from: GuildChannel
setPosition(position: numberoptions?: SetChannelPositionOptions) : Promise<this>
Sets a new position for the guild channel.
// Set a new channel position
channel.setPosition(2)
.then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
.catch(console.error);Inherited from: GuildChannel
Sets the rate limit per user (slowmode) for this channel.
Inherited from: BaseGuildVoiceChannel
setRTCRegion() : Promise<VoiceChannel>
Sets the RTC region of the channel.
// Set the RTC region to sydney
voiceChannel.setRTCRegion('sydney');// Remove a fixed region for this channel - let Discord decide automatically
voiceChannel.setRTCRegion(null, 'We want to let Discord decide.');setUserLimit() : Promise<VoiceChannel>
Sets the user limit of the channel.
// Set the user limit of a voice channel
voiceChannel.setUserLimit(42)
.then(channel => console.log(`Set user limit to ${channel.userLimit} for ${channel.name}`))
.catch(console.error); setVideoQualityMode(videoQualityMode: VideoQualityModereason?: string) : Promise<VoiceChannel>
Sets the camera video quality mode of the channel.
toString() : ChannelMention
When concatenated with a string, this automatically returns the channel's mention instead of the Channel object.
// Logs: Hello from <#123456789012345678>!
console.log(`Hello from ${channel}!`);Inherited from: GuildChannel