feat(enumResolvers): strengthen typings (#7344)

This commit is contained in:
IRONM00N
2022-01-26 04:24:13 -05:00
committed by GitHub
parent d6b56d0080
commit 9a566e8068
5 changed files with 347 additions and 63 deletions

View File

@@ -1,7 +1,6 @@
'use strict'; 'use strict';
const { Collection } = require('@discordjs/collection'); const { Collection } = require('@discordjs/collection');
const { InviteTargetType } = require('discord-api-types/v9');
const CachedManager = require('./CachedManager'); const CachedManager = require('./CachedManager');
const { Error } = require('../errors'); const { Error } = require('../errors');
const Invite = require('../structures/Invite'); const Invite = require('../structures/Invite');
@@ -191,7 +190,7 @@ class GuildInviteManager extends CachedManager {
unique, unique,
target_user_id: this.client.users.resolveId(targetUser), target_user_id: this.client.users.resolveId(targetUser),
target_application_id: targetApplication?.id ?? targetApplication?.applicationId ?? targetApplication, target_application_id: targetApplication?.id ?? targetApplication?.applicationId ?? targetApplication,
target_type: InviteTargetType[targetType], target_type: targetType,
}, },
reason, reason,
}); });

View File

@@ -2,7 +2,6 @@
const Base = require('./Base'); const Base = require('./Base');
const IntegrationApplication = require('./IntegrationApplication'); const IntegrationApplication = require('./IntegrationApplication');
const { IntegrationExpireBehaviors } = require('../util/Constants');
/** /**
* The information account for an integration * The information account for an integration
@@ -156,7 +155,7 @@ class Integration extends Base {
* The behavior of expiring subscribers * The behavior of expiring subscribers
* @type {?IntegrationExpireBehavior} * @type {?IntegrationExpireBehavior}
*/ */
this.expireBehavior = IntegrationExpireBehaviors[data.expire_behavior]; this.expireBehavior = data.expire_behavior;
} else { } else {
this.expireBehavior ??= null; this.expireBehavior ??= null;
} }

View File

