ThreadChannel class

The ThreadChannel class extends the Zyno Bot Addons BaseChannel class.

const threadChannel = new ThreadChannel(data: ThreadChannel, addon: Addon, guild: Guild);

constructor

The ThreadChannel class provides three required arguments. The first is a Discord.js channel which is an instance of the ThreadChannel 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 thread channel.

guild

An instance of the Guild class which represents the Discord server the thread channel belongs to.

addon

An instance of the Addon class which defines the addon where the ThreadChannel 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>

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 NodeJS built-in Date class which defines the time when the channel was created.

createdTimestamp

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

threadArchived

A boolean which defines whether the thread has been archived or not.

archived

An instance of the NodeJS built-in Date class which represents the time when the thread was archived. When the thread channel has not been archived, this will return a value of null.

archivedTimestamp

A number which represents the timestamp of the time when the thread channel was archived. When the thread channel has not been archived, this will return a value of null.

autoArchive

The amount of milliseconds after the thread channel automatically gets archived after inactivity.

memberCount

The amount of members active in the thread channel.

members

An instance of the Save class which returns the members who are active in the thread channel. (Save<userId, Member>)

editable

A boolean which defines whether the bot is able to edit the thread channel or not. (name, archived, autoArchive)

locked

A boolean which defines whether the thread channel has been locked or not.

sendable

A boolean which defines whether the bot can send a message in the thread channel or not.

viewable

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

manageable

A boolean which defines whether the bot can manage the thread channel or not. (delete, slowMode, locked)

threadJoined

A boolean which defines whether the bot has joined the thread channel or not.

threadJoinable

A boolean which defines whether the thread channel is joinable or not for the bot.

slowMode

The amount of milliseconds a member has to wait before sending another message after sending a message.

parentId

The id of the channel the thread channel was created for.

parent

The channel the thread channel was created for. (An instance of the TextChannel class or ForumChannel class)

owner

An instance of the Member class which represents the creator of the thread channel.

string

Returns the channel mention as a string.

url

The url of the channel.

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;
}

isArchived

threadChannel.isArchived() : boolean;

Returns a boolean which defines whether the thread channel has been archived or not.

delete

threadChannel.delete() : Promise<void>;

Deletes the thread channel and returns a Promise which gets fulfilled once the thread channel has been deleted.

setName

threadChannel.setName(name: string, reason?: string) : Promise<ThreadChannel>;

Changes the name of the thread channel. The function returns a Promise which returns an instance of the ThreadChannel class with the updated data once the name has been updated..

ArgumentDescription

name

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

reason

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

deleteMessages

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

Deletes an amount of messages in the thread channel. The function returns a Promise which returns an instance of the ThreadChannel 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.

join

threadChannel.join() : Promise<ThreadChannel>;

Joins the thread channel if the bot hasn't joined the thread channel yet. The function returns a Promise which returns an instance of the ThreadChannel class once the bot has joined the thread channel.

leave

threadChannel.leave() : Promise<ThreadChannel>;

Leaves the thread channel if the bot has joined the thread channel before. The functionr returns a Promise which returns an instance of the ThreadChannel class once the bot has left the thread channel.

pin

threadChannel.pin(reason?: string) : Promise<ThreadChannel>;

Pins the thread channel at the top of the forum channel. The function returns a Promise which returns an instance of the ThreadChannel class once the channel has been pinned at the top of the forum channel.

This function only works when the parent is a forum channel. This function does not work when the parent is a text channel.

ArgumentDescription

reason

The reason to pin the thread channel. This must be a string between 1-512 characters, but is not required.

unpin

threadChannel.unpin(reason?: string) : Promise<ThreadChannel>;

Unpins the thread channel from the top of the forum channel if the thread channel was pinned at the top of the forum channel before. The function returns a Promise which returns an instance of the ThreadChannel class once the channel has been unpinned from the top of the forum channel.

This function only works when the parent is a forum channel. This function does not work when the parent is a text channel.

ArgumentDescription

reason

The reason to unpin the thread channel. This must be a string between 1-512 characters, but is not required.

send

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

Send a message in the thread 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

threadChannel.update() : Promise<ThreadChannel>;

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

getMessage

threadChannel.getMessage(messageId: string) : Promise<Message>;

Gets a message which was sent in this channel. The function returns a Promise which returns an instance of the Message class when the message was received from the Discord API.

ArgumentDescription

messageId

The id of the message you want to receive.

setArchived

threadChannel.setArchived(archived?: boolean, reason?: string) : Promise<ThreadChannel>;

Archives or unarchives the thread channel. The function returns a Promise which returns an instance of the ThreadChannel class with the updated data once the archived status of the thread channel has been updated.

ArgumentDescription

archived

A boolean which defines whether the thread channel should be archived or not. When this argument is not provided, the thread channel will get the opposite archive status of what it currently has.

reason

The reason to archive or unarchive the thread channel. This must be a string between 1-512 characters, but is not required.

setAutoArchive

threadChannel.setAutoArchive(dateResolvable: Date | string | number, reason?: string) : Promise<ThreadChannel>;

Changes the auto archive duration of the thread channel. The function returns a Promise which returns an instance of the ThreadChannel class with the updated data once the auto archive duration has been updated.

ArgumentDescription

dateResolvable

The time it takes before the thread channel automatically archives. 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 auto archive duration or a string which defines the time like 1 hour. The duration must be an hour, a day, 3 days or a week.

reason

The reason to change the auto archive duration of the thread channel. This must be a string between 1-512 characters, but is not required.

setLocked

threadChannel.setLocked(locked?: boolean, reason?: string) : Promise<ThreadChannel>;

Locks or unlocks the thread channel. The function returns a Promise which returns an instance of the ThreadChannel class with the updated data once the locked status of the thread channel has been updated. Once a thread channel is locked, it automatically archives and only moderators can unarchive it.

ArgumentDescription

locked

A boolean which defines whether the thread channel should be locked or not. When this argument is not provided, the thread channel will get the opposite locked status of what it currently has.

reason

The reason to lock or unlock the thread channel. This must be a string between 1-512 characters, but is not required.

setSlowMode

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

Changes the slow mode for the channel. The function returns a Promise which returns the ThreadChannel class once the slow mode duration has been changed.

ArgumentDescription

dateResolvable

The time the users have to wait before they can send another message after sending a message in the thread 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.

reason

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

edit

threadChannel.edit(options: object) : Promise<ThreadChannel>;

Edits the settings of the thread channel. The function returns a Promise which returns an instance of the ThreadChannel class once the changes have been made.

ArgumentDescription

options

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

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

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

  • reason: The reason you want to change the thread 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 thread 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.

  • autoArchiveThreads: The time it takes before the thread channel automatically archives. 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 auto archive duration or a string which defines the time like 1 hour. The duration must be an hour, a day, 3 days or a week.

  • archived: A boolean which defines whether the thread channel should be archived or not.

  • locked: A boolean which defines whether the thread channel should be locked or not.

Last updated