From 47633f0fd2435d6d8c694d8d37b26039a7b3797a Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Tue, 25 Jan 2022 15:23:13 -0500 Subject: [PATCH] fix: missed enums and typings from #7290 (#7331) --- .../managers/GuildScheduledEventManager.js | 25 +-- .../src/managers/StageInstanceManager.js | 5 - .../discord.js/src/managers/ThreadManager.js | 9 +- .../src/structures/ApplicationCommand.js | 24 +- .../src/structures/BaseGuildTextChannel.js | 5 +- .../src/structures/CategoryChannel.js | 3 +- .../ContextMenuCommandInteraction.js | 3 +- packages/discord.js/src/structures/Guild.js | 2 +- .../src/structures/GuildScheduledEvent.js | 36 ++- .../src/structures/InteractionCollector.js | 13 +- packages/discord.js/src/structures/Message.js | 12 +- packages/discord.js/src/structures/Sticker.js | 3 +- .../src/structures/ThreadChannel.js | 2 +- packages/discord.js/src/util/Constants.js | 30 +-- packages/discord.js/src/util/EnumResolvers.js | 208 +++++++++++++++++- packages/discord.js/typings/index.d.ts | 134 +++++------ packages/discord.js/typings/index.test-d.ts | 2 +- 17 files changed, 337 insertions(+), 179 deletions(-) diff --git a/packages/discord.js/src/managers/GuildScheduledEventManager.js b/packages/discord.js/src/managers/GuildScheduledEventManager.js index ea2266714..b6ac54302 100644 --- a/packages/discord.js/src/managers/GuildScheduledEventManager.js +++ b/packages/discord.js/src/managers/GuildScheduledEventManager.js @@ -1,11 +1,7 @@ 'use strict'; const { Collection } = require('@discordjs/collection'); -const { - GuildScheduledEventPrivacyLevel, - GuildScheduledEventEntityType, - GuildScheduledEventStatus, -} = require('discord-api-types/v9'); +const { GuildScheduledEventEntityType } = require('discord-api-types/v9'); const CachedManager = require('./CachedManager'); const { TypeError, Error } = require('../errors'); const { GuildScheduledEvent } = require('../structures/GuildScheduledEvent'); @@ -44,16 +40,16 @@ class GuildScheduledEventManager extends CachedManager { * @property {string} name The name of the guild scheduled event * @property {DateResolvable} scheduledStartTime The time to schedule the event at * @property {DateResolvable} [scheduledEndTime] The time to end the event at - * This is required if `entityType` is `GuildScheduledEventEntityType.External` + * This is required if `entityType` is {@link GuildScheduledEventEntityType.External} * @property {PrivacyLevel|number} privacyLevel The privacy level of the guild scheduled event * @property {GuildScheduledEventEntityType|number} entityType The scheduled entity type of the event * @property {string} [description] The description of the guild scheduled event * @property {GuildVoiceChannelResolvable} [channel] The channel of the guild scheduled event - * This is required if `entityType` is `GuildScheduledEventEntityType.StageInstance` or - * `GuildScheduledEventEntityType.Voice` + * This is required if `entityType` is {@link GuildScheduledEventEntityType.StageInstance} or + * {@link GuildScheduledEventEntityType.Voice} * @property {GuildScheduledEventEntityMetadataOptions} [entityMetadata] The entity metadata of the * guild scheduled event - * This is required if `entityType` is `GuildScheduledEventEntityType.External` + * This is required if `entityType` is {@link GuildScheduledEventEntityType.External} * @property {string} [reason] The reason for creating the guild scheduled event */ @@ -61,7 +57,7 @@ class GuildScheduledEventManager extends CachedManager { * Options used to set entity metadata of a guild scheduled event. * @typedef {Object} GuildScheduledEventEntityMetadataOptions * @property {string} [location] The location of the guild scheduled event - * This is required if `entityType` is `GuildScheduledEventEntityType.External` + * This is required if `entityType` is {@link GuildScheduledEventEntityType.External} */ /** @@ -83,9 +79,6 @@ class GuildScheduledEventManager extends CachedManager { reason, } = options; - if (typeof privacyLevel === 'string') privacyLevel = GuildScheduledEventPrivacyLevel[privacyLevel]; - if (typeof entityType === 'string') entityType = GuildScheduledEventEntityType[entityType]; - let entity_metadata, channel_id; if (entityType === GuildScheduledEventEntityType.External) { channel_id = typeof channel === 'undefined' ? channel : null; @@ -177,7 +170,7 @@ class GuildScheduledEventManager extends CachedManager { * @property {GuildScheduledEventEntityMetadataOptions} [entityMetadata] The entity metadata of the * guild scheduled event * This can be modified only if `entityType` of the `GuildScheduledEvent` to be edited is - * `GuildScheduledEventEntityType.External` + * {@link GuildScheduledEventEntityType.External} * @property {string} [reason] The reason for editing the guild scheduled event */ @@ -205,10 +198,6 @@ class GuildScheduledEventManager extends CachedManager { reason, } = options; - if (typeof privacyLevel === 'string') privacyLevel = GuildScheduledEventPrivacyLevel[privacyLevel]; - if (typeof entityType === 'string') entityType = GuildScheduledEventEntityType[entityType]; - if (typeof status === 'string') status = GuildScheduledEventStatus[status]; - let entity_metadata; if (entityMetadata) { entity_metadata = { diff --git a/packages/discord.js/src/managers/StageInstanceManager.js b/packages/discord.js/src/managers/StageInstanceManager.js index a905be275..da58fe135 100644 --- a/packages/discord.js/src/managers/StageInstanceManager.js +++ b/packages/discord.js/src/managers/StageInstanceManager.js @@ -1,6 +1,5 @@ 'use strict'; -const { GuildScheduledEventPrivacyLevel } = require('discord-api-types/v9'); const CachedManager = require('./CachedManager'); const { TypeError, Error } = require('../errors'); const { StageInstance } = require('../structures/StageInstance'); @@ -60,8 +59,6 @@ class StageInstanceManager extends CachedManager { if (typeof options !== 'object') throw new TypeError('INVALID_TYPE', 'options', 'object', true); let { topic, privacyLevel } = options; - privacyLevel &&= typeof privacyLevel === 'number' ? privacyLevel : GuildScheduledEventPrivacyLevel[privacyLevel]; - const data = await this.client.api['stage-instances'].post({ data: { channel_id: channelId, @@ -122,8 +119,6 @@ class StageInstanceManager extends CachedManager { let { topic, privacyLevel } = options; - privacyLevel &&= typeof privacyLevel === 'number' ? privacyLevel : GuildScheduledEventPrivacyLevel[privacyLevel]; - const data = await this.client.api('stage-instances', channelId).patch({ data: { topic, diff --git a/packages/discord.js/src/managers/ThreadManager.js b/packages/discord.js/src/managers/ThreadManager.js index b9841a699..38620a100 100644 --- a/packages/discord.js/src/managers/ThreadManager.js +++ b/packages/discord.js/src/managers/ThreadManager.js @@ -64,11 +64,12 @@ class ThreadManager extends CachedManager { * @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 {ThreadChannelTypes|number} [type] The type of thread to create. Defaults to `GUILD_PUBLIC_THREAD` if - * created in a {@link TextChannel} When creating threads in a {@link NewsChannel} this is ignored and is always - * `GUILD_NEWS_THREAD` + * @property {ThreadChannelTypes|number} [type] The type of thread to create. + * Defaults to {@link ChannelType.GuildPublicThread} if created in a {@link TextChannel} + * When creating threads in a {@link NewsChannel} this is ignored and is always + * {@link ChannelType.GuildNewsThread} * @property {boolean} [invitable] Whether non-moderators can add other non-moderators to the thread - * Can only be set when type will be `GUILD_PRIVATE_THREAD` + * Can only be set when type will be {@link ChannelType.GuildPrivateThread} * @property {number} [rateLimitPerUser] The rate limit per user (slowmode) for the new channel in seconds */ diff --git a/packages/discord.js/src/structures/ApplicationCommand.js b/packages/discord.js/src/structures/ApplicationCommand.js index e84772bfb..d7daed7f3 100644 --- a/packages/discord.js/src/structures/ApplicationCommand.js +++ b/packages/discord.js/src/structures/ApplicationCommand.js @@ -1,7 +1,7 @@ 'use strict'; const { DiscordSnowflake } = require('@sapphire/snowflake'); -const { ApplicationCommandOptionType, ChannelType } = require('discord-api-types/v9'); +const { ApplicationCommandOptionType } = require('discord-api-types/v9'); const Base = require('./Base'); const ApplicationCommandPermissionsManager = require('../managers/ApplicationCommandPermissionsManager'); @@ -141,17 +141,19 @@ class ApplicationCommand extends Base { * Note that providing a value for the `camelCase` counterpart for any `snake_case` property * will discard the provided `snake_case` property. * @typedef {Object} ApplicationCommandOptionData - * @property {ApplicationCommandOptionType|number} type The type of the option + * @property {ApplicationCommandOptionType} type The type of the option * @property {string} name The name of the option * @property {string} description The description of the option * @property {boolean} [autocomplete] Whether the option is an autocomplete option * @property {boolean} [required] Whether the option is required * @property {ApplicationCommandOptionChoice[]} [choices] The choices of the option for the user to pick from * @property {ApplicationCommandOptionData[]} [options] Additional options if this option is a subcommand (group) - * @property {ChannelType[]|number[]} [channelTypes] When the option type is channel, + * @property {ChannelType[]} [channelTypes] When the option type is channel, * the allowed types of channels that can be selected - * @property {number} [minValue] The minimum value for an `INTEGER` or `NUMBER` option - * @property {number} [maxValue] The maximum value for an `INTEGER` or `NUMBER` option + * @property {number} [minValue] The minimum value for an {@link ApplicationCommandOptionType.Integer} or + * {@link ApplicationCommandOptionType.Number} option + * @property {number} [maxValue] The maximum value for an {@link ApplicationCommandOptionType.Integer} or + * {@link ApplicationCommandOptionType.Number} option */ /** @@ -349,8 +351,10 @@ class ApplicationCommand extends Base { * @property {ApplicationCommandOption[]} [options] Additional options if this option is a subcommand (group) * @property {ChannelType[]} [channelTypes] When the option type is channel, * the allowed types of channels that can be selected - * @property {number} [minValue] The minimum value for an `INTEGER` or `NUMBER` option - * @property {number} [maxValue] The maximum value for an `INTEGER` or `NUMBER` option + * @property {number} [minValue] The minimum value for an {@link ApplicationCommandOptionType.Integer} or + * {@link ApplicationCommandOptionType.Number} option + * @property {number} [maxValue] The maximum value for an {@link ApplicationCommandOptionType.Integer} or + * {@link ApplicationCommandOptionType.Number} option */ /** @@ -384,11 +388,7 @@ class ApplicationCommand extends Base { autocomplete: option.autocomplete, choices: option.choices, options: option.options?.map(o => this.transformOption(o, received)), - [channelTypesKey]: received - ? option.channel_types?.map(type => ChannelType[type]) - : option.channelTypes?.map(type => (typeof type === 'string' ? ChannelType[type] : type)) ?? - // When transforming to API data, accept API data - option.channel_types, + [channelTypesKey]: option.channelTypes ?? option.channel_types, [minValueKey]: option.minValue ?? option.min_value, [maxValueKey]: option.maxValue ?? option.max_value, }; diff --git a/packages/discord.js/src/structures/BaseGuildTextChannel.js b/packages/discord.js/src/structures/BaseGuildTextChannel.js index ac25c10ef..28387ac06 100644 --- a/packages/discord.js/src/structures/BaseGuildTextChannel.js +++ b/packages/discord.js/src/structures/BaseGuildTextChannel.js @@ -187,9 +187,10 @@ class BaseGuildTextChannel extends GuildChannel { * @property {number} [maxUses=0] Maximum number of uses * @property {boolean} [unique=false] Create a unique invite, or use an existing one with similar settings * @property {UserResolvable} [targetUser] The user whose stream to display for this invite, - * required if `targetType` is `STREAM`, the user must be streaming in the channel + * required if `targetType` is {@link InviteTargetType.Stream}, the user must be streaming in the channel * @property {ApplicationResolvable} [targetApplication] The embedded application to open for this invite, - * required if `targetType` is `EMBEDDED_APPLICATION`, the application must have the `EMBEDDED` flag + * required if `targetType` is {@link InviteTargetType.Stream}, the application must have the + * {@link InviteTargetType.EmbeddedApplication} flag * @property {InviteTargetType} [targetType] The type of the target for this voice channel invite * @property {string} [reason] The reason for creating the invite */ diff --git a/packages/discord.js/src/structures/CategoryChannel.js b/packages/discord.js/src/structures/CategoryChannel.js index 0095532bd..bebe976a2 100644 --- a/packages/discord.js/src/structures/CategoryChannel.js +++ b/packages/discord.js/src/structures/CategoryChannel.js @@ -45,7 +45,8 @@ class CategoryChannel extends GuildChannel { /** * Creates a new channel within this category. - * You cannot create a channel of type `GUILD_CATEGORY` inside a CategoryChannel. + * You cannot create a channel of type {@link ChannelType.GuildCategory} inside a + * CategoryChannel. * @param {string} name The name of the new channel * @param {CategoryCreateChannelOptions} options Options for creating the new channel * @returns {Promise} diff --git a/packages/discord.js/src/structures/ContextMenuCommandInteraction.js b/packages/discord.js/src/structures/ContextMenuCommandInteraction.js index 1d8536b3e..25fdaba74 100644 --- a/packages/discord.js/src/structures/ContextMenuCommandInteraction.js +++ b/packages/discord.js/src/structures/ContextMenuCommandInteraction.js @@ -28,7 +28,8 @@ class ContextMenuCommandInteraction extends CommandInteraction { this.targetId = data.data.target_id; /** - * The type of the target of the interaction; either `.User` or `.Message` + * The type of the target of the interaction; either {@link ApplicationCommandType.User} + * or {@link ApplicationCommandType.Message} * @type {ApplicationCommandType.User|ApplicationCommandType.Message} */ this.targetType = data.data.type; diff --git a/packages/discord.js/src/structures/Guild.js b/packages/discord.js/src/structures/Guild.js index 69f87d4f4..0a8ad7ce1 100644 --- a/packages/discord.js/src/structures/Guild.js +++ b/packages/discord.js/src/structures/Guild.js @@ -971,7 +971,7 @@ class Guild extends AnonymousGuild { /** * Edits the verification level of the guild. - * @param {VerificationLevel|number} verificationLevel The new verification level of the guild + * @param {VerificationLevel} verificationLevel The new verification level of the guild * @param {string} [reason] Reason for changing the guild's verification level * @returns {Promise} * @example diff --git a/packages/discord.js/src/structures/GuildScheduledEvent.js b/packages/discord.js/src/structures/GuildScheduledEvent.js index 128e5481d..675c041b5 100644 --- a/packages/discord.js/src/structures/GuildScheduledEvent.js +++ b/packages/discord.js/src/structures/GuildScheduledEvent.js @@ -1,11 +1,7 @@ 'use strict'; const { DiscordSnowflake } = require('@sapphire/snowflake'); -const { - GuildScheduledEventPrivacyLevel, - GuildScheduledEventStatus, - GuildScheduledEventEntityType, -} = require('discord-api-types/v9'); +const { GuildScheduledEventStatus, GuildScheduledEventEntityType } = require('discord-api-types/v9'); const Base = require('./Base'); const { Error } = require('../errors'); const { Endpoints } = require('../util/Constants'); @@ -36,7 +32,8 @@ class GuildScheduledEvent extends Base { _patch(data) { if ('channel_id' in data) { /** - * The channel id in which the scheduled event will be hosted, or `null` if entity type is `EXTERNAL` + * The channel id in which the scheduled event will be hosted, + * or `null` if entity type is {@link GuildScheduledEventEntityType.External} * @type {?Snowflake} */ this.channelId = data.channel_id; @@ -86,21 +83,21 @@ class GuildScheduledEvent extends Base { /** * The privacy level of the guild scheduled event - * @type {PrivacyLevel} + * @type {GuildScheduledEventPrivacyLevel} */ - this.privacyLevel = GuildScheduledEventPrivacyLevel[data.privacy_level]; + this.privacyLevel = data.privacy_level; /** * The status of the guild scheduled event * @type {GuildScheduledEventStatus} */ - this.status = GuildScheduledEventStatus[data.status]; + this.status = data.status; /** * The type of hosting entity associated with the scheduled event * @type {GuildScheduledEventEntityType} */ - this.entityType = GuildScheduledEventEntityType[data.entity_type]; + this.entityType = data.entity_type; if ('entity_id' in data) { /** @@ -226,7 +223,8 @@ class GuildScheduledEvent extends Base { * Options used to create an invite URL to a {@link GuildScheduledEvent} * @typedef {CreateInviteOptions} CreateGuildScheduledEventInviteURLOptions * @property {GuildInvitableChannelResolvable} [channel] The channel to create the invite in. - * This is required when the `entityType` of `GuildScheduledEvent` is `EXTERNAL`, gets ignored otherwise + * This is required when the `entityType` of `GuildScheduledEvent` is + * {@link GuildScheduledEventEntityType.External}, gets ignored otherwise */ /** @@ -387,35 +385,35 @@ class GuildScheduledEvent extends Base { } /** - * Indicates whether this guild scheduled event has an `ACTIVE` status. + * Indicates whether this guild scheduled event has an {@link GuildScheduledEventStatus.Active} status. * @returns {boolean} */ isActive() { - return GuildScheduledEventStatus[this.status] === GuildScheduledEventStatus.Active; + return this.status === GuildScheduledEventStatus.Active; } /** - * Indicates whether this guild scheduled event has a `CANCELED` status. + * Indicates whether this guild scheduled event has a {@link GuildScheduledEventStatus.Canceled} status. * @returns {boolean} */ isCanceled() { - return GuildScheduledEventStatus[this.status] === GuildScheduledEventStatus.Canceled; + return this.status === GuildScheduledEventStatus.Canceled; } /** - * Indicates whether this guild scheduled event has a `COMPLETED` status. + * Indicates whether this guild scheduled event has a {@link GuildScheduledEventStatus.Completed} status. * @returns {boolean} */ isCompleted() { - return GuildScheduledEventStatus[this.status] === GuildScheduledEventStatus.Completed; + return this.status === GuildScheduledEventStatus.Completed; } /** - * Indicates whether this guild scheduled event has a `SCHEDULED` status. + * Indicates whether this guild scheduled event has a {@link GuildScheduledEventStatus.Scheduled} status. * @returns {boolean} */ isScheduled() { - return GuildScheduledEventStatus[this.status] === GuildScheduledEventStatus.Scheduled; + return this.status === GuildScheduledEventStatus.Scheduled; } } diff --git a/packages/discord.js/src/structures/InteractionCollector.js b/packages/discord.js/src/structures/InteractionCollector.js index e6b99f2c5..d29cc0f2b 100644 --- a/packages/discord.js/src/structures/InteractionCollector.js +++ b/packages/discord.js/src/structures/InteractionCollector.js @@ -1,14 +1,13 @@ 'use strict'; const { Collection } = require('@discordjs/collection'); -const { InteractionType, ComponentType } = require('discord-api-types/v9'); const Collector = require('./interfaces/Collector'); const { Events } = require('../util/Constants'); /** * @typedef {CollectorOptions} InteractionCollectorOptions * @property {TextBasedChannels} [channel] The channel to listen to interactions from - * @property {MessageComponentType} [componentType] The type of component to listen for + * @property {ComponentType} [componentType] The type of component to listen for * @property {Guild} [guild] The guild to listen to interactions from * @property {InteractionType} [interactionType] The type of interaction to listen for * @property {number} [max] The maximum total amount of interactions to collect @@ -64,17 +63,13 @@ class InteractionCollector extends Collector { * The type of interaction to collect * @type {?InteractionType} */ - this.interactionType = - typeof options.interactionType === 'number' - ? InteractionType[options.interactionType] - : options.interactionType ?? null; + this.interactionType = options.interactionType ?? null; /** * The type of component to collect - * @type {?MessageComponentType} + * @type {?ComponentType} */ - this.componentType = - typeof options.componentType === 'number' ? ComponentType[options.componentType] : options.componentType ?? null; + this.componentType = options.componentType ?? null; /** * The users that have interacted with this collector diff --git a/packages/discord.js/src/structures/Message.js b/packages/discord.js/src/structures/Message.js index 556f71bca..8d0a6c135 100644 --- a/packages/discord.js/src/structures/Message.js +++ b/packages/discord.js/src/structures/Message.js @@ -288,10 +288,10 @@ class Message extends Base { * Reference data sent in a message that contains ids identifying the referenced message. * This can be present in the following types of message: * * Crossposted messages (IS_CROSSPOST {@link MessageFlags.FLAGS message flag}) - * * CHANNEL_FOLLOW_ADD - * * CHANNEL_PINNED_MESSAGE - * * REPLY - * * THREAD_STARTER_MESSAGE + * * {@link MessageType.ChannelFollowAdd} + * * {@link MessageType.ChannelPinnedMessage} + * * {@link MessageType.Reply} + * * {@link MessageType.ThreadStarterMessage} * @see {@link https://discord.com/developers/docs/resources/channel#message-types} * @typedef {Object} MessageReference * @property {Snowflake} channelId The channel's id the message was referenced @@ -482,7 +482,7 @@ class Message extends Base { /** * @typedef {CollectorOptions} MessageComponentCollectorOptions - * @property {MessageComponentType} [componentType] The type of component to listen for + * @property {ComponentType} [componentType] The type of component to listen for * @property {number} [max] The maximum total amount of interactions to collect * @property {number} [maxComponents] The maximum number of components to collect * @property {number} [maxUsers] The maximum number of users to interact @@ -512,7 +512,7 @@ class Message extends Base { * @typedef {Object} AwaitMessageComponentOptions * @property {CollectorFilter} [filter] The filter applied to this collector * @property {number} [time] Time to wait for an interaction before rejecting - * @property {MessageComponentType} [componentType] The type of component interaction to collect + * @property {ComponentType} [componentType] The type of component interaction to collect */ /** diff --git a/packages/discord.js/src/structures/Sticker.js b/packages/discord.js/src/structures/Sticker.js index 834f48e76..78f523e88 100644 --- a/packages/discord.js/src/structures/Sticker.js +++ b/packages/discord.js/src/structures/Sticker.js @@ -156,7 +156,8 @@ class Sticker extends Base { /** * A link to the sticker - * If the sticker's format is LOTTIE, it returns the URL of the Lottie JSON file. + * If the sticker's format is {@link StickerFormatType.Lottie}, it returns + * the URL of the Lottie JSON file. * @type {string} */ get url() { diff --git a/packages/discord.js/src/structures/ThreadChannel.js b/packages/discord.js/src/structures/ThreadChannel.js index 5acdee6ef..e317c3836 100644 --- a/packages/discord.js/src/structures/ThreadChannel.js +++ b/packages/discord.js/src/structures/ThreadChannel.js @@ -292,7 +292,7 @@ class ThreadChannel extends Channel { * @property {number} [rateLimitPerUser] The rate limit per user (slowmode) for the thread in seconds * @property {boolean} [locked] Whether the thread is locked * @property {boolean} [invitable] Whether non-moderators can add other non-moderators to a thread - * Can only be edited on `GUILD_PRIVATE_THREAD` + * Can only be edited on {@link ChannelType.GuildPrivateThread} */ /** diff --git a/packages/discord.js/src/util/Constants.js b/packages/discord.js/src/util/Constants.js index 476db7fbc..0d8ab1e81 100644 --- a/packages/discord.js/src/util/Constants.js +++ b/packages/discord.js/src/util/Constants.js @@ -423,10 +423,10 @@ exports.SweeperKeys = [ /** * The types of messages that are not `System`. The available types are: - * * `MessageType.Default` - * * `MessageType.Reply` - * * `MessageType.ChatInputCommand` - * * `MessageType.ContextMenuCommand` + * * {@link MessageType.Default} + * * {@link MessageType.Reply} + * * {@link MessageType.ChatInputCommand} + * * {@link MessageType.ContextMenuCommand} * @typedef {MessageType[]} NonSystemMessageTypes */ exports.NonSystemMessageTypes = [ @@ -447,12 +447,12 @@ exports.NonSystemMessageTypes = [ /** * The types of channels that are text-based. The available types are: - * * `ChannelType.DM` - * * `ChannelType.GuildText` - * * `ChannelType.GuildNews` - * * `ChannelType.GuildNewsThread` - * * `ChannelType.GuildPublicThread` - * * `ChannelType.GuildPrivateThread` + * * {@link ChannelType.DM} + * * {@link ChannelType.GuildText} + * * {@link ChannelType.GuildNews} + * * {@link ChannelType.GuildNewsThread} + * * {@link ChannelType.GuildPublicThread} + * * {@link ChannelType.GuildPrivateThread} * @typedef {ChannelType} TextBasedChannelTypes */ exports.TextBasedChannelTypes = [ @@ -466,9 +466,9 @@ exports.TextBasedChannelTypes = [ /** * The types of channels that are threads. The available types are: - * * `ChannelType.GuildNewsThread` - * * `ChannelType.GuildPublicThread` - * * `ChannelType.GuildPrivateThread` + * * {@link ChannelType.GuildNewsThread} + * * {@link ChannelType.GuildPublicThread} + * * {@link ChannelType.GuildPrivateThread} * @typedef {ChannelType[]} ThreadChannelTypes */ exports.ThreadChannelTypes = [ @@ -479,8 +479,8 @@ exports.ThreadChannelTypes = [ /** * The types of channels that are voice-based. The available types are: - * * `ChannelType.GuildVoice` - * * `ChannelType.GuildStageVoice` + * * {@link ChannelType.GuildVoice} + * * {@link ChannelType.GuildStageVoice} * @typedef {ChannelType[]} VoiceBasedChannelTypes */ exports.VoiceBasedChannelTypes = [ChannelType.GuildVoice, ChannelType.GuildStageVoice]; diff --git a/packages/discord.js/src/util/EnumResolvers.js b/packages/discord.js/src/util/EnumResolvers.js index 947ec4a80..ff39445dc 100644 --- a/packages/discord.js/src/util/EnumResolvers.js +++ b/packages/discord.js/src/util/EnumResolvers.js @@ -9,6 +9,16 @@ const { ChannelType, ApplicationCommandPermissionType, MessageType, + GuildNSFWLevel, + GuildVerificationLevel, + GuildDefaultMessageNotifications, + GuildExplicitContentFilter, + GuildPremiumTier, + GuildScheduledEventStatus, + StageInstancePrivacyLevel, + GuildMFALevel, + TeamMemberMembershipState, + GuildScheduledEventEntityType, } = require('discord-api-types/v9'); function unknownKeyStrategy(val) { @@ -17,7 +27,7 @@ function unknownKeyStrategy(val) { class EnumResolvers extends null { /** - * Resolves enum key to `ChannelType` enum value + * Resolves enum key to {@link ChannelType} enum value * @param {string|ChannelType} key The key to resolve * @returns {ChannelType} */ @@ -49,7 +59,7 @@ class EnumResolvers extends null { } /** - * Resolves enum key to `InteractionType` enum value + * Resolves enum key to {@link InteractionType} enum value * @param {string|InteractionType} key The key to resolve * @returns {InteractionType} */ @@ -69,7 +79,7 @@ class EnumResolvers extends null { } /** - * Resolves enum key to `ApplicationCommandType` enum value + * Resolves enum key to {@link ApplicationCommandType} enum value * @param {string|ApplicationCommandType} key The key to resolve * @returns {ApplicationCommandType} */ @@ -87,7 +97,7 @@ class EnumResolvers extends null { } /** - * Resolves enum key to `ApplicationCommandOptionType` enum value + * Resolves enum key to {@link ApplicationCommandOptionType} enum value * @param {string|ApplicationCommandOptionType} key The key to resolve * @returns {ApplicationCommandOptionType} */ @@ -119,7 +129,7 @@ class EnumResolvers extends null { } /** - * Resolves enum key to `ApplicationCommandPermissionType` enum value + * Resolves enum key to {@link ApplicationCommandPermissionType} enum value * @param {string|ApplicationCommandPermissionType} key The key to resolve * @returns {ApplicationCommandPermissionType} */ @@ -135,7 +145,7 @@ class EnumResolvers extends null { } /** - * Resolves enum key to `ComponentType` enum value + * Resolves enum key to {@link ComponentType} enum value * @param {string|ComponentType} key The key to resolve * @returns {ComponentType} */ @@ -153,7 +163,7 @@ class EnumResolvers extends null { } /** - * Resolves enum key to `ButtonStyle` enum value + * Resolves enum key to {@link ButtonStyle} enum value * @param {string|ButtonStyle} key The key to resolve * @returns {ButtonStyle} */ @@ -175,7 +185,7 @@ class EnumResolvers extends null { } /** - * Resolves enum key to `MessageType` enum value + * Resolves enum key to {@link MessageType} enum value * @param {string|MessageType} key The key to lookup * @returns {MessageType} */ @@ -231,6 +241,188 @@ class EnumResolvers extends null { return unknownKeyStrategy(key); } } + + /** + * Resolves enum key to {@link GuildNSFWLevel} enum value + * @param {string|GuildNSFWLevel} key The key to lookup + * @returns {GuildNSFWLevel} + */ + static resolveGuildNSFWLevel(key) { + switch (key) { + case 'DEFAULT': + return GuildNSFWLevel.Default; + case 'EXPLICIT': + return GuildNSFWLevel.Explicit; + case 'SAFE': + return GuildNSFWLevel.Safe; + case 'AGE_RESTRICTED': + return GuildNSFWLevel.AgeRestricted; + default: + return unknownKeyStrategy(key); + } + } + + /** + * Resolves enum key to {@link GuildVerificationLevel} enum value + * @param {string|GuildVerificationLevel} key The key to lookup + * @returns {GuildVerificationLevel} + */ + static resolveGuildVerificationLevel(key) { + switch (key) { + case 'NONE': + return GuildVerificationLevel.None; + case 'LOW': + return GuildVerificationLevel.Low; + case 'MEDIUM': + return GuildVerificationLevel.Medium; + case 'HIGH': + return GuildVerificationLevel.High; + case 'VERY_HIGH': + return GuildVerificationLevel.VeryHigh; + default: + return unknownKeyStrategy(key); + } + } + + /** + * Resolves enum key to {@link GuildDefaultMessageNotifications} enum value + * @param {string|GuildDefaultMessageNotifications} key The key to lookup + * @returns {GuildDefaultMessageNotifications} + */ + static resolveGuildDefaultMessageNotifications(key) { + switch (key) { + case 'ALL_MESSAGES': + return GuildDefaultMessageNotifications.AllMessages; + case 'ONLY_MENTIONS': + return GuildDefaultMessageNotifications.OnlyMentions; + default: + return unknownKeyStrategy(key); + } + } + + /** + * Resolves enum key to {@link GuildExplicitContentFilter} enum value + * @param {string|GuildExplicitContentFilter} key The key to lookup + * @returns {GuildExplicitContentFilter} + */ + static resolveGuildExplicitContentFilter(key) { + switch (key) { + case 'DISABLED': + return GuildExplicitContentFilter.Disabled; + case 'MEMBERS_WITHOUT_ROLES': + return GuildExplicitContentFilter.MembersWithoutRoles; + case 'ALL_MEMBERS': + return GuildExplicitContentFilter.AllMembers; + default: + return unknownKeyStrategy(key); + } + } + + /** + * Resolves enum key to {@link GuildPremiumTier} enum value + * @param {string|GuildPremiumTier} key The key to lookup + * @returns {GuildPremiumTier} + */ + static resolveGuildPremiumTier(key) { + switch (key) { + case 'NONE': + return GuildPremiumTier.None; + case 'TIER_1': + return GuildPremiumTier.Tier1; + case 'TIER_2': + return GuildPremiumTier.Tier2; + case 'TIER_3': + return GuildPremiumTier.Tier3; + default: + return unknownKeyStrategy(key); + } + } + + /** + * Resolves enum key to {@link GuildScheduledEventStatus} enum value + * @param {string|GuildScheduledEventStatus} key The key to lookup + * @returns {GuildScheduledEventStatus} + */ + static resolveGuildScheduledEventStatus(key) { + switch (key) { + case 'SCHEDULED': + return GuildScheduledEventStatus.Scheduled; + case 'ACTIVE': + return GuildScheduledEventStatus.Active; + case 'COMPLETED': + return GuildScheduledEventStatus.Completed; + case 'CANCELED': + return GuildScheduledEventStatus.Canceled; + default: + return unknownKeyStrategy(key); + } + } + + /** + * Resolves enum key to {@link StageInstancePrivacyLevel} enum value + * @param {string|StageInstancePrivacyLevel} key The key to lookup + * @returns {StageInstancePrivacyLevel} + */ + static resolveStageInstancePrivacyLevel(key) { + switch (key) { + case 'PUBLIC': + return StageInstancePrivacyLevel.Public; + case 'GUILD_ONLY': + return StageInstancePrivacyLevel.GuildOnly; + default: + return unknownKeyStrategy(key); + } + } + + /** + * Resolves enum key to {@link GuildMFALevel} enum value + * @param {string|GuildMFALevel} key The key to lookup + * @returns {GuildMFALevel} + */ + static resolveGuildMFALevel(key) { + switch (key) { + case 'NONE': + return GuildMFALevel.None; + case 'ELEVATED': + return GuildMFALevel.Elevated; + default: + return unknownKeyStrategy(key); + } + } + + /** + * Resolves enum key to {@link TeamMemberMembershipState} enum value + * @param {string|TeamMemberMembershipState} key The key to lookup + * @returns {TeamMemberMembershipState} + */ + static resolveTeamMemberMembershipState(key) { + switch (key) { + case 'INVITED': + return TeamMemberMembershipState.Invited; + case 'ACCEPTED': + return TeamMemberMembershipState.Accepted; + default: + return unknownKeyStrategy(key); + } + } + + /** + * Resolves enum key to {@link GuildScheduledEventEntityType} enum value + * @param {string|GuildScheduledEventEntityType} key The key to lookup + * @returns {GuildScheduledEventEntityType} + */ + static resolveGuildScheduledEventEntityType(key) { + switch (key) { + case 'STAGE_INSTANCE': + return GuildScheduledEventEntityType.StageInstance; + case 'VOICE': + return GuildScheduledEventEntityType.Voice; + case 'EXTERNAL': + return GuildScheduledEventEntityType.External; + default: + return unknownKeyStrategy(key); + } + } } // Precondition logic wrapper diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 6237f9fd2..363f0f882 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -31,7 +31,6 @@ import { APIApplicationCommand, APIApplicationCommandInteractionData, APIApplicationCommandOption, - APIApplicationCommandPermission, APIAuditLogChange, APIButtonComponent, APIEmbed, @@ -58,7 +57,6 @@ import { GuildNSFWLevel, GuildPremiumTier, GuildVerificationLevel, - InteractionResponseType, InteractionType, InviteTargetType, MessageType, @@ -68,7 +66,6 @@ import { StickerFormatType, StickerType, TeamMemberMembershipState, - UserPremiumType, WebhookType, OverwriteType, GuildExplicitContentFilter, @@ -77,11 +74,9 @@ import { ApplicationCommandOptionType, ApplicationCommandType, ActivityType, - AuditLogEvent, GuildScheduledEventEntityType, GuildScheduledEventPrivacyLevel, GuildScheduledEventStatus, - RESTJSONErrorCodes, } from 'discord-api-types/v9'; import { ChildProcess } from 'node:child_process'; import { EventEmitter } from 'node:events'; @@ -189,10 +184,10 @@ export abstract class AnonymousGuild extends BaseGuild { protected constructor(client: Client, data: RawAnonymousGuildData, immediatePatch?: boolean); public banner: string | null; public description: string | null; - public nsfwLevel: GuildNSFWLevelKey; + public nsfwLevel: GuildNSFWLevel; public splash: string | null; public vanityURLCode: string | null; - public verificationLevel: GuildVerificationLevelKey; + public verificationLevel: GuildVerificationLevel; public bannerURL(options?: ImageURLOptions): string | null; public splashURL(options?: ImageURLOptions): string | null; } @@ -468,7 +463,7 @@ export class ButtonInteraction extends Mes ButtonComponent | APIButtonComponent, ButtonComponent | APIButtonComponent >; - public componentType: 'Button'; + public componentType: ComponentType.Button; public inGuild(): this is ButtonInteraction<'raw' | 'cached'>; public inCachedGuild(): this is ButtonInteraction<'cached'>; public inRawGuild(): this is ButtonInteraction<'raw'>; @@ -844,6 +839,20 @@ export class EnumResolvers extends null { public static resolveComponentType(key: string | ComponentType): ComponentType; public static resolveButtonStyle(key: string | ButtonStyle): ButtonStyle; public static resolveMessageType(key: string | MessageType): MessageType; + public static resolveGuildNSFWLevel(key: string | GuildNSFWLevel): GuildNSFWLevel; + public static resolveGuildVerificationLevel(key: string | GuildVerificationLevel): GuildVerificationLevel; + public static resolveGuildDefaultMessageNotifications( + key: string | GuildDefaultMessageNotifications, + ): GuildDefaultMessageNotifications; + public static resolveGuildExplicitContentFilter(key: string | GuildExplicitContentFilter): GuildExplicitContentFilter; + public static resolveGuildPremiumTier(key: string | GuildPremiumTier): GuildPremiumTier; + public static resolveGuildScheduledEventStatus(key: string | GuildScheduledEventStatus): GuildScheduledEventStatus; + public static resolveStageInstancePrivacyLevel(key: string | StageInstancePrivacyLevel): StageInstancePrivacyLevel; + public static resolveGuildMFALevel(key: string | GuildMFALevel): GuildMFALevel; + public static resolveTeamMemberMembershipState(key: string | TeamMemberMembershipState): TeamMemberMembershipState; + public static resolveGuildScheduledEventEntityType( + key: string | GuildScheduledEventEntityType, + ): GuildScheduledEventEntityType; } export class DiscordAPIError extends Error { @@ -893,10 +902,10 @@ export class Guild extends AnonymousGuild { public bans: GuildBanManager; public channels: GuildChannelManager; public commands: GuildApplicationCommandManager; - public defaultMessageNotifications: GuildDefaultMessageNotificationsKey | number; + public defaultMessageNotifications: GuildDefaultMessageNotifications; public discoverySplash: string | null; public emojis: GuildEmojiManager; - public explicitContentFilter: GuildExplicitContentFilterKey; + public explicitContentFilter: GuildExplicitContentFilter; public invites: GuildInviteManager; public readonly joinedAt: Date; public joinedTimestamp: number; @@ -911,7 +920,7 @@ export class Guild extends AnonymousGuild { public preferredLocale: string; public premiumSubscriptionCount: number | null; public premiumProgressBarEnabled: boolean; - public premiumTier: PremiumTier; + public premiumTier: GuildPremiumTier; public presences: PresenceManager; public readonly publicUpdatesChannel: TextChannel | null; public publicUpdatesChannelId: Snowflake | null; @@ -956,17 +965,14 @@ export class Guild extends AnonymousGuild { public setAFKTimeout(afkTimeout: number, reason?: string): Promise; public setBanner(banner: BufferResolvable | Base64Resolvable | null, reason?: string): Promise; public setDefaultMessageNotifications( - defaultMessageNotifications: GuildDefaultMessageNotificationsKey | number, + defaultMessageNotifications: GuildDefaultMessageNotifications, reason?: string, ): Promise; public setDiscoverySplash( discoverySplash: BufferResolvable | Base64Resolvable | null, reason?: string, ): Promise; - public setExplicitContentFilter( - explicitContentFilter: GuildExplicitContentFilterKey | number, - reason?: string, - ): Promise; + public setExplicitContentFilter(explicitContentFilter: GuildExplicitContentFilter, reason?: string): Promise; public setIcon(icon: BufferResolvable | Base64Resolvable | null, reason?: string): Promise; public setName(name: string, reason?: string): Promise; public setOwner(owner: GuildMemberResolvable, reason?: string): Promise; @@ -976,7 +982,7 @@ export class Guild extends AnonymousGuild { public setSplash(splash: BufferResolvable | Base64Resolvable | null, reason?: string): Promise; public setSystemChannel(systemChannel: TextChannelResolvable | null, reason?: string): Promise; public setSystemChannelFlags(systemChannelFlags: SystemChannelFlagsResolvable, reason?: string): Promise; - public setVerificationLevel(verificationLevel: GuildVerificationLevelKey | number, reason?: string): Promise; + public setVerificationLevel(verificationLevel: GuildVerificationLevel, reason?: string): Promise; public setPremiumProgressBarEnabled(enabled?: boolean, reason?: string): Promise; public setWidgetSettings(settings: GuildWidgetSettingsData, reason?: string): Promise; public toJSON(): unknown; @@ -1161,7 +1167,7 @@ export class GuildPreview extends Base { public toString(): string; } -export class GuildScheduledEvent extends Base { +export class GuildScheduledEvent extends Base { private constructor(client: Client, data: RawGuildScheduledEventData); public id: Snowflake; public guildId: Snowflake; @@ -1203,10 +1209,10 @@ export class GuildScheduledEvent>; public toString(): string; - public isActive(): this is GuildScheduledEvent<'Active'>; - public isCanceled(): this is GuildScheduledEvent<'Canceled'>; - public isCompleted(): this is GuildScheduledEvent<'Completed'>; - public isScheduled(): this is GuildScheduledEvent<'Scheduled'>; + public isActive(): this is GuildScheduledEvent; + public isCanceled(): this is GuildScheduledEvent; + public isCompleted(): this is GuildScheduledEvent; + public isScheduled(): this is GuildScheduledEvent; } export class GuildTemplate extends Base { @@ -1587,7 +1593,7 @@ export class MessageComponentInteraction e ActionRowComponent | Exclude, ActionRowComponent | Exclude >; - public componentType: Exclude; + public componentType: Exclude; public customId: string; public channelId: Snowflake; public deferred: boolean; @@ -1854,7 +1860,7 @@ export class SelectMenuInteraction extends SelectMenuComponent | APISelectMenuComponent, SelectMenuComponent | APISelectMenuComponent >; - public componentType: 'SelectMenu'; + public componentType: ComponentType.SelectMenu; public values: string[]; public inGuild(): this is SelectMenuInteraction<'raw' | 'cached'>; public inCachedGuild(): this is SelectMenuInteraction<'cached'>; @@ -1999,7 +2005,7 @@ export class StageInstance extends Base { public guildId: Snowflake; public channelId: Snowflake; public topic: string; - public privacyLevel: StageInstancePrivacyLevelKey; + public privacyLevel: StageInstancePrivacyLevel; /** @deprecated See https://github.com/discord/discord-api-docs/pull/4296 for more information */ public discoverableDisabled: boolean | null; public readonly channel: StageChannel | null; @@ -2152,7 +2158,7 @@ export class TeamMember extends Base { public team: Team; public readonly id: Snowflake; public permissions: string[]; - public membershipState: TeamMemberMembershipStateKey; + public membershipState: TeamMemberMembershipState; public user: User; public toString(): UserMention; @@ -2917,7 +2923,7 @@ export class GuildScheduledEventManager extends CachedManager< public fetch< T extends GuildScheduledEventResolvable | FetchGuildScheduledEventOptions | FetchGuildScheduledEventsOptions, >(options?: T): Promise>; - public edit>( + public edit>( guildScheduledEvent: GuildScheduledEventResolvable, options: GuildScheduledEventEditOptions, ): Promise>; @@ -3238,16 +3244,16 @@ export interface BaseApplicationCommandOptionsData { } export interface UserApplicationCommandData extends BaseApplicationCommandData { - type: 'User' | ApplicationCommandType.User; + type: ApplicationCommandType.User; } export interface MessageApplicationCommandData extends BaseApplicationCommandData { - type: 'Message' | ApplicationCommandType.Message; + type: ApplicationCommandType.Message; } export interface ChatInputApplicationCommandData extends BaseApplicationCommandData { description: string; - type?: 'ChatInput' | ApplicationCommandType.ChatInput; + type?: ApplicationCommandType.ChatInput; options?: ApplicationCommandOptionData[]; } @@ -3258,20 +3264,17 @@ export type ApplicationCommandData = export interface ApplicationCommandChannelOptionData extends BaseApplicationCommandOptionsData { type: CommandOptionChannelResolvableType; - channelTypes?: (keyof typeof ChannelType)[]; - channel_types?: (keyof typeof ChannelType)[]; + channelTypes?: ChannelType[]; + channel_types?: ChannelType[]; } export interface ApplicationCommandChannelOption extends BaseApplicationCommandOptionsData { type: ApplicationCommandOptionType.Channel; - channelTypes?: (keyof typeof ChannelType)[]; + channelTypes?: ChannelType[]; } export interface ApplicationCommandAutocompleteOption extends Omit { type: - | 'String' - | 'Number' - | 'Integer' | ApplicationCommandOptionType.String | ApplicationCommandOptionType.Number | ApplicationCommandOptionType.Integer; @@ -3305,17 +3308,17 @@ export interface ApplicationCommandNumericOption extends ApplicationCommandChoic } export interface ApplicationCommandSubGroupData extends Omit { - type: 'SubcommandGroup' | ApplicationCommandOptionType.SubcommandGroup; + type: ApplicationCommandOptionType.SubcommandGroup; options?: ApplicationCommandSubCommandData[]; } export interface ApplicationCommandSubGroup extends Omit { - type: 'SubcommandGroup'; + type: ApplicationCommandOptionType.SubcommandGroup; options?: ApplicationCommandSubCommand[]; } export interface ApplicationCommandSubCommandData extends Omit { - type: 'Subcommand' | ApplicationCommandOptionType.Subcommand; + type: ApplicationCommandOptionType.Subcommand; options?: ( | ApplicationCommandChoicesData | ApplicationCommandNonOptionsData @@ -3326,7 +3329,7 @@ export interface ApplicationCommandSubCommandData extends Omit { - type: 'Subcommand'; + type: ApplicationCommandOptionType.Subcommand; options?: (ApplicationCommandChoicesOption | ApplicationCommandNonOptions | ApplicationCommandChannelOption)[]; } @@ -3893,20 +3896,18 @@ export interface CreateRoleOptions extends RoleData { export interface StageInstanceCreateOptions { topic: string; - privacyLevel?: StageInstancePrivacyLevelKey | number; + privacyLevel?: StageInstancePrivacyLevel; } export interface CrosspostedChannel { channelId: Snowflake; guildId: Snowflake; - type: keyof typeof ChannelType; + type: ChannelType; name: string; } export type DateResolvable = Date | number | string; -export type GuildDefaultMessageNotificationsKey = keyof typeof GuildDefaultMessageNotifications; - export interface EditGuildTemplateOptions { name?: string; description?: string; @@ -3958,8 +3959,6 @@ export interface EscapeMarkdownOptions { codeBlockContent?: boolean; } -export type GuildExplicitContentFilterKey = keyof typeof GuildExplicitContentFilter; - export interface FetchApplicationCommandOptions extends BaseFetchOptions { guildId?: Snowflake; } @@ -4257,13 +4256,13 @@ export interface GuildCreateOptions { afkChannelId?: Snowflake | number; afkTimeout?: number; channels?: PartialChannelData[]; - defaultMessageNotifications?: GuildDefaultMessageNotificationsKey | number; - explicitContentFilter?: GuildExplicitContentFilterKey | number; + defaultMessageNotifications?: GuildDefaultMessageNotifications; + explicitContentFilter?: GuildExplicitContentFilter; icon?: BufferResolvable | Base64Resolvable | null; roles?: PartialRoleData[]; systemChannelFlags?: SystemChannelFlagsResolvable; systemChannelId?: Snowflake | number; - verificationLevel?: GuildVerificationLevelKey | number; + verificationLevel?: GuildVerificationLevel; } export interface GuildWidgetSettings { @@ -4273,9 +4272,9 @@ export interface GuildWidgetSettings { export interface GuildEditData { name?: string; - verificationLevel?: GuildVerificationLevelKey | number; - explicitContentFilter?: GuildExplicitContentFilterKey | number; - defaultMessageNotifications?: GuildDefaultMessageNotificationsKey | number; + verificationLevel?: GuildVerificationLevel; + explicitContentFilter?: GuildExplicitContentFilter; + defaultMessageNotifications?: GuildDefaultMessageNotifications; afkChannel?: VoiceChannelResolvable; systemChannel?: TextChannelResolvable; systemChannelFlags?: SystemChannelFlagsResolvable; @@ -4390,7 +4389,7 @@ export interface GuildScheduledEventCreateOptions { } export interface GuildScheduledEventEditOptions< - S extends GuildScheduledEventStatusKey, + S extends GuildScheduledEventStatus, T extends GuildScheduledEventSetStatusArg, > extends Omit, 'channel'> { channel?: GuildVoiceChannelResolvable | null; @@ -4418,13 +4417,12 @@ export type GuildScheduledEventManagerFetchSubscribersResult = T extends 'Scheduled' - ? 'Active' | 'Canceled' - : T extends 'Active' - ? 'Completed' - : never; - -export type GuildScheduledEventStatusKey = keyof typeof GuildScheduledEventStatus; +export type GuildScheduledEventSetStatusArg = + T extends GuildScheduledEventStatus.Scheduled + ? GuildScheduledEventStatus.Active | GuildScheduledEventStatus.Canceled + : T extends GuildScheduledEventStatus.Active + ? GuildScheduledEventStatus.Completed + : never; export interface GuildScheduledEventUser { guildScheduledEventId: Snowflake; @@ -4578,8 +4576,6 @@ export interface MakeErrorOptions { export type MemberMention = UserMention | `<@!${Snowflake}>`; -export type TeamMemberMembershipStateKey = keyof typeof TeamMemberMembershipState; - export type ActionRowComponentOptions = | (Required & MessageButtonOptions) | (Required & MessageSelectMenuOptions); @@ -4763,8 +4759,6 @@ export interface MultipleShardSpawnOptions { timeout?: number; } -export type GuildNSFWLevelKey = keyof typeof GuildNSFWLevel; - export interface OverwriteData { allow?: PermissionResolvable; deny?: PermissionResolvable; @@ -4833,8 +4827,6 @@ export interface PartialRecipient { username: string; } -export type PremiumTier = keyof typeof GuildPremiumTier; - export interface PresenceData { status?: PresenceStatusData; afk?: boolean; @@ -4911,8 +4903,6 @@ export type PresenceStatusData = ClientPresenceStatus | 'invisible'; export type PresenceStatus = PresenceStatusData | 'offline'; -export type StageInstancePrivacyLevelKey = keyof typeof StageInstancePrivacyLevel; - export interface RateLimitData { timeout: number; limit: number; @@ -5020,12 +5010,8 @@ export interface StartThreadOptions { export type Status = number; -export type StickerFormatKey = keyof typeof StickerFormatType; - export type StickerResolvable = Sticker | Snowflake; -export type StickerKey = keyof typeof StickerType; - export type SystemChannelFlagsString = | 'SUPPRESS_JOIN_NOTIFICATIONS' | 'SUPPRESS_PREMIUM_SUBSCRIPTIONS' @@ -5043,7 +5029,7 @@ export type StageChannelResolvable = StageChannel | Snowflake; export interface StageInstanceEditOptions { topic?: string; - privacyLevel?: StageInstancePrivacyLevelKey | number; + privacyLevel?: StageInstancePrivacyLevel; } export type SweeperKey = keyof SweeperDefinitions; @@ -5168,8 +5154,6 @@ export interface Vanity { uses: number; } -export type GuildVerificationLevelKey = keyof typeof GuildVerificationLevel; - export type VoiceBasedChannelTypes = VoiceBasedChannel['type']; export type VoiceChannelResolvable = Snowflake | VoiceChannel; diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index 24fd16c8e..f4eeb8f69 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -891,7 +891,7 @@ declare const applicationNonChoiceOptionData: ApplicationCommandOptionData & { declare const applicationSubGroupCommandData: ApplicationCommandSubGroupData; { - expectType<'SubcommandGroup' | ApplicationCommandOptionType.SubcommandGroup>(applicationSubGroupCommandData.type); + expectType(applicationSubGroupCommandData.type); expectType(applicationSubGroupCommandData.options); }