Skip to content

ThreadChannel ​

classe · Source

Represents a thread channel on Discord.

Extends: ChannelImplements: TextBasedChannel

Properties ​

guild ​

guild: Guild

The guild the thread is in Source

ownerId ​

ownerId: Snowflake

The id of the member who created this thread Source

guildId ​

guildId: Snowflake

The id of the guild the channel is in Source

messages ​

messages: MessageManager

A manager of the messages sent to this thread Source

members ​

members: ThreadMemberManager

A manager of the members that are part of this thread Source

name ​

name: string

The name of the thread Source

parentId ​

nullable

parentId: Snowflake

The id of the parent channel of this thread Source

locked ​

nullable

locked: boolean

Whether the thread is locked Source

invitable ​

nullable

invitable: boolean

Whether members without MANAGE_THREADS can invite other members without MANAGE_THREADS Always null in public threads Source

archived ​

nullable

archived: boolean

Whether the thread is archived Source

autoArchiveDuration ​

nullable

autoArchiveDuration: number

The amount of time (in minutes) after which the thread will automatically archive in case of no recent activity Source

archiveTimestamp ​

nullable

archiveTimestamp: number

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 Source

lastMessageId ​

nullable

lastMessageId: Snowflake

The last message id sent in this thread, if one was sent Source

lastPinTimestamp ​

nullable

lastPinTimestamp: number

The timestamp when the last pinned message was pinned, if there was one Source

rateLimitPerUser ​

nullable

rateLimitPerUser: number

The rate limit per user (slowmode) for this thread in seconds Source

messageCount ​

nullable

messageCount: number

Threads created before July 1, 2022 may have an inaccurate count. If you need an approximate value higher than that, use ThreadChannel#messages.cache.sizeSource

memberCount ​

nullable

memberCount: number

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

totalMessageSent ​

nullable

totalMessageSent: number

The number of messages ever sent in a thread, similar to ThreadChannel#messageCount except it will not decrement whenever a message is deleted Source

appliedTags ​

appliedTags: Array<Snowflake>

The tags applied to this thread Source

createdTimestamp ​

readonly · nullable

createdTimestamp: number

The timestamp when this thread was created. This isn't available for threads created before 2022-01-09 Source

guildMembers ​

readonly

guildMembers: Collection<Snowflake, GuildMember>

A collection of associated guild member objects of this thread's members Source

archivedAt ​

readonly · nullable

archivedAt: Date

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 Source

createdAt ​

readonly · nullable

createdAt: Date

The time the thread was created at Source

parent ​

readonly · nullable

parent: NewsChannel | TextChannel | ForumChannel | MediaChannel

The parent channel of this thread Source

joined ​

readonly

joined: boolean

Whether the client user is a member of the thread. Source

editable ​

readonly

editable: boolean

Whether the thread is editable by the client user (name, archived, autoArchiveDuration) Source

joinable ​

readonly

joinable: boolean

Whether the thread is joinable by the client user Source

manageable ​

readonly

manageable: boolean

Whether the thread is manageable by the client user, for deleting or editing rateLimitPerUser or locked. Source

viewable ​

readonly

viewable: boolean

Whether the thread is viewable by the client user Source

sendable ​

readonly

sendable: boolean

Whether the client user can send messages in this thread Source

unarchivable ​

readonly

unarchivable: boolean

Whether the thread is unarchivable by the client user Source

lastMessage ​

readonly · nullable

lastMessage: Message

The Message object of the last message in the channel, if one was sent Source

lastPinAt ​

readonly · nullable

lastPinAt: Date

The date when the last pinned message was pinned, if there was one Source

type ​

type: ChannelType

The type of the channel Source

id ​

id: Snowflake

The channel's id Source

flags ​

nullable

flags: Readonly<ChannelFlags>

The flags that are applied to the channel. Source

deleted ​

deprecated

deleted: boolean

Whether or not the structure has been deleted Source

partial ​

readonly

partial: boolean

Whether this Channel is a partial This is always false outside of DM channels. Source

client ​

readonly

client: Client

The client that instantiated this Source

Methods ​

join ​

async

async join(): Promise<ThreadChannel>

Makes the client user join the thread. Returns: Promise<ThreadChannel>Source

leave ​

async

async leave(): Promise<ThreadChannel>

Makes the client user leave the thread. Returns: Promise<ThreadChannel>Source

permissionsFor ​

