VoiceChannel class

The VoiceChannel class extends the Zyno Bot Addons GuildChannel class.

const voiceChannel = new VoiceChannel(data: VoiceChannel, addon: Addon, guild: Guild);

constructor

The VoiceChannel class provides three required arguments. The first is a Discord.js channel which is an instance of the VoiceChannel class. The second argument is the addon where to create the channel for and has to be an instance of the Addon class. The third argument is the guild where the channel is located in and is an instance of the Guild class.

Properties

id

The id of the channel and is a Twitter snowflake.

name

The name of the channel.

joinable

A boolean which defines whether the bot is allowed to join the voice channel or not.

full

A boolean which defines whether the voice channel is full or not.

rtcRegion

The voice region the channel is set to.

bitrate

The quality of the voice channel in kbps.

userLimit

The amount of users which are allowed to join the voice channel.

videoQuality

The video quality which is set to this voice channel. This can either be Full or Auto.

members

An instance of the Save class which provides the members who are currently in the voice channel. (Save<userId, Member>)

guild

The guild where the channel is located in and is an instance of the Guild class.

guildId

The id of the guild where the channel is located in.

addon

An instance of the Addon class which defines the addon where the VoiceChannel class was created for.

messages

An instance of the Save class which provides all the cached messages that have been sent in this channel.

Save<messageId, Message>

manageable

A boolean which defines whether the bot is able to make changes to the channel or not.

position

A number which defines the position compared to the other channels in the same category (CategoryChannel class) where 0 is the highest position.

deletable

A boolean which defines whether the bot can delete the channel or not.

parent

The CategoryChannel class where the channel is placed in, if the channel is a child of a category channel. If not, this will result in null.

parentId

The id of the category channel where the channel is placed in, if the channel is a child of a category channel. If not, this will result in null.

permissionsLocked

A boolean which defines whether the permissions in the channel are synced with the parent (the category channel where the channel is placed in) or not.

slowMode

The time in miliseconds of the slow mode in the channel. If there isn't set a slow mode, this will result in 0.

nsfw

A boolean which defines whether the channel is a nsfw channel or not.

permissions

A save with the permissions for the members or roles in this channel where the key is the id of the member or role and the value the Permissions class which defines the permissions of the member or role.

type

A string which provides the type of the channel. In the table below is mentioned which types are available:

TypeDescription

GuildText

A default Discord text channel where everyone with a certain permission is allowed to communicate with each other.

DM

A Discord DM channel which only communicates between the bot and a specific user.

GuildVoice

A default Discord voice channel where everyone with a certain permission can call with each other.

GroupDM

A Discord DM channel which communicates with a specific set of people. This is not supported for bots.

GuildCategory

A category channel where channels can be organized in.

GuildAnnouncement

An announcement text channel in which server announcements are sent and users can follow and crosspost into their own guild.

AnnouncementThread

A Discord thread channel which only can be created in announcement channels.

PublicThread

A Discord thread channel where everyone who has access to the parent channel can communicate in.

PrivateThread

A Discord thread channel where only a specific set of people has access to unlike the PublicThread channel.

GuildStageVoice

A Discord voice channel where only a specific set of people can talk and the other participants can only listen to what's being told by the hosters.

GuildDirectory

A channel in a Student Hub which contains a list of servers.

GuildForum

A Discord channel where posts can be created and only can be communicated in the posts.

created

An instance of the default Date class which defines the time when the channel was created.

createdTimestamp

A number which represents the timestamp of when the channel was created.

string

Returns the channel mention as a string.

url

The url of the channel.

viewable

A boolean which defines whether the bot is able to view the channel or not.

Functions

isTextChannel

baseChannel.isTextChannel() : boolean;

Returns a boolean which defines whether the channel is a text channel or not (GuildText or GuildAnnouncement).

isVoiceChannel

baseChannel.isVoiceChannel() : boolean;

Returns a boolean which defines whether the channel is a voice channel or not (GuildVoice).

isVoiceStage

baseChannel.isVoiceStage() : boolean;

Returns a boolean which defines whether the channel is a voice stage channel or not (GuildVoiceStage)

isDM

baseChannel.isDM() : boolean;

Returns a boolean which defines whether the channel is a DM channel or not (DM).

isThread

baseChannel.isThread() : boolean;

