Skip to content

Commit

Permalink
fix(docs): some link tags didn't resolve correctly (#10269)
Browse files Browse the repository at this point in the history
* fix(docs): some link tags didn't resolve in summaries

* fix: add TextBasedChannels type
  • Loading branch information
Qjuh authored May 13, 2024
1 parent 393ded4 commit 914cc4b
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 37 deletions.
2 changes: 1 addition & 1 deletion apps/website/src/components/DocNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`}
</a>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/src/managers/GuildManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/discord.js/src/managers/GuildTextThreadManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class GuildTextThreadManager extends ThreadManager {

/**
* Options for creating a thread. <warn>Only one of `startMessage` or `type` can be defined.</warn>
* @typedef {StartThreadOptions} ThreadCreateOptions
* @typedef {StartThreadOptions} GuildTextThreadCreateOptions
* @property {MessageResolvable} [startMessage] The message to start a thread from.
* <warn>If this is defined, then the `type` of thread gets inferred automatically and cannot be changed.</warn>
* @property {ThreadChannelTypes} [type] The type of thread to create.
Expand All @@ -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<ThreadChannel>}
* @example
* // Create a new public thread
Expand Down
14 changes: 0 additions & 14 deletions packages/discord.js/src/managers/ThreadManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,6 @@ class ThreadManager extends CachedManager {
* @returns {?Snowflake}
*/

/**
* Options for creating a thread. <warn>Only one of `startMessage` or `type` can be defined.</warn>
* @typedef {StartThreadOptions} ThreadCreateOptions
* @property {MessageResolvable} [startMessage] The message to start a thread from. <warn>If this is defined then type
* of thread gets automatically defined and cannot be changed. The provided `type` field will be ignored</warn>
* @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}
* <warn>When creating threads in a {@link NewsChannel} this is ignored and is always
* {@link ChannelType.AnnouncementThread}</warn>
* @property {boolean} [invitable] Whether non-moderators can add other non-moderators to the thread
* <info>Can only be set when type will be {@link ChannelType.PrivateThread}</info>
*/

/**
* Options for fetching multiple threads.
* @typedef {Object} FetchThreadsOptions
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/src/sharding/ShardingManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand Down
11 changes: 7 additions & 4 deletions packages/discord.js/src/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info>
* <info>You will need to fetch the guild using {@link BaseGuild#fetch} if you want to receive
* this parameter</info>
* @type {?number}
*/
this.maximumPresences = data.max_presences;
Expand Down Expand Up @@ -322,7 +323,8 @@ class Guild extends AnonymousGuild {
if ('approximate_member_count' in data) {
/**
* The approximate amount of members the guild has
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info>
* <info>You will need to fetch the guild using {@link BaseGuild#fetch} if you want to receive
* this parameter</info>
* @type {?number}
*/
this.approximateMemberCount = data.approximate_member_count;
Expand All @@ -333,7 +335,8 @@ class Guild extends AnonymousGuild {
if ('approximate_presence_count' in data) {
/**
* The approximate amount of presences the guild has
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info>
* <info>You will need to fetch the guild using {@link BaseGuild#fetch} if you want to receive
* this parameter</info>
* @type {?number}
*/
this.approximatePresenceCount = data.approximate_presence_count;
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/src/structures/GuildScheduledEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class GuildScheduledEvent extends Base {

/**
* The time the guild scheduled event will start at
* <info>This can be potentially `null` only when it's an {@link AuditLogEntryTarget}</info>
* <info>This can be potentially `null` only when it's an {@link GuildAuditLogsEntry#target}</info>
* @type {?Date}
* @readonly
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/discord.js/src/structures/PermissionOverwrites.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/src/structures/ReactionCollector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/src/structures/ThreadChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class ThreadChannel extends BaseChannel {
* Fetches the message that started this thread, if any.
* <info>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.</info>
* If you just need the id of that message, use {@link BaseChannel#id} instead.</info>
* @param {BaseFetchOptions} [options] Additional options for this fetch
* @returns {Promise<?Message<true>>}
*/
Expand Down
5 changes: 5 additions & 0 deletions packages/discord.js/src/util/APITypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
8 changes: 4 additions & 4 deletions packages/discord.js/src/util/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand Down
15 changes: 10 additions & 5 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -5197,11 +5204,7 @@ export interface ClientEvents {
guildMemberAdd: [member: GuildMember];
guildMemberAvailable: [member: GuildMember | PartialGuildMember];
guildMemberRemove: [member: GuildMember | PartialGuildMember];
guildMembersChunk: [
members: ReadonlyCollection<Snowflake, GuildMember>,
guild: Guild,
data: { index: number; count: number; notFound: readonly unknown[]; nonce: string | undefined },
];
guildMembersChunk: [members: ReadonlyCollection<Snowflake, GuildMember>, guild: Guild, data: GuildMembersChunk];
guildMemberUpdate: [oldMember: GuildMember | PartialGuildMember, newMember: GuildMember];
guildUpdate: [oldGuild: Guild, newGuild: Guild];
inviteCreate: [invite: Invite];
Expand Down Expand Up @@ -6723,6 +6726,8 @@ export type TextBasedChannel = Exclude<
PartialGroupDMChannel | ForumChannel | MediaChannel
>;

export type TextBasedChannels = TextBasedChannel;

export type TextBasedChannelTypes = TextBasedChannel['type'];

export type GuildTextBasedChannelTypes = Exclude<TextBasedChannelTypes, ChannelType.DM>;
Expand Down

0 comments on commit 914cc4b

Please sign in to comment.