ThreadChannel

export class ThreadChannel<ThreadOnly extends boolean = boolean> extends BaseChannel
export class ThreadChannel<ThreadOnly extends boolean = boolean> extends BaseChannel
Represents a thread channel on Discord.
NameConstraintsOptionalDefaultDescription
ThreadOnlybooleanYesbooleanNone
appliedTags:Snowflake[]
The tags applied to this thread
archived:boolean | null
Whether the thread is archived
Readonly
archivedAt:Date | null
The time at which this thread's archive status was last changed If the thread was never archived or unarchived, this is the time at which the thread was created
archiveTimestamp:number | null
The timestamp when the thread's archive status was last changed If the thread was never archived or unarchived, this is the timestamp at which the thread was created
autoArchiveDuration:ThreadAutoArchiveDuration | null
The amount of time (in minutes) after which the thread will automatically archive in case of no recent activity
Readonly
client:Client<true>
The client that instantiated this
Inherited from Base
Readonly
createdAt:Date | null
The time the thread was created at
Readonly
createdTimestamp:number | null
The timestamp when this thread was created. This isn't available for threads created before 2022-01-09
Readonly
editable:boolean
Whether the thread is editable by the client user (name, archived, autoArchiveDuration)
The flags that are applied to the channel. This is only null in a PartialGroupDMChannel. In all other cases, it is not null.
guild:Guild
The guild the thread is in
guildId:Snowflake
The id of the guild the channel is in
Readonly
A collection of associated guild member objects of this thread's members
The channel's id
Inherited from BaseChannel
invitable:boolean | null
Whether members without the PermissionFlagsBits.ManageThreads permission can invite other members to this thread. This property is always null in public threads.
Readonly
joinable:boolean
Whether the thread is joinable by the client user
Readonly
joined:boolean
Whether the client user is a member of the thread.
Readonly
lastMessage?:Message
The Message object of the last message in the channel, if one was sent
lastMessageId?:Snowflake
The last message id sent in this thread, if one was sent
Readonly
lastPinAt?:Date
The date when the last pinned message was pinned, if there was one
lastPinTimestamp?:number
The timestamp when the last pinned message was pinned, if there was one
locked:boolean | null
Whether the thread is locked
Readonly
manageable:boolean
Whether the thread is manageable by the client user, for deleting or editing rateLimitPerUser or locked.
memberCount:number | null
The approximate count of users in this thread This stops counting at 50. If you need an approximate value higher than that, use ThreadChannel#members.cache.size
A manager of the members that are part of this thread
messageCount:number | null
The approximate count of messages in this thread Threads created before July 1, 2022 may have an inaccurate count. If you need an approximate value higher than that, use ThreadChannel#messages.cache.size
A manager of the messages sent to this thread
name:string
The name of the thread
ownerId:Snowflake | null
The id of the member who created this thread
Readonly
The parent channel of this thread
parentId:Snowflake | null
The id of the parent channel of this thread
Readonly
partial:false
Whether this Channel is a partial This is always false outside of DM channels.
Inherited from BaseChannel
rateLimitPerUser:number | null
The rate limit per user (slowmode) for this thread in seconds
Readonly
sendable:boolean
Whether the client user can send messages in this thread
totalMessageSent:number | null
The number of messages ever sent in a thread, similar to except it will not decrement whenever a message is deleted
The type of the channel
Readonly
unarchivable:boolean
Whether the thread is unarchivable by the client user
Readonly
url:string
The URL to the channel
Inherited from BaseChannel
Readonly
viewable:boolean
Whether the thread is viewable by the client user
awaitMessageComponent(options?):Promise<MessageComponentInteraction>
Collects a single component interaction that passes the filter. The Promise will reject if the time expires.
Example
// 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);
// 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);
NameTypeOptionalDescription
optionsAwaitMessageComponentOptionsYesOptions to pass to the internal collector
awaitMessages(options?):Promise<Collection<Snowflake, Message>>
Similar to createMessageCollector but in promise form. Resolves with a collection of messages that pass the specified filter.
Example
// 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.`));
// 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.`));
NameTypeOptionalDescription
optionsAwaitMessagesOptionsYesOptional options to pass to the internal collector
bulkDelete(messages, filterOld?):Promise<Collection<Snowflake, (Message|undefined)>>
Bulk deletes given messages that are newer than two weeks.
Returns
Returns the deleted messages *
Example
// Bulk delete messages
channel.bulkDelete(5)
.then(messages => console.log(`Bulk deleted ${messages.size} messages`))
.catch(console.error);
// Bulk delete messages
channel.bulkDelete(5)
.then(messages => console.log(`Bulk deleted ${messages.size} messages`))
.catch(console.error);
NameTypeOptionalDescription
messagesCollection<Snowflake, Message> | Array<MessageResolvable> | numberNoMessages or number of messages to delete
filterOldbooleanYesFilter messages to remove those which are older than two weeks automatically
createMessageCollector(options?):MessageCollector
Creates a Message Collector.
Example
// 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`));
// 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`));
NameTypeOptionalDescription
optionsMessageCollectorOptionsYesThe options to pass to the collector
createMessageComponentCollector(options?):InteractionCollector
Creates a component interaction collector.
Example
// 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`));
// 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`));
NameTypeOptionalDescription
optionsMessageComponentCollectorOptionsYesOptions to send to the collector
delete(reason?):Promise<this>
Deletes this thread.
Example
// Delete the thread
thread.delete('cleaning out old threads')
.then(deletedThread => console.log(deletedThread))
.catch(console.error);
// Delete the thread
thread.delete('cleaning out old threads')
.then(deletedThread => console.log(deletedThread))
.catch(console.error);
NameTypeOptionalDescription
reasonstringYesReason for deleting this thread
edit(options):Promise<this>
Edits this thread.
Example
// Edit a thread
thread.edit({ name: 'new-thread' })
.then(editedThread => console.log(editedThread))
.catch(console.error);
// Edit a thread
thread.edit({ name: 'new-thread' })
.then(editedThread => console.log(editedThread))
.catch(console.error);
NameTypeOptionalDescription
optionsThreadEditOptionsNoThe options to provide
fetch(force?):Promise<this>
Fetches this channel.
NameTypeOptionalDescription
forcebooleanYesWhether to skip the cache check and request the API
Inherited from BaseChannel
fetchOwner(options?):Promise<ThreadMember | null>
Fetches the owner of this thread. If the thread member object isn't needed, use instead.
NameTypeOptionalDescription
optionsBaseFetchOptionsYesThe options for fetching the member
fetchStarterMessage(options?):Promise<Message<true> | null>
Fetches the message that started this thread, if any. The Promise will reject if the original message in a forum post is deleted or when the original message in the parent channel is deleted. If you just need the id of that message, use id instead.
NameTypeOptionalDescription
optionsBaseFetchOptionsYesAdditional options for this fetch
Indicates whether this channel is DM-based (either a or a PartialGroupDMChannel).
Inherited from BaseChannel
isSendable():this is SendableChannels
Indicates whether this channel is sendable.
Inherited from BaseChannel
isTextBased():this is TextBasedChannel
Indicates whether this channel is text-based.
Inherited from BaseChannel
isThread():this is AnyThreadChannel
Indicates whether this channel is a .
Inherited from BaseChannel
isThreadOnly():this is ThreadOnlyChannel
Indicates whether this channel is .
Inherited from BaseChannel
isVoiceBased():this is VoiceBasedChannel
Indicates whether this channel is .
Inherited from BaseChannel
join():Promise<this>
Makes the client user join the thread.
leave():Promise<this>
Makes the client user leave the thread.
permissionsFor(memberOrRole, checkAdmin?):Readonly<PermissionsBitField>
Gets the overall set of permissions for a member or role in this thread's parent channel, taking overwrites into account.
Returns
NameTypeOptionalDescription
memberOrRoleGuildMember | RoleNoThe member or role to obtain the overall permissions for
checkAdminbooleanYesWhether having the PermissionFlagsBits.Administrator permission will return all permissions
pin(reason?):Promise<If<ThreadOnly, this, never>>
Pins this thread from the forum channel (only applicable to forum threads).
NameTypeOptionalDescription
reasonstringYesReason for pinning
send(options):Promise<Message>
Sends a message to this channel.
Example
// Send a basic message
channel.send('hello!')
.then(message => console.log(`Sent message: ${message.content}`))
.catch(console.error);
// Send a basic message
channel.send('hello!')
.then(message => console.log(`Sent message: ${message.content}`))
.catch(console.error);
Example
// Send a remote file
channel.send({
files: ['https://cdn.discordapp.com/icons/222078108977594368/6e1019b3179d71046e463a75915e7244.png?size=2048']
})
.then(console.log)
.catch(console.error);
// Send a remote file
channel.send({
files: ['https://cdn.discordapp.com/icons/222078108977594368/6e1019b3179d71046e463a75915e7244.png?size=2048']
})
.then(console.log)
.catch(console.error);
Example
// 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);
// 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);
NameTypeOptionalDescription
optionsstring | MessagePayload | MessageCreateOptionsNoThe options to provide
sendTyping():Promise<void>
Sends a typing indicator in the channel.
Returns
Resolves upon the typing status being sent *
Example
// Start typing in a channel
channel.sendTyping();
// Start typing in a channel
channel.sendTyping();
setAppliedTags(appliedTags, reason?):Promise<If<ThreadOnly, this, never>>
Set the applied tags for this channel (only applicable to forum threads)
NameTypeOptionalDescription
appliedTagsreadonly Snowflake[]NoThe tags to set for this channel
reasonstringYesReason for changing the thread's applied tags
setArchived(archived?, reason?):Promise<this>
Sets whether the thread is archived.
Example
// Archive the thread
thread.setArchived(true)
.then(newThread => console.log(`Thread is now ${newThread.archived ? 'archived' : 'active'}`))
.catch(console.error);
// Archive the thread
thread.setArchived(true)
.then(newThread => console.log(`Thread is now ${newThread.archived ? 'archived' : 'active'}`))
.catch(console.error);
NameTypeOptionalDescription
archivedbooleanYesWhether the thread is archived
reasonstringYesReason for archiving or unarchiving
setAutoArchiveDuration(autoArchiveDuration, reason?):Promise<this>
Sets the duration after which the thread will automatically archive in case of no recent activity.
Example
// Set the thread's auto archive time to 1 hour
thread.setAutoArchiveDuration(ThreadAutoArchiveDuration.OneHour)
.then(newThread => {
console.log(`Thread will now archive after ${newThread.autoArchiveDuration} minutes of inactivity`);
});
.catch(console.error);
// Set the thread's auto archive time to 1 hour
thread.setAutoArchiveDuration(ThreadAutoArchiveDuration.OneHour)
.then(newThread => {
console.log(`Thread will now archive after ${newThread.autoArchiveDuration} minutes of inactivity`);
});
.catch(console.error);
NameTypeOptionalDescription
autoArchiveDurationThreadAutoArchiveDurationNoThe amount of time after which the thread should automatically archive in case of no recent activity
reasonstringYesReason for changing the auto archive duration
setInvitable(invitable?, reason?):Promise<this>
Sets whether members without the PermissionFlagsBits.ManageThreads permission can invite other members to this thread.
NameTypeOptionalDescription
invitablebooleanYesWhether non-moderators can invite non-moderators to this thread
reasonstringYesReason for changing invite
setLocked(locked?, reason?):Promise<this>
Sets whether the thread can be **unarchived* * by anyone with the PermissionFlagsBits.SendMessages permission. When a thread is locked, only members with the PermissionFlagsBits.ManageThreads permission can unarchive it.
Example
// Set the thread to locked
thread.setLocked(true)
.then(newThread => console.log(`Thread is now ${newThread.locked ? 'locked' : 'unlocked'}`))
.catch(console.error);
// Set the thread to locked
thread.setLocked(true)
.then(newThread => console.log(`Thread is now ${newThread.locked ? 'locked' : 'unlocked'}`))
.catch(console.error);
NameTypeOptionalDescription
lockedbooleanYesWhether the thread is locked
reasonstringYesReason for locking or unlocking the thread
setName(name, reason?):Promise<this>
Sets a new name for this thread.
Example
// Change the thread's name
thread.setName('not_general')
.then(newThread => console.log(`Thread's new name is ${newThread.name}`))
.catch(console.error);
// Change the thread's name
thread.setName('not_general')
.then(newThread => console.log(`Thread's new name is ${newThread.name}`))
.catch(console.error);
NameTypeOptionalDescription
namestringNoThe new name for the thread
reasonstringYesReason for changing the thread's name
setRateLimitPerUser(rateLimitPerUser, reason?):Promise<ThreadChannel>
Sets the rate limit per user (slowmode) for this thread.
NameTypeOptionalDescription
rateLimitPerUsernumberNoThe new rate limit in seconds
reasonstringYesReason for changing the thread's rate limit
toJSON(...props):unknown
NameTypeOptionalDescription
...propsRecord<string, boolean | string>[]NoNone
Inherited from Base
toString():ChannelMention
When concatenated with a string, this automatically returns the channel's mention instead of the Channel object.
Example
// Logs: Hello from <#123456789012345678>!
console.log(`Hello from ${channel}!`);
// Logs: Hello from <#123456789012345678>!
console.log(`Hello from ${channel}!`);
unpin(reason?):Promise<If<ThreadOnly, this, never>>
Unpins this thread from the forum channel (only applicable to forum threads).
NameTypeOptionalDescription
reasonstringYesReason for unpinning
valueOf():string