TextChannel class
The TextChannel class extends the Zyno Bot Addons GuildChannel class.
constructor
The TextChannel class provides three required arguments. The first is a Discord.js channel which is an instance of the TextChannel 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.
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 TextChannnel 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>
topic
The topic of the channel which is visible next to the channel's name at the top of the Discord client.
autoArchiveThreads
The time it takes before automatically archiving a thread channel of the text channel after inactivity in milliseconds.
threads
An instance of the Save class which provides the thread channels which were created in this text channel. (Save<channelId, ThreadChannel>)
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:
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
Returns a boolean which defines whether the channel is a text channel or not (GuildText
or GuildAnnouncement
).
isVoiceChannel
Returns a boolean which defines whether the channel is a voice channel or not (GuildVoice
).
isVoiceStage
Returns a boolean which defines whether the channel is a voice stage channel or not (GuildVoiceStage
)
isDM
Returns a boolean which defines whether the channel is a DM channel or not (DM
).
isThread
Returns a boolean which defines whether the channel is a thread channel or no t(PublicThread
, PrivateThread
, AnnouncementThread
).
isTicket
Returns a boolean which defines whether the channel is an open ticket of a user or not.
getTicketOwner
Returns a Member class of the member who opened the ticket. If the channel is not a ticket, the function will return undefined
.
getTicketInfo
Returns an object with information of the open ticket. If the channel is not a ticket, the function will return undefined
.
setNSFW
Changes the nsfw status of the channel.
delete
Deletes the channel. The function returns a Promise
which will return a void
once it's fulfilled.
setName
Changes the name of the channel. The function returns a Promise
which returns the GuildChannel class once it's fulfilled.
setPosition
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.
setParent
Changes the category the channel is in. The function returns a Promise
which returns the GuildChannel class once it's fulfilled.
lockPermissions
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
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.
setSlowMode
Changes the slow mode for the channel. The function returns a Promise
which returns the GuildChannel class once it's fulfilled.
createInvite
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.
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 rolemaxAge
: A number which defines the amount of milliseconds the invite is valid. Use0
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. Use0
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 thetargetUser
.)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 thetargetApplication
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
orEmbeddedApplication
)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.
setTopic
Changes the topic of the text channel. The function returns a Promise
which returns an instance of the TextChannel class with the updated data once the text channel has been updated.
send
Send a message in the text 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 uploadattachment
: The path of the file you want to uploaddescription
: The description of the file
update
Updates the text channel in case changes have been made to it. The function returns a Promise
which returns an instance of the TextChannel class with the updated data of the text channel.
getMessage
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.
deleteMessages
Deletes an amount of messages in the text channel. The function returns a Promise
which returns an instance of the TextChannel class once the messages have been deleted. The messages may not be older than 14 days.
edit
Changes the settings of the text channel. The function returns a Promise
which returns an instance of the TextChannel class with the updated data 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 text channel. The name must be a string between 1-100 characters.reason
: The reason you want to change the text 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 text 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 like1 hour
.autoArchiveThreads
: The time it takes before thread channels created in the text channel automatically archive after inactivity. 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 like1 hour
. The duration must be an hour, a day, 3 days or a week.position
: The new position you want to give to the text channel. This must be a number where0
is the highest position.topic
: A string between 0-1024 characters which represents the new topic which you'd like to give to the text channel.nsfw
: A boolean which defines whether the text channel should be marked as nsfw or not.parent
: The category where the text 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.permissions
: An array which includes JSON objects. Every object should have a key namedid
where the value is the id of the role or member the permissions apply to. Every object should either have a key namedallow
ordeny
(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 atype
key where the value ismember
,user
orrole
which represents whether theid
belongs to a member/user or a role.
createThread
Creates a thread channel inside the text channel. The function returns a Promise
which returns the ThreadChannel class which represents the created thread channel once the thread channel has been created.
The object of the options may include the following information (everything is optional):
name
: The name you'd like to give to the thread channel. The value must be a string between 1-100 characters.reason
: The reason you'd like to create a thread. This must be a string between 1-512 characters.autoArchiveThread
: The time it takes before thread channel created in the text channel automatically archives after inactivity. 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 like1 hour
. The duration must be an hour, a day, 3 days or a week.slowMode
: The time the users have to wait before they can send another message after sending a message in the new 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 like1 hour
.type
: The type of thread channel you'd like to create. Valid types in this case areannouncement
,public
andprivate
.message
: The message you'd like to link this thread to. This must be an instance of the Message class.
Either the name
or message
key of the object must be provided. When the name
isn't provided, it will use a part of the content of the message as the name of the thread channel. If there is no content in the message, the name will become the username of the creator of the message.
Last updated