@@ -377,15 +377,6 @@ exports.InviteScopes = [
'webhook.incoming', 'webhook.incoming',
]; ];
/**
* The behavior of expiring subscribers for Integrations. This can be:
* * REMOVE_ROLE
* * KICK
* @typedef {string} IntegrationExpireBehavior
* @see {@link https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors}
*/
exports.IntegrationExpireBehaviors = createEnum(['REMOVE_ROLE', 'KICK']);
/** /**
* The name of an item to be swept in Sweepers * The name of an item to be swept in Sweepers
* * `applicationCommands` - both global and guild commands * * `applicationCommands` - both global and guild commands
@@ -526,16 +517,6 @@ function keyMirror(arr) {
return tmp; return tmp;
} }
function createEnum(keys) {
const obj = {};
for (const [index, key] of keys.entries()) {
if (key === null) continue;
obj[key] = index;
obj[index] = key;
}
return obj;
}
/** /**
* @typedef {Object} Constants Constants that can be used in an enum or object-like way. * @typedef {Object} Constants Constants that can be used in an enum or object-like way.
* @property {Status} Status The available statuses of the client. * @property {Status} Status The available statuses of the client.

View File

@@ -19,6 +19,7 @@ const {
GuildMFALevel, GuildMFALevel,
TeamMemberMembershipState, TeamMemberMembershipState,
GuildScheduledEventEntityType, GuildScheduledEventEntityType,
IntegrationExpireBehavior,
} = require('discord-api-types/v9'); } = require('discord-api-types/v9');
function unknownKeyStrategy(val) { function unknownKeyStrategy(val) {
@@ -26,9 +27,24 @@ function unknownKeyStrategy(val) {
} }
class EnumResolvers extends null { class EnumResolvers extends null {
/**
* A string that can be resolved to a {@link ChannelType} enum value. Here are the available types:
* * GUILD_TEXT
* * DM
* * GUILD_VOICE
* * GROUP_DM
* * GUILD_CATEGORY
* * GUILD_NEWS
* * GUILD_NEWS_THREAD
* * GUILD_PUBLIC_THREAD
* * GUILD_PRIVATE_THREAD
* * GUILD_STAGE_VOICE
* @typedef {string} ChannelTypeEnumResolvable
*/
/** /**
* Resolves enum key to {@link ChannelType} enum value * Resolves enum key to {@link ChannelType} enum value
* @param {string|ChannelType} key The key to resolve * @param {ChannelTypeEnumResolvable|ChannelType} key The key to resolve
* @returns {ChannelType} * @returns {ChannelType}
*/ */
static resolveChannelType(key) { static resolveChannelType(key) {
@@ -58,9 +74,18 @@ class EnumResolvers extends null {
} }
} }
/**
* A string that can be resolved to an {@link InteractionType} enum value. Here are the available types:
* * PING
* * APPLICATION_COMMAND
* * MESSAGE_COMPONENT
* * APPLICATION_COMMAND_AUTOCOMPLETE
* @typedef {string} InteractionTypeEnumResolvable
*/
/** /**
* Resolves enum key to {@link InteractionType} enum value * Resolves enum key to {@link InteractionType} enum value
* @param {string|InteractionType} key The key to resolve * @param {InteractionTypeEnumResolvable|InteractionType} key The key to resolve
* @returns {InteractionType} * @returns {InteractionType}
*/ */
static resolveInteractionType(key) { static resolveInteractionType(key) {
@@ -78,9 +103,17 @@ class EnumResolvers extends null {
} }
} }
/**
* A string that can be resolved to an {@link ApplicationCommandType} enum value. Here are the available types:
* * CHAT_INPUT
* * USER
* * MESSAGE
* @typedef {string} ApplicationCommandTypeEnumResolvable
*/
/** /**
* Resolves enum key to {@link ApplicationCommandType} enum value * Resolves enum key to {@link ApplicationCommandType} enum value
* @param {string|ApplicationCommandType} key The key to resolve * @param {ApplicationCommandTypeEnumResolvable|ApplicationCommandType} key The key to resolve
* @returns {ApplicationCommandType} * @returns {ApplicationCommandType}
*/ */
static resolveApplicationCommandType(key) { static resolveApplicationCommandType(key) {
@@ -96,9 +129,24 @@ class EnumResolvers extends null {
} }
} }
/**
* A string that can be resolved to an {@link ApplicationCommandOptionType} enum value. Here are the available types:
* * SUB_COMMAND
* * SUB_COMMAND_GROUP
* * STRING
* * INTEGER
* * BOOLEAN
* * USER
* * CHANNEL
* * ROLE
* * NUMBER
* * MENTIONABLE
* @typedef {string} ApplicationCommandOptionTypeEnumResolvable
*/
/** /**
* Resolves enum key to {@link ApplicationCommandOptionType} enum value * Resolves enum key to {@link ApplicationCommandOptionType} enum value
* @param {string|ApplicationCommandOptionType} key The key to resolve * @param {ApplicationCommandOptionTypeEnumResolvable|ApplicationCommandOptionType} key The key to resolve
* @returns {ApplicationCommandOptionType} * @returns {ApplicationCommandOptionType}
*/ */
static resolveApplicationCommandOptionType(key) { static resolveApplicationCommandOptionType(key) {
@@ -128,9 +176,17 @@ class EnumResolvers extends null {
} }
} }
/**
* A string that can be resolved to an {@link ApplicationCommandPermissionType} enum value.
* Here are the available types:
* * ROLE
* * USER
* @typedef {string} ApplicationCommandPermissionTypeEnumResolvable
*/
/** /**
* Resolves enum key to {@link ApplicationCommandPermissionType} enum value * Resolves enum key to {@link ApplicationCommandPermissionType} enum value
* @param {string|ApplicationCommandPermissionType} key The key to resolve * @param {ApplicationCommandPermissionTypeEnumResolvable|ApplicationCommandPermissionType} key The key to resolve
* @returns {ApplicationCommandPermissionType} * @returns {ApplicationCommandPermissionType}
*/ */
static resolveApplicationCommandPermissionType(key) { static resolveApplicationCommandPermissionType(key) {
@@ -144,9 +200,17 @@ class EnumResolvers extends null {
} }
} }
/**
* A string that can be resolved to a {@link ComponentType} enum value. Here are the available types:
* * ACTION_ROW
* * BUTTON
* * SELECT_MENU
* @typedef {string} ComponentTypeEnumResolvable
*/
/** /**
* Resolves enum key to {@link ComponentType} enum value * Resolves enum key to {@link ComponentType} enum value
* @param {string|ComponentType} key The key to resolve * @param {ComponentTypeEnumResolvable|ComponentType} key The key to resolve
* @returns {ComponentType} * @returns {ComponentType}
*/ */
static resolveComponentType(key) { static resolveComponentType(key) {
@@ -162,9 +226,19 @@ class EnumResolvers extends null {
} }
} }
/**
* A string that can be resolved to a {@link ButtonStyle} enum value. Here are the available types:
* * PRIMARY
* * SECONDARY
* * SUCCESS
* * DANGER
* * LINK
* @typedef {string} ButtonStyleEnumResolvable
*/
/** /**
* Resolves enum key to {@link ButtonStyle} enum value * Resolves enum key to {@link ButtonStyle} enum value
* @param {string|ButtonStyle} key The key to resolve * @param {ButtonStyleEnumResolvable|ButtonStyle} key The key to resolve
* @returns {ButtonStyle} * @returns {ButtonStyle}
*/ */
static resolveButtonStyle(key) { static resolveButtonStyle(key) {
@@ -184,9 +258,37 @@ class EnumResolvers extends null {
} }
} }
/**
* A string that can be resolved to a {@link MessageType} enum value. Here are the available types:
* * DEFAULT
* * RECIPIENT_ADD
* * RECIPIENT_REMOVE
* * CALL
* * CHANNEL_NAME_CHANGE
* * CHANNEL_ICON_CHANGE
* * CHANNEL_PINNED_MESSAGE
* * GUILD_MEMBER_JOIN
* * USER_PREMIUM_GUILD_SUBSCRIPTION
* * USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1
* * USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2
* * USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3
* * CHANNEL_FOLLOW_ADD
* * GUILD_DISCOVERY_DISQUALIFIED
* * GUILD_DISCOVERY_REQUALIFIED
* * GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING
* * GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING
* * THREAD_CREATED
* * REPLY
* * CHAT_INPUT_COMMAND
* * THREAD_STARTER_MESSAGE
* * GUILD_INVITE_REMINDER
* * CONTEXT_MENU_COMMAND
* @typedef {string} MessageTypeEnumResolvable
*/
/** /**
* Resolves enum key to {@link MessageType} enum value * Resolves enum key to {@link MessageType} enum value
* @param {string|MessageType} key The key to lookup * @param {MessageTypeEnumResolvable|MessageType} key The key to lookup
* @returns {MessageType} * @returns {MessageType}
*/ */
static resolveMessageType(key) { static resolveMessageType(key) {
@@ -242,9 +344,18 @@ class EnumResolvers extends null {
} }
} }
/**
* A string that can be resolved to a {@link GuildNSFWLevel} enum value. Here are the available types:
* * DEFAULT
* * EXPLICIT
* * SAFE
* * AGE_RESTRICTED
* @typedef {string} GuildNSFWLevelEnumResolvable
*/
/** /**
* Resolves enum key to {@link GuildNSFWLevel} enum value * Resolves enum key to {@link GuildNSFWLevel} enum value
* @param {string|GuildNSFWLevel} key The key to lookup * @param {GuildNSFWLevelEnumResolvable|GuildNSFWLevel} key The key to lookup
* @returns {GuildNSFWLevel} * @returns {GuildNSFWLevel}
*/ */
static resolveGuildNSFWLevel(key) { static resolveGuildNSFWLevel(key) {
@@ -262,9 +373,19 @@ class EnumResolvers extends null {
} }
} }
/**
* A string that can be resolved to a {@link GuildVerificationLevel} enum value. Here are the available types:
* * NONE
* * LOW
* * MEDIUM
* * HIGH
* * VERY_HIGH
* @typedef {string} GuildVerificationLevelEnumResolvable
*/
/** /**
* Resolves enum key to {@link GuildVerificationLevel} enum value * Resolves enum key to {@link GuildVerificationLevel} enum value
* @param {string|GuildVerificationLevel} key The key to lookup * @param {GuildVerificationLevelEnumResolvable|GuildVerificationLevel} key The key to lookup
* @returns {GuildVerificationLevel} * @returns {GuildVerificationLevel}
*/ */
static resolveGuildVerificationLevel(key) { static resolveGuildVerificationLevel(key) {
@@ -284,9 +405,17 @@ class EnumResolvers extends null {
} }
} }
/**
* A string that can be resolved to a {@link GuildDefaultMessageNotifications} enum value.
* Here are the available types:
* * ALL_MESSAGES
* * ONLY_MENTIONS
* @typedef {string} GuildDefaultMessageNotificationsEnumResolvable
*/
/** /**
* Resolves enum key to {@link GuildDefaultMessageNotifications} enum value * Resolves enum key to {@link GuildDefaultMessageNotifications} enum value
* @param {string|GuildDefaultMessageNotifications} key The key to lookup * @param {GuildDefaultMessageNotificationsEnumResolvable|GuildDefaultMessageNotifications} key The key to lookup
* @returns {GuildDefaultMessageNotifications} * @returns {GuildDefaultMessageNotifications}
*/ */
static resolveGuildDefaultMessageNotifications(key) { static resolveGuildDefaultMessageNotifications(key) {
@@ -300,9 +429,17 @@ class EnumResolvers extends null {
} }
} }
/**
* A string that can be resolved to a {@link GuildExplicitContentFilter} enum value. Here are the available types:
* * DISABLED
* * MEMBERS_WITHOUT_ROLES
* * ALL_MEMBERS
* @typedef {string} GuildExplicitContentFilterEnumResolvable
*/
/** /**
* Resolves enum key to {@link GuildExplicitContentFilter} enum value * Resolves enum key to {@link GuildExplicitContentFilter} enum value
* @param {string|GuildExplicitContentFilter} key The key to lookup * @param {GuildExplicitContentFilterEnumResolvable|GuildExplicitContentFilter} key The key to lookup
* @returns {GuildExplicitContentFilter} * @returns {GuildExplicitContentFilter}
*/ */
static resolveGuildExplicitContentFilter(key) { static resolveGuildExplicitContentFilter(key) {
@@ -318,9 +455,18 @@ class EnumResolvers extends null {
} }
} }
/**
* A string that can be resolved to a {@link GuildPremiumTier} enum value. Here are the available types:
* * NONE
* * TIER_1
* * TIER_2
* * TIER_3
* @typedef {string} GuildPremiumTierEnumResolvable
*/
/** /**
* Resolves enum key to {@link GuildPremiumTier} enum value * Resolves enum key to {@link GuildPremiumTier} enum value
* @param {string|GuildPremiumTier} key The key to lookup * @param {GuildPremiumTierEnumResolvable|GuildPremiumTier} key The key to lookup
* @returns {GuildPremiumTier} * @returns {GuildPremiumTier}
*/ */
static resolveGuildPremiumTier(key) { static resolveGuildPremiumTier(key) {
@@ -338,9 +484,18 @@ class EnumResolvers extends null {
} }
} }
/**
* A string that can be resolved to a {@link GuildScheduledEventStatus} enum value. Here are the available types:
* * SCHEDULED
* * ACTIVE
* * COMPLETED
* * CANCELED
* @typedef {string} GuildScheduledEventStatusEnumResolvable
*/
/** /**
* Resolves enum key to {@link GuildScheduledEventStatus} enum value * Resolves enum key to {@link GuildScheduledEventStatus} enum value
* @param {string|GuildScheduledEventStatus} key The key to lookup * @param {GuildScheduledEventStatusEnumResolvable|GuildScheduledEventStatus} key The key to lookup
* @returns {GuildScheduledEventStatus} * @returns {GuildScheduledEventStatus}
*/ */
static resolveGuildScheduledEventStatus(key) { static resolveGuildScheduledEventStatus(key) {
@@ -358,9 +513,16 @@ class EnumResolvers extends null {
} }
} }
/**
* A string that can be resolved to a {@link StageInstancePrivacyLevel} enum value. Here are the available types:
* * PUBLIC
* * GUILD_ONLY
* @typedef {string} StageInstancePrivacyLevelEnumResolvable
*/
/** /**
* Resolves enum key to {@link StageInstancePrivacyLevel} enum value * Resolves enum key to {@link StageInstancePrivacyLevel} enum value
* @param {string|StageInstancePrivacyLevel} key The key to lookup * @param {StageInstancePrivacyLevelEnumResolvable|StageInstancePrivacyLevel} key The key to lookup
* @returns {StageInstancePrivacyLevel} * @returns {StageInstancePrivacyLevel}
*/ */
static resolveStageInstancePrivacyLevel(key) { static resolveStageInstancePrivacyLevel(key) {
@@ -374,9 +536,16 @@ class EnumResolvers extends null {
} }
} }
/**
* A string that can be resolved to a {@link GuildMFALevel} enum value. Here are the available types:
* * NONE
* * ELEVATED
* @typedef {string} GuildMFALevelEnumResolvable
*/
/** /**
* Resolves enum key to {@link GuildMFALevel} enum value * Resolves enum key to {@link GuildMFALevel} enum value
* @param {string|GuildMFALevel} key The key to lookup * @param {GuildMFALevelEnumResolvable|GuildMFALevel} key The key to lookup
* @returns {GuildMFALevel} * @returns {GuildMFALevel}
*/ */
static resolveGuildMFALevel(key) { static resolveGuildMFALevel(key) {
@@ -390,9 +559,16 @@ class EnumResolvers extends null {
} }
} }
/**
* A string that can be resolved to a {@link TeamMemberMembershipState} enum value. Here are the available types:
* * INVITED
* * ACCEPTED
* @typedef {string} TeamMemberMembershipStateEnumResolvable
*/
/** /**
* Resolves enum key to {@link TeamMemberMembershipState} enum value * Resolves enum key to {@link TeamMemberMembershipState} enum value
* @param {string|TeamMemberMembershipState} key The key to lookup * @param {TeamMemberMembershipStateEnumResolvable|TeamMemberMembershipState} key The key to lookup
* @returns {TeamMemberMembershipState} * @returns {TeamMemberMembershipState}
*/ */
static resolveTeamMemberMembershipState(key) { static resolveTeamMemberMembershipState(key) {
@@ -406,9 +582,17 @@ class EnumResolvers extends null {
} }
} }
/**
* A string that can be resolved to a {@link GuildScheduledEventEntityType} enum value. Here are the available types:
* * STAGE_INSTANCE
* * VOICE
* * EXTERNAL
* @typedef {string} GuildScheduledEventEntityTypeEnumResolvable
*/
/** /**
* Resolves enum key to {@link GuildScheduledEventEntityType} enum value * Resolves enum key to {@link GuildScheduledEventEntityType} enum value
* @param {string|GuildScheduledEventEntityType} key The key to lookup * @param {GuildScheduledEventEntityTypeEnumResolvable|GuildScheduledEventEntityType} key The key to lookup
* @returns {GuildScheduledEventEntityType} * @returns {GuildScheduledEventEntityType}
*/ */
static resolveGuildScheduledEventEntityType(key) { static resolveGuildScheduledEventEntityType(key) {
@@ -423,6 +607,29 @@ class EnumResolvers extends null {
return unknownKeyStrategy(key); return unknownKeyStrategy(key);
} }
} }
/**
* A string that can be resolved to a {@link IntegrationExpireBehavior} enum value. Here are the available types:
* * REMOVE_ROLE
* * KICK
* @typedef {string} IntegrationExpireBehaviorEnumResolvable
*/
/**
* Resolves enum key to {@link IntegrationExpireBehavior} enum value
* @param {IntegrationExpireBehaviorEnumResolvable|IntegrationExpireBehavior} key The key to lookup
* @returns {IntegrationExpireBehavior}
*/
static resolveIntegrationExpireBehavior(key) {
switch (key) {
case 'REMOVE_ROLE':
return IntegrationExpireBehavior.RemoveRole;
case 'KICK':
return IntegrationExpireBehavior.Kick;
default:
return unknownKeyStrategy(key);
}
}
} }
// Precondition logic wrapper // Precondition logic wrapper