permissionsFor(memberOrRole: GuildMemberResolvable | RoleResolvable, checkAdmin?: boolean): Readonly<Permissions>

Gets the overall set of permissions for a member or role in this thread's parent channel, taking overwrites into account. Parameters

NameTypeDescription
memberOrRoleGuildMemberResolvable | RoleResolvableThe member or role to obtain the overall permissions for
checkAdmin?booleanWhether having ADMINISTRATOR will return all permissions Default: true.

Returns: Readonly<Permissions>Source

fetchOwner ​

async

async fetchOwner(options?: BaseFetchOptions): Promise<?ThreadMember>

Fetches the owner of this thread. If the thread member object isn't needed, use ThreadChannel#ownerId instead. Parameters

NameTypeDescription
options?BaseFetchOptionsThe options for fetching the member

Returns: Promise<?ThreadMember>Source

fetchStarterMessage ​

async

async fetchStarterMessage(options?: BaseFetchOptions): Promise<(Message|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 ThreadChannel#id instead. Parameters

NameTypeDescription
options?BaseFetchOptionsAdditional options for this fetch

Returns: Promise<(Message\|null)>Source

edit ​

async

async edit(data: ThreadEditData, reason?: string): Promise<ThreadChannel>

Edits this thread. Parameters

NameTypeDescription
dataThreadEditDataThe new data for this thread
reason?stringReason for editing this thread

Returns: Promise<ThreadChannel>

js
// Edit a thread
thread.edit({ name: 'new-thread' })
  .then(editedThread => console.log(editedThread))
  .catch(console.error);

Source

setArchived ​

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

Sets whether the thread is archived. Parameters

NameTypeDescription
archived?booleanWhether the thread is archived Default: true.
reason?stringReason for archiving or unarchiving

Returns: Promise<ThreadChannel>

js
// Archive the thread
thread.setArchived(true)
  .then(newThread => console.log(`Thread is now ${newThread.archived ? 'archived' : 'active'}`))
  .catch(console.error);

Source

setAutoArchiveDuration ​

setAutoArchiveDuration(autoArchiveDuration: ThreadAutoArchiveDuration, reason?: string): Promise<ThreadChannel>

Sets the duration after which the thread will automatically archive in case of no recent activity. Parameters

NameTypeDescription
autoArchiveDurationThreadAutoArchiveDurationThe amount of time (in minutes) after which the thread
should automatically archive in case of no recent activity
reason?stringReason for changing the auto archive duration

Returns: Promise<ThreadChannel>

js
// Set the thread's auto archive time to 1 hour
thread.setAutoArchiveDuration(60)
  .then(newThread => {
    console.log(`Thread will now archive after ${newThread.autoArchiveDuration} minutes of inactivity`);
   });
  .catch(console.error);

Source

setInvitable ​

async

async setInvitable(invitable?: boolean, reason?: string): Promise<ThreadChannel>

Sets whether members without the MANAGE_THREADS permission can invite other members without the MANAGE_THREADS permission to this thread. Parameters

NameTypeDescription
invitable?booleanWhether non-moderators can invite non-moderators to this thread Default: true.
reason?stringReason for changing invite

Returns: Promise<ThreadChannel>Source

setLocked ​

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

Sets whether the thread can be unarchived by anyone with SEND_MESSAGES permission. When a thread is locked only members with MANAGE_THREADS can unarchive it. Parameters

NameTypeDescription
locked?booleanWhether the thread is locked Default: true.
reason?stringReason for locking or unlocking the thread

Returns: Promise<ThreadChannel>

js
// Set the thread to locked
thread.setLocked(true)
  .then(newThread => console.log(`Thread is now ${newThread.locked ? 'locked' : 'unlocked'}`))
  .catch(console.error);

Source

setName ​

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

Sets a new name for this thread. Parameters

NameTypeDescription
namestringThe new name for the thread
reason?stringReason for changing the thread's name

Returns: Promise<ThreadChannel>

js
// Change the thread's name
thread.setName('not_general')
  .then(newThread => console.log(`Thread's new name is ${newThread.name}`))
  .catch(console.error);

Source

setRateLimitPerUser ​

setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise<ThreadChannel>

Sets the rate limit per user (slowmode) for this thread. Parameters

NameTypeDescription
rateLimitPerUsernumberThe new rate limit in seconds
reason?stringReason for changing the thread's rate limit

Returns: Promise<ThreadChannel>Source

pin ​

pin(reason?: string): Promise<ThreadChannel>

Pins this thread from the forum channel. Parameters

NameTypeDescription
reason?stringReason for pinning

Returns: Promise<ThreadChannel>Source

unpin ​

unpin(reason?: string): Promise<ThreadChannel>

Unpins this thread from the forum channel. Parameters

NameTypeDescription
reason?stringReason for unpinning

Returns: Promise<ThreadChannel>Source

setAppliedTags ​

setAppliedTags(appliedTags: Array<Snowflake>, reason?: string): Promise<ThreadChannel>

Set the applied tags for this channel (only applicable to forum threads) Parameters

NameTypeDescription
appliedTagsArray<Snowflake>The tags to set for this channel
reason?stringReason for changing the thread's applied tags

Returns: Promise<ThreadChannel>Source

isPrivate ​

isPrivate(): boolean

Whether this thread is a private thread Returns: booleanSource

delete ​

async

async delete(reason?: string): Promise<ThreadChannel>

Deletes this thread. Parameters

NameTypeDescription
reason?stringReason for deleting this thread

Returns: Promise<ThreadChannel>

js
// Delete the thread
thread.delete('cleaning out old threads')
  .then(deletedThread => console.log(deletedThread))
  .catch(console.error);

Source

send ​

async

async send(options: string | MessagePayload | MessageOptions): Promise<Message>

Sends a message to this channel. Parameters

NameTypeDescription
optionsstring | MessagePayload | MessageOptionsThe options to provide

Returns: Promise<Message>

js
// Send a basic message
channel.send('hello!')
  .then(message => console.log(`Sent message: ${message.content}`))
  .catch(console.error);
js
// Send a remote file
channel.send({
  files: ['https://cdn.discordapp.com/icons/222078108977594368/6e1019b3179d71046e463a75915e7244.png?size=2048']
})
  .then(console.log)
  .catch(console.error);
js
// 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);

Source

sendTyping ​

sendTyping(): Promise<({message_send_cooldown_ms: number, thread_create_cooldown_ms: number}|void)>

Sends a typing indicator in the channel. Returns: Promise<({message_send_cooldown_ms: number, thread_create_cooldown_ms: number}\|void)> — Resolves upon the typing status being sent

js
// Start typing in a channel
channel.sendTyping();

Source

createMessageCollector ​

createMessageCollector(options?: MessageCollectorOptions): MessageCollector

Creates a Message Collector. Parameters

NameTypeDescription
options?MessageCollectorOptionsThe options to pass to the collector Default: {}.

Returns: MessageCollector

js
// Create a message collector
const filter = m => m.content.includes('discord');
const collector = channel.createMessageCollector({ filter, time: 15_000 });
collector.on('collect', m => console.log(`Collected ${m.content}`));
collector.on('end', collected => console.log(`Collected ${collected.size} items`));

Source

awaitMessages ​

awaitMessages(options?: AwaitMessagesOptions): Promise<Collection<Snowflake, Message>>

Similar to createMessageCollector but in promise form. Resolves with a collection of messages that pass the specified filter. Parameters

NameTypeDescription
options?AwaitMessagesOptionsOptional options to pass to the internal collector Default: {}.

Returns: Promise<Collection<Snowflake, Message>>

js
// 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.`));

Source

toString ​

toString(): string

When concatenated with a string, this automatically returns the channel's mention instead of the Channel object. Returns: string

js
// Logs: Hello from <#123456789012345678>!
console.log(`Hello from ${channel}!`);

Source

fetch ​

fetch(force?: boolean): Promise<Channel>

Fetches this channel. Parameters

NameTypeDescription
force?booleanWhether to skip the cache check and request the API Default: true.

Returns: Promise<Channel>Source

isText ​

isText(): boolean

Indicates whether this channel is text-based. Returns: booleanSource

isVoice ​

isVoice(): boolean

Indicates whether this channel is voice-based. Returns: booleanSource

isThread ​

isThread(): boolean

Indicates whether this channel is a ThreadChannel. Returns: booleanSource

isThreadOnly ​

isThreadOnly(): boolean

Indicates whether this channel is ThreadOnlyChannel. Returns: booleanSource

isDirectory ​

isDirectory(): boolean

Indicates whether this channel is a DirectoryChannelReturns: booleanSource

Unofficial software. Not affiliated with or supported by Discord.