Skip to content

GuildTextThreadManager

classe · Source

Manages API methods for ThreadChannel objects and stores their cache.

Extends: ThreadManager

Properties

channel

channel: TextChannel | NewsChannel

The channel this Manager belongs to Source

cache

cache: Collection<Snowflake, ThreadChannel>

The cache of this Manager Source

_cache

readonly · private

_cache: Collection

The private cache of items for this manager. Source

holds

readonly · private

holds: function

The data structure belonging to this manager. Source

client

readonly

client: Client

The client that instantiated this Manager Source

Methods

create

async

async create(options?: GuildTextThreadCreateOptions): Promise<ThreadChannel>

Creates a new thread in the channel. Parameters

NameTypeDescription
options?GuildTextThreadCreateOptionsOptions to create a new thread

Returns: Promise<ThreadChannel>

js
// Create a new public thread
channel.threads
  .create({
    name: 'food-talk',
    autoArchiveDuration: 60,
    reason: 'Needed a separate thread for food',
  })
  .then(threadChannel => console.log(threadChannel))
  .catch(console.error);
js
// Create a new private thread
channel.threads
  .create({
     name: 'mod-talk',
     autoArchiveDuration: 60,
     type: 'GUILD_PRIVATE_THREAD',
     reason: 'Needed a separate thread for moderation',
   })
  .then(threadChannel => console.log(threadChannel))
  .catch(console.error);

Source

resolve

resolve(thread: ThreadChannelResolvable): ThreadChannel

Resolves a ThreadChannelResolvable to a ThreadChannel object. Parameters

NameTypeDescription
threadThreadChannelResolvableThe ThreadChannel resolvable to resolve

Returns: ThreadChannelSource

resolveId

resolveId(thread: ThreadChannelResolvable): Snowflake

Resolves a ThreadChannelResolvable to a ThreadChannel id. Parameters

NameTypeDescription
threadThreadChannelResolvableThe ThreadChannel resolvable to resolve

Returns: SnowflakeSource

fetch

fetch(options?: ThreadChannelResolvable | FetchChannelThreadsOptions | FetchThreadsOptions, cacheOptions?: BaseFetchOptions): Promise<?(ThreadChannel|FetchedThreads)>

Obtains a thread from Discord, or the channel cache if it's already available. Parameters

NameTypeDescription
options?ThreadChannelResolvable | FetchChannelThreadsOptions | FetchThreadsOptionsThe options to fetch threads. If it is a
ThreadChannelResolvable then the specified thread will be fetched. Fetches all active threads if undefined
cacheOptions?BaseFetchOptionsAdditional options for this fetch. The force field gets ignored
if options is not a ThreadChannelResolvable

Returns: Promise<?(ThreadChannel\|FetchedThreads)>

js
// Fetch a thread by its id
channel.threads.fetch('831955138126104859')
  .then(channel => console.log(channel.name))
  .catch(console.error);

Source

fetchArchived

fetchArchived(options?: FetchChannelThreadsOptions, cache?: boolean): Promise<FetchedThreads>

Obtains a set of archived threads from Discord, requires READ_MESSAGE_HISTORY in the parent channel. Parameters

NameTypeDescription
options?FetchChannelThreadsOptionsThe options to fetch archived threads
cache?booleanWhether to cache the new thread objects if they aren't already Default: true.

Returns: Promise<FetchedThreads>Source

fetchActive

async

async fetchActive(cache?: boolean, options?: FetchChannelThreadsOptions): Promise<FetchedThreads>

Obtains the accessible active threads from Discord, requires READ_MESSAGE_HISTORY in the parent channel. Parameters

NameTypeDescription
cache?booleanWhether to cache the new thread objects if they aren't already Default: true.
options?FetchChannelThreadsOptionsOptions for self-bots where advanced users can specify further options

Returns: Promise<FetchedThreads>Source

Unofficial software. Not affiliated with or supported by Discord.