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:

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..

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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