From 914cc4ba5441cde5aa6dc8ec6406a283855d6828 Mon Sep 17 00:00:00 2001 From: Qjuh <76154676+Qjuh@users.noreply.github.com> Date: Mon, 13 May 2024 11:34:11 +0200 Subject: [PATCH] fix(docs): some link tags didn't resolve correctly (#10269) * fix(docs): some link tags didn't resolve in summaries * fix: add TextBasedChannels type --- apps/website/src/components/DocNode.tsx | 2 +- .../src/model/ModelReferenceResolver.ts | 5 +++++ packages/discord.js/src/managers/GuildManager.js | 2 +- .../src/managers/GuildTextThreadManager.js | 4 ++-- packages/discord.js/src/managers/ThreadManager.js | 14 -------------- .../discord.js/src/sharding/ShardingManager.js | 2 +- packages/discord.js/src/structures/Guild.js | 11 +++++++---- .../src/structures/GuildScheduledEvent.js | 2 +- .../src/structures/PermissionOverwrites.js | 4 ++-- .../src/structures/ReactionCollector.js | 2 +- .../discord.js/src/structures/ThreadChannel.js | 2 +- packages/discord.js/src/util/APITypes.js | 5 +++++ packages/discord.js/src/util/Constants.js | 8 ++++---- packages/discord.js/typings/index.d.ts | 15 ++++++++++----- 14 files changed, 41 insertions(+), 37 deletions(-) diff --git a/apps/website/src/components/DocNode.tsx b/apps/website/src/components/DocNode.tsx index bd9682ae64d6..acd2e0262399 100644 --- a/apps/website/src/components/DocNode.tsx +++ b/apps/website/src/components/DocNode.tsx @@ -30,7 +30,7 @@ export async function DocNode({ node, version }: { readonly node?: any; readonly rel="external noreferrer noopener" target="_blank" > - {node.text} + {`${node.text}${node.members}`} ); } diff --git a/packages/api-extractor-model/src/model/ModelReferenceResolver.ts b/packages/api-extractor-model/src/model/ModelReferenceResolver.ts index 48722f1fe555..944e8c6677e6 100644 --- a/packages/api-extractor-model/src/model/ModelReferenceResolver.ts +++ b/packages/api-extractor-model/src/model/ModelReferenceResolver.ts @@ -6,6 +6,7 @@ import { type ApiItem, ApiItemKind } from '../items/ApiItem.js'; import { ApiItemContainerMixin } from '../mixins/ApiItemContainerMixin.js'; import { ApiParameterListMixin } from '../mixins/ApiParameterListMixin.js'; import type { ApiEntryPoint } from './ApiEntryPoint.js'; +import type { ApiMethod } from './ApiMethod.js'; import type { ApiModel } from './ApiModel.js'; import type { ApiPackage } from './ApiPackage.js'; @@ -119,6 +120,10 @@ export class ModelReferenceResolver { foundMembers.filter((member) => member.kind === ApiItemKind.Interface).length === foundMembers.length - 1 ) { currentItem = foundClass; + } else if ( + foundMembers.every((member) => member.kind === ApiItemKind.Method && (member as ApiMethod).overloadIndex) + ) { + currentItem = foundMembers.find((member) => (member as ApiMethod).overloadIndex === 1)!; } else { result.errorMessage = `The member reference ${JSON.stringify(identifier)} was ambiguous`; return result; diff --git a/packages/discord.js/src/managers/GuildManager.js b/packages/discord.js/src/managers/GuildManager.js index 48853cd893c5..1ab9090bd1ee 100644 --- a/packages/discord.js/src/managers/GuildManager.js +++ b/packages/discord.js/src/managers/GuildManager.js @@ -97,7 +97,7 @@ class GuildManager extends CachedManager { */ /** - * Resolves a GuildResolvable to a Guild object. + * Resolves a {@link GuildResolvable} to a {@link Guild} object. * @method resolve * @memberof GuildManager * @instance diff --git a/packages/discord.js/src/managers/GuildTextThreadManager.js b/packages/discord.js/src/managers/GuildTextThreadManager.js index 5591845b20b1..9fdcd7141c52 100644 --- a/packages/discord.js/src/managers/GuildTextThreadManager.js +++ b/packages/discord.js/src/managers/GuildTextThreadManager.js @@ -17,7 +17,7 @@ class GuildTextThreadManager extends ThreadManager { /** * Options for creating a thread. Only one of `startMessage` or `type` can be defined. - * @typedef {StartThreadOptions} ThreadCreateOptions + * @typedef {StartThreadOptions} GuildTextThreadCreateOptions * @property {MessageResolvable} [startMessage] The message to start a thread from. * If this is defined, then the `type` of thread gets inferred automatically and cannot be changed. * @property {ThreadChannelTypes} [type] The type of thread to create. @@ -30,7 +30,7 @@ class GuildTextThreadManager extends ThreadManager { /** * Creates a new thread in the channel. - * @param {ThreadCreateOptions} [options] Options to create a new thread + * @param {GuildTextThreadCreateOptions} [options] Options to create a new thread * @returns {Promise} * @example * // Create a new public thread diff --git a/packages/discord.js/src/managers/ThreadManager.js b/packages/discord.js/src/managers/ThreadManager.js index c4b2e60f6dca..ab32cc495dc3 100644 --- a/packages/discord.js/src/managers/ThreadManager.js +++ b/packages/discord.js/src/managers/ThreadManager.js @@ -63,20 +63,6 @@ class ThreadManager extends CachedManager { * @returns {?Snowflake} */ - /** - * Options for creating a thread. Only one of `startMessage` or `type` can be defined. - * @typedef {StartThreadOptions} ThreadCreateOptions - * @property {MessageResolvable} [startMessage] The message to start a thread from. If this is defined then type - * of thread gets automatically defined and cannot be changed. The provided `type` field will be ignored - * @property {ChannelType.AnnouncementThread|ChannelType.PublicThread|ChannelType.PrivateThread} [type] - * The type of thread to create. - * Defaults to {@link ChannelType.PublicThread} if created in a {@link TextChannel} - * When creating threads in a {@link NewsChannel} this is ignored and is always - * {@link ChannelType.AnnouncementThread} - * @property {boolean} [invitable] Whether non-moderators can add other non-moderators to the thread - * Can only be set when type will be {@link ChannelType.PrivateThread} - */ - /** * Options for fetching multiple threads. * @typedef {Object} FetchThreadsOptions diff --git a/packages/discord.js/src/sharding/ShardingManager.js b/packages/discord.js/src/sharding/ShardingManager.js index d2b146775c6b..4b15b46c562c 100644 --- a/packages/discord.js/src/sharding/ShardingManager.js +++ b/packages/discord.js/src/sharding/ShardingManager.js @@ -23,7 +23,7 @@ class ShardingManager extends EventEmitter { /** * The mode to spawn shards with for a {@link ShardingManager}. Can be either one of: * * 'process' to use child processes - * * 'worker' to use [Worker threads](https://nodejs.org/api/worker_threads.html) + * * 'worker' to use {@link Worker} threads * @typedef {string} ShardingManagerMode */ diff --git a/packages/discord.js/src/structures/Guild.js b/packages/discord.js/src/structures/Guild.js index 831dae326dc3..6fc78f07a8ca 100644 --- a/packages/discord.js/src/structures/Guild.js +++ b/packages/discord.js/src/structures/Guild.js @@ -164,7 +164,7 @@ class Guild extends AnonymousGuild { if ('large' in data) { /** - * Whether the guild is "large" (has more than {@link WebsocketOptions large_threshold} members, 50 by default) + * Whether the guild is "large" (has more than {@link WebSocketOptions large_threshold} members, 50 by default) * @type {boolean} */ this.large = Boolean(data.large); @@ -291,7 +291,8 @@ class Guild extends AnonymousGuild { if ('max_presences' in data) { /** * The maximum amount of presences the guild can have (this is `null` for all but the largest of guilds) - * You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter + * You will need to fetch the guild using {@link BaseGuild#fetch} if you want to receive + * this parameter * @type {?number} */ this.maximumPresences = data.max_presences; @@ -322,7 +323,8 @@ class Guild extends AnonymousGuild { if ('approximate_member_count' in data) { /** * The approximate amount of members the guild has - * You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter + * You will need to fetch the guild using {@link BaseGuild#fetch} if you want to receive + * this parameter * @type {?number} */ this.approximateMemberCount = data.approximate_member_count; @@ -333,7 +335,8 @@ class Guild extends AnonymousGuild { if ('approximate_presence_count' in data) { /** * The approximate amount of presences the guild has - * You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter + * You will need to fetch the guild using {@link BaseGuild#fetch} if you want to receive + * this parameter * @type {?number} */ this.approximatePresenceCount = data.approximate_presence_count; diff --git a/packages/discord.js/src/structures/GuildScheduledEvent.js b/packages/discord.js/src/structures/GuildScheduledEvent.js index 66f189eeedf1..f5a5291232e5 100644 --- a/packages/discord.js/src/structures/GuildScheduledEvent.js +++ b/packages/discord.js/src/structures/GuildScheduledEvent.js @@ -229,7 +229,7 @@ class GuildScheduledEvent extends Base { /** * The time the guild scheduled event will start at - * This can be potentially `null` only when it's an {@link AuditLogEntryTarget} + * This can be potentially `null` only when it's an {@link GuildAuditLogsEntry#target} * @type {?Date} * @readonly */ diff --git a/packages/discord.js/src/structures/PermissionOverwrites.js b/packages/discord.js/src/structures/PermissionOverwrites.js index 2cdc827327bc..3f3c286ff798 100644 --- a/packages/discord.js/src/structures/PermissionOverwrites.js +++ b/packages/discord.js/src/structures/PermissionOverwrites.js @@ -148,7 +148,7 @@ class PermissionOverwrites extends Base { */ /** - * Data that can be resolved into {@link RawOverwriteData}. This can be: + * Data that can be resolved into {@link APIOverwrite}. This can be: * * PermissionOverwrites * * OverwriteData * @typedef {PermissionOverwrites|OverwriteData} OverwriteResolvable @@ -164,7 +164,7 @@ class PermissionOverwrites extends Base { */ /** - * Resolves an overwrite into {@link RawOverwriteData}. + * Resolves an overwrite into {@link APIOverwrite}. * @param {OverwriteResolvable} overwrite The overwrite-like data to resolve * @param {Guild} [guild] The guild to resolve from * @returns {RawOverwriteData} diff --git a/packages/discord.js/src/structures/ReactionCollector.js b/packages/discord.js/src/structures/ReactionCollector.js index e6e46241dc7c..8a0ca9063d51 100644 --- a/packages/discord.js/src/structures/ReactionCollector.js +++ b/packages/discord.js/src/structures/ReactionCollector.js @@ -81,7 +81,7 @@ class ReactionCollector extends Collector { this.on('collect', (reaction, user) => { /** * Emitted whenever a reaction is newly created on a message. Will emit only when a new reaction is - * added to the message, as opposed to {@link Collector#collect} which will + * added to the message, as opposed to {@link Collector#event:collect} which will * be emitted even when a reaction has already been added to the message. * @event ReactionCollector#create * @param {MessageReaction} reaction The reaction that was added diff --git a/packages/discord.js/src/structures/ThreadChannel.js b/packages/discord.js/src/structures/ThreadChannel.js index 49901e464837..a2c7aa661f4f 100644 --- a/packages/discord.js/src/structures/ThreadChannel.js +++ b/packages/discord.js/src/structures/ThreadChannel.js @@ -315,7 +315,7 @@ class ThreadChannel extends BaseChannel { * 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 {@link ThreadChannel#id} instead. + * If you just need the id of that message, use {@link BaseChannel#id} instead. * @param {BaseFetchOptions} [options] Additional options for this fetch * @returns {Promise>} */ diff --git a/packages/discord.js/src/util/APITypes.js b/packages/discord.js/src/util/APITypes.js index 176e59046420..1031c13bee25 100644 --- a/packages/discord.js/src/util/APITypes.js +++ b/packages/discord.js/src/util/APITypes.js @@ -160,6 +160,11 @@ * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIModalSubmission} */ +/** + * @external APIOverwrite + * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIOverwrite} + */ + /** * @external APIPartialEmoji * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIPartialEmoji} diff --git a/packages/discord.js/src/util/Constants.js b/packages/discord.js/src/util/Constants.js index d08a86dde2e9..e64d807e4300 100644 --- a/packages/discord.js/src/util/Constants.js +++ b/packages/discord.js/src/util/Constants.js @@ -95,15 +95,15 @@ exports.GuildTextBasedChannelTypes = [ /** * The channels that are text-based. - * * DMChannel - * * GuildTextBasedChannel + * * {@link DMChannel} + * * {@link GuildTextBasedChannel} * @typedef {DMChannel|GuildTextBasedChannel} TextBasedChannels */ /** * Data that resolves to give a text-based channel. This can be: - * * A text-based channel - * * A snowflake + * * A {@link TextBasedChannel} + * * A {@link Snowflake} * @typedef {TextBasedChannels|Snowflake} TextBasedChannelsResolvable */ diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 76fdcc12c6d6..b4ff840dbc9b 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -5160,6 +5160,13 @@ export interface WebhookCreateOptions extends ChannelWebhookCreateOptions { channel: TextChannel | NewsChannel | VoiceChannel | StageChannel | ForumChannel | MediaChannel | Snowflake; } +export interface GuildMembersChunk { + index: number; + count: number; + notFound: readonly unknown[]; + nonce: string | undefined; +} + export interface ClientEvents { applicationCommandPermissionsUpdate: [data: ApplicationCommandPermissionsUpdateData]; autoModerationActionExecution: [autoModerationActionExecution: AutoModerationActionExecution]; @@ -5197,11 +5204,7 @@ export interface ClientEvents { guildMemberAdd: [member: GuildMember]; guildMemberAvailable: [member: GuildMember | PartialGuildMember]; guildMemberRemove: [member: GuildMember | PartialGuildMember]; - guildMembersChunk: [ - members: ReadonlyCollection, - guild: Guild, - data: { index: number; count: number; notFound: readonly unknown[]; nonce: string | undefined }, - ]; + guildMembersChunk: [members: ReadonlyCollection, guild: Guild, data: GuildMembersChunk]; guildMemberUpdate: [oldMember: GuildMember | PartialGuildMember, newMember: GuildMember]; guildUpdate: [oldGuild: Guild, newGuild: Guild]; inviteCreate: [invite: Invite]; @@ -6723,6 +6726,8 @@ export type TextBasedChannel = Exclude< PartialGroupDMChannel | ForumChannel | MediaChannel >; +export type TextBasedChannels = TextBasedChannel; + export type TextBasedChannelTypes = TextBasedChannel['type']; export type GuildTextBasedChannelTypes = Exclude;