Returns a boolean which defines whether the channel is a thread channel or no t(PublicThread, PrivateThread, AnnouncementThread).

isTicket

baseChannel.isTicket() : boolean;

Returns a boolean which defines whether the channel is an open ticket of a user or not.

getTicketOwner

baseChannel.getTicketOwner() : Member | undefined;

Returns a Member class of the member who opened the ticket. If the channel is not a ticket, the function will return undefined.

getTicketInfo

baseChannel.getTicketInfo() : object | undefined;

Returns an object with information of the open ticket. If the channel is not a ticket, the function will return undefined.

{
    channelId: string;
    claimed?: boolean; // Works for tickets created since Zyno Bot version 1.5.0
    category?: string; // Works for tickets created since Zyno Bot version 1.5.0
    owner?: Member; // Almost certainly defined
    closed: boolean;
}

setNSFW

guildChannel.setNSFW(nsfw?: boolean, reason?: string) : Promise<GuildChannel>;

Changes the nsfw status of the channel.

ArgumentDescription

nsfw

A boolean which defines whether the channel should be marked as nsfw or not. By not providing the boolean, it will change it to the status it currently doesn't have.

reason

The reason to change the nsfw status. This must be a string between 1-512 characters, but is not required.

delete

guildChannel.delete() : Promise<void>;

Deletes the channel. The function returns a Promise which will return a void once it's fulfilled.

setName

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

Changes the name of the channel. The function returns a Promise which returns the GuildChannel class once it's fulfilled.

ArgumentDescription

name

The new name you want to give to the channel. This must be a string between 1-100 characters.

reason

The reason you want to change the channel's name. This must be a string between 1-512 characters, but is not required.

setPosition

guildChannel.setPosition(position: number, reason?: string) : Promise<GuildChannel>;

Changes the position of the channel comparing to other channels in the same category. The function returns a Promise which returns the GuildChannel class once it's fulfilled.

ArgumentDescription

position

The new position you want to give to the channel. This must be a number where 0 is the highest position.

reason

The reason you want to change the channel's position. This must be a string between 1-512 characters, but is not required.

setParent

guildChannel.setParent(parent: CategoryChannel | string, reason?: string) : Promise<GuildChannel>;

Changes the category the channel is in. The function returns a Promise which returns the GuildChannel class once it's fulfilled.

ArgumentDescription

parent

The category where the channel should be placed in. This may be the id of the category channel or an instance of the CategoryChannel class where the channel should be placed in.

reason

The reason you want to change the channel's parent. This must be a string between 1-512 characters, but is not required.

lockPermissions

guildChannel.lockPermissions() : Promise<GuildChannel>;

Syncs the permissions of the category where the channel is placed in with the channel. The function returns a Promise which returns the GuildChannel class once it's fulfilled.

permissionsFor

guildChannel.permissionsFor(resolvableMemberOrRole: User | Member | Role | string) : PermissionsBitField;

Gets the permissions for a member or role in the channel. The function returns the Discord.js PermissionsBitField class which includes the permissions the member or role has.

ArgumentDescription

resolvableMemberOrRole

The member or role you want to get the permissions of for the channel. This must be an instance of the User class, Member class, Role class or a string which defines the id of the member or role.

setSlowMode

guildChannel.setSlowMode(dateResolvable: string | Date | number, reason?: string) : Promise<GuildChannel>;

Changes the slow mode for the channel. The function returns a Promise which returns the GuildChannel class once it's fulfilled.

ArgumentDescription

dateResolvable

The time the users have to wait before they can send another message after sending a message. This must be a number which defines the time in miliseconds, an instance of the Date class where the timestamp gets substracted of the current timestamp and the difference is used as the slow mode time or a string which defines the time like 1 hour.

reason

The reason you want to change the channel's slow mode. This must be a string between 1-512 characters, but is not required.

createInvite

guildChannel.createInvite(options: object) : Promise<Invite>;

Creates a new invite for this channel with settings based on the information provided in the options argument. The function returns a Promise which returns an instance of the Invite class once it has been fulfilled.

ArgumentDescription

options

An object with the information where the settings of the invite should be based on.