View File

@@ -77,6 +77,7 @@ import {
GuildScheduledEventEntityType, GuildScheduledEventEntityType,
GuildScheduledEventPrivacyLevel, GuildScheduledEventPrivacyLevel,
GuildScheduledEventStatus, GuildScheduledEventStatus,
IntegrationExpireBehavior,
} from 'discord-api-types/v9'; } from 'discord-api-types/v9';
import { ChildProcess } from 'node:child_process'; import { ChildProcess } from 'node:child_process';
import { EventEmitter } from 'node:events'; import { EventEmitter } from 'node:events';
@@ -827,32 +828,47 @@ export class DataResolver extends null {
export class EnumResolvers extends null { export class EnumResolvers extends null {
private constructor(); private constructor();
public static resolveChannelType(key: string | ChannelType): ChannelType; public static resolveChannelType(key: ChannelTypeEnumResolvable | ChannelType): ChannelType;
public static resolveInteractionType(key: string | InteractionType): InteractionType; public static resolveInteractionType(key: InteractionTypeEnumResolvable | InteractionType): InteractionType;
public static resolveApplicationCommandType(key: string | ApplicationCommandType): ApplicationCommandType; public static resolveApplicationCommandType(
key: ApplicationCommandTypeEnumResolvable | ApplicationCommandType,
): ApplicationCommandType;
public static resolveApplicationCommandOptionType( public static resolveApplicationCommandOptionType(
key: string | ApplicationCommandOptionType, key: ApplicationCommandOptionTypeEnumResolvable | ApplicationCommandOptionType,
): ApplicationCommandOptionType; ): ApplicationCommandOptionType;
public static resolveApplicationCommandPermissionType( public static resolveApplicationCommandPermissionType(
key: string | ApplicationCommandPermissionType, key: ApplicationCommandPermissionTypeEnumResolvable | ApplicationCommandPermissionType,
): ApplicationCommandPermissionType; ): ApplicationCommandPermissionType;
public static resolveComponentType(key: string | ComponentType): ComponentType; public static resolveComponentType(key: ComponentTypeEnumResolvable | ComponentType): ComponentType;
public static resolveButtonStyle(key: string | ButtonStyle): ButtonStyle; public static resolveButtonStyle(key: ButtonStyleEnumResolvable | ButtonStyle): ButtonStyle;
public static resolveMessageType(key: string | MessageType): MessageType; public static resolveMessageType(key: MessageTypeEnumResolvable | MessageType): MessageType;
public static resolveGuildNSFWLevel(key: string | GuildNSFWLevel): GuildNSFWLevel; public static resolveGuildNSFWLevel(key: GuildNSFWLevelEnumResolvable | GuildNSFWLevel): GuildNSFWLevel;
public static resolveGuildVerificationLevel(key: string | GuildVerificationLevel): GuildVerificationLevel; public static resolveGuildVerificationLevel(
key: GuildVerificationLevelEnumResolvable | GuildVerificationLevel,
): GuildVerificationLevel;
public static resolveGuildDefaultMessageNotifications( public static resolveGuildDefaultMessageNotifications(
key: string | GuildDefaultMessageNotifications, key: GuildDefaultMessageNotificationsEnumResolvable | GuildDefaultMessageNotifications,
): GuildDefaultMessageNotifications; ): GuildDefaultMessageNotifications;
public static resolveGuildExplicitContentFilter(key: string | GuildExplicitContentFilter): GuildExplicitContentFilter; public static resolveGuildExplicitContentFilter(
public static resolveGuildPremiumTier(key: string | GuildPremiumTier): GuildPremiumTier; key: GuildExplicitContentFilterEnumResolvable | GuildExplicitContentFilter,
public static resolveGuildScheduledEventStatus(key: string | GuildScheduledEventStatus): GuildScheduledEventStatus; ): GuildExplicitContentFilter;
public static resolveStageInstancePrivacyLevel(key: string | StageInstancePrivacyLevel): StageInstancePrivacyLevel; public static resolveGuildPremiumTier(key: GuildPremiumTierEnumResolvable | GuildPremiumTier): GuildPremiumTier;
public static resolveGuildMFALevel(key: string | GuildMFALevel): GuildMFALevel; public static resolveGuildScheduledEventStatus(
public static resolveTeamMemberMembershipState(key: string | TeamMemberMembershipState): TeamMemberMembershipState; key: GuildScheduledEventStatusEnumResolvable | GuildScheduledEventStatus,
): GuildScheduledEventStatus;
public static resolveStageInstancePrivacyLevel(
key: StageInstancePrivacyLevelEnumResolvable | StageInstancePrivacyLevel,
): StageInstancePrivacyLevel;
public static resolveGuildMFALevel(key: GuildMFALevelEnumResolvable | GuildMFALevel): GuildMFALevel;
public static resolveTeamMemberMembershipState(
key: TeamMemberMembershipStateEnumResolvable | TeamMemberMembershipState,
): TeamMemberMembershipState;
public static resolveGuildScheduledEventEntityType( public static resolveGuildScheduledEventEntityType(
key: string | GuildScheduledEventEntityType, key: GuildScheduledEventEntityTypeEnumResolvable | GuildScheduledEventEntityType,
): GuildScheduledEventEntityType; ): GuildScheduledEventEntityType;
public static resolveIntegrationExpireBehavior(
key: IntegrationExpireBehaviorEnumResolvable | IntegrationExpireBehavior,
): IntegrationExpireBehavior;
} }
export class DiscordAPIError extends Error { export class DiscordAPIError extends Error {
@@ -1266,7 +1282,7 @@ export class Integration extends Base {
public account: IntegrationAccount; public account: IntegrationAccount;
public application: IntegrationApplication | null; public application: IntegrationApplication | null;
public enabled: boolean; public enabled: boolean;
public expireBehavior: IntegrationExpireBehaviors | null; public expireBehavior: IntegrationExpireBehavior | null;
public expireGracePeriod: number | null; public expireGracePeriod: number | null;
public guild: Guild; public guild: Guild;
public id: Snowflake | string; public id: Snowflake | string;
@@ -2662,7 +2678,6 @@ export const Constants: {
ThreadChannelTypes: ThreadChannelType[]; ThreadChannelTypes: ThreadChannelType[];
TextBasedChannelTypes: TextBasedChannelTypes[]; TextBasedChannelTypes: TextBasedChannelTypes[];
VoiceBasedChannelTypes: VoiceBasedChannelTypes[]; VoiceBasedChannelTypes: VoiceBasedChannelTypes[];
IntegrationExpireBehaviors: IntegrationExpireBehaviors[];
InviteScopes: InviteScope[]; InviteScopes: InviteScope[];
MessageTypes: MessageType[]; MessageTypes: MessageType[];
SystemMessageTypes: SystemMessageType[]; SystemMessageTypes: SystemMessageType[];
@@ -3940,6 +3955,91 @@ export type EmojiIdentifierResolvable = string | EmojiResolvable;
export type EmojiResolvable = Snowflake | GuildEmoji | ReactionEmoji; export type EmojiResolvable = Snowflake | GuildEmoji | ReactionEmoji;
export type ChannelTypeEnumResolvable =
| 'GUILD_TEXT'
| 'DM'
| 'GUILD_VOICE'
| 'GROUP_DM'
| 'GUILD_CATEGORY'
| 'GUILD_NEWS'
| 'GUILD_NEWS_THREAD'
| 'GUILD_PUBLIC_THREAD'
| 'GUILD_PRIVATE_THREAD'
| 'GUILD_STAGE_VOICE';
export type InteractionTypeEnumResolvable =
| 'PING'
| 'APPLICATION_COMMAND'
| 'MESSAGE_COMPONENT'
| 'APPLICATION_COMMAND_AUTOCOMPLETE';
export type ApplicationCommandTypeEnumResolvable = 'CHAT_INPUT' | 'USER' | 'MESSAGE';
export type ApplicationCommandOptionTypeEnumResolvable =
| 'SUB_COMMAND'
| 'SUB_COMMAND_GROUP'
| 'STRING'
| 'INTEGER'
| 'BOOLEAN'
| 'USER'
| 'CHANNEL'
| 'ROLE'
| 'NUMBER'
| 'MENTIONABLE';
export type ApplicationCommandPermissionTypeEnumResolvable = 'ROLE' | 'USER';
export type ComponentTypeEnumResolvable = 'ACTION_ROW' | 'BUTTON' | 'SELECT_MENU';
export type ButtonStyleEnumResolvable = 'PRIMARY' | 'SECONDARY' | 'SUCCESS' | 'DANGER' | 'LINK';
export type MessageTypeEnumResolvable =
| 'DEFAULT'
| 'RECIPIENT_ADD'
| 'RECIPIENT_REMOVE'
| 'CALL'
| 'CHANNEL_NAME_CHANGE'
| 'CHANNEL_ICON_CHANGE'
| 'CHANNEL_PINNED_MESSAGE'
| 'GUILD_MEMBER_JOIN'
| 'USER_PREMIUM_GUILD_SUBSCRIPTION'
| 'USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1'
| 'USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2'
| 'USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3'
| 'CHANNEL_FOLLOW_ADD'
| 'GUILD_DISCOVERY_DISQUALIFIED'
| 'GUILD_DISCOVERY_REQUALIFIED'
| 'GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING'
| 'GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING'
| 'THREAD_CREATED'
| 'REPLY'
| 'CHAT_INPUT_COMMAND'
| 'THREAD_STARTER_MESSAGE'
| 'GUILD_INVITE_REMINDER'
| 'CONTEXT_MENU_COMMAND';
export type GuildNSFWLevelEnumResolvable = 'DEFAULT' | 'EXPLICIT' | 'SAFE' | 'AGE_RESTRICTED';
export type GuildVerificationLevelEnumResolvable = 'NONE' | 'LOW' | 'MEDIUM' | 'HIGH' | 'VERY_HIGH';
export type GuildDefaultMessageNotificationsEnumResolvable = 'ALL_MESSAGES' | 'ONLY_MENTIONS';
export type GuildExplicitContentFilterEnumResolvable = 'DISABLED' | 'MEMBERS_WITHOUT_ROLES' | 'ALL_MEMBERS';
export type GuildPremiumTierEnumResolvable = 'NONE' | 'TIER_1' | 'TIER_2' | 'TIER_3';
export type GuildScheduledEventStatusEnumResolvable = 'SCHEDULED' | 'ACTIVE' | 'COMPLETED' | 'CANCELED';
export type StageInstancePrivacyLevelEnumResolvable = 'PUBLIC' | 'GUILD_ONLY';
export type GuildMFALevelEnumResolvable = 'NONE' | 'ELEVATED';
export type TeamMemberMembershipStateEnumResolvable = 'INVITED' | 'ACCEPTED';
export type GuildScheduledEventEntityTypeEnumResolvable = 'STAGE_INSTANCE' | 'VOICE' | 'EXTERNAL';
export type IntegrationExpireBehaviorEnumResolvable = 'REMOVE_ROLE' | 'KICK';
export interface ErrorEvent { export interface ErrorEvent {
error: unknown; error: unknown;
message: string; message: string;
@@ -4545,8 +4645,6 @@ export interface CreateInviteOptions {
targetType?: InviteTargetType; targetType?: InviteTargetType;
} }
export type IntegrationExpireBehaviors = 'REMOVE_ROLE' | 'KICK';
export type InviteResolvable = string; export type InviteResolvable = string;
export type InviteScope = export type InviteScope =