GuildTextThreadManager
classe · Source
Manages API methods for ThreadChannel objects and stores their cache.
Extends: ThreadManager
Properties
channel
The channel this Manager belongs to Source
cache
The cache of this Manager Source
_cache
The private cache of items for this manager. Source
holds
The data structure belonging to this manager. Source
client
The client that instantiated this Manager Source
Methods
create
Creates a new thread in the channel. Parameters
| Name | Type | Description |
|---|---|---|
options? | GuildTextThreadCreateOptions | Options to create a new thread |
Returns: Promise<ThreadChannel>
// 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);// 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);resolve
Resolves a ThreadChannelResolvable to a ThreadChannel object. Parameters
| Name | Type | Description |
|---|---|---|
thread | ThreadChannelResolvable | The ThreadChannel resolvable to resolve |
Returns: ThreadChannelSource
resolveId
Resolves a ThreadChannelResolvable to a ThreadChannel id. Parameters
| Name | Type | Description |
|---|---|---|
thread | ThreadChannelResolvable | The ThreadChannel resolvable to resolve |
Returns: SnowflakeSource
fetch
Obtains a thread from Discord, or the channel cache if it's already available. Parameters
| Name | Type | Description |
|---|---|---|
options? | ThreadChannelResolvable | FetchChannelThreadsOptions | FetchThreadsOptions | The options to fetch threads. If it is a ThreadChannelResolvable then the specified thread will be fetched. Fetches all active threads if undefined |
cacheOptions? | BaseFetchOptions | Additional options for this fetch. The force field gets ignoredif options is not a ThreadChannelResolvable |
Returns: Promise<?(ThreadChannel\|FetchedThreads)>
// Fetch a thread by its id
channel.threads.fetch('831955138126104859')
.then(channel => console.log(channel.name))
.catch(console.error);fetchArchived
Obtains a set of archived threads from Discord, requires READ_MESSAGE_HISTORY in the parent channel. Parameters
| Name | Type | Description |
|---|---|---|
options? | FetchChannelThreadsOptions | The options to fetch archived threads |
cache? | boolean | Whether to cache the new thread objects if they aren't already Default: true. |
Returns: Promise<FetchedThreads>Source
fetchActive
Obtains the accessible active threads from Discord, requires READ_MESSAGE_HISTORY in the parent channel. Parameters
| Name | Type | Description |
|---|---|---|
cache? | boolean | Whether to cache the new thread objects if they aren't already Default: true. |
options? | FetchChannelThreadsOptions | Options for self-bots where advanced users can specify further options |
Returns: Promise<FetchedThreads>Source