The options object may contain the following information:

  • temporary: A boolean which defines whether members that joined via the invite should be automatically kicked after 24 hours if they have not yet received a role

  • maxAge: A number which defines the amount of milliseconds the invite is valid. Use 0 if you want the invite to last forever.

  • maxUses: A number which defines how many times the invite may be used before it automatically should be removed. Use 0 if you want no limit of uses.

  • unique: A boolean which defines whether the bot should forcebly create a new invite with these settings or may also use an existing invite with the same settings.

  • targetUser: Whose stream users should automatically watch when they use the invite. (A user must be streaming in a voice channel. Members using this invite will automatically view the stream when they join the server of this user when this user is the targetUser.)

  • targetApplication: Which embedded application should be opened when a member joins a server. (An application such as YouTube Together is being played in a voice channel. Members will automatically join this application activity when the targetApplication has been set to the id of this application.) (The id of the application)

  • targetType: The type of target for a voice channel invite (Stream, Application or EmbeddedApplication)

  • reason: The reason you want to create a new invite for this channel. This must be a string between 1-512 characters, but is not required.

send

voiceChannel.send(...content: [string, Embed, ActionRowBuilder, ButtonBuilder, SelectMenuBuilder, object]) : Promise<Message>;

Send a message in the voice channel. The function returns a Promise which returns an instance of the Message class once the message has been sent.

ArgumentDescription

content

The content of the message the bot should send. The content must be a string, an Embed class, the ActionRowBuilder class, the ButtonBuilder class, the SelectMenuBuilder class or an object which provides the message its content.

The object of the message may contain the following information:

  • content: A string of the content of the message.

  • embeds: An array with the Embed class.

  • files: An array with a string which represents a file url or an object when uploading a file.

  • components: An array with the Discord.js ActionRowBuilder class.

The file object data may contain the following information:

  • name: The name of the file you want to upload

  • attachment: The path of the file you want to upload

  • description: The description of the file

update

voiceChannel.update() : Promise<VoiceChannel>;

Updates the voice channel in case changes have been made to it. The function returns a Promise which returns an instance of the VoiceChannel class with the updated data of the text channel.

deleteMessages

voiceChannel.deleteMessages(amount: number, filter: (Message) => boolean) : Promise<VoiceChannel>;

Deletes an amount of messages in the voice channel. The function returns a Promise which returns an instance of the VoiceChannel class once the messages have been deleted. The messages may not be older than 14 days.

ArgumentDescription

amount

The amount of messages you'd like to delete. The messages may not be older than 14 days. The maximum is 100 messages per time and the minimum is 1 message.

filter

A function with one parameter, an instance of the Message class, which is used to filter messages which should be deleted in the deleteMessages function. The function must return a boolean.

setRtcRegion

voiceChannel.setRtcRegion(region: string, reason?: string) : Promise<VoiceChannel>;

Changes the voice region of the voice channel. The function returns a Promise which returns an instance of the VoiceChannel class once the voice region has been changed.

ArgumentDescription

region

The region you want to change the voice region of the voice channel to. The regions you can use hasn't been specified by the Discord API docs, but can be found by using it's endpoint according to the docs (more info).

reason

The reason you want to change the channel's rtc region. This must be a string between 1-512 characters, but is not required.

setUserLimit

voiceChannel.setUserLimit(limit: number, reason?: string) : Promise<VoiceChannel>;

Changes the amount of users which are allowed to join the voice channel. The function returns a Promise which returns an instance of the VoiceChannel class once the user limit has been changed.

ArgumentDescription

limit

A number which represents the amount of users which are allowed to join the voice channel.

reason

The reason you want to change the channel's user limit. This must be a string between 1-512 characters, but is not required.

setVideoQuality

voiceChannel.setVideoQuality(qualityMode: string | number, reason?: string) : Promise<VoiceChannel>;

Changes the default video quality mode in the voice channel. The function returns a Promise which returns an instance of the VoiceChannel class once the video quality mode has been changed.

ArgumentDescription

qualityMode

A string which is either Full or Auto or a number which represents one of these above mentioned options. 1 represents Auto and 2 represents Full.

reason

The reason you want to change the channel's video quality. This must be a string between 1-512 characters, but is not required.

setBitrate

voiceChannel.setBitrate(bitrate: number, reason?: string) : Promise<VoiceChannel>;

Changes the bitrate voice quality of the voice chanel. The function returns a Promise which returns an instance of the VoiceChannel class once the bitrate has been changed.

ArgumentDescription

bitrate

A number which represents the voice quality in kbps.

