mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 20:43:30 +01:00
fix(ThreadManager): Ensure fetchActive() only returns active threads in a channel (#9568)
fix(ThreadManager): revert breaking change Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -468,8 +468,17 @@ class GuildChannelManager extends CachedManager {
|
|||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
async fetchActiveThreads(cache = true) {
|
async fetchActiveThreads(cache = true) {
|
||||||
const raw = await this.client.rest.get(Routes.guildActiveThreads(this.guild.id));
|
const data = await this.rawFetchGuildActiveThreads();
|
||||||
return GuildTextThreadManager._mapThreads(raw, this.client, { guild: this.guild, cache });
|
return GuildTextThreadManager._mapThreads(data, this.client, { guild: this.guild, cache });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `GET /guilds/{guild.id}/threads/active`
|
||||||
|
* @private
|
||||||
|
* @returns {Promise<RESTGetAPIGuildThreadsResult>}
|
||||||
|
*/
|
||||||
|
rawFetchGuildActiveThreads() {
|
||||||
|
return this.client.rest.get(Routes.guildActiveThreads(this.guild.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -171,13 +171,13 @@ class ThreadManager extends CachedManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtains all active thread channels in the guild.
|
* Obtains all active threads in the channel.
|
||||||
* This internally calls {@link GuildChannelManager#fetchActiveThreads}.
|
|
||||||
* @param {boolean} [cache=true] Whether to cache the fetched data
|
* @param {boolean} [cache=true] Whether to cache the fetched data
|
||||||
* @returns {Promise<FetchedThreads>}
|
* @returns {Promise<FetchedThreads>}
|
||||||
*/
|
*/
|
||||||
fetchActive(cache = true) {
|
async fetchActive(cache = true) {
|
||||||
return this.channel.guild.channels.fetchActiveThreads(cache);
|
const data = await this.channel.guild.channels.rawFetchGuildActiveThreads();
|
||||||
|
return this.constructor._mapThreads(data, this.client, { parent: this.channel, cache });
|
||||||
}
|
}
|
||||||
|
|
||||||
static _mapThreads(rawThreads, client, { parent, guild, cache }) {
|
static _mapThreads(rawThreads, client, { parent, guild, cache }) {
|
||||||
|
|||||||
@@ -400,6 +400,11 @@
|
|||||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-payloads/common#PermissionFlagsBits}
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-payloads/common#PermissionFlagsBits}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @external RESTGetAPIGuildThreadsResult
|
||||||
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10#RESTGetAPIGuildThreadsResult}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @external RESTJSONErrorCodes
|
* @external RESTJSONErrorCodes
|
||||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-rest/common/enum/RESTJSONErrorCodes}
|
* @see {@link https://discord-api-types.dev/api/discord-api-types-rest/common/enum/RESTJSONErrorCodes}
|
||||||
|
|||||||
2
packages/discord.js/typings/index.d.ts
vendored
2
packages/discord.js/typings/index.d.ts
vendored
@@ -156,6 +156,7 @@ import {
|
|||||||
APIApplicationRoleConnectionMetadata,
|
APIApplicationRoleConnectionMetadata,
|
||||||
ImageFormat,
|
ImageFormat,
|
||||||
GuildMemberFlags,
|
GuildMemberFlags,
|
||||||
|
RESTGetAPIGuildThreadsResult,
|
||||||
} from 'discord-api-types/v10';
|
} from 'discord-api-types/v10';
|
||||||
import { ChildProcess } from 'node:child_process';
|
import { ChildProcess } from 'node:child_process';
|
||||||
import { EventEmitter } from 'node:events';
|
import { EventEmitter } from 'node:events';
|
||||||
@@ -3860,6 +3861,7 @@ export class GuildChannelManager extends CachedManager<Snowflake, GuildBasedChan
|
|||||||
): Promise<GuildChannel>;
|
): Promise<GuildChannel>;
|
||||||
public setPositions(channelPositions: readonly ChannelPosition[]): Promise<Guild>;
|
public setPositions(channelPositions: readonly ChannelPosition[]): Promise<Guild>;
|
||||||
public fetchActiveThreads(cache?: boolean): Promise<FetchedThreads>;
|
public fetchActiveThreads(cache?: boolean): Promise<FetchedThreads>;
|
||||||
|
private rawFetchGuildActiveThreads(): Promise<RESTGetAPIGuildThreadsResult>;
|
||||||
public delete(channel: GuildChannelResolvable, reason?: string): Promise<void>;
|
public delete(channel: GuildChannelResolvable, reason?: string): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user