reason

The reason you want to change the channel's bitrate. This must be a string between 1-512 characters, but is not required.

edit

voiceChannel.edit(options: object) : Promise<VoiceChannel>;

Changes the settings of the voice channel. The function returns a Promise which returns an instance of the VoiceChannel class with the updated data once the changes have been made.

ArgumentDescription

options

An object with the things you'd like to change to this channel.

The object of the options may include the following information (everything is optional):

  • name: The new name you would like to give the voice channel. The name must be a string between 1-100 characters.

  • reason: The reason you want to change the voice channel. This must be a string between 1-512 characters.

  • slowMode: The time the users have to wait before they can send another message after sending a message in the voice channel. This must be a number which defines the time in miliseconds, an instance of the Date class where the timestamp gets substracted of the current timestamp and the difference is used as the slow mode time or a string which defines the time like 1 hour.

  • position: The new position you want to give to the voice channel. This must be a number where 0 is the highest position.

  • nsfw: A boolean which defines whether the voice channel should be marked as nsfw or not.

  • parent: The category where the voice channel should be placed in. This may be the id of the category channel or an instance of the CategoryChannel class where the channel should be placed in.

  • bitrate: A number which represents the voice quality in kbps.

  • userLimit: A number which represents the amount of users which are allowed to join the voice channel.

  • videoQuality: A string which is either Full or Auto or a number which represents one of these above mentioned options. 1 represents Auto and 2 represents Full.

  • rtcRegion: The region you want to change the voice region of the voice channel to. The regions you can use hasn't been specified by the Discord API docs, but can be found by using it's endpoint according to the docs (more info).

  • permissions: An array which includes JSON objects. Every object should have a key named id where the value is the id of the role or member the permissions apply to. Every object should either have a key named allow or deny (both are also allowed) where the value is an array with the permissions as bigints the member or role should or shouldn't have (you can also use the permissionsBitfield object instead of writing the bigints). It is optional to add a type key where the value is member , user or role which represents whether the id belongs to a member/user or a role.

playSong

voiceChannel.playSong(stream: string) : Promise<void>;

Makes the bot join the voice channel and play a song in it. The function returns a Promise which gets fulfilled once the bot starts playing the song or has added the song in the queue.

ArgumentDescription

stream

The stream the bot should play. This must be a url. YouTube url's can also be used to play.

disconnect

voiceChannel.disconnect() : Promise<void>;

Makes the bot disconnect from the voice channel if it is playing in the voice channel. The function returns a Promise which gets fulfilled once the bot has left the voice channel.

getQueue

voiceChannel.getQueue() : Promise<[{title: string | null, url: string | Stream.Readable}]>;

Gets the queue for the voice channel if the bot is playing in the voice channel. The function returns a Promise which returns an array with the data of the songs which are in the queue once the addons module has received the information.

skipSong

voiceChannel.skipSong() : Promise<void>;

Skips the current playing song. The function returns a Promise which gets fulfilled once the bot has skipped the song.

pauseSong

voiceChannel.pauseSong() : Promise<void>;

Pauses the current playing song. The function returns a Promise which gets fulfilled once the bot has paused the song.

resumeSong

voiceChannel.resumeSong() : Promise<void>;

Resumes the current song if it's been paused. The function returns a Promise which gets fulfilled once the bot has resumed the song.

shuffle

voiceChannel.shuffle() : Promise<void>;

Shuffles the queue. The function returns a Promise which gets fulfilled once the queue has been shuffled.

setLoop

voiceChannel.setLoop() : Promise<void>;

Loops the current playing song. The function returns a Promise which gets fulfilled once the loop has been enabled.

setQueueLoop

voiceChannel.setQueueLoop() : Promise<void>;

Loops the complete queue. The function returns a Promise which gets fulfiilled once the queue loop has been enabled.

setUnloop

voiceChannel.setUnloop() : Promise<void>;

Unloops the current playing song or the queue if the loop or queueloop has been enabled. The function returns a Promise which gets fulfilled once the queue or song has been unlooped.

setVolume

voiceChannel.setVolume(volume: number) : Promise<void>;

Changes the volume of the current playing song. The function returns a Promise which gets fulfilled once the volume has been changed.

ArgumentDescription

volume

A number which represents the volume of the song. The volume must be a number between 1-10.

Last updated