From aa6d1c74de01dd9a8f020c43fb2c193c4729df8d Mon Sep 17 00:00:00 2001 From: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com> Date: Tue, 11 Jan 2022 20:00:41 -0500 Subject: [PATCH] refactor: remove discord.js enums and use discord-api-types enums instead (#7077) --- .../src/client/actions/ChannelUpdate.js | 4 +- .../src/client/actions/InteractionCreate.js | 35 +- packages/discord.js/src/index.js | 25 + .../src/managers/ApplicationCommandManager.js | 4 +- .../ApplicationCommandPermissionsManager.js | 10 +- .../src/managers/GuildChannelManager.js | 7 +- .../discord.js/src/managers/GuildManager.js | 26 +- .../managers/GuildScheduledEventManager.js | 18 +- .../managers/PermissionOverwriteManager.js | 4 +- .../src/managers/StageInstanceManager.js | 6 +- .../discord.js/src/managers/ThreadManager.js | 9 +- .../src/structures/AnonymousGuild.js | 6 +- .../src/structures/ApplicationCommand.js | 18 +- .../src/structures/AutocompleteInteraction.js | 6 +- packages/discord.js/src/structures/Channel.js | 27 +- .../src/structures/ClientPresence.js | 7 +- .../src/structures/CommandInteraction.js | 4 +- .../ContextMenuCommandInteraction.js | 6 +- packages/discord.js/src/structures/Guild.js | 45 +- .../src/structures/GuildAuditLogs.js | 246 ++--- .../discord.js/src/structures/GuildChannel.js | 7 +- .../src/structures/GuildScheduledEvent.js | 26 +- .../discord.js/src/structures/Interaction.js | 26 +- .../src/structures/InteractionCollector.js | 8 +- packages/discord.js/src/structures/Message.js | 9 +- .../structures/MessageComponentInteraction.js | 6 +- .../src/structures/MessageMentions.js | 4 +- .../src/structures/PermissionOverwrites.js | 14 +- .../discord.js/src/structures/Presence.js | 4 +- .../src/structures/StageInstance.js | 6 +- packages/discord.js/src/structures/Sticker.js | 6 +- .../discord.js/src/structures/TeamMember.js | 6 +- packages/discord.js/src/structures/Webhook.js | 6 +- .../interfaces/InteractionResponses.js | 10 +- .../structures/interfaces/TextBasedChannel.js | 4 +- packages/discord.js/src/util/Constants.js | 633 ------------- packages/discord.js/typings/enums.d.ts | 198 ---- packages/discord.js/typings/index.d.ts | 875 ++++++++---------- packages/discord.js/typings/index.test-d.ts | 192 ++-- 39 files changed, 744 insertions(+), 1809 deletions(-) delete mode 100644 packages/discord.js/typings/enums.d.ts diff --git a/packages/discord.js/src/client/actions/ChannelUpdate.js b/packages/discord.js/src/client/actions/ChannelUpdate.js index 34d1a86a4..dab52d153 100644 --- a/packages/discord.js/src/client/actions/ChannelUpdate.js +++ b/packages/discord.js/src/client/actions/ChannelUpdate.js @@ -1,8 +1,8 @@ 'use strict'; +const { ChannelType } = require('discord-api-types/v9'); const Action = require('./Action'); const { Channel } = require('../../structures/Channel'); -const { ChannelTypes } = require('../../util/Constants'); class ChannelUpdateAction extends Action { handle(data) { @@ -12,7 +12,7 @@ class ChannelUpdateAction extends Action { if (channel) { const old = channel._update(data); - if (ChannelTypes[channel.type] !== data.type) { + if (ChannelType[channel.type] !== data.type) { const newChannel = Channel.create(this.client, data, channel.guild); for (const [id, message] of channel.messages.cache) newChannel.messages.cache.set(id, message); channel = newChannel; diff --git a/packages/discord.js/src/client/actions/InteractionCreate.js b/packages/discord.js/src/client/actions/InteractionCreate.js index e412f1a9a..432281bae 100644 --- a/packages/discord.js/src/client/actions/InteractionCreate.js +++ b/packages/discord.js/src/client/actions/InteractionCreate.js @@ -1,5 +1,6 @@ 'use strict'; +const { InteractionType, ComponentType, ApplicationCommandType } = require('discord-api-types/v9'); const Action = require('./Action'); const AutocompleteInteraction = require('../../structures/AutocompleteInteraction'); const ButtonInteraction = require('../../structures/ButtonInteraction'); @@ -7,7 +8,7 @@ const ChatInputCommandInteraction = require('../../structures/ChatInputCommandIn const MessageContextMenuCommandInteraction = require('../../structures/MessageContextMenuCommandInteraction'); const SelectMenuInteraction = require('../../structures/SelectMenuInteraction'); const UserContextMenuCommandInteraction = require('../../structures/UserContextMenuCommandInteraction'); -const { Events, InteractionTypes, MessageComponentTypes, ApplicationCommandTypes } = require('../../util/Constants'); +const { Events } = require('../../util/Constants'); class InteractionCreateAction extends Action { handle(data) { @@ -16,18 +17,18 @@ class InteractionCreateAction extends Action { // Resolve and cache partial channels for Interaction#channel getter this.getChannel(data); - let InteractionType; + let InteractionClass; switch (data.type) { - case InteractionTypes.APPLICATION_COMMAND: + case InteractionType.ApplicationCommand: switch (data.data.type) { - case ApplicationCommandTypes.CHAT_INPUT: - InteractionType = ChatInputCommandInteraction; + case ApplicationCommandType.ChatInput: + InteractionClass = ChatInputCommandInteraction; break; - case ApplicationCommandTypes.USER: - InteractionType = UserContextMenuCommandInteraction; + case ApplicationCommandType.User: + InteractionClass = UserContextMenuCommandInteraction; break; - case ApplicationCommandTypes.MESSAGE: - InteractionType = MessageContextMenuCommandInteraction; + case ApplicationCommandType.Message: + InteractionClass = MessageContextMenuCommandInteraction; break; default: client.emit( @@ -37,13 +38,13 @@ class InteractionCreateAction extends Action { return; } break; - case InteractionTypes.MESSAGE_COMPONENT: + case InteractionType.MessageComponent: switch (data.data.component_type) { - case MessageComponentTypes.BUTTON: - InteractionType = ButtonInteraction; + case ComponentType.Button: + InteractionClass = ButtonInteraction; break; - case MessageComponentTypes.SELECT_MENU: - InteractionType = SelectMenuInteraction; + case ComponentType.SelectMenu: + InteractionClass = SelectMenuInteraction; break; default: client.emit( @@ -53,15 +54,15 @@ class InteractionCreateAction extends Action { return; } break; - case InteractionTypes.APPLICATION_COMMAND_AUTOCOMPLETE: - InteractionType = AutocompleteInteraction; + case InteractionType.ApplicationCommandAutocomplete: + InteractionClass = AutocompleteInteraction; break; default: client.emit(Events.DEBUG, `[INTERACTION] Received interaction with unknown type: ${data.type}`); return; } - const interaction = new InteractionType(client, data); + const interaction = new InteractionClass(client, data); /** * Emitted when an interaction is created. diff --git a/packages/discord.js/src/index.js b/packages/discord.js/src/index.js index d734a34b9..0c6bc1193 100644 --- a/packages/discord.js/src/index.js +++ b/packages/discord.js/src/index.js @@ -155,3 +155,28 @@ exports.WelcomeChannel = require('./structures/WelcomeChannel'); exports.WelcomeScreen = require('./structures/WelcomeScreen'); exports.WebSocket = require('./WebSocket'); + +// External +exports.ActivityType = require('discord-api-types/v9').ActivityType; +exports.ApplicationCommandType = require('discord-api-types/v9').ApplicationCommandOptionType; +exports.ApplicationCommandOptionType = require('discord-api-types/v9').ApplicationCommandOptionType; +exports.ApplicationCommandPermissionType = require('discord-api-types/v9').ApplicationCommandPermissionType; +exports.ButtonStyle = require('discord-api-types/v9').ButtonStyle; +exports.ChannelType = require('discord-api-types/v9').ChannelType; +exports.ComponentType = require('discord-api-types/v9').ComponentType; +exports.GuildMFALevel = require('discord-api-types/v9').GuildMFALevel; +exports.GuildNSFWLevel = require('discord-api-types/v9').GuildNSFWLevel; +exports.GuildPremiumTier = require('discord-api-types/v9').GuildPremiumTier; +exports.GuildScheduledEventEntityType = require('discord-api-types/v9').GuildScheduledEventEntityType; +exports.GuildScheduledEventPrivacyLevel = require('discord-api-types/v9').GuildScheduledEventPrivacyLevel; +exports.GuildScheduledEventStatus = require('discord-api-types/v9').GuildScheduledEventStatus; +exports.GuildVerificationLevel = require('discord-api-types/v9').GuildVerificationLevel; +exports.InteractionType = require('discord-api-types/v9').InteractionType; +exports.InteractionResponseType = require('discord-api-types/v9').InteractionResponseType; +exports.InviteTargetType = require('discord-api-types/v9').InviteTargetType; +exports.MessageType = require('discord-api-types/v9').MessageType; +exports.RESTJSONErrorCodes = require('discord-api-types/v9').RESTJSONErrorCodes; +exports.StageInstancePrivacyLevel = require('discord-api-types/v9').StageInstancePrivacyLevel; +exports.StickerType = require('discord-api-types/v9').StickerType; +exports.StickerFormatType = require('discord-api-types/v9').StickerFormatType; +exports.WebhookType = require('discord-api-types/v9').WebhookType; diff --git a/packages/discord.js/src/managers/ApplicationCommandManager.js b/packages/discord.js/src/managers/ApplicationCommandManager.js index 5456dd578..4dbec0929 100644 --- a/packages/discord.js/src/managers/ApplicationCommandManager.js +++ b/packages/discord.js/src/managers/ApplicationCommandManager.js @@ -1,11 +1,11 @@ 'use strict'; const { Collection } = require('@discordjs/collection'); +const { ApplicationCommandType } = require('discord-api-types/v9'); const ApplicationCommandPermissionsManager = require('./ApplicationCommandPermissionsManager'); const CachedManager = require('./CachedManager'); const { TypeError } = require('../errors'); const ApplicationCommand = require('../structures/ApplicationCommand'); -const { ApplicationCommandTypes } = require('../util/Constants'); /** * Manages API methods for application commands and stores their cache. @@ -207,7 +207,7 @@ class ApplicationCommandManager extends CachedManager { return { name: command.name, description: command.description, - type: typeof command.type === 'number' ? command.type : ApplicationCommandTypes[command.type], + type: typeof command.type === 'number' ? command.type : ApplicationCommandType[command.type], options: command.options?.map(o => ApplicationCommand.transformOption(o)), default_permission: command.defaultPermission ?? command.default_permission, }; diff --git a/packages/discord.js/src/managers/ApplicationCommandPermissionsManager.js b/packages/discord.js/src/managers/ApplicationCommandPermissionsManager.js index a93a8f276..bb46a558c 100644 --- a/packages/discord.js/src/managers/ApplicationCommandPermissionsManager.js +++ b/packages/discord.js/src/managers/ApplicationCommandPermissionsManager.js @@ -1,9 +1,9 @@ 'use strict'; const { Collection } = require('@discordjs/collection'); +const { ApplicationCommandPermissionType, RESTJSONErrorCodes } = require('discord-api-types/v9'); const BaseManager = require('./BaseManager'); const { Error, TypeError } = require('../errors'); -const { ApplicationCommandPermissionTypes, APIErrors } = require('../util/Constants'); /** * Manages API methods for permissions of Application Commands. @@ -230,7 +230,7 @@ class ApplicationCommandPermissionsManager extends BaseManager { try { existing = await this.fetch({ guild: guildId, command: commandId }); } catch (error) { - if (error.code !== APIErrors.UNKNOWN_APPLICATION_COMMAND_PERMISSIONS) throw error; + if (error.code !== RESTJSONErrorCodes.UnknownApplicationCommandPermissions) throw error; } const newPermissions = permissions.slice(); @@ -319,7 +319,7 @@ class ApplicationCommandPermissionsManager extends BaseManager { try { existing = await this.fetch({ guild: guildId, command: commandId }); } catch (error) { - if (error.code !== APIErrors.UNKNOWN_APPLICATION_COMMAND_PERMISSIONS) throw error; + if (error.code !== RESTJSONErrorCodes.UnknownApplicationCommandPermissions) throw error; } const permissions = existing.filter(perm => !resolvedIds.includes(perm.id)); @@ -366,7 +366,7 @@ class ApplicationCommandPermissionsManager extends BaseManager { try { existing = await this.fetch({ guild: guildId, command: commandId }); } catch (error) { - if (error.code !== APIErrors.UNKNOWN_APPLICATION_COMMAND_PERMISSIONS) throw error; + if (error.code !== RESTJSONErrorCodes.UnknownApplicationCommandPermissions) throw error; } return existing.some(perm => perm.id === resolvedId); @@ -403,7 +403,7 @@ class ApplicationCommandPermissionsManager extends BaseManager { type: typeof permissions.type === 'number' && !received ? permissions.type - : ApplicationCommandPermissionTypes[permissions.type], + : ApplicationCommandPermissionType[permissions.type], }; } } diff --git a/packages/discord.js/src/managers/GuildChannelManager.js b/packages/discord.js/src/managers/GuildChannelManager.js index dfb97fc25..e5183947d 100644 --- a/packages/discord.js/src/managers/GuildChannelManager.js +++ b/packages/discord.js/src/managers/GuildChannelManager.js @@ -2,13 +2,14 @@ const process = require('node:process'); const { Collection } = require('@discordjs/collection'); +const { ChannelType } = require('discord-api-types/v9'); const CachedManager = require('./CachedManager'); const ThreadManager = require('./ThreadManager'); const { Error } = require('../errors'); const GuildChannel = require('../structures/GuildChannel'); const PermissionOverwrites = require('../structures/PermissionOverwrites'); const ThreadChannel = require('../structures/ThreadChannel'); -const { ChannelTypes, ThreadChannelTypes } = require('../util/Constants'); +const { ThreadChannelTypes } = require('../util/Constants'); let cacheWarningEmitted = false; let storeChannelDeprecationEmitted = false; @@ -139,9 +140,9 @@ class GuildChannelManager extends CachedManager { ) { parent &&= this.client.channels.resolveId(parent); permissionOverwrites &&= permissionOverwrites.map(o => PermissionOverwrites.resolve(o, this.guild)); - const intType = typeof type === 'number' ? type : ChannelTypes[type] ?? ChannelTypes.GUILD_TEXT; + const intType = typeof type === 'number' ? type : ChannelType[type] ?? ChannelType.GuildText; - if (intType === ChannelTypes.GUILD_STORE && !storeChannelDeprecationEmitted) { + if (intType === ChannelType.GuildStore && !storeChannelDeprecationEmitted) { storeChannelDeprecationEmitted = true; process.emitWarning( // eslint-disable-next-line max-len diff --git a/packages/discord.js/src/managers/GuildManager.js b/packages/discord.js/src/managers/GuildManager.js index ad6c0d056..82eb3db54 100644 --- a/packages/discord.js/src/managers/GuildManager.js +++ b/packages/discord.js/src/managers/GuildManager.js @@ -3,6 +3,13 @@ const process = require('node:process'); const { setTimeout } = require('node:timers'); const { Collection } = require('@discordjs/collection'); +const { + GuildVerificationLevel, + GuildDefaultMessageNotifications, + GuildExplicitContentFilter, + ChannelType, + OverwriteType, +} = require('discord-api-types/v9'); const CachedManager = require('./CachedManager'); const { Guild } = require('../structures/Guild'); const GuildChannel = require('../structures/GuildChannel'); @@ -11,14 +18,7 @@ const { GuildMember } = require('../structures/GuildMember'); const Invite = require('../structures/Invite'); const OAuth2Guild = require('../structures/OAuth2Guild'); const { Role } = require('../structures/Role'); -const { - ChannelTypes, - Events, - OverwriteTypes, - VerificationLevels, - DefaultMessageNotificationLevels, - ExplicitContentFilterLevels, -} = require('../util/Constants'); +const { Events } = require('../util/Constants'); const DataResolver = require('../util/DataResolver'); const Permissions = require('../util/Permissions'); const SystemChannelFlags = require('../util/SystemChannelFlags'); @@ -182,16 +182,16 @@ class GuildManager extends CachedManager { ) { icon = await DataResolver.resolveImage(icon); if (typeof verificationLevel === 'string') { - verificationLevel = VerificationLevels[verificationLevel]; + verificationLevel = GuildVerificationLevel[verificationLevel]; } if (typeof defaultMessageNotifications === 'string') { - defaultMessageNotifications = DefaultMessageNotificationLevels[defaultMessageNotifications]; + defaultMessageNotifications = GuildDefaultMessageNotifications[defaultMessageNotifications]; } if (typeof explicitContentFilter === 'string') { - explicitContentFilter = ExplicitContentFilterLevels[explicitContentFilter]; + explicitContentFilter = GuildExplicitContentFilter[explicitContentFilter]; } for (const channel of channels) { - channel.type &&= typeof channel.type === 'number' ? channel.type : ChannelTypes[channel.type]; + channel.type &&= typeof channel.type === 'number' ? channel.type : ChannelType[channel.type]; channel.parent_id = channel.parentId; delete channel.parentId; channel.user_limit = channel.userLimit; @@ -204,7 +204,7 @@ class GuildManager extends CachedManager { if (!channel.permissionOverwrites) continue; for (const overwrite of channel.permissionOverwrites) { if (typeof overwrite.type === 'string') { - overwrite.type = OverwriteTypes[overwrite.type]; + overwrite.type = OverwriteType[overwrite.type]; } overwrite.allow &&= Permissions.resolve(overwrite.allow).toString(); overwrite.deny &&= Permissions.resolve(overwrite.deny).toString(); diff --git a/packages/discord.js/src/managers/GuildScheduledEventManager.js b/packages/discord.js/src/managers/GuildScheduledEventManager.js index b35e45c39..086767ec4 100644 --- a/packages/discord.js/src/managers/GuildScheduledEventManager.js +++ b/packages/discord.js/src/managers/GuildScheduledEventManager.js @@ -1,10 +1,14 @@ 'use strict'; const { Collection } = require('@discordjs/collection'); +const { + GuildScheduledEventPrivacyLevel, + GuildScheduledEventEntityType, + GuildScheduledEventStatus, +} = require('discord-api-types/v9'); const CachedManager = require('./CachedManager'); const { TypeError, Error } = require('../errors'); const { GuildScheduledEvent } = require('../structures/GuildScheduledEvent'); -const { PrivacyLevels, GuildScheduledEventEntityTypes, GuildScheduledEventStatuses } = require('../util/Constants'); /** * Manages API methods for GuildScheduledEvents and stores their cache. @@ -78,11 +82,11 @@ class GuildScheduledEventManager extends CachedManager { reason, } = options; - if (typeof privacyLevel === 'string') privacyLevel = PrivacyLevels[privacyLevel]; - if (typeof entityType === 'string') entityType = GuildScheduledEventEntityTypes[entityType]; + if (typeof privacyLevel === 'string') privacyLevel = GuildScheduledEventPrivacyLevel[privacyLevel]; + if (typeof entityType === 'string') entityType = GuildScheduledEventEntityType[entityType]; let entity_metadata, channel_id; - if (entityType === GuildScheduledEventEntityTypes.EXTERNAL) { + if (entityType === GuildScheduledEventEntityType.External) { channel_id = typeof channel === 'undefined' ? channel : null; entity_metadata = { location: entityMetadata?.location }; } else { @@ -199,9 +203,9 @@ class GuildScheduledEventManager extends CachedManager { reason, } = options; - if (typeof privacyLevel === 'string') privacyLevel = PrivacyLevels[privacyLevel]; - if (typeof entityType === 'string') entityType = GuildScheduledEventEntityTypes[entityType]; - if (typeof status === 'string') status = GuildScheduledEventStatuses[status]; + 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) { diff --git a/packages/discord.js/src/managers/PermissionOverwriteManager.js b/packages/discord.js/src/managers/PermissionOverwriteManager.js index 8dbc881dc..6e4b6e00c 100644 --- a/packages/discord.js/src/managers/PermissionOverwriteManager.js +++ b/packages/discord.js/src/managers/PermissionOverwriteManager.js @@ -2,11 +2,11 @@ const process = require('node:process'); const { Collection } = require('@discordjs/collection'); +const { OverwriteType } = require('discord-api-types/v9'); const CachedManager = require('./CachedManager'); const { TypeError } = require('../errors'); const PermissionOverwrites = require('../structures/PermissionOverwrites'); const { Role } = require('../structures/Role'); -const { OverwriteTypes } = require('../util/Constants'); let cacheWarningEmitted = false; @@ -94,7 +94,7 @@ class PermissionOverwriteManager extends CachedManager { if (typeof type !== 'number') { userOrRole = this.channel.guild.roles.resolve(userOrRole) ?? this.client.users.resolve(userOrRole); if (!userOrRole) throw new TypeError('INVALID_TYPE', 'parameter', 'User nor a Role'); - type = userOrRole instanceof Role ? OverwriteTypes.role : OverwriteTypes.member; + type = userOrRole instanceof Role ? OverwriteType.Role : OverwriteType.Member; } const { allow, deny } = PermissionOverwrites.resolveOverwriteOptions(options, existing); diff --git a/packages/discord.js/src/managers/StageInstanceManager.js b/packages/discord.js/src/managers/StageInstanceManager.js index 478f26f5c..e5b02e014 100644 --- a/packages/discord.js/src/managers/StageInstanceManager.js +++ b/packages/discord.js/src/managers/StageInstanceManager.js @@ -1,9 +1,9 @@ 'use strict'; +const { GuildScheduledEventPrivacyLevel } = require('discord-api-types/v9'); const CachedManager = require('./CachedManager'); const { TypeError, Error } = require('../errors'); const { StageInstance } = require('../structures/StageInstance'); -const { PrivacyLevels } = require('../util/Constants'); /** * Manages API methods for {@link StageInstance} objects and holds their cache. @@ -60,7 +60,7 @@ 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 : PrivacyLevels[privacyLevel]; + privacyLevel &&= typeof privacyLevel === 'number' ? privacyLevel : GuildScheduledEventPrivacyLevel[privacyLevel]; const data = await this.client.api['stage-instances'].post({ data: { @@ -122,7 +122,7 @@ class StageInstanceManager extends CachedManager { let { topic, privacyLevel } = options; - privacyLevel &&= typeof privacyLevel === 'number' ? privacyLevel : PrivacyLevels[privacyLevel]; + privacyLevel &&= typeof privacyLevel === 'number' ? privacyLevel : GuildScheduledEventPrivacyLevel[privacyLevel]; const data = await this.client.api('stage-instances', channelId).patch({ data: { diff --git a/packages/discord.js/src/managers/ThreadManager.js b/packages/discord.js/src/managers/ThreadManager.js index 9cd4f049e..bcc3d99cb 100644 --- a/packages/discord.js/src/managers/ThreadManager.js +++ b/packages/discord.js/src/managers/ThreadManager.js @@ -1,10 +1,10 @@ 'use strict'; const { Collection } = require('@discordjs/collection'); +const { ChannelType } = require('discord-api-types/v9'); const CachedManager = require('./CachedManager'); const { TypeError } = require('../errors'); const ThreadChannel = require('../structures/ThreadChannel'); -const { ChannelTypes } = require('../util/Constants'); /** * Manages API methods for {@link ThreadChannel} objects and stores their cache. @@ -111,14 +111,13 @@ class ThreadManager extends CachedManager { if (type && typeof type !== 'string' && typeof type !== 'number') { throw new TypeError('INVALID_TYPE', 'type', 'ThreadChannelType or Number'); } - let resolvedType = - this.channel.type === 'GUILD_NEWS' ? ChannelTypes.GUILD_NEWS_THREAD : ChannelTypes.GUILD_PUBLIC_THREAD; + let resolvedType = this.channel.type === 'GUILD_NEWS' ? ChannelType.GuildNewsThread : ChannelType.GuildPublicThread; if (startMessage) { const startMessageId = this.channel.messages.resolveId(startMessage); if (!startMessageId) throw new TypeError('INVALID_TYPE', 'startMessage', 'MessageResolvable'); path = path.messages(startMessageId); } else if (this.channel.type !== 'GUILD_NEWS') { - resolvedType = typeof type === 'string' ? ChannelTypes[type] : type ?? resolvedType; + resolvedType = typeof type === 'string' ? ChannelType[type] : type ?? resolvedType; } if (autoArchiveDuration === 'MAX') { autoArchiveDuration = 1440; @@ -134,7 +133,7 @@ class ThreadManager extends CachedManager { name, auto_archive_duration: autoArchiveDuration, type: resolvedType, - invitable: resolvedType === ChannelTypes.GUILD_PRIVATE_THREAD ? invitable : undefined, + invitable: resolvedType === ChannelType.GuildPrivateThread ? invitable : undefined, rate_limit_per_user: rateLimitPerUser, }, reason, diff --git a/packages/discord.js/src/structures/AnonymousGuild.js b/packages/discord.js/src/structures/AnonymousGuild.js index 5415e5485..9c6069a3c 100644 --- a/packages/discord.js/src/structures/AnonymousGuild.js +++ b/packages/discord.js/src/structures/AnonymousGuild.js @@ -1,7 +1,7 @@ 'use strict'; +const { GuildVerificationLevel, GuildNSFWLevel } = require('discord-api-types/v9'); const BaseGuild = require('./BaseGuild'); -const { VerificationLevels, NSFWLevels } = require('../util/Constants'); /** * Bundles common attributes and methods between {@link Guild} and {@link InviteGuild} @@ -46,7 +46,7 @@ class AnonymousGuild extends BaseGuild { * The verification level of the guild * @type {VerificationLevel} */ - this.verificationLevel = VerificationLevels[data.verification_level]; + this.verificationLevel = GuildVerificationLevel[data.verification_level]; } if ('vanity_url_code' in data) { @@ -62,7 +62,7 @@ class AnonymousGuild extends BaseGuild { * The NSFW level of this guild * @type {NSFWLevel} */ - this.nsfwLevel = NSFWLevels[data.nsfw_level]; + this.nsfwLevel = GuildNSFWLevel[data.nsfw_level]; } } diff --git a/packages/discord.js/src/structures/ApplicationCommand.js b/packages/discord.js/src/structures/ApplicationCommand.js index 3ac524e5f..7dc630cdf 100644 --- a/packages/discord.js/src/structures/ApplicationCommand.js +++ b/packages/discord.js/src/structures/ApplicationCommand.js @@ -1,9 +1,9 @@ 'use strict'; const { DiscordSnowflake } = require('@sapphire/snowflake'); +const { ApplicationCommandType, ApplicationCommandOptionType, ChannelType } = require('discord-api-types/v9'); const Base = require('./Base'); const ApplicationCommandPermissionsManager = require('../managers/ApplicationCommandPermissionsManager'); -const { ApplicationCommandOptionTypes, ApplicationCommandTypes, ChannelTypes } = require('../util/Constants'); /** * Represents an application command. @@ -48,7 +48,7 @@ class ApplicationCommand extends Base { * The type of this application command * @type {ApplicationCommandType} */ - this.type = ApplicationCommandTypes[data.type]; + this.type = ApplicationCommandType[data.type]; this._patch(data); } @@ -233,7 +233,7 @@ class ApplicationCommand extends Base { if (command.id && this.id !== command.id) return false; // Check top level parameters - const commandType = typeof command.type === 'string' ? command.type : ApplicationCommandTypes[command.type]; + const commandType = typeof command.type === 'string' ? command.type : ApplicationCommandType[command.type]; if ( command.name !== this.name || ('description' in command && command.description !== this.description) || @@ -289,7 +289,7 @@ class ApplicationCommand extends Base { * @private */ static _optionEquals(existing, option, enforceOptionOrder = false) { - const optionType = typeof option.type === 'string' ? option.type : ApplicationCommandOptionTypes[option.type]; + const optionType = typeof option.type === 'string' ? option.type : ApplicationCommandOptionType[option.type]; if ( option.name !== existing.name || optionType !== existing.type || @@ -326,7 +326,7 @@ class ApplicationCommand extends Base { if (existing.channelTypes) { const newTypes = (option.channelTypes ?? option.channel_types).map(type => - typeof type === 'number' ? ChannelTypes[type] : type, + typeof type === 'number' ? ChannelType[type] : type, ); for (const type of existing.channelTypes) { if (!newTypes.includes(type)) return false; @@ -370,12 +370,12 @@ class ApplicationCommand extends Base { * @private */ static transformOption(option, received) { - const stringType = typeof option.type === 'string' ? option.type : ApplicationCommandOptionTypes[option.type]; + const stringType = typeof option.type === 'string' ? option.type : ApplicationCommandOptionType[option.type]; const channelTypesKey = received ? 'channelTypes' : 'channel_types'; const minValueKey = received ? 'minValue' : 'min_value'; const maxValueKey = received ? 'maxValue' : 'max_value'; return { - type: typeof option.type === 'number' && !received ? option.type : ApplicationCommandOptionTypes[option.type], + type: typeof option.type === 'number' && !received ? option.type : ApplicationCommandOptionType[option.type], name: option.name, description: option.description, required: @@ -384,8 +384,8 @@ class ApplicationCommand extends Base { choices: option.choices, options: option.options?.map(o => this.transformOption(o, received)), [channelTypesKey]: received - ? option.channel_types?.map(type => ChannelTypes[type]) - : option.channelTypes?.map(type => (typeof type === 'string' ? ChannelTypes[type] : type)) ?? + ? 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, [minValueKey]: option.minValue ?? option.min_value, diff --git a/packages/discord.js/src/structures/AutocompleteInteraction.js b/packages/discord.js/src/structures/AutocompleteInteraction.js index e942a6dc4..fed027caa 100644 --- a/packages/discord.js/src/structures/AutocompleteInteraction.js +++ b/packages/discord.js/src/structures/AutocompleteInteraction.js @@ -1,8 +1,8 @@ 'use strict'; +const { ApplicationCommandOptionType, InteractionResponseType } = require('discord-api-types/v9'); const CommandInteractionOptionResolver = require('./CommandInteractionOptionResolver'); const Interaction = require('./Interaction'); -const { InteractionResponseTypes, ApplicationCommandOptionTypes } = require('../util/Constants'); /** * Represents an autocomplete interaction. @@ -64,7 +64,7 @@ class AutocompleteInteraction extends Interaction { transformOption(option) { const result = { name: option.name, - type: ApplicationCommandOptionTypes[option.type], + type: ApplicationCommandOptionType[option.type], }; if ('value' in option) result.value = option.value; @@ -94,7 +94,7 @@ class AutocompleteInteraction extends Interaction { await this.client.api.interactions(this.id, this.token).callback.post({ data: { - type: InteractionResponseTypes.APPLICATION_COMMAND_AUTOCOMPLETE_RESULT, + type: InteractionResponseType.ApplicationCommandAutocompleteResult, data: { choices: options, }, diff --git a/packages/discord.js/src/structures/Channel.js b/packages/discord.js/src/structures/Channel.js index 4afa76759..7c57330d7 100644 --- a/packages/discord.js/src/structures/Channel.js +++ b/packages/discord.js/src/structures/Channel.js @@ -1,6 +1,7 @@ 'use strict'; const { DiscordSnowflake } = require('@sapphire/snowflake'); +const { ChannelType } = require('discord-api-types/v9'); const Base = require('./Base'); let CategoryChannel; let DMChannel; @@ -10,7 +11,7 @@ let StoreChannel; let TextChannel; let ThreadChannel; let VoiceChannel; -const { ChannelTypes, ThreadChannelTypes, VoiceBasedChannelTypes } = require('../util/Constants'); +const { ThreadChannelTypes, VoiceBasedChannelTypes } = require('../util/Constants'); /** * Represents any channel on Discord. @@ -21,7 +22,7 @@ class Channel extends Base { constructor(client, data, immediatePatch = true) { super(client); - const type = ChannelTypes[data?.type]; + const type = ChannelType[data?.type]; /** * The type of the channel * @type {ChannelType} @@ -137,9 +138,9 @@ class Channel extends Base { let channel; if (!data.guild_id && !guild) { - if ((data.recipients && data.type !== ChannelTypes.GROUP_DM) || data.type === ChannelTypes.DM) { + if ((data.recipients && data.type !== ChannelType.GroupDM) || data.type === ChannelType.DM) { channel = new DMChannel(client, data); - } else if (data.type === ChannelTypes.GROUP_DM) { + } else if (data.type === ChannelType.GroupDM) { const PartialGroupDMChannel = require('./PartialGroupDMChannel'); channel = new PartialGroupDMChannel(client, data); } @@ -148,33 +149,33 @@ class Channel extends Base { if (guild || allowUnknownGuild) { switch (data.type) { - case ChannelTypes.GUILD_TEXT: { + case ChannelType.GuildText: { channel = new TextChannel(guild, data, client); break; } - case ChannelTypes.GUILD_VOICE: { + case ChannelType.GuildVoice: { channel = new VoiceChannel(guild, data, client); break; } - case ChannelTypes.GUILD_CATEGORY: { + case ChannelType.GuildCategory: { channel = new CategoryChannel(guild, data, client); break; } - case ChannelTypes.GUILD_NEWS: { + case ChannelType.GuildNews: { channel = new NewsChannel(guild, data, client); break; } - case ChannelTypes.GUILD_STORE: { + case ChannelType.GuildStore: { channel = new StoreChannel(guild, data, client); break; } - case ChannelTypes.GUILD_STAGE_VOICE: { + case ChannelType.GuildStageVoice: { channel = new StageChannel(guild, data, client); break; } - case ChannelTypes.GUILD_NEWS_THREAD: - case ChannelTypes.GUILD_PUBLIC_THREAD: - case ChannelTypes.GUILD_PRIVATE_THREAD: { + case ChannelType.GuildNewsThread: + case ChannelType.GuildPublicThread: + case ChannelType.GuildPrivateThread: { channel = new ThreadChannel(guild, data, client, fromInteraction); if (!allowUnknownGuild) channel.parent?.threads.cache.set(channel.id, channel); break; diff --git a/packages/discord.js/src/structures/ClientPresence.js b/packages/discord.js/src/structures/ClientPresence.js index 04ccce6e4..8f16200b9 100644 --- a/packages/discord.js/src/structures/ClientPresence.js +++ b/packages/discord.js/src/structures/ClientPresence.js @@ -1,8 +1,9 @@ 'use strict'; +const { ActivityType } = require('discord-api-types/v9'); const { Presence } = require('./Presence'); const { TypeError } = require('../errors'); -const { ActivityTypes, Opcodes } = require('../util/Constants'); +const { Opcodes } = require('../util/Constants'); /** * Represents the client's presence. @@ -52,7 +53,7 @@ class ClientPresence extends Presence { activity.type ??= 0; data.activities.push({ - type: typeof activity.type === 'number' ? activity.type : ActivityTypes[activity.type], + type: typeof activity.type === 'number' ? activity.type : ActivityType[activity.type], name: activity.name, url: activity.url, }); @@ -61,7 +62,7 @@ class ClientPresence extends Presence { data.activities.push( ...this.activities.map(a => ({ name: a.name, - type: ActivityTypes[a.type], + type: ActivityType[a.type], url: a.url ?? undefined, })), ); diff --git a/packages/discord.js/src/structures/CommandInteraction.js b/packages/discord.js/src/structures/CommandInteraction.js index a9741a0e7..5052ba195 100644 --- a/packages/discord.js/src/structures/CommandInteraction.js +++ b/packages/discord.js/src/structures/CommandInteraction.js @@ -1,10 +1,10 @@ 'use strict'; const { Collection } = require('@discordjs/collection'); +const { ApplicationCommandType } = require('discord-api-types/v9'); const Interaction = require('./Interaction'); const InteractionWebhook = require('./InteractionWebhook'); const InteractionResponses = require('./interfaces/InteractionResponses'); -const { ApplicationCommandOptionTypes } = require('../util/Constants'); /** * Represents a command interaction. @@ -151,7 +151,7 @@ class CommandInteraction extends Interaction { transformOption(option, resolved) { const result = { name: option.name, - type: ApplicationCommandOptionTypes[option.type], + type: ApplicationCommandType[option.type], }; if ('value' in option) result.value = option.value; diff --git a/packages/discord.js/src/structures/ContextMenuCommandInteraction.js b/packages/discord.js/src/structures/ContextMenuCommandInteraction.js index 46d352e67..da2fa80f5 100644 --- a/packages/discord.js/src/structures/ContextMenuCommandInteraction.js +++ b/packages/discord.js/src/structures/ContextMenuCommandInteraction.js @@ -1,8 +1,8 @@ 'use strict'; +const { ApplicationCommandType } = require('discord-api-types/v9'); const CommandInteraction = require('./CommandInteraction'); const CommandInteractionOptionResolver = require('./CommandInteractionOptionResolver'); -const { ApplicationCommandOptionTypes, ApplicationCommandTypes } = require('../util/Constants'); /** * Represents a context menu interaction. @@ -31,7 +31,7 @@ class ContextMenuCommandInteraction extends CommandInteraction { * The type of the target of the interaction; either USER or MESSAGE * @type {ApplicationCommandType} */ - this.targetType = ApplicationCommandTypes[data.data.type]; + this.targetType = ApplicationCommandType[data.data.type]; } /** @@ -45,7 +45,7 @@ class ContextMenuCommandInteraction extends CommandInteraction { if (resolved.users?.[target_id]) { result.push( - this.transformOption({ name: 'user', type: ApplicationCommandOptionTypes.USER, value: target_id }, resolved), + this.transformOption({ name: 'user', type: ApplicationCommandType.User, value: target_id }, resolved), ); } diff --git a/packages/discord.js/src/structures/Guild.js b/packages/discord.js/src/structures/Guild.js index 06b48b08e..2d942f562 100644 --- a/packages/discord.js/src/structures/Guild.js +++ b/packages/discord.js/src/structures/Guild.js @@ -1,6 +1,14 @@ 'use strict'; const { Collection } = require('@discordjs/collection'); +const { + GuildPremiumTier, + GuildMFALevel, + GuildExplicitContentFilter, + GuildDefaultMessageNotifications, + GuildVerificationLevel, + ChannelType, +} = require('discord-api-types/v9'); const AnonymousGuild = require('./AnonymousGuild'); const GuildAuditLogs = require('./GuildAuditLogs'); const GuildPreview = require('./GuildPreview'); @@ -21,16 +29,7 @@ const PresenceManager = require('../managers/PresenceManager'); const RoleManager = require('../managers/RoleManager'); const StageInstanceManager = require('../managers/StageInstanceManager'); const VoiceStateManager = require('../managers/VoiceStateManager'); -const { - ChannelTypes, - DefaultMessageNotificationLevels, - PartialTypes, - VerificationLevels, - ExplicitContentFilterLevels, - Status, - MFALevels, - PremiumTiers, -} = require('../util/Constants'); +const { PartialTypes, Status } = require('../util/Constants'); const DataResolver = require('../util/DataResolver'); const SystemChannelFlags = require('../util/SystemChannelFlags'); const Util = require('../util/Util'); @@ -241,7 +240,7 @@ class Guild extends AnonymousGuild { * The premium tier of this guild * @type {PremiumTier} */ - this.premiumTier = PremiumTiers[data.premium_tier]; + this.premiumTier = GuildPremiumTier[data.premium_tier]; } if ('premium_subscription_count' in data) { @@ -273,7 +272,7 @@ class Guild extends AnonymousGuild { * The explicit content filter level of the guild * @type {ExplicitContentFilterLevel} */ - this.explicitContentFilter = ExplicitContentFilterLevels[data.explicit_content_filter]; + this.explicitContentFilter = GuildExplicitContentFilter[data.explicit_content_filter]; } if ('mfa_level' in data) { @@ -281,7 +280,7 @@ class Guild extends AnonymousGuild { * The required MFA level for this guild * @type {MFALevel} */ - this.mfaLevel = MFALevels[data.mfa_level]; + this.mfaLevel = GuildMFALevel[data.mfa_level]; } if ('joined_at' in data) { @@ -295,9 +294,9 @@ class Guild extends AnonymousGuild { if ('default_message_notifications' in data) { /** * The default message notification level of the guild - * @type {DefaultMessageNotificationLevel} + * @type {GuildDefaultMessageNotifications} */ - this.defaultMessageNotifications = DefaultMessageNotificationLevels[data.default_message_notifications]; + this.defaultMessageNotifications = GuildDefaultMessageNotifications[data.default_message_notifications]; } if ('system_channel_flags' in data) { @@ -567,12 +566,12 @@ class Guild extends AnonymousGuild { return 384_000; } - switch (PremiumTiers[this.premiumTier]) { - case PremiumTiers.TIER_1: + switch (GuildPremiumTier[this.premiumTier]) { + case GuildPremiumTier.Tier1: return 128_000; - case PremiumTiers.TIER_2: + case GuildPremiumTier.Tier2: return 256_000; - case PremiumTiers.TIER_3: + case GuildPremiumTier.Tier3: return 384_000; default: return 96_000; @@ -821,7 +820,7 @@ class Guild extends AnonymousGuild { _data.verification_level = typeof data.verificationLevel === 'number' ? data.verificationLevel - : VerificationLevels[data.verificationLevel]; + : GuildVerificationLevel[data.verificationLevel]; } if (typeof data.afkChannel !== 'undefined') { _data.afk_channel_id = this.client.channels.resolveId(data.afkChannel); @@ -841,13 +840,13 @@ class Guild extends AnonymousGuild { _data.explicit_content_filter = typeof data.explicitContentFilter === 'number' ? data.explicitContentFilter - : ExplicitContentFilterLevels[data.explicitContentFilter]; + : GuildExplicitContentFilter[data.explicitContentFilter]; } if (typeof data.defaultMessageNotifications !== 'undefined') { _data.default_message_notifications = typeof data.defaultMessageNotifications === 'number' ? data.defaultMessageNotifications - : DefaultMessageNotificationLevels[data.defaultMessageNotifications]; + : GuildDefaultMessageNotifications[data.defaultMessageNotifications]; } if (typeof data.systemChannelFlags !== 'undefined') { _data.system_channel_flags = SystemChannelFlags.resolve(data.systemChannelFlags); @@ -1303,7 +1302,7 @@ class Guild extends AnonymousGuild { * @private */ _sortedChannels(channel) { - const category = channel.type === ChannelTypes.GUILD_CATEGORY; + const category = channel.type === ChannelType.GuildCategory; return Util.discordSort( this.channels.cache.filter( c => diff --git a/packages/discord.js/src/structures/GuildAuditLogs.js b/packages/discord.js/src/structures/GuildAuditLogs.js index 09b6342c8..39228d379 100644 --- a/packages/discord.js/src/structures/GuildAuditLogs.js +++ b/packages/discord.js/src/structures/GuildAuditLogs.js @@ -2,13 +2,14 @@ const { Collection } = require('@discordjs/collection'); const { DiscordSnowflake } = require('@sapphire/snowflake'); +const { OverwriteType, AuditLogEvent } = require('discord-api-types/v9'); const { GuildScheduledEvent } = require('./GuildScheduledEvent'); const Integration = require('./Integration'); const Invite = require('./Invite'); const { StageInstance } = require('./StageInstance'); const { Sticker } = require('./Sticker'); const Webhook = require('./Webhook'); -const { OverwriteTypes, PartialTypes } = require('../util/Constants'); +const { PartialTypes } = require('../util/Constants'); const Util = require('../util/Util'); /** @@ -52,116 +53,6 @@ const Targets = { UNKNOWN: 'UNKNOWN', }; -/** - * The action of an entry. Here are the available actions: - * * ALL: null - * * GUILD_UPDATE: 1 - * * CHANNEL_CREATE: 10 - * * CHANNEL_UPDATE: 11 - * * CHANNEL_DELETE: 12 - * * CHANNEL_OVERWRITE_CREATE: 13 - * * CHANNEL_OVERWRITE_UPDATE: 14 - * * CHANNEL_OVERWRITE_DELETE: 15 - * * MEMBER_KICK: 20 - * * MEMBER_PRUNE: 21 - * * MEMBER_BAN_ADD: 22 - * * MEMBER_BAN_REMOVE: 23 - * * MEMBER_UPDATE: 24 - * * MEMBER_ROLE_UPDATE: 25 - * * MEMBER_MOVE: 26 - * * MEMBER_DISCONNECT: 27 - * * BOT_ADD: 28, - * * ROLE_CREATE: 30 - * * ROLE_UPDATE: 31 - * * ROLE_DELETE: 32 - * * INVITE_CREATE: 40 - * * INVITE_UPDATE: 41 - * * INVITE_DELETE: 42 - * * WEBHOOK_CREATE: 50 - * * WEBHOOK_UPDATE: 51 - * * WEBHOOK_DELETE: 52 - * * EMOJI_CREATE: 60 - * * EMOJI_UPDATE: 61 - * * EMOJI_DELETE: 62 - * * MESSAGE_DELETE: 72 - * * MESSAGE_BULK_DELETE: 73 - * * MESSAGE_PIN: 74 - * * MESSAGE_UNPIN: 75 - * * INTEGRATION_CREATE: 80 - * * INTEGRATION_UPDATE: 81 - * * INTEGRATION_DELETE: 82 - * * STAGE_INSTANCE_CREATE: 83 - * * STAGE_INSTANCE_UPDATE: 84 - * * STAGE_INSTANCE_DELETE: 85 - * * STICKER_CREATE: 90 - * * STICKER_UPDATE: 91 - * * STICKER_DELETE: 92 - * * GUILD_SCHEDULED_EVENT_CREATE: 100 - * * GUILD_SCHEDULED_EVENT_UPDATE: 101 - * * GUILD_SCHEDULED_EVENT_DELETE: 102 - * * THREAD_CREATE: 110 - * * THREAD_UPDATE: 111 - * * THREAD_DELETE: 112 - * @typedef {?(number|string)} AuditLogAction - * @see {@link https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events} - */ - -/** - * All available actions keyed under their names to their numeric values. - * @name GuildAuditLogs.Actions - * @type {Object} - */ -const Actions = { - ALL: null, - GUILD_UPDATE: 1, - CHANNEL_CREATE: 10, - CHANNEL_UPDATE: 11, - CHANNEL_DELETE: 12, - CHANNEL_OVERWRITE_CREATE: 13, - CHANNEL_OVERWRITE_UPDATE: 14, - CHANNEL_OVERWRITE_DELETE: 15, - MEMBER_KICK: 20, - MEMBER_PRUNE: 21, - MEMBER_BAN_ADD: 22, - MEMBER_BAN_REMOVE: 23, - MEMBER_UPDATE: 24, - MEMBER_ROLE_UPDATE: 25, - MEMBER_MOVE: 26, - MEMBER_DISCONNECT: 27, - BOT_ADD: 28, - ROLE_CREATE: 30, - ROLE_UPDATE: 31, - ROLE_DELETE: 32, - INVITE_CREATE: 40, - INVITE_UPDATE: 41, - INVITE_DELETE: 42, - WEBHOOK_CREATE: 50, - WEBHOOK_UPDATE: 51, - WEBHOOK_DELETE: 52, - EMOJI_CREATE: 60, - EMOJI_UPDATE: 61, - EMOJI_DELETE: 62, - MESSAGE_DELETE: 72, - MESSAGE_BULK_DELETE: 73, - MESSAGE_PIN: 74, - MESSAGE_UNPIN: 75, - INTEGRATION_CREATE: 80, - INTEGRATION_UPDATE: 81, - INTEGRATION_DELETE: 82, - STAGE_INSTANCE_CREATE: 83, - STAGE_INSTANCE_UPDATE: 84, - STAGE_INSTANCE_DELETE: 85, - STICKER_CREATE: 90, - STICKER_UPDATE: 91, - STICKER_DELETE: 92, - GUILD_SCHEDULED_EVENT_CREATE: 100, - GUILD_SCHEDULED_EVENT_UPDATE: 101, - GUILD_SCHEDULED_EVENT_DELETE: 102, - THREAD_CREATE: 110, - THREAD_UPDATE: 111, - THREAD_DELETE: 112, -}; - /** * Audit logs entries are held in this class. */ @@ -274,20 +165,20 @@ class GuildAuditLogs { static actionType(action) { if ( [ - Actions.CHANNEL_CREATE, - Actions.CHANNEL_OVERWRITE_CREATE, - Actions.MEMBER_BAN_REMOVE, - Actions.BOT_ADD, - Actions.ROLE_CREATE, - Actions.INVITE_CREATE, - Actions.WEBHOOK_CREATE, - Actions.EMOJI_CREATE, - Actions.MESSAGE_PIN, - Actions.INTEGRATION_CREATE, - Actions.STAGE_INSTANCE_CREATE, - Actions.STICKER_CREATE, - Actions.GUILD_SCHEDULED_EVENT_CREATE, - Actions.THREAD_CREATE, + AuditLogEvent.ChannelCreate, + AuditLogEvent.ChannelOverwriteCreate, + AuditLogEvent.MemberBanRemove, + AuditLogEvent.BotAdd, + AuditLogEvent.RoleCreate, + AuditLogEvent.InviteCreate, + AuditLogEvent.WebhookCreate, + AuditLogEvent.EmojiCreate, + AuditLogEvent.MessagePin, + AuditLogEvent.IntegrationCreate, + AuditLogEvent.StageInstanceCreate, + AuditLogEvent.StickerCreate, + AuditLogEvent.GuildScheduledEventCreate, + AuditLogEvent.ThreadCreate, ].includes(action) ) { return 'CREATE'; @@ -295,24 +186,24 @@ class GuildAuditLogs { if ( [ - Actions.CHANNEL_DELETE, - Actions.CHANNEL_OVERWRITE_DELETE, - Actions.MEMBER_KICK, - Actions.MEMBER_PRUNE, - Actions.MEMBER_BAN_ADD, - Actions.MEMBER_DISCONNECT, - Actions.ROLE_DELETE, - Actions.INVITE_DELETE, - Actions.WEBHOOK_DELETE, - Actions.EMOJI_DELETE, - Actions.MESSAGE_DELETE, - Actions.MESSAGE_BULK_DELETE, - Actions.MESSAGE_UNPIN, - Actions.INTEGRATION_DELETE, - Actions.STAGE_INSTANCE_DELETE, - Actions.STICKER_DELETE, - Actions.GUILD_SCHEDULED_EVENT_DELETE, - Actions.THREAD_DELETE, + AuditLogEvent.ChannelDelete, + AuditLogEvent.ChannelOverwriteDelete, + AuditLogEvent.MemberKick, + AuditLogEvent.MemberPrune, + AuditLogEvent.MemberBanAdd, + AuditLogEvent.MemberDisconnect, + AuditLogEvent.RoleDelete, + AuditLogEvent.InviteDelete, + AuditLogEvent.WebhookDelete, + AuditLogEvent.EmojiDelete, + AuditLogEvent.MessageDelete, + AuditLogEvent.MessageBulkDelete, + AuditLogEvent.MessageUnpin, + AuditLogEvent.IntegrationDelete, + AuditLogEvent.StageInstanceDelete, + AuditLogEvent.StickerDelete, + AuditLogEvent.GuildScheduledEventDelete, + AuditLogEvent.ThreadDelete, ].includes(action) ) { return 'DELETE'; @@ -320,21 +211,21 @@ class GuildAuditLogs { if ( [ - Actions.GUILD_UPDATE, - Actions.CHANNEL_UPDATE, - Actions.CHANNEL_OVERWRITE_UPDATE, - Actions.MEMBER_UPDATE, - Actions.MEMBER_ROLE_UPDATE, - Actions.MEMBER_MOVE, - Actions.ROLE_UPDATE, - Actions.INVITE_UPDATE, - Actions.WEBHOOK_UPDATE, - Actions.EMOJI_UPDATE, - Actions.INTEGRATION_UPDATE, - Actions.STAGE_INSTANCE_UPDATE, - Actions.STICKER_UPDATE, - Actions.GUILD_SCHEDULED_EVENT_UPDATE, - Actions.THREAD_UPDATE, + AuditLogEvent.GuildUpdate, + AuditLogEvent.ChannelUpdate, + AuditLogEvent.ChannelOverwriteUpdate, + AuditLogEvent.MemberUpdate, + AuditLogEvent.MemberRoleUpdate, + AuditLogEvent.MemberMove, + AuditLogEvent.RoleUpdate, + AuditLogEvent.InviteUpdate, + AuditLogEvent.WebhookUpdate, + AuditLogEvent.EmojiUpdate, + AuditLogEvent.IntegrationUpdate, + AuditLogEvent.StageInstanceUpdate, + AuditLogEvent.StickerUpdate, + AuditLogEvent.GuildScheduledEventUpdate, + AuditLogEvent.ThreadUpdate, ].includes(action) ) { return 'UPDATE'; @@ -370,7 +261,7 @@ class GuildAuditLogsEntry { * Specific action type of this entry in its string presentation * @type {AuditLogAction} */ - this.action = Object.keys(Actions).find(k => Actions[k] === data.action_type); + this.action = Object.keys(AuditLogEvent).find(k => AuditLogEvent[k] === data.action_type); /** * The reason of this entry @@ -414,52 +305,52 @@ class GuildAuditLogsEntry { */ this.extra = null; switch (data.action_type) { - case Actions.MEMBER_PRUNE: + case AuditLogEvent.MemberPrune: this.extra = { removed: Number(data.options.members_removed), days: Number(data.options.delete_member_days), }; break; - case Actions.MEMBER_MOVE: - case Actions.MESSAGE_DELETE: - case Actions.MESSAGE_BULK_DELETE: + case AuditLogEvent.MemberMove: + case AuditLogEvent.MessageDelete: + case AuditLogEvent.MessageBulkDelete: this.extra = { channel: guild.channels.cache.get(data.options.channel_id) ?? { id: data.options.channel_id }, count: Number(data.options.count), }; break; - case Actions.MESSAGE_PIN: - case Actions.MESSAGE_UNPIN: + case AuditLogEvent.MessagePin: + case AuditLogEvent.MessageUnpin: this.extra = { channel: guild.client.channels.cache.get(data.options.channel_id) ?? { id: data.options.channel_id }, messageId: data.options.message_id, }; break; - case Actions.MEMBER_DISCONNECT: + case AuditLogEvent.MemberDisconnect: this.extra = { count: Number(data.options.count), }; break; - case Actions.CHANNEL_OVERWRITE_CREATE: - case Actions.CHANNEL_OVERWRITE_UPDATE: - case Actions.CHANNEL_OVERWRITE_DELETE: + case AuditLogEvent.ChannelOverwriteCreate: + case AuditLogEvent.ChannelOverwriteUpdate: + case AuditLogEvent.ChannelOverwriteDelete: switch (Number(data.options.type)) { - case OverwriteTypes.role: + case OverwriteType.Role: this.extra = guild.roles.cache.get(data.options.id) ?? { id: data.options.id, name: data.options.role_name, - type: OverwriteTypes[OverwriteTypes.role], + type: OverwriteType[OverwriteType.Role], }; break; - case OverwriteTypes.member: + case OverwriteType.Member: this.extra = guild.members.cache.get(data.options.id) ?? { id: data.options.id, - type: OverwriteTypes[OverwriteTypes.member], + type: OverwriteType[OverwriteType.Member], }; break; @@ -468,9 +359,9 @@ class GuildAuditLogsEntry { } break; - case Actions.STAGE_INSTANCE_CREATE: - case Actions.STAGE_INSTANCE_DELETE: - case Actions.STAGE_INSTANCE_UPDATE: + case AuditLogEvent.StageInstanceCreate: + case AuditLogEvent.StageInstanceDelete: + case AuditLogEvent.StageInstanceUpdate: this.extra = { channel: guild.client.channels.cache.get(data.options?.channel_id) ?? { id: data.options?.channel_id }, }; @@ -533,7 +424,7 @@ class GuildAuditLogsEntry { } else if (targetType === Targets.MESSAGE) { // Discord sends a channel id for the MESSAGE_BULK_DELETE action type. this.target = - data.action_type === Actions.MESSAGE_BULK_DELETE + data.action_type === AuditLogEvent.MessageBulkDelete ? guild.channels.cache.get(data.target_id) ?? { id: data.target_id } : guild.client.users.cache.get(data.target_id); } else if (targetType === Targets.INTEGRATION) { @@ -631,7 +522,6 @@ class GuildAuditLogsEntry { } } -GuildAuditLogs.Actions = Actions; GuildAuditLogs.Targets = Targets; GuildAuditLogs.Entry = GuildAuditLogsEntry; diff --git a/packages/discord.js/src/structures/GuildChannel.js b/packages/discord.js/src/structures/GuildChannel.js index 03e86d3a4..b761372fc 100644 --- a/packages/discord.js/src/structures/GuildChannel.js +++ b/packages/discord.js/src/structures/GuildChannel.js @@ -1,10 +1,11 @@ 'use strict'; +const { ChannelType } = require('discord-api-types/v9'); const { Channel } = require('./Channel'); const PermissionOverwrites = require('./PermissionOverwrites'); const { Error } = require('../errors'); const PermissionOverwriteManager = require('../managers/PermissionOverwriteManager'); -const { ChannelTypes, VoiceBasedChannelTypes } = require('../util/Constants'); +const { VoiceBasedChannelTypes } = require('../util/Constants'); const Permissions = require('../util/Permissions'); const Util = require('../util/Util'); @@ -321,7 +322,7 @@ class GuildChannel extends Channel { if (data.lockPermissions) { if (data.parent) { const newParent = this.guild.channels.resolve(data.parent); - if (newParent?.type === 'GUILD_CATEGORY') { + if (newParent?.type === 'GuildCategory') { permission_overwrites = newParent.permissionOverwrites.cache.map(o => PermissionOverwrites.resolve(o, this.guild), ); @@ -336,7 +337,7 @@ class GuildChannel extends Channel { const newData = await this.client.api.channels(this.id).patch({ data: { name: (data.name ?? this.name).trim(), - type: ChannelTypes[data.type], + type: ChannelType[data.type], topic: data.topic, nsfw: data.nsfw, bitrate: data.bitrate ?? this.bitrate, diff --git a/packages/discord.js/src/structures/GuildScheduledEvent.js b/packages/discord.js/src/structures/GuildScheduledEvent.js index 017c496ce..bb5999814 100644 --- a/packages/discord.js/src/structures/GuildScheduledEvent.js +++ b/packages/discord.js/src/structures/GuildScheduledEvent.js @@ -1,14 +1,14 @@ 'use strict'; const { DiscordSnowflake } = require('@sapphire/snowflake'); +const { + GuildScheduledEventPrivacyLevel, + GuildScheduledEventStatus, + GuildScheduledEventEntityType, +} = require('discord-api-types/v9'); const Base = require('./Base'); const { Error } = require('../errors'); -const { - GuildScheduledEventEntityTypes, - GuildScheduledEventStatuses, - GuildScheduledEventPrivacyLevels, - Endpoints, -} = require('../util/Constants'); +const { Endpoints } = require('../util/Constants'); /** * Represents a scheduled event in a {@link Guild}. @@ -88,19 +88,19 @@ class GuildScheduledEvent extends Base { * The privacy level of the guild scheduled event * @type {PrivacyLevel} */ - this.privacyLevel = GuildScheduledEventPrivacyLevels[data.privacy_level]; + this.privacyLevel = GuildScheduledEventPrivacyLevel[data.privacy_level]; /** * The status of the guild scheduled event * @type {GuildScheduledEventStatus} */ - this.status = GuildScheduledEventStatuses[data.status]; + this.status = GuildScheduledEventStatus[data.status]; /** * The type of hosting entity associated with the scheduled event * @type {GuildScheduledEventEntityType} */ - this.entityType = GuildScheduledEventEntityTypes[data.entity_type]; + this.entityType = GuildScheduledEventEntityType[data.entity_type]; if ('entity_id' in data) { /** @@ -391,7 +391,7 @@ class GuildScheduledEvent extends Base { * @returns {boolean} */ isActive() { - return GuildScheduledEventStatuses[this.status] === GuildScheduledEventStatuses.ACTIVE; + return GuildScheduledEventStatus[this.status] === GuildScheduledEventStatus.Active; } /** @@ -399,7 +399,7 @@ class GuildScheduledEvent extends Base { * @returns {boolean} */ isCanceled() { - return GuildScheduledEventStatuses[this.status] === GuildScheduledEventStatuses.CANCELED; + return GuildScheduledEventStatus[this.status] === GuildScheduledEventStatus.Canceled; } /** @@ -407,7 +407,7 @@ class GuildScheduledEvent extends Base { * @returns {boolean} */ isCompleted() { - return GuildScheduledEventStatuses[this.status] === GuildScheduledEventStatuses.COMPLETED; + return GuildScheduledEventStatus[this.status] === GuildScheduledEventStatus.Completed; } /** @@ -415,7 +415,7 @@ class GuildScheduledEvent extends Base { * @returns {boolean} */ isScheduled() { - return GuildScheduledEventStatuses[this.status] === GuildScheduledEventStatuses.SCHEDULED; + return GuildScheduledEventStatus[this.status] === GuildScheduledEventStatus.Scheduled; } } diff --git a/packages/discord.js/src/structures/Interaction.js b/packages/discord.js/src/structures/Interaction.js index de1f829ee..fdab6a868 100644 --- a/packages/discord.js/src/structures/Interaction.js +++ b/packages/discord.js/src/structures/Interaction.js @@ -1,8 +1,8 @@ 'use strict'; const { DiscordSnowflake } = require('@sapphire/snowflake'); +const { InteractionType, ApplicationCommandType, ComponentType } = require('discord-api-types/v9'); const Base = require('./Base'); -const { InteractionTypes, MessageComponentTypes, ApplicationCommandTypes } = require('../util/Constants'); const Permissions = require('../util/Permissions'); /** @@ -17,7 +17,7 @@ class Interaction extends Base { * The interaction's type * @type {InteractionType} */ - this.type = InteractionTypes[data.type]; + this.type = InteractionType[data.type]; /** * The interaction's id @@ -153,7 +153,7 @@ class Interaction extends Base { * @returns {boolean} */ isCommand() { - return InteractionTypes[this.type] === InteractionTypes.APPLICATION_COMMAND; + return InteractionType[this.type] === InteractionType.ApplicationCommand; } /** @@ -161,7 +161,7 @@ class Interaction extends Base { * @returns {boolean} */ isChatInputCommand() { - return InteractionTypes[this.type] === InteractionTypes.APPLICATION_COMMAND && typeof this.targetId === 'undefined'; + return InteractionType[this.type] === InteractionType.ApplicationCommand && typeof this.targetId === 'undefined'; } /** @@ -169,7 +169,7 @@ class Interaction extends Base { * @returns {boolean} */ isContextMenuCommand() { - return InteractionTypes[this.type] === InteractionTypes.APPLICATION_COMMAND && typeof this.targetId !== 'undefined'; + return InteractionType[this.type] === InteractionType.ApplicationCommand && typeof this.targetId !== 'undefined'; } /** @@ -177,7 +177,7 @@ class Interaction extends Base { * @returns {boolean} */ isUserContextMenuCommand() { - return this.isContextMenuCommand() && ApplicationCommandTypes[this.targetType] === ApplicationCommandTypes.USER; + return this.isContextMenuCommand() && ApplicationCommandType[this.targetType] === ApplicationCommandType.User; } /** @@ -185,7 +185,7 @@ class Interaction extends Base { * @returns {boolean} */ isMessageContextMenuCommand() { - return this.isContextMenuCommand() && ApplicationCommandTypes[this.targetType] === ApplicationCommandTypes.MESSAGE; + return this.isContextMenuCommand() && ApplicationCommandType[this.targetType] === ApplicationCommandType.Message; } /** @@ -193,7 +193,7 @@ class Interaction extends Base { * @returns {boolean} */ isAutocomplete() { - return InteractionTypes[this.type] === InteractionTypes.APPLICATION_COMMAND_AUTOCOMPLETE; + return InteractionType[this.type] === InteractionType.ApplicationCommandAutocomplete; } /** @@ -201,7 +201,7 @@ class Interaction extends Base { * @returns {boolean} */ isMessageComponent() { - return InteractionTypes[this.type] === InteractionTypes.MESSAGE_COMPONENT; + return InteractionType[this.type] === InteractionType.MessageComponent; } /** @@ -210,8 +210,8 @@ class Interaction extends Base { */ isButton() { return ( - InteractionTypes[this.type] === InteractionTypes.MESSAGE_COMPONENT && - MessageComponentTypes[this.componentType] === MessageComponentTypes.BUTTON + InteractionType[this.type] === InteractionType.MessageComponent && + ComponentType[this.componentType] === ComponentType.Button ); } @@ -221,8 +221,8 @@ class Interaction extends Base { */ isSelectMenu() { return ( - InteractionTypes[this.type] === InteractionTypes.MESSAGE_COMPONENT && - MessageComponentTypes[this.componentType] === MessageComponentTypes.SELECT_MENU + InteractionType[this.type] === InteractionType.MessageComponent && + ComponentType[this.componentType] === ComponentType.SelectMenu ); } } diff --git a/packages/discord.js/src/structures/InteractionCollector.js b/packages/discord.js/src/structures/InteractionCollector.js index 574c047e2..e6b99f2c5 100644 --- a/packages/discord.js/src/structures/InteractionCollector.js +++ b/packages/discord.js/src/structures/InteractionCollector.js @@ -1,9 +1,9 @@ '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'); -const { InteractionTypes, MessageComponentTypes } = require('../util/Constants'); /** * @typedef {CollectorOptions} InteractionCollectorOptions @@ -66,7 +66,7 @@ class InteractionCollector extends Collector { */ this.interactionType = typeof options.interactionType === 'number' - ? InteractionTypes[options.interactionType] + ? InteractionType[options.interactionType] : options.interactionType ?? null; /** @@ -74,9 +74,7 @@ class InteractionCollector extends Collector { * @type {?MessageComponentType} */ this.componentType = - typeof options.componentType === 'number' - ? MessageComponentTypes[options.componentType] - : options.componentType ?? null; + typeof options.componentType === 'number' ? ComponentType[options.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 17b387a37..7da715aa1 100644 --- a/packages/discord.js/src/structures/Message.js +++ b/packages/discord.js/src/structures/Message.js @@ -2,6 +2,7 @@ const { Collection } = require('@discordjs/collection'); const { DiscordSnowflake } = require('@sapphire/snowflake'); +const { MessageType, InteractionType } = require('discord-api-types/v9'); const Base = require('./Base'); const BaseMessageComponent = require('./BaseMessageComponent'); const ClientApplication = require('./ClientApplication'); @@ -14,7 +15,7 @@ const ReactionCollector = require('./ReactionCollector'); const { Sticker } = require('./Sticker'); const { Error } = require('../errors'); const ReactionManager = require('../managers/ReactionManager'); -const { InteractionTypes, MessageTypes, SystemMessageTypes } = require('../util/Constants'); +const { SystemMessageTypes } = require('../util/Constants'); const MessageFlags = require('../util/MessageFlags'); const Permissions = require('../util/Permissions'); const Util = require('../util/Util'); @@ -60,7 +61,7 @@ class Message extends Base { * The type of the message * @type {?MessageType} */ - this.type = MessageTypes[data.type]; + this.type = MessageType[data.type]; /** * Whether or not this message was sent by Discord, not actually a user (e.g. pin notifications) @@ -333,7 +334,7 @@ class Message extends Base { */ this.interaction = { id: data.interaction.id, - type: InteractionTypes[data.interaction.type], + type: InteractionType[data.interaction.type], commandName: data.interaction.name, user: this.client.users._add(data.interaction.user), }; @@ -502,7 +503,7 @@ class Message extends Base { createMessageComponentCollector(options = {}) { return new InteractionCollector(this.client, { ...options, - interactionType: InteractionTypes.MESSAGE_COMPONENT, + interactionType: InteractionType.MessageComponent, message: this, }); } diff --git a/packages/discord.js/src/structures/MessageComponentInteraction.js b/packages/discord.js/src/structures/MessageComponentInteraction.js index dae0107e4..f421fc38d 100644 --- a/packages/discord.js/src/structures/MessageComponentInteraction.js +++ b/packages/discord.js/src/structures/MessageComponentInteraction.js @@ -1,9 +1,9 @@ 'use strict'; +const { ComponentType } = require('discord-api-types/v9'); const Interaction = require('./Interaction'); const InteractionWebhook = require('./InteractionWebhook'); const InteractionResponses = require('./interfaces/InteractionResponses'); -const { MessageComponentTypes } = require('../util/Constants'); /** * Represents a message component interaction. @@ -84,11 +84,11 @@ class MessageComponentInteraction extends Interaction { /** * Resolves the type of a MessageComponent * @param {MessageComponentTypeResolvable} type The type to resolve - * @returns {MessageComponentType} + * @returns {ComponentType} * @private */ static resolveType(type) { - return typeof type === 'string' ? type : MessageComponentTypes[type]; + return typeof type === 'string' ? type : ComponentType[type]; } // These are here only for documentation purposes - they are implemented by InteractionResponses diff --git a/packages/discord.js/src/structures/MessageMentions.js b/packages/discord.js/src/structures/MessageMentions.js index 9b935f940..04188320a 100644 --- a/packages/discord.js/src/structures/MessageMentions.js +++ b/packages/discord.js/src/structures/MessageMentions.js @@ -1,7 +1,7 @@ 'use strict'; const { Collection } = require('@discordjs/collection'); -const { ChannelTypes } = require('../util/Constants'); +const { ChannelType } = require('discord-api-types/v9'); const Util = require('../util/Util'); /** @@ -112,7 +112,7 @@ class MessageMentions { this.crosspostedChannels = new Collection(crosspostedChannels); } else { this.crosspostedChannels = new Collection(); - const channelTypes = Object.keys(ChannelTypes); + const channelTypes = Object.keys(ChannelType); for (const d of crosspostedChannels) { const type = channelTypes[d.type]; this.crosspostedChannels.set(d.id, { diff --git a/packages/discord.js/src/structures/PermissionOverwrites.js b/packages/discord.js/src/structures/PermissionOverwrites.js index 017bf26bc..e3005ed87 100644 --- a/packages/discord.js/src/structures/PermissionOverwrites.js +++ b/packages/discord.js/src/structures/PermissionOverwrites.js @@ -1,9 +1,9 @@ 'use strict'; +const { OverwriteType } = require('discord-api-types/v9'); const Base = require('./Base'); const { Role } = require('./Role'); const { TypeError } = require('../errors'); -const { OverwriteTypes } = require('../util/Constants'); const Permissions = require('../util/Permissions'); /** @@ -37,7 +37,7 @@ class PermissionOverwrites extends Base { * The type of this overwrite * @type {OverwriteType} */ - this.type = typeof data.type === 'number' ? OverwriteTypes[data.type] : data.type; + this.type = typeof data.type === 'number' ? OverwriteType[data.type] : data.type; } if ('deny' in data) { @@ -71,7 +71,7 @@ class PermissionOverwrites extends Base { * .catch(console.error); */ async edit(options, reason) { - await this.channel.permissionOverwrites.upsert(this.id, options, { type: OverwriteTypes[this.type], reason }, this); + await this.channel.permissionOverwrites.upsert(this.id, options, { type: OverwriteType[this.type], reason }, this); return this; } @@ -88,7 +88,7 @@ class PermissionOverwrites extends Base { toJSON() { return { id: this.id, - type: OverwriteTypes[this.type], + type: OverwriteType[this.type], allow: this.allow, deny: this.deny, }; @@ -171,10 +171,10 @@ class PermissionOverwrites extends Base { */ static resolve(overwrite, guild) { if (overwrite instanceof this) return overwrite.toJSON(); - if (typeof overwrite.id === 'string' && overwrite.type in OverwriteTypes) { + if (typeof overwrite.id === 'string' && overwrite.type in OverwriteType) { return { id: overwrite.id, - type: OverwriteTypes[overwrite.type], + type: OverwriteType[overwrite.type], allow: Permissions.resolve(overwrite.allow ?? Permissions.defaultBit).toString(), deny: Permissions.resolve(overwrite.deny ?? Permissions.defaultBit).toString(), }; @@ -182,7 +182,7 @@ class PermissionOverwrites extends Base { const userOrRole = guild.roles.resolve(overwrite.id) ?? guild.client.users.resolve(overwrite.id); if (!userOrRole) throw new TypeError('INVALID_TYPE', 'parameter', 'User nor a Role'); - const type = userOrRole instanceof Role ? OverwriteTypes.role : OverwriteTypes.member; + const type = userOrRole instanceof Role ? OverwriteType.Role : OverwriteType.Member; return { id: userOrRole.id, diff --git a/packages/discord.js/src/structures/Presence.js b/packages/discord.js/src/structures/Presence.js index 35fdb8d02..924bbf926 100644 --- a/packages/discord.js/src/structures/Presence.js +++ b/packages/discord.js/src/structures/Presence.js @@ -1,9 +1,9 @@ 'use strict'; +const { ActivityType } = require('discord-api-types/v9'); const Base = require('./Base'); const { Emoji } = require('./Emoji'); const ActivityFlags = require('../util/ActivityFlags'); -const { ActivityTypes } = require('../util/Constants'); const Util = require('../util/Util'); /** @@ -168,7 +168,7 @@ class Activity { * The activity status's type * @type {ActivityType} */ - this.type = typeof data.type === 'number' ? ActivityTypes[data.type] : data.type; + this.type = typeof data.type === 'number' ? ActivityType[data.type] : data.type; /** * If the activity is being streamed, a link to the stream diff --git a/packages/discord.js/src/structures/StageInstance.js b/packages/discord.js/src/structures/StageInstance.js index a9a0a97e5..f01582ae3 100644 --- a/packages/discord.js/src/structures/StageInstance.js +++ b/packages/discord.js/src/structures/StageInstance.js @@ -1,8 +1,8 @@ 'use strict'; const { DiscordSnowflake } = require('@sapphire/snowflake'); +const { StageInstancePrivacyLevel } = require('discord-api-types/v9'); const Base = require('./Base'); -const { PrivacyLevels } = require('../util/Constants'); /** * Represents a stage instance. @@ -49,9 +49,9 @@ class StageInstance extends Base { if ('privacy_level' in data) { /** * The privacy level of the stage instance - * @type {PrivacyLevel} + * @type {StageInstancePrivacyLevel} */ - this.privacyLevel = PrivacyLevels[data.privacy_level]; + this.privacyLevel = StageInstancePrivacyLevel[data.privacy_level]; } if ('discoverable_disabled' in data) { diff --git a/packages/discord.js/src/structures/Sticker.js b/packages/discord.js/src/structures/Sticker.js index f43663fd6..754ff6556 100644 --- a/packages/discord.js/src/structures/Sticker.js +++ b/packages/discord.js/src/structures/Sticker.js @@ -1,8 +1,8 @@ 'use strict'; const { DiscordSnowflake } = require('@sapphire/snowflake'); +const { StickerType, StickerFormatType } = require('discord-api-types/v9'); const Base = require('./Base'); -const { StickerFormatTypes, StickerTypes } = require('../util/Constants'); /** * Represents a Sticker. @@ -37,7 +37,7 @@ class Sticker extends Base { * The type of the sticker * @type {?StickerType} */ - this.type = StickerTypes[sticker.type]; + this.type = StickerType[sticker.type]; } else { this.type ??= null; } @@ -47,7 +47,7 @@ class Sticker extends Base { * The format of the sticker * @type {StickerFormatType} */ - this.format = StickerFormatTypes[sticker.format_type]; + this.format = StickerFormatType[sticker.format_type]; } if ('name' in sticker) { diff --git a/packages/discord.js/src/structures/TeamMember.js b/packages/discord.js/src/structures/TeamMember.js index 9bd5993aa..92011ab6f 100644 --- a/packages/discord.js/src/structures/TeamMember.js +++ b/packages/discord.js/src/structures/TeamMember.js @@ -1,7 +1,7 @@ 'use strict'; +const { TeamMemberMembershipState } = require('discord-api-types/v9'); const Base = require('./Base'); -const { MembershipStates } = require('../util/Constants'); /** * Represents a Client OAuth2 Application Team Member. @@ -32,9 +32,9 @@ class TeamMember extends Base { if ('membership_state' in data) { /** * The permissions this Team Member has with regard to the team - * @type {MembershipState} + * @type {TeamMemberMembershipState} */ - this.membershipState = MembershipStates[data.membership_state]; + this.membershipState = TeamMemberMembershipState[data.membership_state]; } if ('user' in data) { diff --git a/packages/discord.js/src/structures/Webhook.js b/packages/discord.js/src/structures/Webhook.js index 60d80ef9e..69a27e768 100644 --- a/packages/discord.js/src/structures/Webhook.js +++ b/packages/discord.js/src/structures/Webhook.js @@ -2,9 +2,9 @@ const process = require('node:process'); const { DiscordSnowflake } = require('@sapphire/snowflake'); +const { WebhookType } = require('discord-api-types/v9'); const MessagePayload = require('./MessagePayload'); const { Error } = require('../errors'); -const { WebhookTypes } = require('../util/Constants'); const DataResolver = require('../util/DataResolver'); let deprecationEmittedForFetchMessage = false; @@ -59,7 +59,7 @@ class Webhook { * The type of the webhook * @type {WebhookType} */ - this.type = WebhookTypes[data.type]; + this.type = WebhookType[data.type]; } if ('guild_id' in data) { @@ -416,7 +416,7 @@ class Webhook { * @returns {boolean} */ isChannelFollower() { - return this.type === 'Channel Follower'; + return this.type === 'ChannelFollower'; } /** diff --git a/packages/discord.js/src/structures/interfaces/InteractionResponses.js b/packages/discord.js/src/structures/interfaces/InteractionResponses.js index dbe7c2327..d7e56357a 100644 --- a/packages/discord.js/src/structures/interfaces/InteractionResponses.js +++ b/packages/discord.js/src/structures/interfaces/InteractionResponses.js @@ -1,7 +1,7 @@ 'use strict'; +const { InteractionResponseType } = require('discord-api-types/v9'); const { Error } = require('../../errors'); -const { InteractionResponseTypes } = require('../../util/Constants'); const MessageFlags = require('../../util/MessageFlags'); const MessagePayload = require('../MessagePayload'); @@ -56,7 +56,7 @@ class InteractionResponses { this.ephemeral = options.ephemeral ?? false; await this.client.api.interactions(this.id, this.token).callback.post({ data: { - type: InteractionResponseTypes.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE, + type: InteractionResponseType.DeferredChannelMessageWithSource, data: { flags: options.ephemeral ? MessageFlags.FLAGS.EPHEMERAL : undefined, }, @@ -98,7 +98,7 @@ class InteractionResponses { await this.client.api.interactions(this.id, this.token).callback.post({ data: { - type: InteractionResponseTypes.CHANNEL_MESSAGE_WITH_SOURCE, + type: InteractionResponseType.ChannelMessageWithSource, data, }, files, @@ -180,7 +180,7 @@ class InteractionResponses { if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED'); await this.client.api.interactions(this.id, this.token).callback.post({ data: { - type: InteractionResponseTypes.DEFERRED_MESSAGE_UPDATE, + type: InteractionResponseType.DeferredMessageUpdate, }, auth: false, }); @@ -213,7 +213,7 @@ class InteractionResponses { await this.client.api.interactions(this.id, this.token).callback.post({ data: { - type: InteractionResponseTypes.UPDATE_MESSAGE, + type: InteractionResponseType.UpdateMessage, data, }, files, diff --git a/packages/discord.js/src/structures/interfaces/TextBasedChannel.js b/packages/discord.js/src/structures/interfaces/TextBasedChannel.js index ba97b553e..a2adf1971 100644 --- a/packages/discord.js/src/structures/interfaces/TextBasedChannel.js +++ b/packages/discord.js/src/structures/interfaces/TextBasedChannel.js @@ -5,8 +5,8 @@ const MessageCollector = require('../MessageCollector'); const MessagePayload = require('../MessagePayload'); const { Collection } = require('@discordjs/collection'); const { DiscordSnowflake } = require('@sapphire/snowflake'); -const { InteractionTypes } = require('../../util/Constants'); const { TypeError, Error } = require('../../errors'); +const { InteractionType } = require('discord-api-types/v9'); const InteractionCollector = require('../InteractionCollector'); /** @@ -249,7 +249,7 @@ class TextBasedChannel { createMessageComponentCollector(options = {}) { return new InteractionCollector(this.client, { ...options, - interactionType: InteractionTypes.MESSAGE_COMPONENT, + interactionType: InteractionType.MessageComponent, channel: this, }); } diff --git a/packages/discord.js/src/util/Constants.js b/packages/discord.js/src/util/Constants.js index 737582976..7b149923c 100644 --- a/packages/discord.js/src/util/Constants.js +++ b/packages/discord.js/src/util/Constants.js @@ -478,56 +478,6 @@ exports.SystemMessageTypes = exports.MessageTypes.filter( type => type && !['DEFAULT', 'REPLY', 'CHAT_INPUT_COMMAND', 'CONTEXT_MENU_COMMAND'].includes(type), ); -/** - * Bots cannot set a `CUSTOM` activity type, it is only for custom statuses received from users - * The type of an activity of a user's presence. Here are the available types: - * * PLAYING - * * STREAMING - * * LISTENING - * * WATCHING - * * CUSTOM - * * COMPETING - * @typedef {string} ActivityType - * @see {@link https://discord.com/developers/docs/game-sdk/activities#data-models-activitytype-enum} - */ -exports.ActivityTypes = createEnum(['PLAYING', 'STREAMING', 'LISTENING', 'WATCHING', 'CUSTOM', 'COMPETING']); - -/** - * All available channel types: - * * `GUILD_TEXT` - a guild text channel - * * `DM` - a DM channel - * * `GUILD_VOICE` - a guild voice channel - * * `GROUP_DM` - a group DM channel - * * `GUILD_CATEGORY` - a guild category channel - * * `GUILD_NEWS` - a guild news channel - * * `GUILD_STORE` - a guild store channel - * Store channels are deprecated and will be removed from Discord in March 2022. See - * [Self-serve Game Selling Deprecation](https://support-dev.discord.com/hc/en-us/articles/4414590563479) - * for more information. - * * `GUILD_NEWS_THREAD` - a guild news channel's public thread channel - * * `GUILD_PUBLIC_THREAD` - a guild text channel's public thread channel - * * `GUILD_PRIVATE_THREAD` - a guild text channel's private thread channel - * * `GUILD_STAGE_VOICE` - a guild stage voice channel - * * `UNKNOWN` - a generic channel of unknown type, could be Channel or GuildChannel - * @typedef {string} ChannelType - * @see {@link https://discord.com/developers/docs/resources/channel#channel-object-channel-types} - */ -exports.ChannelTypes = createEnum([ - 'GUILD_TEXT', - 'DM', - 'GUILD_VOICE', - 'GROUP_DM', - 'GUILD_CATEGORY', - 'GUILD_NEWS', - 'GUILD_STORE', - ...Array(3).fill(null), - // 10 - 'GUILD_NEWS_THREAD', - 'GUILD_PUBLIC_THREAD', - 'GUILD_PRIVATE_THREAD', - 'GUILD_STAGE_VOICE', -]); - /** * The channels that are text-based. * * DMChannel @@ -606,558 +556,6 @@ exports.Colors = { NOT_QUITE_BLACK: 0x23272a, }; -/** - * The value set for the explicit content filter levels for a guild: - * * DISABLED - * * MEMBERS_WITHOUT_ROLES - * * ALL_MEMBERS - * @typedef {string} ExplicitContentFilterLevel - * @see {@link https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level} - */ -exports.ExplicitContentFilterLevels = createEnum(['DISABLED', 'MEMBERS_WITHOUT_ROLES', 'ALL_MEMBERS']); - -/** - * The value set for the verification levels for a guild: - * * NONE - * * LOW - * * MEDIUM - * * HIGH - * * VERY_HIGH - * @typedef {string} VerificationLevel - * @see {@link https://discord.com/developers/docs/resources/guild#guild-object-verification-level} - */ -exports.VerificationLevels = createEnum(['NONE', 'LOW', 'MEDIUM', 'HIGH', 'VERY_HIGH']); - -/** - * An error encountered while performing an API request. Here are the potential errors: - * * UNKNOWN_ACCOUNT - * * UNKNOWN_APPLICATION - * * UNKNOWN_CHANNEL - * * UNKNOWN_GUILD - * * UNKNOWN_INTEGRATION - * * UNKNOWN_INVITE - * * UNKNOWN_MEMBER - * * UNKNOWN_MESSAGE - * * UNKNOWN_OVERWRITE - * * UNKNOWN_PROVIDER - * * UNKNOWN_ROLE - * * UNKNOWN_TOKEN - * * UNKNOWN_USER - * * UNKNOWN_EMOJI - * * UNKNOWN_WEBHOOK - * * UNKNOWN_WEBHOOK_SERVICE - * * UNKNOWN_SESSION - * * UNKNOWN_BAN - * * UNKNOWN_SKU - * * UNKNOWN_STORE_LISTING - * * UNKNOWN_ENTITLEMENT - * * UNKNOWN_BUILD - * * UNKNOWN_LOBBY - * * UNKNOWN_BRANCH - * * UNKNOWN_STORE_DIRECTORY_LAYOUT - * * UNKNOWN_REDISTRIBUTABLE - * * UNKNOWN_GIFT_CODE - * * UNKNOWN_STREAM - * * UNKNOWN_PREMIUM_SERVER_SUBSCRIBE_COOLDOWN - * * UNKNOWN_GUILD_TEMPLATE - * * UNKNOWN_DISCOVERABLE_SERVER_CATEGORY - * * UNKNOWN_STICKER - * * UNKNOWN_INTERACTION - * * UNKNOWN_APPLICATION_COMMAND - * * UNKNOWN_APPLICATION_COMMAND_PERMISSIONS - * * UNKNOWN_STAGE_INSTANCE - * * UNKNOWN_GUILD_MEMBER_VERIFICATION_FORM - * * UNKNOWN_GUILD_WELCOME_SCREEN - * * UNKNOWN_GUILD_SCHEDULED_EVENT - * * UNKNOWN_GUILD_SCHEDULED_EVENT_USER - * * BOT_PROHIBITED_ENDPOINT - * * BOT_ONLY_ENDPOINT - * * CANNOT_SEND_EXPLICIT_CONTENT - * * NOT_AUTHORIZED - * * SLOWMODE_RATE_LIMIT - * * ACCOUNT_OWNER_ONLY - * * ANNOUNCEMENT_EDIT_LIMIT_EXCEEDED - * * CHANNEL_HIT_WRITE_RATELIMIT - * * SERVER_HIT_WRITE_RATELIMIT - * * CONTENT_NOT_ALLOWED - * * GUILD_PREMIUM_LEVEL_TOO_LOW - * * MAXIMUM_GUILDS - * * MAXIMUM_FRIENDS - * * MAXIMUM_PINS - * * MAXIMUM_RECIPIENTS - * * MAXIMUM_ROLES - * * MAXIMUM_WEBHOOKS - * * MAXIMUM_EMOJIS - * * MAXIMUM_REACTIONS - * * MAXIMUM_CHANNELS - * * MAXIMUM_ATTACHMENTS - * * MAXIMUM_INVITES - * * MAXIMUM_ANIMATED_EMOJIS - * * MAXIMUM_SERVER_MEMBERS - * * MAXIMUM_NUMBER_OF_SERVER_CATEGORIES - * * GUILD_ALREADY_HAS_TEMPLATE - * * MAXIMUM_THREAD_PARTICIPANTS - * * MAXIMUM_NON_GUILD_MEMBERS_BANS - * * MAXIMUM_BAN_FETCHES - * * MAXIMUM_NUMBER_OF_UNCOMPLETED_GUILD_SCHEDULED_EVENTS_REACHED - * * MAXIMUM_NUMBER_OF_STICKERS_REACHED - * * MAXIMUM_PRUNE_REQUESTS - * * MAXIMUM_GUILD_WIDGET_SETTINGS_UPDATE - * * UNAUTHORIZED - * * ACCOUNT_VERIFICATION_REQUIRED - * * DIRECT_MESSAGES_TOO_FAST - * * REQUEST_ENTITY_TOO_LARGE - * * FEATURE_TEMPORARILY_DISABLED - * * USER_BANNED - * * TARGET_USER_NOT_CONNECTED_TO_VOICE - * * ALREADY_CROSSPOSTED - * * MISSING_ACCESS - * * INVALID_ACCOUNT_TYPE - * * CANNOT_EXECUTE_ON_DM - * * EMBED_DISABLED - * * CANNOT_EDIT_MESSAGE_BY_OTHER - * * CANNOT_SEND_EMPTY_MESSAGE - * * CANNOT_MESSAGE_USER - * * CANNOT_SEND_MESSAGES_IN_VOICE_CHANNEL - * * CHANNEL_VERIFICATION_LEVEL_TOO_HIGH - * * OAUTH2_APPLICATION_BOT_ABSENT - * * MAXIMUM_OAUTH2_APPLICATIONS - * * INVALID_OAUTH_STATE - * * MISSING_PERMISSIONS - * * INVALID_AUTHENTICATION_TOKEN - * * NOTE_TOO_LONG - * * INVALID_BULK_DELETE_QUANTITY - * * CANNOT_PIN_MESSAGE_IN_OTHER_CHANNEL - * * INVALID_OR_TAKEN_INVITE_CODE - * * CANNOT_EXECUTE_ON_SYSTEM_MESSAGE - * * CANNOT_EXECUTE_ON_CHANNEL_TYPE - * * INVALID_OAUTH_TOKEN - * * MISSING_OAUTH_SCOPE - * * INVALID_WEBHOOK_TOKEN - * * INVALID_ROLE - * * INVALID_RECIPIENTS - * * BULK_DELETE_MESSAGE_TOO_OLD - * * INVALID_FORM_BODY - * * INVITE_ACCEPTED_TO_GUILD_NOT_CONTAINING_BOT - * * INVALID_API_VERSION - * * FILE_UPLOADED_EXCEEDS_MAXIMUM_SIZE - * * INVALID_FILE_UPLOADED - * * CANNOT_SELF_REDEEM_GIFT - * * INVALID_GUILD - * * PAYMENT_SOURCE_REQUIRED - * * CANNOT_DELETE_COMMUNITY_REQUIRED_CHANNEL - * * INVALID_STICKER_SENT - * * INVALID_OPERATION_ON_ARCHIVED_THREAD - * * INVALID_THREAD_NOTIFICATION_SETTINGS - * * PARAMETER_EARLIER_THAN_CREATION - * * GUILD_NOT_AVAILABLE_IN_LOCATION - * * GUILD_MONETIZATION_REQUIRED - * * INSUFFICIENT_BOOSTS - * * INVALID_JSON - * * TWO_FACTOR_REQUIRED - * * NO_USERS_WITH_DISCORDTAG_EXIST - * * REACTION_BLOCKED - * * RESOURCE_OVERLOADED - * * STAGE_ALREADY_OPEN - * * CANNOT_REPLY_WITHOUT_READ_MESSAGE_HISTORY_PERMISSION - * * MESSAGE_ALREADY_HAS_THREAD - * * THREAD_LOCKED - * * MAXIMUM_ACTIVE_THREADS - * * MAXIMUM_ACTIVE_ANNOUNCEMENT_THREAD - * * INVALID_JSON_FOR_UPLOADED_LOTTIE_FILE - * * UPLOADED_LOTTIES_CANNOT_CONTAIN_RASTERIZED_IMAGES - * * STICKER_MAXIMUM_FRAMERATE_EXCEEDED - * * STICKER_FRAME_COUNT_EXCEEDS_MAXIMUM_OF_1000_FRAMES - * * LOTTIE_ANIMATION_MAXIMUM_DIMENSIONS_EXCEEDED - * * STICKER_FRAME_RATE_IS_TOO_SMALL_OR_TOO_LARGE - * * STICKER_ANIMATION_DURATION_EXCEEDS_MAXIMUM_OF_5_SECONDS - * * CANNOT_UPDATE_A_FINISHED_EVENT - * * FAILED_TO_CREATE_STAGE_NEEDED_FOR_STAGE_EVENT - * @typedef {string} APIError - * @see {@link https://discord.com/developers/docs/topics/opcodes-and-status-codes#json-json-error-codes} - */ -exports.APIErrors = { - UNKNOWN_ACCOUNT: 10001, - UNKNOWN_APPLICATION: 10002, - UNKNOWN_CHANNEL: 10003, - UNKNOWN_GUILD: 10004, - UNKNOWN_INTEGRATION: 10005, - UNKNOWN_INVITE: 10006, - UNKNOWN_MEMBER: 10007, - UNKNOWN_MESSAGE: 10008, - UNKNOWN_OVERWRITE: 10009, - UNKNOWN_PROVIDER: 10010, - UNKNOWN_ROLE: 10011, - UNKNOWN_TOKEN: 10012, - UNKNOWN_USER: 10013, - UNKNOWN_EMOJI: 10014, - UNKNOWN_WEBHOOK: 10015, - UNKNOWN_WEBHOOK_SERVICE: 10016, - UNKNOWN_SESSION: 10020, - UNKNOWN_BAN: 10026, - UNKNOWN_SKU: 10027, - UNKNOWN_STORE_LISTING: 10028, - UNKNOWN_ENTITLEMENT: 10029, - UNKNOWN_BUILD: 10030, - UNKNOWN_LOBBY: 10031, - UNKNOWN_BRANCH: 10032, - UNKNOWN_STORE_DIRECTORY_LAYOUT: 10033, - UNKNOWN_REDISTRIBUTABLE: 10036, - UNKNOWN_GIFT_CODE: 10038, - UNKNOWN_STREAM: 10049, - UNKNOWN_PREMIUM_SERVER_SUBSCRIBE_COOLDOWN: 10050, - UNKNOWN_GUILD_TEMPLATE: 10057, - UNKNOWN_DISCOVERABLE_SERVER_CATEGORY: 10059, - UNKNOWN_STICKER: 10060, - UNKNOWN_INTERACTION: 10062, - UNKNOWN_APPLICATION_COMMAND: 10063, - UNKNOWN_APPLICATION_COMMAND_PERMISSIONS: 10066, - UNKNOWN_STAGE_INSTANCE: 10067, - UNKNOWN_GUILD_MEMBER_VERIFICATION_FORM: 10068, - UNKNOWN_GUILD_WELCOME_SCREEN: 10069, - UNKNOWN_GUILD_SCHEDULED_EVENT: 10070, - UNKNOWN_GUILD_SCHEDULED_EVENT_USER: 10071, - BOT_PROHIBITED_ENDPOINT: 20001, - BOT_ONLY_ENDPOINT: 20002, - CANNOT_SEND_EXPLICIT_CONTENT: 20009, - NOT_AUTHORIZED: 20012, - SLOWMODE_RATE_LIMIT: 20016, - ACCOUNT_OWNER_ONLY: 20018, - ANNOUNCEMENT_EDIT_LIMIT_EXCEEDED: 20022, - CHANNEL_HIT_WRITE_RATELIMIT: 20028, - SERVER_HIT_WRITE_RATELIMIT: 20029, - CONTENT_NOT_ALLOWED: 20031, - GUILD_PREMIUM_LEVEL_TOO_LOW: 20035, - MAXIMUM_GUILDS: 30001, - MAXIMUM_FRIENDS: 30002, - MAXIMUM_PINS: 30003, - MAXIMUM_RECIPIENTS: 30004, - MAXIMUM_ROLES: 30005, - MAXIMUM_WEBHOOKS: 30007, - MAXIMUM_EMOJIS: 30008, - MAXIMUM_REACTIONS: 30010, - MAXIMUM_CHANNELS: 30013, - MAXIMUM_ATTACHMENTS: 30015, - MAXIMUM_INVITES: 30016, - MAXIMUM_ANIMATED_EMOJIS: 30018, - MAXIMUM_SERVER_MEMBERS: 30019, - MAXIMUM_NUMBER_OF_SERVER_CATEGORIES: 30030, - GUILD_ALREADY_HAS_TEMPLATE: 30031, - MAXIMUM_THREAD_PARTICIPANTS: 30033, - MAXIMUM_NON_GUILD_MEMBERS_BANS: 30035, - MAXIMUM_BAN_FETCHES: 30037, - MAXIMUM_NUMBER_OF_UNCOMPLETED_GUILD_SCHEDULED_EVENTS_REACHED: 30038, - MAXIMUM_NUMBER_OF_STICKERS_REACHED: 30039, - MAXIMUM_PRUNE_REQUESTS: 30040, - MAXIMUM_GUILD_WIDGET_SETTINGS_UPDATE: 30042, - UNAUTHORIZED: 40001, - ACCOUNT_VERIFICATION_REQUIRED: 40002, - DIRECT_MESSAGES_TOO_FAST: 40003, - REQUEST_ENTITY_TOO_LARGE: 40005, - FEATURE_TEMPORARILY_DISABLED: 40006, - USER_BANNED: 40007, - TARGET_USER_NOT_CONNECTED_TO_VOICE: 40032, - ALREADY_CROSSPOSTED: 40033, - MISSING_ACCESS: 50001, - INVALID_ACCOUNT_TYPE: 50002, - CANNOT_EXECUTE_ON_DM: 50003, - EMBED_DISABLED: 50004, - CANNOT_EDIT_MESSAGE_BY_OTHER: 50005, - CANNOT_SEND_EMPTY_MESSAGE: 50006, - CANNOT_MESSAGE_USER: 50007, - CANNOT_SEND_MESSAGES_IN_VOICE_CHANNEL: 50008, - CHANNEL_VERIFICATION_LEVEL_TOO_HIGH: 50009, - OAUTH2_APPLICATION_BOT_ABSENT: 50010, - MAXIMUM_OAUTH2_APPLICATIONS: 50011, - INVALID_OAUTH_STATE: 50012, - MISSING_PERMISSIONS: 50013, - INVALID_AUTHENTICATION_TOKEN: 50014, - NOTE_TOO_LONG: 50015, - INVALID_BULK_DELETE_QUANTITY: 50016, - CANNOT_PIN_MESSAGE_IN_OTHER_CHANNEL: 50019, - INVALID_OR_TAKEN_INVITE_CODE: 50020, - CANNOT_EXECUTE_ON_SYSTEM_MESSAGE: 50021, - CANNOT_EXECUTE_ON_CHANNEL_TYPE: 50024, - INVALID_OAUTH_TOKEN: 50025, - MISSING_OAUTH_SCOPE: 50026, - INVALID_WEBHOOK_TOKEN: 50027, - INVALID_ROLE: 50028, - INVALID_RECIPIENTS: 50033, - BULK_DELETE_MESSAGE_TOO_OLD: 50034, - INVALID_FORM_BODY: 50035, - INVITE_ACCEPTED_TO_GUILD_NOT_CONTAINING_BOT: 50036, - INVALID_API_VERSION: 50041, - FILE_UPLOADED_EXCEEDS_MAXIMUM_SIZE: 50045, - INVALID_FILE_UPLOADED: 50046, - CANNOT_SELF_REDEEM_GIFT: 50054, - INVALID_GUILD: 50055, - PAYMENT_SOURCE_REQUIRED: 50070, - CANNOT_DELETE_COMMUNITY_REQUIRED_CHANNEL: 50074, - INVALID_STICKER_SENT: 50081, - INVALID_OPERATION_ON_ARCHIVED_THREAD: 50083, - INVALID_THREAD_NOTIFICATION_SETTINGS: 50084, - PARAMETER_EARLIER_THAN_CREATION: 50085, - GUILD_NOT_AVAILABLE_IN_LOCATION: 50095, - GUILD_MONETIZATION_REQUIRED: 50097, - INSUFFICIENT_BOOSTS: 50101, - INVALID_JSON: 50109, - TWO_FACTOR_REQUIRED: 60003, - NO_USERS_WITH_DISCORDTAG_EXIST: 80004, - REACTION_BLOCKED: 90001, - RESOURCE_OVERLOADED: 130000, - STAGE_ALREADY_OPEN: 150006, - CANNOT_REPLY_WITHOUT_READ_MESSAGE_HISTORY_PERMISSION: 160002, - MESSAGE_ALREADY_HAS_THREAD: 160004, - THREAD_LOCKED: 160005, - MAXIMUM_ACTIVE_THREADS: 160006, - MAXIMUM_ACTIVE_ANNOUNCEMENT_THREADS: 160007, - INVALID_JSON_FOR_UPLOADED_LOTTIE_FILE: 170001, - UPLOADED_LOTTIES_CANNOT_CONTAIN_RASTERIZED_IMAGES: 170002, - STICKER_MAXIMUM_FRAMERATE_EXCEEDED: 170003, - STICKER_FRAME_COUNT_EXCEEDS_MAXIMUM_OF_1000_FRAMES: 170004, - LOTTIE_ANIMATION_MAXIMUM_DIMENSIONS_EXCEEDED: 170005, - STICKER_FRAME_RATE_IS_TOO_SMALL_OR_TOO_LARGE: 170006, - STICKER_ANIMATION_DURATION_EXCEEDS_MAXIMUM_OF_5_SECONDS: 170007, - CANNOT_UPDATE_A_FINISHED_EVENT: 180000, - FAILED_TO_CREATE_STAGE_NEEDED_FOR_STAGE_EVENT: 180002, -}; - -/** - * The value set for a guild's default message notifications, e.g. `ALL_MESSAGES`. Here are the available types: - * * ALL_MESSAGES - * * ONLY_MENTIONS - * @typedef {string} DefaultMessageNotificationLevel - * @see {@link https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level} - */ -exports.DefaultMessageNotificationLevels = createEnum(['ALL_MESSAGES', 'ONLY_MENTIONS']); - -/** - * The value set for a team member's membership state: - * * INVITED - * * ACCEPTED - * @typedef {string} MembershipState - * @see {@link https://discord.com/developers/docs/topics/teams#data-models-membership-state-enum} - */ -exports.MembershipStates = createEnum([null, 'INVITED', 'ACCEPTED']); - -/** - * The value set for a webhook's type: - * * Incoming - * * Channel Follower - * * Application - * @typedef {string} WebhookType - * @see {@link https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types} - */ -exports.WebhookTypes = createEnum([null, 'Incoming', 'Channel Follower', 'Application']); - -/** - * The value set for a sticker's type: - * * STANDARD - * * GUILD - * @typedef {string} StickerType - * @see {@link https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types} - */ -exports.StickerTypes = createEnum([null, 'STANDARD', 'GUILD']); - -/** - * The value set for a sticker's format type: - * * PNG - * * APNG - * * LOTTIE - * @typedef {string} StickerFormatType - * @see {@link https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types} - */ -exports.StickerFormatTypes = createEnum([null, 'PNG', 'APNG', 'LOTTIE']); - -/** - * An overwrite type: - * * role - * * member - * @typedef {string} OverwriteType - * @see {@link https://discord.com/developers/docs/resources/channel#overwrite-object-overwrite-structure} - */ -exports.OverwriteTypes = createEnum(['role', 'member']); - -/* eslint-disable max-len */ -/** - * The type of an {@link ApplicationCommand} object: - * * CHAT_INPUT - * * USER - * * MESSAGE - * @typedef {string} ApplicationCommandType - * @see {@link https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types} - */ -exports.ApplicationCommandTypes = createEnum([null, 'CHAT_INPUT', 'USER', 'MESSAGE']); - -/** - * The type of an {@link ApplicationCommandOption} object: - * * SUB_COMMAND - * * SUB_COMMAND_GROUP - * * STRING - * * INTEGER - * * BOOLEAN - * * USER - * * CHANNEL - * * ROLE - * * MENTIONABLE - * * NUMBER - * @typedef {string} ApplicationCommandOptionType - * @see {@link https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type} - */ -exports.ApplicationCommandOptionTypes = createEnum([ - null, - 'SUB_COMMAND', - 'SUB_COMMAND_GROUP', - 'STRING', - 'INTEGER', - 'BOOLEAN', - 'USER', - 'CHANNEL', - 'ROLE', - 'MENTIONABLE', - 'NUMBER', -]); - -/** - * The type of an {@link ApplicationCommandPermissions} object: - * * ROLE - * * USER - * @typedef {string} ApplicationCommandPermissionType - * @see {@link https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permission-type} - */ -exports.ApplicationCommandPermissionTypes = createEnum([null, 'ROLE', 'USER']); - -/** - * The type of an {@link Interaction} object: - * * PING - * * APPLICATION_COMMAND - * * MESSAGE_COMPONENT - * * APPLICATION_COMMAND_AUTOCOMPLETE - * @typedef {string} InteractionType - * @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type} - */ -exports.InteractionTypes = createEnum([ - null, - 'PING', - 'APPLICATION_COMMAND', - 'MESSAGE_COMPONENT', - 'APPLICATION_COMMAND_AUTOCOMPLETE', -]); - -/** - * The type of an interaction response: - * * PONG - * * CHANNEL_MESSAGE_WITH_SOURCE - * * DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE - * * DEFERRED_MESSAGE_UPDATE - * * UPDATE_MESSAGE - * * APPLICATION_COMMAND_AUTOCOMPLETE_RESULT - * @typedef {string} InteractionResponseType - * @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type} - */ -exports.InteractionResponseTypes = createEnum([ - null, - 'PONG', - null, - null, - 'CHANNEL_MESSAGE_WITH_SOURCE', - 'DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE', - 'DEFERRED_MESSAGE_UPDATE', - 'UPDATE_MESSAGE', - 'APPLICATION_COMMAND_AUTOCOMPLETE_RESULT', -]); - -/** - * The type of a message component - * * ACTION_ROW - * * BUTTON - * * SELECT_MENU - * @typedef {string} MessageComponentType - * @see {@link https://discord.com/developers/docs/interactions/message-components#component-object-component-types} - */ -exports.MessageComponentTypes = createEnum([null, 'ACTION_ROW', 'BUTTON', 'SELECT_MENU']); - -/** - * The style of a message button - * * PRIMARY - * * SECONDARY - * * SUCCESS - * * DANGER - * * LINK - * @typedef {string} MessageButtonStyle - * @see {@link https://discord.com/developers/docs/interactions/message-components#button-object-button-styles} - */ -exports.MessageButtonStyles = createEnum([null, 'PRIMARY', 'SECONDARY', 'SUCCESS', 'DANGER', 'LINK']); - -/** - * The required MFA level for a guild - * * NONE - * * ELEVATED - * @typedef {string} MFALevel - * @see {@link https://discord.com/developers/docs/resources/guild#guild-object-mfa-level} - */ -exports.MFALevels = createEnum(['NONE', 'ELEVATED']); - -/** - * NSFW level of a Guild: - * * DEFAULT - * * EXPLICIT - * * SAFE - * * AGE_RESTRICTED - * @typedef {string} NSFWLevel - * @see {@link https://discord.com/developers/docs/resources/guild#guild-object-guild-nsfw-level} - */ -exports.NSFWLevels = createEnum(['DEFAULT', 'EXPLICIT', 'SAFE', 'AGE_RESTRICTED']); - -/** - * Privacy level of a {@link StageInstance} object: - * * PUBLIC - * * GUILD_ONLY - * @typedef {string} PrivacyLevel - * @see {@link https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-privacy-level} - */ -exports.PrivacyLevels = createEnum([null, 'PUBLIC', 'GUILD_ONLY']); - -/** - * Privacy level of a {@link GuildScheduledEvent} object: - * * GUILD_ONLY - * @typedef {string} GuildScheduledEventPrivacyLevel - * @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-privacy-level} - */ -exports.GuildScheduledEventPrivacyLevels = createEnum([null, null, 'GUILD_ONLY']); - -/** - * The premium tier (Server Boost level) of a guild: - * * NONE - * * TIER_1 - * * TIER_2 - * * TIER_3 - * @typedef {string} PremiumTier - * @see {@link https://discord.com/developers/docs/resources/guild#guild-object-premium-tier} - */ -exports.PremiumTiers = createEnum(['NONE', 'TIER_1', 'TIER_2', 'TIER_3']); - -/** - * The status of a {@link GuildScheduledEvent}: - * * SCHEDULED - * * ACTIVE - * * COMPLETED - * * CANCELED - * @typedef {string} GuildScheduledEventStatus - * @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status} - */ -exports.GuildScheduledEventStatuses = createEnum([null, 'SCHEDULED', 'ACTIVE', 'COMPLETED', 'CANCELED']); - -/** - * The entity type of a {@link GuildScheduledEvent}: - * * NONE - * * STAGE_INSTANCE - * * VOICE - * * EXTERNAL - * @typedef {string} GuildScheduledEventEntityType - * @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types} - */ -exports.GuildScheduledEventEntityTypes = createEnum([null, 'STAGE_INSTANCE', 'VOICE', 'EXTERNAL']); /* eslint-enable max-len */ function keyMirror(arr) { @@ -1178,37 +576,6 @@ function createEnum(keys) { /** * @typedef {Object} Constants Constants that can be used in an enum or object-like way. - * @property {ActivityType} ActivityTypes The type of an activity of a users presence. - * @property {APIError} APIErrors An error encountered while performing an API request. - * @property {ApplicationCommandOptionType} ApplicationCommandOptionTypes - * The type of an {@link ApplicationCommandOption} object. - * @property {ApplicationCommandPermissionType} ApplicationCommandPermissionTypes - * The type of an {@link ApplicationCommandPermissions} object. - * @property {ChannelType} ChannelTypes All available channel types. - * @property {DefaultMessageNotificationLevel} DefaultMessageNotificationLevels - * The value set for a guild's default message notifications. - * @property {ExplicitContentFilterLevel} ExplicitContentFilterLevels - * The value set for the explicit content filter levels for a guild. - * @property {GuildScheduledEventStatus} GuildScheduledEventStatuses The status of a {@link GuildScheduledEvent} object. - * @property {GuildScheduledEventEntityType} GuildScheduledEventEntityTypes The entity type of a - * {@link GuildScheduledEvent} object. - * @property {GuildScheduledEventPrivacyLevel} GuildScheduledEventPrivacyLevels Privacy level of a - * {@link GuildScheduledEvent} object. - * @property {InteractionResponseType} InteractionResponseTypes The type of an interaction response. - * @property {InteractionType} InteractionTypes The type of an {@link Interaction} object. - * @property {MembershipState} MembershipStates The value set for a team member's membership state. - * @property {MessageButtonStyle} MessageButtonStyles The style of a message button. - * @property {MessageComponentType} MessageComponentTypes The type of a message component. - * @property {MFALevel} MFALevels The required MFA level for a guild. - * @property {NSFWLevel} NSFWLevels NSFW level of a guild. - * @property {OverwriteType} OverwriteTypes An overwrite type. - * @property {PartialType} PartialTypes The type of Structure allowed to be a partial. - * @property {PremiumTier} PremiumTiers The premium tier (Server Boost level) of a guild. - * @property {PrivacyLevel} PrivacyLevels Privacy level of a {@link StageInstance} object. * @property {Status} Status The available statuses of the client. - * @property {StickerFormatType} StickerFormatTypes The value set for a sticker's format type. - * @property {StickerType} StickerTypes The value set for a sticker's type. - * @property {VerificationLevel} VerificationLevels The value set for the verification levels for a guild. - * @property {WebhookType} WebhookTypes The value set for a webhook's type. * @property {WSEventType} WSEvents The type of a WebSocket message event. */ diff --git a/packages/discord.js/typings/enums.d.ts b/packages/discord.js/typings/enums.d.ts deleted file mode 100644 index 6b2721f23..000000000 --- a/packages/discord.js/typings/enums.d.ts +++ /dev/null @@ -1,198 +0,0 @@ -// These are enums that are used in the typings file but do not exist as actual exported values. To prevent them from -// showing up in an editor, they are imported from here instead of exporting them there directly. - -export const enum ActivityTypes { - PLAYING = 0, - STREAMING = 1, - LISTENING = 2, - WATCHING = 3, - CUSTOM = 4, - COMPETING = 5, -} - -export const enum ApplicationCommandTypes { - CHAT_INPUT = 1, - USER = 2, - MESSAGE = 3, -} - -export const enum ApplicationCommandOptionTypes { - SUB_COMMAND = 1, - SUB_COMMAND_GROUP = 2, - STRING = 3, - INTEGER = 4, - BOOLEAN = 5, - USER = 6, - CHANNEL = 7, - ROLE = 8, - MENTIONABLE = 9, - NUMBER = 10, -} - -export const enum ApplicationCommandPermissionTypes { - ROLE = 1, - USER = 2, -} - -export const enum ChannelTypes { - GUILD_TEXT = 0, - DM = 1, - GUILD_VOICE = 2, - GROUP_DM = 3, - GUILD_CATEGORY = 4, - GUILD_NEWS = 5, - GUILD_STORE = 6, - UNKNOWN = 7, - GUILD_NEWS_THREAD = 10, - GUILD_PUBLIC_THREAD = 11, - GUILD_PRIVATE_THREAD = 12, - GUILD_STAGE_VOICE = 13, -} - -export const enum MessageTypes { - 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 = 14, - 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 const enum DefaultMessageNotificationLevels { - ALL_MESSAGES = 0, - ONLY_MENTIONS = 1, -} - -export const enum ExplicitContentFilterLevels { - DISABLED = 0, - MEMBERS_WITHOUT_ROLES = 1, - ALL_MEMBERS = 2, -} - -export const enum GuildScheduledEventEntityTypes { - STAGE_INSTANCE = 1, - VOICE = 2, - EXTERNAL = 3, -} - -export const enum GuildScheduledEventPrivacyLevels { - GUILD_ONLY = 2, -} - -export const enum GuildScheduledEventStatuses { - SCHEDULED = 1, - ACTIVE = 2, - COMPLETED = 3, - CANCELED = 4, -} - -export const enum InteractionResponseTypes { - PONG = 1, - CHANNEL_MESSAGE_WITH_SOURCE = 4, - DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE = 5, - DEFERRED_MESSAGE_UPDATE = 6, - UPDATE_MESSAGE = 7, - APPLICATION_COMMAND_AUTOCOMPLETE_RESULT = 8, -} - -export const enum InteractionTypes { - PING = 1, - APPLICATION_COMMAND = 2, - MESSAGE_COMPONENT = 3, - APPLICATION_COMMAND_AUTOCOMPLETE = 4, -} - -export const enum InviteTargetType { - STREAM = 1, - EMBEDDED_APPLICATION = 2, -} - -export const enum MembershipStates { - INVITED = 1, - ACCEPTED = 2, -} - -export const enum MessageButtonStyles { - PRIMARY = 1, - SECONDARY = 2, - SUCCESS = 3, - DANGER = 4, - LINK = 5, -} - -export const enum MessageComponentTypes { - ACTION_ROW = 1, - BUTTON = 2, - SELECT_MENU = 3, -} - -export const enum MFALevels { - NONE = 0, - ELEVATED = 1, -} - -export const enum NSFWLevels { - DEFAULT = 0, - EXPLICIT = 1, - SAFE = 2, - AGE_RESTRICTED = 3, -} - -export const enum OverwriteTypes { - role = 0, - member = 1, -} - -export const enum PremiumTiers { - NONE = 0, - TIER_1 = 1, - TIER_2 = 2, - TIER_3 = 3, -} - -export const enum PrivacyLevels { - PUBLIC = 1, - GUILD_ONLY = 2, -} - -export const enum StickerFormatTypes { - PNG = 1, - APNG = 2, - LOTTIE = 3, -} - -export const enum StickerTypes { - STANDARD = 1, - GUILD = 2, -} - -export const enum VerificationLevels { - NONE = 0, - LOW = 1, - MEDIUM = 2, - HIGH = 3, - VERY_HIGH = 4, -} - -export const enum WebhookTypes { - Incoming = 1, - 'Channel Follower' = 2, - Application = 3, -} diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 0b2aeedf5..5b36524c9 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -44,10 +44,39 @@ import { APISelectMenuComponent, APITemplateSerializedSourceGuild, APIUser, + ButtonStyle, + ChannelType, + ComponentType, GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData, + GuildMFALevel, + GuildNSFWLevel, + GuildPremiumTier, + GuildVerificationLevel, + InteractionResponseType, + InteractionType, + InviteTargetType, + MessageType, RESTPostAPIApplicationCommandsJSONBody, Snowflake, + StageInstancePrivacyLevel, + StickerFormatType, + StickerType, + TeamMemberMembershipState, + UserPremiumType, + WebhookType, + OverwriteType, + GuildExplicitContentFilter, + GuildDefaultMessageNotifications, + ApplicationCommandPermissionType, + ApplicationCommandOptionType, + ApplicationCommandType, + ActivityType, + AuditLogEvent, + GuildScheduledEventEntityType, + GuildScheduledEventPrivacyLevel, + GuildScheduledEventStatus, + RESTJSONErrorCodes, } from 'discord-api-types/v9'; import { ChildProcess } from 'node:child_process'; import { EventEmitter } from 'node:events'; @@ -56,34 +85,6 @@ import { Response } from 'node-fetch'; import { Stream } from 'node:stream'; import { MessagePort, Worker } from 'node:worker_threads'; import * as WebSocket from 'ws'; -import { - ActivityTypes, - ApplicationCommandOptionTypes, - ApplicationCommandPermissionTypes, - ApplicationCommandTypes, - ChannelTypes, - DefaultMessageNotificationLevels, - ExplicitContentFilterLevels, - InteractionResponseTypes, - InteractionTypes, - InviteTargetType, - MembershipStates, - MessageButtonStyles, - MessageComponentTypes, - MessageTypes, - MFALevels, - NSFWLevels, - OverwriteTypes, - PremiumTiers, - PrivacyLevels, - StickerFormatTypes, - StickerTypes, - VerificationLevels, - WebhookTypes, - GuildScheduledEventEntityTypes, - GuildScheduledEventStatuses, - GuildScheduledEventPrivacyLevels, -} from './enums'; import { RawActivityData, RawAnonymousGuildData, @@ -169,7 +170,7 @@ export class Activity { start: Date | null; end: Date | null; } | null; - public type: ActivityType; + public type: ActivityTypeKey; public url: string | null; public equals(activity: Activity): boolean; } @@ -183,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: NSFWLevel; + public nsfwLevel: GuildNSFWLevel; public splash: string | null; public vanityURLCode: string | null; - public verificationLevel: VerificationLevel; + public verificationLevel: GuildVerificationLevelKey; public bannerURL(options?: StaticImageURLOptions): string | null; public splashURL(options?: StaticImageURLOptions): string | null; } @@ -225,7 +226,7 @@ export class ApplicationCommand extends Base { Guild | null, Snowflake >; - public type: ApplicationCommandType; + public type: ApplicationCommandTypeKey; public version: Snowflake; public delete(): Promise>; public edit(data: ApplicationCommandData): Promise>; @@ -405,8 +406,8 @@ export class BaseGuildTextChannel extends TextBasedChannelMixin(GuildChannel) { ): Promise; public setNSFW(nsfw?: boolean, reason?: string): Promise; public setTopic(topic: string | null, reason?: string): Promise; - public setType(type: Pick, reason?: string): Promise; - public setType(type: Pick, reason?: string): Promise; + public setType(type: Pick, reason?: string): Promise; + public setType(type: Pick, reason?: string): Promise; public fetchWebhooks(): Promise>; } @@ -425,9 +426,9 @@ export class BaseGuildVoiceChannel extends GuildChannel { export class BaseMessageComponent { protected constructor(data?: BaseMessageComponent | BaseMessageComponentOptions); - public type: MessageComponentType | null; + public type: MessageComponentTypeKey | null; private static create(data: MessageComponentOptions, client?: Client | WebhookClient): MessageComponent | undefined; - private static resolveType(type: MessageComponentTypeResolvable): MessageComponentType; + private static resolveType(type: MessageComponentTypeResolvable): MessageComponentTypeKey; } export class BitField { @@ -458,7 +459,7 @@ export class ButtonInteraction extends Mes MessageButton | APIButtonComponent, MessageButton | APIButtonComponent >; - public componentType: 'BUTTON'; + public componentType: 'Button'; public inGuild(): this is ButtonInteraction<'raw' | 'cached'>; public inCachedGuild(): this is ButtonInteraction<'cached'>; public inRawGuild(): this is ButtonInteraction<'raw'>; @@ -473,32 +474,26 @@ export type EnumValueMapped, T extends Partial; export type CategoryChannelTypes = ExcludeEnum< - typeof ChannelTypes, - | 'DM' - | 'GROUP_DM' - | 'UNKNOWN' - | 'GUILD_PUBLIC_THREAD' - | 'GUILD_NEWS_THREAD' - | 'GUILD_PRIVATE_THREAD' - | 'GUILD_CATEGORY' + typeof ChannelType, + 'DM' | 'GroupDM' | 'GuildPublicThread' | 'GuildNewsThread' | 'GuildPrivateThread' | 'GuildCategory' >; export class CategoryChannel extends GuildChannel { public readonly children: Collection>; - public type: 'GUILD_CATEGORY'; + public type: 'GuildCategory'; - public createChannel>( + public createChannel>( name: string, options: CategoryCreateChannelOptions & { type: T }, ): Promise; @@ -506,9 +501,12 @@ export class CategoryChannel extends GuildChannel { /** @deprecated See [Self-serve Game Selling Deprecation](https://support-dev.discord.com/hc/en-us/articles/4414590563479) for more information */ public createChannel( name: string, - options: CategoryCreateChannelOptions & { type: 'GUILD_STORE' | ChannelTypes.GUILD_STORE }, + options: CategoryCreateChannelOptions & { type: 'GuildStore' | ChannelType.GuildStore }, ): Promise; - public createChannel(name: string, options?: CategoryCreateChannelOptions): Promise; + public createChannel( + name: string, + options?: CategoryCreateChannelOptions, + ): Promise>; } export type CategoryChannelResolvable = Snowflake | CategoryChannel; @@ -519,7 +517,7 @@ export abstract class Channel extends Base { public readonly createdTimestamp: number; public id: Snowflake; public readonly partial: false; - public type: keyof typeof ChannelTypes; + public type: keyof typeof ChannelType; public delete(): Promise; public fetch(force?: boolean): Promise; public isText(): this is TextBasedChannel; @@ -747,13 +745,13 @@ export class CommandInteractionOptionResolver; private _getTypedOption( name: string, - type: ApplicationCommandOptionType, + type: ApplicationCommandOptionTypeKey, properties: (keyof ApplicationCommandOption)[], required: boolean, ): CommandInteractionOption | null; @@ -810,7 +808,7 @@ export class ContextMenuCommandInteraction | 'getSubcommand' >; public targetId: Snowflake; - public targetType: Exclude; + public targetType: Exclude; public inGuild(): this is ContextMenuCommandInteraction<'raw' | 'cached'>; public inCachedGuild(): this is ContextMenuCommandInteraction<'cached'>; public inRawGuild(): this is ContextMenuCommandInteraction<'raw'>; @@ -875,10 +873,10 @@ export class Guild extends AnonymousGuild { public bans: GuildBanManager; public channels: GuildChannelManager; public commands: GuildApplicationCommandManager; - public defaultMessageNotifications: DefaultMessageNotificationLevel | number; + public defaultMessageNotifications: GuildDefaultMessageNotificationsKey | number; public discoverySplash: string | null; public emojis: GuildEmojiManager; - public explicitContentFilter: ExplicitContentFilterLevel; + public explicitContentFilter: GuildExplicitContentFilterKey; public invites: GuildInviteManager; public readonly joinedAt: Date; public joinedTimestamp: number; @@ -888,7 +886,7 @@ export class Guild extends AnonymousGuild { public readonly me: GuildMember | null; public memberCount: number; public members: GuildMemberManager; - public mfaLevel: MFALevel; + public mfaLevel: GuildMFALevelKey; public ownerId: Snowflake; public preferredLocale: string; public premiumSubscriptionCount: number | null; @@ -921,7 +919,7 @@ export class Guild extends AnonymousGuild { public edit(data: GuildEditData, reason?: string): Promise; public editWelcomeScreen(data: WelcomeScreenEditData): Promise; public equals(guild: Guild): boolean; - public fetchAuditLogs( + public fetchAuditLogs( options?: GuildAuditLogsFetchOptions, ): Promise>; public fetchIntegrations(): Promise>; @@ -938,7 +936,7 @@ export class Guild extends AnonymousGuild { public setAFKTimeout(afkTimeout: number, reason?: string): Promise; public setBanner(banner: BufferResolvable | Base64Resolvable | null, reason?: string): Promise; public setDefaultMessageNotifications( - defaultMessageNotifications: DefaultMessageNotificationLevel | number, + defaultMessageNotifications: GuildDefaultMessageNotificationsKey | number, reason?: string, ): Promise; public setDiscoverySplash( @@ -946,7 +944,7 @@ export class Guild extends AnonymousGuild { reason?: string, ): Promise; public setExplicitContentFilter( - explicitContentFilter: ExplicitContentFilterLevel | number, + explicitContentFilter: GuildExplicitContentFilterKey | number, reason?: string, ): Promise; public setIcon(icon: BufferResolvable | Base64Resolvable | null, reason?: string): Promise; @@ -958,13 +956,13 @@ 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: VerificationLevel | number, reason?: string): Promise; + public setVerificationLevel(verificationLevel: GuildVerificationLevelKey | number, reason?: string): Promise; public setPremiumProgressBarEnabled(enabled?: boolean, reason?: string): Promise; public setWidgetSettings(settings: GuildWidgetSettingsData, reason?: string): Promise; public toJSON(): unknown; } -export class GuildAuditLogs { +export class GuildAuditLogs { private constructor(guild: Guild, data: RawGuildAuditLogData); private webhooks: Collection; private integrations: Collection; @@ -981,18 +979,18 @@ export class GuildAuditLogs { } export class GuildAuditLogsEntry< - TActionRaw extends GuildAuditLogsResolvable = 'ALL', + TActionRaw extends GuildAuditLogsResolvable = 'All', TAction = TActionRaw extends keyof GuildAuditLogsIds ? GuildAuditLogsIds[TActionRaw] : TActionRaw extends null - ? 'ALL' + ? 'All' : TActionRaw, TActionType extends GuildAuditLogsActionType = TAction extends keyof GuildAuditLogsTypes ? GuildAuditLogsTypes[TAction][1] - : 'ALL', + : 'All', TTargetType extends GuildAuditLogsTarget = TAction extends keyof GuildAuditLogsTypes ? GuildAuditLogsTypes[TAction][0] - : 'UNKNOWN', + : 'Unknown', > { private constructor(logs: GuildAuditLogs, guild: Guild, data: RawGuildAuditLogEntryData); public action: TAction; @@ -1038,7 +1036,7 @@ export abstract class GuildChannel extends Channel { public readonly permissionsLocked: boolean | null; public readonly position: number; public rawPosition: number; - public type: Exclude; + public type: Exclude; public readonly viewable: boolean; public clone(options?: GuildChannelCloneOptions): Promise; public delete(reason?: string): Promise; @@ -1141,7 +1139,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; @@ -1183,10 +1181,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<'Active'>; + public isCanceled(): this is GuildScheduledEvent<'Canceled'>; + public isCompleted(): this is GuildScheduledEvent<'Completed'>; + public isScheduled(): this is GuildScheduledEvent<'Scheduled'>; } export class GuildTemplate extends Base { @@ -1338,7 +1336,7 @@ export class InteractionCollector extends Collector; export interface StringMappedInteractionTypes { - BUTTON: ButtonInteraction; - SELECT_MENU: SelectMenuInteraction; - ACTION_ROW: MessageComponentInteraction; + Button: ButtonInteraction; + SelectMenu: SelectMenuInteraction; + ActionRow: MessageComponentInteraction; } export type WrapBooleanCache = If; export type MappedInteractionTypes = EnumValueMapped< - typeof MessageComponentTypes, + typeof ComponentType, { - BUTTON: ButtonInteraction>; - SELECT_MENU: SelectMenuInteraction>; - ACTION_ROW: MessageComponentInteraction>; + Button: ButtonInteraction>; + SelectMenu: SelectMenuInteraction>; + ActionRow: MessageComponentInteraction>; } >; @@ -1502,12 +1500,12 @@ export class Message extends Base { public webhookId: Snowflake | null; public flags: Readonly; public reference: MessageReference | null; - public awaitMessageComponent( + public awaitMessageComponent( options?: AwaitMessageCollectorOptionsParams, ): Promise[T]>; public awaitReactions(options?: AwaitReactionsOptions): Promise>; public createReactionCollector(options?: ReactionCollectorOptions): ReactionCollector; - public createMessageComponentCollector( + public createMessageComponentCollector( options?: MessageCollectorOptionsParams, ): InteractionCollector[T]>; public delete(): Promise; @@ -1532,7 +1530,7 @@ export class Message extends Base { export class MessageActionRow extends BaseMessageComponent { public constructor(data?: MessageActionRow | MessageActionRowOptions | APIActionRowComponent); - public type: 'ACTION_ROW'; + public type: 'ActionRow'; public components: MessageActionRowComponent[]; public addComponents( ...components: MessageActionRowComponentResolvable[] | MessageActionRowComponentResolvable[][] @@ -1576,8 +1574,8 @@ export class MessageButton extends BaseMessageComponent { public disabled: boolean; public emoji: APIPartialEmoji | null; public label: string | null; - public style: MessageButtonStyle | null; - public type: 'BUTTON'; + public style: ButtonStyleKey | null; + public type: 'Button'; public url: string | null; public setCustomId(customId: string): this; public setDisabled(disabled?: boolean): this; @@ -1586,7 +1584,7 @@ export class MessageButton extends BaseMessageComponent { public setStyle(style: MessageButtonStyleResolvable): this; public setURL(url: string): this; public toJSON(): APIButtonComponent; - private static resolveStyle(style: MessageButtonStyleResolvable): MessageButtonStyle; + private static resolveStyle(style: MessageButtonStyleResolvable): ButtonStyleKey; } export class MessageCollector extends Collector { @@ -1612,7 +1610,7 @@ export class MessageComponentInteraction e MessageActionRowComponent | Exclude, MessageActionRowComponent | Exclude >; - public componentType: Exclude; + public componentType: Exclude; public customId: string; public channelId: Snowflake; public deferred: boolean; @@ -1636,7 +1634,7 @@ export class MessageComponentInteraction e public update(options: InteractionUpdateOptions & { fetchReply: true }): Promise>; public update(options: string | MessagePayload | InteractionUpdateOptions): Promise; - public static resolveType(type: MessageComponentTypeResolvable): MessageComponentType; + public static resolveType(type: MessageComponentTypeResolvable): MessageComponentTypeKey; } export class MessageContextMenuCommandInteraction< @@ -1778,7 +1776,7 @@ export class MessageSelectMenu extends BaseMessageComponent { public minValues: number | null; public options: MessageSelectOption[]; public placeholder: string | null; - public type: 'SELECT_MENU'; + public type: 'SelectMenu'; public addOptions(...options: MessageSelectOptionData[] | MessageSelectOptionData[][]): this; public setOptions(...options: MessageSelectOptionData[] | MessageSelectOptionData[][]): this; public setCustomId(customId: string): this; @@ -1796,7 +1794,7 @@ export class MessageSelectMenu extends BaseMessageComponent { export class NewsChannel extends BaseGuildTextChannel { public threads: ThreadManager; - public type: 'GUILD_NEWS'; + public type: 'GuildNews'; public addFollower(channel: TextChannelResolvable, reason?: string): Promise; } @@ -1950,7 +1948,7 @@ export class SelectMenuInteraction extends MessageSelectMenu | APISelectMenuComponent, MessageSelectMenu | APISelectMenuComponent >; - public componentType: 'SELECT_MENU'; + public componentType: 'SelectMenu'; public values: string[]; public inGuild(): this is SelectMenuInteraction<'raw' | 'cached'>; public inCachedGuild(): this is SelectMenuInteraction<'cached'>; @@ -2083,7 +2081,7 @@ export { export class StageChannel extends BaseGuildVoiceChannel { public topic: string | null; - public type: 'GUILD_STAGE_VOICE'; + public type: 'GuildStageVoice'; public readonly stageInstance: StageInstance | null; public createStageInstance(options: StageInstanceCreateOptions): Promise; public setTopic(topic: string): Promise; @@ -2095,7 +2093,7 @@ export class StageInstance extends Base { public guildId: Snowflake; public channelId: Snowflake; public topic: string; - public privacyLevel: PrivacyLevel; + public privacyLevel: StageInstancePrivacyLevelKey; public discoverableDisabled: boolean | null; public readonly channel: StageChannel | null; public readonly guild: Guild | null; @@ -2155,7 +2153,7 @@ export class StoreChannel extends GuildChannel { /** @deprecated See [Self-serve Game Selling Deprecation](https://support-dev.discord.com/hc/en-us/articles/4414590563479) for more information */ public clone(options?: GuildChannelCloneOptions): Promise; public nsfw: boolean; - public type: 'GUILD_STORE'; + public type: 'GuildStore'; } export class Sweepers { @@ -2247,7 +2245,7 @@ export class TeamMember extends Base { public team: Team; public readonly id: Snowflake; public permissions: string[]; - public membershipState: MembershipState; + public membershipState: TeamMemberMembershipStateKey; public user: User; public toString(): UserMention; @@ -2256,7 +2254,7 @@ export class TeamMember extends Base { export class TextChannel extends BaseGuildTextChannel { public rateLimitPerUser: number; public threads: ThreadManager; - public type: 'GUILD_TEXT'; + public type: 'GuildText'; public setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise; } @@ -2286,7 +2284,7 @@ export class ThreadChannel extends TextBasedChannelMixin(Channel) { public readonly parent: TextChannel | NewsChannel | null; public parentId: Snowflake | null; public rateLimitPerUser: number | null; - public type: ThreadChannelTypes; + public type: ThreadChannelTypeKey; public readonly unarchivable: boolean; public delete(reason?: string): Promise; public edit(data: ThreadEditData, reason?: string): Promise; @@ -2452,7 +2450,7 @@ export class VoiceChannel extends BaseGuildVoiceChannel { /** @deprecated Use manageable instead */ public readonly editable: boolean; public readonly speakable: boolean; - public type: 'GUILD_VOICE'; + public type: 'GuildVoice'; public setBitrate(bitrate: number, reason?: string): Promise; public setUserLimit(userLimit: number, reason?: string): Promise; } @@ -2770,38 +2768,13 @@ export const Constants: { Colors: ConstantsColors; Status: ConstantsStatus; Opcodes: ConstantsOpcodes; - APIErrors: APIErrors; - ChannelTypes: EnumHolder; - ThreadChannelTypes: ThreadChannelTypes[]; + ThreadChannelTypes: ThreadChannelTypeKey[]; TextBasedChannelTypes: TextBasedChannelTypes[]; VoiceBasedChannelTypes: VoiceBasedChannelTypes[]; IntegrationExpireBehaviors: IntegrationExpireBehaviors[]; InviteScopes: InviteScope[]; MessageTypes: MessageType[]; SystemMessageTypes: SystemMessageType[]; - ActivityTypes: EnumHolder; - StickerTypes: EnumHolder; - StickerFormatTypes: EnumHolder; - OverwriteTypes: EnumHolder; - ExplicitContentFilterLevels: EnumHolder; - DefaultMessageNotificationLevels: EnumHolder; - VerificationLevels: EnumHolder; - MembershipStates: EnumHolder; - ApplicationCommandOptionTypes: EnumHolder; - ApplicationCommandPermissionTypes: EnumHolder; - InteractionTypes: EnumHolder; - InteractionResponseTypes: EnumHolder; - MessageComponentTypes: EnumHolder; - MessageButtonStyles: EnumHolder; - MFALevels: EnumHolder; - NSFWLevels: EnumHolder; - PrivacyLevels: EnumHolder; - WebhookTypes: EnumHolder; - PremiumTiers: EnumHolder; - ApplicationCommandTypes: EnumHolder; - GuildScheduledEventEntityTypes: EnumHolder; - GuildScheduledEventStatuses: EnumHolder; - GuildScheduledEventPrivacyLevels: EnumHolder; }; export const version: string; @@ -2921,7 +2894,7 @@ export class ApplicationCommandPermissionsManager< private static transformPermissions( permissions: ApplicationCommandPermissionData, received: true, - ): Omit & { type: keyof ApplicationCommandPermissionTypes }; + ): Omit & { type: keyof ApplicationCommandPermissionType }; private static transformPermissions(permissions: ApplicationCommandPermissionData): APIApplicationCommandPermission; } @@ -2951,21 +2924,21 @@ export class GuildApplicationCommandManager extends ApplicationCommandManager & MappedChannelCategoryTypes; -export type GuildChannelTypes = CategoryChannelTypes | ChannelTypes.GUILD_CATEGORY | 'GUILD_CATEGORY'; +export type GuildChannelTypes = CategoryChannelTypes | ChannelType.GuildCategory | 'GuildCategory'; export class GuildChannelManager extends CachedManager { private constructor(guild: Guild, iterable?: Iterable); public readonly channelCountWithoutThreads: number; public guild: Guild; /** @deprecated See [Self-serve Game Selling Deprecation](https://support-dev.discord.com/hc/en-us/articles/4414590563479) for more information */ - public create(name: string, options: GuildChannelCreateOptions & { type: 'GUILD_STORE' }): Promise; + public create(name: string, options: GuildChannelCreateOptions & { type: 'GuildStore' }): Promise; public create( name: string, options: GuildChannelCreateOptions & { type: T }, @@ -3061,7 +3034,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>; @@ -3256,7 +3229,7 @@ export interface TextBasedChannelFields extends PartialTextBasedChannelFields { readonly lastMessage: Message | null; lastPinTimestamp: number | null; readonly lastPinAt: Date | null; - awaitMessageComponent( + awaitMessageComponent( options?: AwaitMessageCollectorOptionsParams, ): Promise; awaitMessages(options?: AwaitMessagesOptions): Promise>; @@ -3264,7 +3237,7 @@ export interface TextBasedChannelFields extends PartialTextBasedChannelFields { messages: Collection | readonly MessageResolvable[] | number, filterOld?: boolean, ): Promise>; - createMessageComponentCollector( + createMessageComponentCollector( options?: MessageChannelCollectorOptionsParams, ): InteractionCollector; createMessageCollector(options?: MessageCollectorOptions): MessageCollector; @@ -3318,13 +3291,13 @@ export type ActivitiesOptions = Omit; export interface ActivityOptions { name?: string; url?: string; - type?: ExcludeEnum; + type?: ExcludeEnum; shardId?: number | readonly number[]; } export type ActivityPlatform = 'desktop' | 'samsung' | 'xbox'; -export type ActivityType = keyof typeof ActivityTypes; +export type ActivityTypeKey = keyof typeof ActivityType; export interface AddGuildMemberOptions { accessToken: string; @@ -3346,152 +3319,6 @@ export type AllowedThreadTypeForNewsChannel = 'GUILD_NEWS_THREAD' | 10; export type AllowedThreadTypeForTextChannel = 'GUILD_PUBLIC_THREAD' | 'GUILD_PRIVATE_THREAD' | 11 | 12; -export interface APIErrors { - UNKNOWN_ACCOUNT: 10001; - UNKNOWN_APPLICATION: 10002; - UNKNOWN_CHANNEL: 10003; - UNKNOWN_GUILD: 10004; - UNKNOWN_INTEGRATION: 10005; - UNKNOWN_INVITE: 10006; - UNKNOWN_MEMBER: 10007; - UNKNOWN_MESSAGE: 10008; - UNKNOWN_OVERWRITE: 10009; - UNKNOWN_PROVIDER: 10010; - UNKNOWN_ROLE: 10011; - UNKNOWN_TOKEN: 10012; - UNKNOWN_USER: 10013; - UNKNOWN_EMOJI: 10014; - UNKNOWN_WEBHOOK: 10015; - UNKNOWN_WEBHOOK_SERVICE: 10016; - UNKNOWN_SESSION: 10020; - UNKNOWN_BAN: 10026; - UNKNOWN_SKU: 10027; - UNKNOWN_STORE_LISTING: 10028; - UNKNOWN_ENTITLEMENT: 10029; - UNKNOWN_BUILD: 10030; - UNKNOWN_LOBBY: 10031; - UNKNOWN_BRANCH: 10032; - UNKNOWN_STORE_DIRECTORY_LAYOUT: 10033; - UNKNOWN_REDISTRIBUTABLE: 10036; - UNKNOWN_GIFT_CODE: 10038; - UNKNOWN_STREAM: 10049; - UNKNOWN_PREMIUM_SERVER_SUBSCRIBE_COOLDOWN: 10050; - UNKNOWN_GUILD_TEMPLATE: 10057; - UNKNOWN_DISCOVERABLE_SERVER_CATEGORY: 10059; - UNKNOWN_STICKER: 10060; - UNKNOWN_INTERACTION: 10062; - UNKNOWN_APPLICATION_COMMAND: 10063; - UNKNOWN_APPLICATION_COMMAND_PERMISSIONS: 10066; - UNKNOWN_STAGE_INSTANCE: 10067; - UNKNOWN_GUILD_MEMBER_VERIFICATION_FORM: 10068; - UNKNOWN_GUILD_WELCOME_SCREEN: 10069; - UNKNOWN_GUILD_SCHEDULED_EVENT: 10070; - UNKNOWN_GUILD_SCHEDULED_EVENT_USER: 10071; - BOT_PROHIBITED_ENDPOINT: 20001; - BOT_ONLY_ENDPOINT: 20002; - CANNOT_SEND_EXPLICIT_CONTENT: 20009; - NOT_AUTHORIZED: 20012; - SLOWMODE_RATE_LIMIT: 20016; - ACCOUNT_OWNER_ONLY: 20018; - ANNOUNCEMENT_EDIT_LIMIT_EXCEEDED: 20022; - CHANNEL_HIT_WRITE_RATELIMIT: 20028; - SERVER_HIT_WRITE_RATELIMIT: 20029; - CONTENT_NOT_ALLOWED: 20031; - GUILD_PREMIUM_LEVEL_TOO_LOW: 20035; - MAXIMUM_GUILDS: 30001; - MAXIMUM_FRIENDS: 30002; - MAXIMUM_PINS: 30003; - MAXIMUM_RECIPIENTS: 30004; - MAXIMUM_ROLES: 30005; - MAXIMUM_WEBHOOKS: 30007; - MAXIMUM_EMOJIS: 30008; - MAXIMUM_REACTIONS: 30010; - MAXIMUM_CHANNELS: 30013; - MAXIMUM_ATTACHMENTS: 30015; - MAXIMUM_INVITES: 30016; - MAXIMUM_ANIMATED_EMOJIS: 30018; - MAXIMUM_SERVER_MEMBERS: 30019; - MAXIMUM_NUMBER_OF_SERVER_CATEGORIES: 30030; - GUILD_ALREADY_HAS_TEMPLATE: 30031; - MAXIMUM_THREAD_PARICIPANTS: 30033; - MAXIMUM_NON_GUILD_MEMBERS_BANS: 30035; - MAXIMUM_BAN_FETCHES: 30037; - MAXIMUM_NUMBER_OF_UNCOMPLETED_GUILD_SCHEDULED_EVENTS_REACHED: 30038; - MAXIMUM_NUMBER_OF_STICKERS_REACHED: 30039; - MAXIMUM_PRUNE_REQUESTS: 30040; - MAXIMUM_GUILD_WIDGET_SETTINGS_UPDATE: 30042; - UNAUTHORIZED: 40001; - ACCOUNT_VERIFICATION_REQUIRED: 40002; - DIRECT_MESSAGES_TOO_FAST: 40003; - REQUEST_ENTITY_TOO_LARGE: 40005; - FEATURE_TEMPORARILY_DISABLED: 40006; - USER_BANNED: 40007; - TARGET_USER_NOT_CONNECTED_TO_VOICE: 40032; - ALREADY_CROSSPOSTED: 40033; - MISSING_ACCESS: 50001; - INVALID_ACCOUNT_TYPE: 50002; - CANNOT_EXECUTE_ON_DM: 50003; - EMBED_DISABLED: 50004; - CANNOT_EDIT_MESSAGE_BY_OTHER: 50005; - CANNOT_SEND_EMPTY_MESSAGE: 50006; - CANNOT_MESSAGE_USER: 50007; - CANNOT_SEND_MESSAGES_IN_VOICE_CHANNEL: 50008; - CHANNEL_VERIFICATION_LEVEL_TOO_HIGH: 50009; - OAUTH2_APPLICATION_BOT_ABSENT: 50010; - MAXIMUM_OAUTH2_APPLICATIONS: 50011; - INVALID_OAUTH_STATE: 50012; - MISSING_PERMISSIONS: 50013; - INVALID_AUTHENTICATION_TOKEN: 50014; - NOTE_TOO_LONG: 50015; - INVALID_BULK_DELETE_QUANTITY: 50016; - CANNOT_PIN_MESSAGE_IN_OTHER_CHANNEL: 50019; - INVALID_OR_TAKEN_INVITE_CODE: 50020; - CANNOT_EXECUTE_ON_SYSTEM_MESSAGE: 50021; - CANNOT_EXECUTE_ON_CHANNEL_TYPE: 50024; - INVALID_OAUTH_TOKEN: 50025; - MISSING_OAUTH_SCOPE: 50026; - INVALID_WEBHOOK_TOKEN: 50027; - INVALID_ROLE: 50028; - INVALID_RECIPIENTS: 50033; - BULK_DELETE_MESSAGE_TOO_OLD: 50034; - INVALID_FORM_BODY: 50035; - INVITE_ACCEPTED_TO_GUILD_NOT_CONTAINING_BOT: 50036; - INVALID_API_VERSION: 50041; - FILE_UPLOADED_EXCEEDS_MAXIMUM_SIZE: 50045; - INVALID_FILE_UPLOADED: 50046; - CANNOT_SELF_REDEEM_GIFT: 50054; - INVALID_GUILD: 50055; - PAYMENT_SOURCE_REQUIRED: 50070; - CANNOT_DELETE_COMMUNITY_REQUIRED_CHANNEL: 50074; - INVALID_STICKER_SENT: 50081; - INVALID_THREAD_ARCHIVE_STATE: 50083; - INVALID_THREAD_NOTIFICATION_SETTINGS: 50084; - PARAMETER_EARLIER_THAN_CREATION: 50085; - GUILD_NOT_AVAILABLE_IN_LOCATION: 50095; - GUILD_MONETIZATION_REQUIRED: 50097; - INSUFFICIENT_BOOSTS: 50101; - INVALID_JSON: 50109; - TWO_FACTOR_REQUIRED: 60003; - NO_USERS_WITH_DISCORDTAG_EXIST: 80004; - REACTION_BLOCKED: 90001; - RESOURCE_OVERLOADED: 130000; - STAGE_ALREADY_OPEN: 150006; - CANNOT_REPLY_WITHOUT_READ_MESSAGE_HISTORY_PERMISSION: 160002; - MESSAGE_ALREADY_HAS_THREAD: 160004; - THREAD_LOCKED: 160005; - MAXIMUM_ACTIVE_THREADS: 160006; - MAXIMUM_ACTIVE_ANNOUNCEMENT_THREADS: 160007; - INVALID_JSON_FOR_UPLOADED_LOTTIE_FILE: 170001; - UPLOADED_LOTTIES_CANNOT_CONTAIN_RASTERIZED_IMAGES: 170002; - STICKER_MAXIMUM_FRAMERATE_EXCEEDED: 170003; - STICKER_FRAME_COUNT_EXCEEDS_MAXIMUM_OF_1000_FRAMES: 170004; - LOTTIE_ANIMATION_MAXIMUM_DIMENSIONS_EXCEEDED: 170005; - STICKER_FRAME_RATE_IS_TOO_SMALL_OR_TOO_LARGE: 170006; - STICKER_ANIMATION_DURATION_EXCEEDS_MAXIMUM_OF_5_SECONDS: 170007; - CANNOT_UPDATE_A_FINISHED_EVENT: 180000; - FAILED_TO_CREATE_STAGE_NEEDED_FOR_STAGE_EVENT: 180002; -} - export interface APIRequest { method: 'get' | 'post' | 'delete' | 'patch' | 'put'; options: unknown; @@ -3505,26 +3332,26 @@ export interface BaseApplicationCommandData { defaultPermission?: boolean; } -export type CommandOptionDataTypeResolvable = ApplicationCommandOptionType | ApplicationCommandOptionTypes; +export type CommandOptionDataTypeResolvable = ApplicationCommandOptionTypeKey | ApplicationCommandOptionType; -export type CommandOptionChannelResolvableType = ApplicationCommandOptionTypes.CHANNEL | 'CHANNEL'; +export type CommandOptionChannelResolvableType = ApplicationCommandOptionType.Channel | 'Channel'; export type CommandOptionChoiceResolvableType = - | ApplicationCommandOptionTypes.STRING - | 'STRING' + | ApplicationCommandOptionType.String + | 'String' | CommandOptionNumericResolvableType; export type CommandOptionNumericResolvableType = - | ApplicationCommandOptionTypes.NUMBER - | 'NUMBER' - | ApplicationCommandOptionTypes.INTEGER - | 'INTEGER'; + | ApplicationCommandOptionType.Number + | 'Number' + | ApplicationCommandOptionType.Integer + | 'Integer'; export type CommandOptionSubOptionResolvableType = - | ApplicationCommandOptionTypes.SUB_COMMAND - | 'SUB_COMMAND' - | ApplicationCommandOptionTypes.SUB_COMMAND_GROUP - | 'SUB_COMMAND_GROUP'; + | ApplicationCommandOptionType.Subcommand + | 'Subcommand' + | ApplicationCommandOptionType.SubcommandGroup + | 'SubcommandGroup'; export type CommandOptionNonChoiceResolvableType = Exclude< CommandOptionDataTypeResolvable, @@ -3539,16 +3366,16 @@ export interface BaseApplicationCommandOptionsData { } export interface UserApplicationCommandData extends BaseApplicationCommandData { - type: 'USER' | ApplicationCommandTypes.USER; + type: 'User' | ApplicationCommandType.User; } export interface MessageApplicationCommandData extends BaseApplicationCommandData { - type: 'MESSAGE' | ApplicationCommandTypes.MESSAGE; + type: 'Message' | ApplicationCommandType.Message; } export interface ChatInputApplicationCommandData extends BaseApplicationCommandData { description: string; - type?: 'CHAT_INPUT' | ApplicationCommandTypes.CHAT_INPUT; + type?: 'ChatInput' | ApplicationCommandType.ChatInput; options?: ApplicationCommandOptionData[]; } @@ -3559,23 +3386,23 @@ export type ApplicationCommandData = export interface ApplicationCommandChannelOptionData extends BaseApplicationCommandOptionsData { type: CommandOptionChannelResolvableType; - channelTypes?: ExcludeEnum[]; - channel_types?: Exclude[]; + channelTypes?: (keyof typeof ChannelType)[]; + channel_types?: (keyof typeof ChannelType)[]; } export interface ApplicationCommandChannelOption extends BaseApplicationCommandOptionsData { type: 'CHANNEL'; - channelTypes?: (keyof typeof ChannelTypes)[]; + channelTypes?: (keyof typeof ChannelType)[]; } export interface ApplicationCommandAutocompleteOption extends Omit { type: - | 'STRING' - | 'NUMBER' - | 'INTEGER' - | ApplicationCommandOptionTypes.STRING - | ApplicationCommandOptionTypes.NUMBER - | ApplicationCommandOptionTypes.INTEGER; + | 'String' + | 'Number' + | 'Integer' + | ApplicationCommandOptionType.String + | ApplicationCommandOptionType.Number + | ApplicationCommandOptionType.Integer; autocomplete: true; } @@ -3586,7 +3413,7 @@ export interface ApplicationCommandChoicesData extends Omit { - type: Exclude; + type: Exclude; choices?: ApplicationCommandOptionChoice[]; autocomplete?: false; } @@ -3600,23 +3427,23 @@ export interface ApplicationCommandNumericOptionData extends ApplicationCommandC } export interface ApplicationCommandNumericOption extends ApplicationCommandChoicesOption { - type: Exclude; + type: Exclude; minValue?: number; maxValue?: number; } export interface ApplicationCommandSubGroupData extends Omit { - type: 'SUB_COMMAND_GROUP' | ApplicationCommandOptionTypes.SUB_COMMAND_GROUP; + type: 'SubcommandGroup' | ApplicationCommandOptionType.SubcommandGroup; options?: ApplicationCommandSubCommandData[]; } export interface ApplicationCommandSubGroup extends Omit { - type: 'SUB_COMMAND_GROUP'; + type: 'SubcommandGroup'; options?: ApplicationCommandSubCommand[]; } export interface ApplicationCommandSubCommandData extends Omit { - type: 'SUB_COMMAND' | ApplicationCommandOptionTypes.SUB_COMMAND; + type: 'Subcommand' | ApplicationCommandOptionType.Subcommand; options?: ( | ApplicationCommandChoicesData | ApplicationCommandNonOptionsData @@ -3627,7 +3454,7 @@ export interface ApplicationCommandSubCommandData extends Omit { - type: 'SUB_COMMAND'; + type: 'Subcommand'; options?: (ApplicationCommandChoicesOption | ApplicationCommandNonOptions | ApplicationCommandChannelOption)[]; } @@ -3636,7 +3463,7 @@ export interface ApplicationCommandNonOptionsData extends BaseApplicationCommand } export interface ApplicationCommandNonOptions extends BaseApplicationCommandOptionsData { - type: Exclude; + type: Exclude; } export type ApplicationCommandOptionData = @@ -3661,13 +3488,13 @@ export interface ApplicationCommandOptionChoice { value: string | number; } -export type ApplicationCommandType = keyof typeof ApplicationCommandTypes; +export type ApplicationCommandTypeKey = keyof typeof ApplicationCommandType; -export type ApplicationCommandOptionType = keyof typeof ApplicationCommandOptionTypes; +export type ApplicationCommandOptionTypeKey = keyof typeof ApplicationCommandOptionType; export interface ApplicationCommandPermissionData { id: Snowflake; - type: ApplicationCommandPermissionType | ApplicationCommandPermissionTypes; + type: ApplicationCommandPermissionTypeKey | ApplicationCommandPermissionType; permission: boolean; } @@ -3675,7 +3502,7 @@ export interface ApplicationCommandPermissions extends ApplicationCommandPermiss type: ApplicationCommandPermissionType; } -export type ApplicationCommandPermissionType = keyof typeof ApplicationCommandPermissionTypes; +export type ApplicationCommandPermissionTypeKey = keyof typeof ApplicationCommandPermissionType; export type ApplicationCommandResolvable = ApplicationCommand | Snowflake; @@ -3729,7 +3556,7 @@ export interface ThreadMemberFetchOptions extends BaseFetchOptions { } export interface BaseMessageComponentOptions { - type?: MessageComponentType | MessageComponentTypes; + type?: MessageComponentTypeKey | ComponentType; } export type BitFieldResolvable = @@ -3787,14 +3614,8 @@ export interface CategoryCreateChannelOptions { permissionOverwrites?: OverwriteResolvable[] | Collection; topic?: string; type?: ExcludeEnum< - typeof ChannelTypes, - | 'DM' - | 'GROUP_DM' - | 'UNKNOWN' - | 'GUILD_PUBLIC_THREAD' - | 'GUILD_NEWS_THREAD' - | 'GUILD_PRIVATE_THREAD' - | 'GUILD_CATEGORY' + typeof ChannelType, + 'DM' | 'GroupDM' | 'GuildPublicThread' | 'GuildNewsThread' | 'GuildPrivateThread' | 'GuildCategory' >; nsfw?: boolean; bitrate?: number; @@ -3813,7 +3634,7 @@ export interface ChannelCreationOverwrites { export interface ChannelData { name?: string; - type?: Pick; + type?: Pick; position?: number; topic?: string; nsfw?: boolean; @@ -4039,7 +3860,7 @@ export type ColorResolvable = export interface CommandInteractionOption { name: string; - type: ApplicationCommandOptionType; + type: ApplicationCommandOptionTypeKey; value?: string | number | boolean; focused?: boolean; autocomplete?: boolean; @@ -4209,19 +4030,19 @@ export interface CreateRoleOptions extends RoleData { export interface StageInstanceCreateOptions { topic: string; - privacyLevel?: PrivacyLevel | number; + privacyLevel?: StageInstancePrivacyLevelKey | number; } export interface CrosspostedChannel { channelId: Snowflake; guildId: Snowflake; - type: keyof typeof ChannelTypes; + type: keyof typeof ChannelType; name: string; } export type DateResolvable = Date | number | string; -export type DefaultMessageNotificationLevel = keyof typeof DefaultMessageNotificationLevels; +export type GuildDefaultMessageNotificationsKey = keyof typeof GuildDefaultMessageNotifications; export type DynamicImageFormat = AllowedImageFormat | 'gif'; @@ -4276,7 +4097,7 @@ export interface EscapeMarkdownOptions { codeBlockContent?: boolean; } -export type ExplicitContentFilterLevel = keyof typeof ExplicitContentFilterLevels; +export type GuildExplicitContentFilterKey = keyof typeof GuildExplicitContentFilter; export interface FetchApplicationCommandOptions extends BaseFetchOptions { guildId?: Snowflake; @@ -4379,151 +4200,151 @@ export interface GuildApplicationCommandPermissionData { } interface GuildAuditLogsTypes { - GUILD_UPDATE: ['GUILD', 'UPDATE']; - CHANNEL_CREATE: ['CHANNEL', 'CREATE']; - CHANNEL_UPDATE: ['CHANNEL', 'UPDATE']; - CHANNEL_DELETE: ['CHANNEL', 'DELETE']; - CHANNEL_OVERWRITE_CREATE: ['CHANNEL', 'CREATE']; - CHANNEL_OVERWRITE_UPDATE: ['CHANNEL', 'UPDATE']; - CHANNEL_OVERWRITE_DELETE: ['CHANNEL', 'DELETE']; - MEMBER_KICK: ['USER', 'DELETE']; - MEMBER_PRUNE: ['USER', 'DELETE']; - MEMBER_BAN_ADD: ['USER', 'DELETE']; - MEMBER_BAN_REMOVE: ['USER', 'CREATE']; - MEMBER_UPDATE: ['USER', 'UPDATE']; - MEMBER_ROLE_UPDATE: ['USER', 'UPDATE']; - MEMBER_MOVE: ['USER', 'UPDATE']; - MEMBER_DISCONNECT: ['USER', 'DELETE']; - BOT_ADD: ['USER', 'CREATE']; - ROLE_CREATE: ['ROLE', 'CREATE']; - ROLE_UPDATE: ['ROLE', 'UPDATE']; - ROLE_DELETE: ['ROLE', 'DELETE']; - INVITE_CREATE: ['INVITE', 'CREATE']; - INVITE_UPDATE: ['INVITE', 'UPDATE']; - INVITE_DELETE: ['INVITE', 'DELETE']; - WEBHOOK_CREATE: ['WEBHOOK', 'CREATE']; - WEBHOOK_UPDATE: ['WEBHOOK', 'UPDATE']; - WEBHOOK_DELETE: ['WEBHOOK', 'DELETE']; - EMOJI_CREATE: ['EMOJI', 'CREATE']; - EMOJI_UPDATE: ['EMOJI', 'UPDATE']; - EMOJI_DELETE: ['EMOJI', 'DELETE']; - MESSAGE_DELETE: ['MESSAGE', 'DELETE']; - MESSAGE_BULK_DELETE: ['MESSAGE', 'DELETE']; - MESSAGE_PIN: ['MESSAGE', 'CREATE']; - MESSAGE_UNPIN: ['MESSAGE', 'DELETE']; - INTEGRATION_CREATE: ['INTEGRATION', 'CREATE']; - INTEGRATION_UPDATE: ['INTEGRATION', 'UPDATE']; - INTEGRATION_DELETE: ['INTEGRATION', 'DELETE']; - STAGE_INSTANCE_CREATE: ['STAGE_INSTANCE', 'CREATE']; - STAGE_INSTANCE_UPDATE: ['STAGE_INSTANCE', 'UPDATE']; - STAGE_INSTANCE_DELETE: ['STAGE_INSTANCE', 'DELETE']; - STICKER_CREATE: ['STICKER', 'CREATE']; - STICKER_UPDATE: ['STICKER', 'UPDATE']; - STICKER_DELETE: ['STICKER', 'DELETE']; - GUILD_SCHEDULED_EVENT_CREATE: ['GUILD_SCHEDULED_EVENT', 'CREATE']; - GUILD_SCHEDULED_EVENT_UPDATE: ['GUILD_SCHEDULED_EVENT', 'UPDATE']; - GUILD_SCHEDULED_EVENT_DELETE: ['GUILD_SCHEDULED_EVENT', 'DELETE']; - THREAD_CREATE: ['THREAD', 'CREATE']; - THREAD_UPDATE: ['THREAD', 'UPDATE']; - THREAD_DELETE: ['THREAD', 'DELETE']; + GuildUpdate: ['Guild', 'Update']; + ChannelCreate: ['Channel', 'Create']; + ChannelUpdate: ['Channel', 'Update']; + ChannelDelete: ['Channel', 'Delete']; + ChannelOverwriteCreate: ['Channel', 'Create']; + ChannelOverwriteUpdate: ['Channel', 'Update']; + ChannelOverwriteDelete: ['CHANNEL', 'Delete']; + MemberKick: ['User', 'Delete']; + MemberPrune: ['User', 'Delete']; + MemberBanAdd: ['User', 'Delete']; + MemberBanRemove: ['User', 'Create']; + MemberUpdate: ['User', 'Update']; + MemberRoleUpdate: ['User', 'Update']; + MemberMove: ['User', 'Update']; + MemberDisconnect: ['User', 'Delete']; + BotAdd: ['User', 'Create']; + RoleCreate: ['Role', 'Create']; + RoleUpdate: ['Role', 'Update']; + RoleDelete: ['Role', 'Delete']; + InviteCreate: ['Invite', 'Create']; + InviteUpdate: ['Invite', 'Update']; + InviteDelete: ['Invite', 'Delete']; + WebhookCreate: ['Webhook', 'Create']; + WebhookUpdate: ['Webhook', 'Update']; + WebhookDelete: ['Webhook', 'Delete']; + EmojiCreate: ['Emoji', 'Create']; + EmojiUpdate: ['Emoji', 'Update']; + EmojiDelete: ['Emoji', 'Delete']; + MessageDelete: ['Message', 'Delete']; + MessageBulkDelete: ['Message', 'Delete']; + MessagePin: ['Message', 'Create']; + MessageUnpin: ['Message', 'Delete']; + IntegrationCreate: ['Integration', 'Create']; + IntegrationUpdate: ['Integration', 'Update']; + IntegrationDelete: ['Integration', 'Delete']; + StageInstanceCreate: ['StageInstance', 'Create']; + StageInstanceUpdate: ['StageInstance', 'Update']; + StageInstanceDelete: ['StageInstance', 'Delete']; + StickerCreate: ['Sticker', 'Create']; + StickerUpdate: ['Sticker', 'Update']; + StickerDelete: ['Sticket', 'Delete']; + GUILD_SCHEDULED_EVENT_CREATE: ['GuildScheduledEvent', 'Create']; + GUILD_SCHEDULED_EVENT_UPDATE: ['GuildScheduledEvent', 'Update']; + GUILD_SCHEDULED_EVENT_DELETE: ['GuildScheduledEvent', 'Delete']; + ThreadCreate: ['Thread', 'Create']; + ThreadUpdate: ['Thread', 'Update']; + ThreadDelete: ['Thread', 'Delete']; } export interface GuildAuditLogsIds { - 1: 'GUILD_UPDATE'; - 10: 'CHANNEL_CREATE'; - 11: 'CHANNEL_UPDATE'; - 12: 'CHANNEL_DELETE'; - 13: 'CHANNEL_OVERWRITE_CREATE'; - 14: 'CHANNEL_OVERWRITE_UPDATE'; - 15: 'CHANNEL_OVERWRITE_DELETE'; - 20: 'MEMBER_KICK'; - 21: 'MEMBER_PRUNE'; - 22: 'MEMBER_BAN_ADD'; - 23: 'MEMBER_BAN_REMOVE'; - 24: 'MEMBER_UPDATE'; - 25: 'MEMBER_ROLE_UPDATE'; - 26: 'MEMBER_MOVE'; - 27: 'MEMBER_DISCONNECT'; - 28: 'BOT_ADD'; - 30: 'ROLE_CREATE'; - 31: 'ROLE_UPDATE'; - 32: 'ROLE_DELETE'; - 40: 'INVITE_CREATE'; - 41: 'INVITE_UPDATE'; - 42: 'INVITE_DELETE'; - 50: 'WEBHOOK_CREATE'; - 51: 'WEBHOOK_UPDATE'; - 52: 'WEBHOOK_DELETE'; - 60: 'EMOJI_CREATE'; - 61: 'EMOJI_UPDATE'; - 62: 'EMOJI_DELETE'; - 72: 'MESSAGE_DELETE'; - 73: 'MESSAGE_BULK_DELETE'; - 74: 'MESSAGE_PIN'; - 75: 'MESSAGE_UNPIN'; - 80: 'INTEGRATION_CREATE'; - 81: 'INTEGRATION_UPDATE'; - 82: 'INTEGRATION_DELETE'; - 83: 'STAGE_INSTANCE_CREATE'; - 84: 'STAGE_INSTANCE_UPDATE'; - 85: 'STAGE_INSTANCE_DELETE'; - 90: 'STICKER_CREATE'; - 91: 'STICKER_UPDATE'; - 92: 'STICKER_DELETE'; - 100: 'GUILD_SCHEDULED_EVENT_CREATE'; - 101: 'GUILD_SCHEDULED_EVENT_UPDATE'; - 102: 'GUILD_SCHEDULED_EVENT_DELETE'; - 110: 'THREAD_CREATE'; - 111: 'THREAD_UPDATE'; - 112: 'THREAD_DELETE'; + 1: 'GuildUpdate'; + 10: 'ChannelCreate'; + 11: 'ChannelUpdate'; + 12: 'ChannelDelete'; + 13: 'ChannelOverwriteCreate'; + 14: 'ChannelOverwriteUpdate'; + 15: 'ChannelOverwriteDelete'; + 20: 'MemberKick'; + 21: 'MemberPrune'; + 22: 'MemberBanAdd'; + 23: 'MemberBanRemove'; + 24: 'MemberUpdate'; + 25: 'MemberRoleUpdate'; + 26: 'MemberMove'; + 27: 'MemberDisconnect'; + 28: 'BotAdd'; + 30: 'RoleCreate'; + 31: 'RoleUpdate'; + 32: 'RoleDelete'; + 40: 'InviteCreate'; + 41: 'InviteUpdate'; + 42: 'InviteDelete'; + 50: 'WebhookCreate'; + 51: 'WebhookUpdate'; + 52: 'WebhookDelete'; + 60: 'EmojiCreate'; + 61: 'EmojiUpdate'; + 62: 'EmojiDelete'; + 72: 'MessageDelete'; + 73: 'MessageBulkDelete'; + 74: 'MessagePin'; + 75: 'MessageUnpin'; + 80: 'IntegrationCreate'; + 81: 'IntegrationUpdate'; + 82: 'IntegrationDelete'; + 83: 'StageInstanceCreate'; + 84: 'StageInstanceUpdate'; + 85: 'StageInstanceDelete'; + 90: 'StickerCreate'; + 91: 'StickerUpdate'; + 92: 'StickerDelete'; + 100: 'GuildScheduledEventCreate'; + 101: 'GuildScheduledEventUpdate'; + 102: 'GuildScheduledEventDelete'; + 110: 'ThreadCreate'; + 111: 'ThreadUpdate'; + 112: 'ThreadDelete'; } -export type GuildAuditLogsActions = { [Key in keyof GuildAuditLogsIds as GuildAuditLogsIds[Key]]: Key } & { ALL: null }; +export type GuildAuditLogsActions = { [Key in keyof GuildAuditLogsIds as GuildAuditLogsIds[Key]]: Key } & { All: null }; export type GuildAuditLogsAction = keyof GuildAuditLogsActions; -export type GuildAuditLogsActionType = GuildAuditLogsTypes[keyof GuildAuditLogsTypes][1] | 'ALL'; +export type GuildAuditLogsActionType = GuildAuditLogsTypes[keyof GuildAuditLogsTypes][1] | 'All'; export interface GuildAuditLogsEntryExtraField { - MEMBER_PRUNE: { removed: number; days: number }; - MEMBER_MOVE: { channel: VoiceBasedChannel | { id: Snowflake }; count: number }; - MESSAGE_DELETE: { channel: GuildTextBasedChannel | { id: Snowflake }; count: number }; - MESSAGE_BULK_DELETE: { channel: GuildTextBasedChannel | { id: Snowflake }; count: number }; - MESSAGE_PIN: { channel: GuildTextBasedChannel | { id: Snowflake }; messageId: Snowflake }; - MESSAGE_UNPIN: { channel: GuildTextBasedChannel | { id: Snowflake }; messageId: Snowflake }; - MEMBER_DISCONNECT: { count: number }; - CHANNEL_OVERWRITE_CREATE: + MemberPrune: { removed: number; days: number }; + MemberMove: { channel: VoiceBasedChannel | { id: Snowflake }; count: number }; + MessageDelete: { channel: GuildTextBasedChannel | { id: Snowflake }; count: number }; + MessageBulkDelete: { channel: GuildTextBasedChannel | { id: Snowflake }; count: number }; + MessagePin: { channel: GuildTextBasedChannel | { id: Snowflake }; messageId: Snowflake }; + MessageUnpin: { channel: GuildTextBasedChannel | { id: Snowflake }; messageId: Snowflake }; + MemberDisconnect: { count: number }; + ChannelOverwriteCreate: | Role | GuildMember - | { id: Snowflake; name: string; type: OverwriteTypes.role } - | { id: Snowflake; type: OverwriteTypes.member }; - CHANNEL_OVERWRITE_UPDATE: + | { id: Snowflake; name: string; type: 'Role' } + | { id: Snowflake; type: 'Member' }; + ChannelOverwriteUpdate: | Role | GuildMember - | { id: Snowflake; name: string; type: OverwriteTypes.role } - | { id: Snowflake; type: OverwriteTypes.member }; - CHANNEL_OVERWRITE_DELETE: + | { id: Snowflake; name: string; type: 'Role' } + | { id: Snowflake; type: 'Member' }; + ChannelOverwriteDelete: | Role | GuildMember - | { id: Snowflake; name: string; type: OverwriteTypes.role } - | { id: Snowflake; type: OverwriteTypes.member }; - STAGE_INSTANCE_CREATE: StageChannel | { id: Snowflake }; - STAGE_INSTANCE_DELETE: StageChannel | { id: Snowflake }; - STAGE_INSTANCE_UPDATE: StageChannel | { id: Snowflake }; + | { id: Snowflake; name: string; type: OverwriteType.Role } + | { id: Snowflake; type: OverwriteType.Member }; + StageInstanceCreate: StageChannel | { id: Snowflake }; + StageInstanceDelete: StageChannel | { id: Snowflake }; + StageInstanceUpdate: StageChannel | { id: Snowflake }; } export interface GuildAuditLogsEntryTargetField { - USER: User | null; - GUILD: Guild; - WEBHOOK: Webhook; - INVITE: Invite; - MESSAGE: TActionType extends 'MESSAGE_BULK_DELETE' ? Guild | { id: Snowflake } : User; - INTEGRATION: Integration; - CHANNEL: NonThreadGuildBasedChannel | { id: Snowflake; [x: string]: unknown }; - THREAD: ThreadChannel | { id: Snowflake; [x: string]: unknown }; - STAGE_INSTANCE: StageInstance; - STICKER: Sticker; - GUILD_SCHEDULED_EVENT: GuildScheduledEvent; + User: User | null; + Guild: Guild; + Webhook: Webhook; + Invite: Invite; + Message: TActionType extends 'MESSAGE_BULK_DELETE' ? Guild | { id: Snowflake } : User; + Integration: Integration; + Channel: NonThreadGuildBasedChannel | { id: Snowflake; [x: string]: unknown }; + Thread: ThreadChannel | { id: Snowflake; [x: string]: unknown }; + StageInstance: StageInstance; + Sticker: Sticker; + GuildScheduledEvent: GuildScheduledEvent; } export interface GuildAuditLogsFetchOptions { @@ -4535,7 +4356,7 @@ export interface GuildAuditLogsFetchOptions export type GuildAuditLogsResolvable = keyof GuildAuditLogsIds | GuildAuditLogsAction | null; -export type GuildAuditLogsTarget = GuildAuditLogsTypes[keyof GuildAuditLogsTypes][0] | 'ALL' | 'UNKNOWN'; +export type GuildAuditLogsTarget = GuildAuditLogsTypes[keyof GuildAuditLogsTypes][0] | 'All' | 'Unknown'; export type GuildAuditLogsTargets = { [key in GuildAuditLogsTarget]?: string; @@ -4553,8 +4374,8 @@ export type GuildChannelResolvable = Snowflake | GuildBasedChannel; export interface GuildChannelCreateOptions extends Omit { parent?: CategoryChannelResolvable; type?: ExcludeEnum< - typeof ChannelTypes, - 'DM' | 'GROUP_DM' | 'UNKNOWN' | 'GUILD_PUBLIC_THREAD' | 'GUILD_NEWS_THREAD' | 'GUILD_PRIVATE_THREAD' + typeof ChannelType, + 'DM' | 'GroupDM' | 'GuildPublicThread' | 'GuildNewsThread' | 'GuildPrivateThread' >; } @@ -4571,13 +4392,13 @@ export interface GuildCreateOptions { afkChannelId?: Snowflake | number; afkTimeout?: number; channels?: PartialChannelData[]; - defaultMessageNotifications?: DefaultMessageNotificationLevel | number; - explicitContentFilter?: ExplicitContentFilterLevel | number; + defaultMessageNotifications?: GuildDefaultMessageNotificationsKey | number; + explicitContentFilter?: GuildExplicitContentFilterKey | number; icon?: BufferResolvable | Base64Resolvable | null; roles?: PartialRoleData[]; systemChannelFlags?: SystemChannelFlagsResolvable; systemChannelId?: Snowflake | number; - verificationLevel?: VerificationLevel | number; + verificationLevel?: GuildVerificationLevelKey | number; } export interface GuildWidgetSettings { @@ -4587,9 +4408,9 @@ export interface GuildWidgetSettings { export interface GuildEditData { name?: string; - verificationLevel?: VerificationLevel | number; - explicitContentFilter?: ExplicitContentFilterLevel | number; - defaultMessageNotifications?: DefaultMessageNotificationLevel | number; + verificationLevel?: GuildVerificationLevelKey | number; + explicitContentFilter?: GuildExplicitContentFilterKey | number; + defaultMessageNotifications?: GuildDefaultMessageNotificationsKey | number; afkChannel?: VoiceChannelResolvable; systemChannel?: TextChannelResolvable; systemChannelFlags?: SystemChannelFlagsResolvable; @@ -4690,13 +4511,15 @@ export interface GuildListMembersOptions { cache?: boolean; } +export type GuildScheduledEventPrivacyLevelKey = keyof typeof GuildScheduledEventPrivacyLevel; + // TODO: use conditional types for better TS support export interface GuildScheduledEventCreateOptions { name: string; scheduledStartTime: DateResolvable; scheduledEndTime?: DateResolvable; - privacyLevel: GuildScheduledEventPrivacyLevel | number; - entityType: GuildScheduledEventEntityType | number; + privacyLevel: GuildScheduledEventPrivacyLevel | GuildScheduledEventPrivacyLevelKey; + entityType: GuildScheduledEventEntityType | GuildScheduledEventEntityTypeKey; description?: string; channel?: GuildVoiceChannelResolvable; entityMetadata?: GuildScheduledEventEntityMetadataOptions; @@ -4704,7 +4527,7 @@ export interface GuildScheduledEventCreateOptions { } export interface GuildScheduledEventEditOptions< - S extends GuildScheduledEventStatus, + S extends GuildScheduledEventStatusKey, T extends GuildScheduledEventSetStatusArg, > extends Omit, 'channel'> { channel?: GuildVoiceChannelResolvable | null; @@ -4719,7 +4542,7 @@ export interface GuildScheduledEventEntityMetadataOptions { location?: string; } -export type GuildScheduledEventEntityType = keyof typeof GuildScheduledEventEntityTypes; +export type GuildScheduledEventEntityTypeKey = keyof typeof GuildScheduledEventEntityType; export type GuildScheduledEventManagerFetchResult< T extends GuildScheduledEventResolvable | FetchGuildScheduledEventOptions | FetchGuildScheduledEventsOptions, @@ -4732,17 +4555,15 @@ export type GuildScheduledEventManagerFetchSubscribersResult> : Collection>; -export type GuildScheduledEventPrivacyLevel = keyof typeof GuildScheduledEventPrivacyLevels; - export type GuildScheduledEventResolvable = Snowflake | GuildScheduledEvent; -export type GuildScheduledEventSetStatusArg = T extends 'SCHEDULED' - ? 'ACTIVE' | 'CANCELED' - : T extends 'ACTIVE' - ? 'COMPLETED' +export type GuildScheduledEventSetStatusArg = T extends 'Scheduled' + ? 'Active' | 'Canceled' + : T extends 'Active' + ? 'Completed' : never; -export type GuildScheduledEventStatus = keyof typeof GuildScheduledEventStatuses; +export type GuildScheduledEventStatusKey = keyof typeof GuildScheduledEventStatus; export interface GuildScheduledEventUser { guildScheduledEventId: Snowflake; @@ -4794,9 +4615,9 @@ export type IntegrationType = 'twitch' | 'youtube' | 'discord'; export interface InteractionCollectorOptions extends CollectorOptions<[T]> { channel?: TextBasedChannel; - componentType?: MessageComponentType | MessageComponentTypes; + componentType?: ComponentType | MessageComponentTypeKey; guild?: Guild; - interactionType?: InteractionType | InteractionTypes; + interactionType?: InteractionTypeKey | InteractionType; max?: number; maxComponents?: number; maxUsers?: number; @@ -4815,9 +4636,9 @@ export interface InteractionReplyOptions extends Omit`; -export type MembershipState = keyof typeof MembershipStates; +export type TeamMemberMembershipStateKey = keyof typeof TeamMemberMembershipState; export type MessageActionRowComponent = MessageButton | MessageSelectMenu; @@ -4925,20 +4746,20 @@ export interface BaseButtonOptions extends BaseMessageComponentOptions { } export interface LinkButtonOptions extends BaseButtonOptions { - style: 'LINK' | MessageButtonStyles.LINK; + style: 'Link' | ButtonStyle.Link; url: string; } export interface InteractionButtonOptions extends BaseButtonOptions { - style: ExcludeEnum; + style: ExcludeEnum; customId: string; } export type MessageButtonOptions = InteractionButtonOptions | LinkButtonOptions; -export type MessageButtonStyle = keyof typeof MessageButtonStyles; +export type ButtonStyleKey = keyof typeof ButtonStyle; -export type MessageButtonStyleResolvable = MessageButtonStyle | MessageButtonStyles; +export type MessageButtonStyleResolvable = ButtonStyleKey | ButtonStyle; export interface MessageCollectorOptions extends CollectorOptions<[Message]> { max?: number; @@ -4963,9 +4784,9 @@ export type MessageComponentOptions = | MessageButtonOptions | MessageSelectMenuOptions; -export type MessageComponentType = keyof typeof MessageComponentTypes; +export type MessageComponentTypeKey = keyof typeof ComponentType; -export type MessageComponentTypeResolvable = MessageComponentType | MessageComponentTypes; +export type MessageComponentTypeResolvable = MessageComponentTypeKey | ComponentType; export interface MessageEditOptions { attachments?: MessageAttachment[]; @@ -5133,9 +4954,9 @@ export type MessageTarget = | Message | MessageManager; -export type MessageType = keyof typeof MessageTypes; +export type MessageTypeKey = keyof typeof MessageType; -export type MFALevel = keyof typeof MFALevels; +export type GuildMFALevelKey = keyof typeof GuildMFALevel; export interface MultipleShardRespawnOptions { shardDelay?: number; @@ -5149,18 +4970,18 @@ export interface MultipleShardSpawnOptions { timeout?: number; } -export type NSFWLevel = keyof typeof NSFWLevels; +export type GuildNSFWLevelKey = keyof typeof GuildNSFWLevel; export interface OverwriteData { allow?: PermissionResolvable; deny?: PermissionResolvable; id: GuildMemberResolvable | RoleResolvable; - type?: OverwriteType; + type?: OverwriteTypeKey; } export type OverwriteResolvable = PermissionOverwrites | OverwriteData; -export type OverwriteType = 'member' | 'role'; +export type OverwriteTypeKey = keyof typeof OverwriteType; export type PermissionFlags = Record; @@ -5221,7 +5042,7 @@ export interface PartialRecipient { username: string; } -export type PremiumTier = keyof typeof PremiumTiers; +export type PremiumTier = keyof typeof GuildPremiumTier; export interface PresenceData { status?: PresenceStatusData; @@ -5236,16 +5057,15 @@ export interface PartialChannelData { id?: Snowflake | number; parentId?: Snowflake | number; type?: ExcludeEnum< - typeof ChannelTypes, + typeof ChannelType, | 'DM' - | 'GROUP_DM' - | 'GUILD_NEWS' - | 'GUILD_STORE' - | 'UNKNOWN' - | 'GUILD_NEWS_THREAD' - | 'GUILD_PUBLIC_THREAD' - | 'GUILD_PRIVATE_THREAD' - | 'GUILD_STAGE_VOICE' + | 'GroupDM' + | 'GuildNews' + | 'GuildStore' + | 'GuildNewsThread' + | 'GuildPublicThread' + | 'GuildPrivateThread' + | 'GuildStageVoice' >; name: string; topic?: string; @@ -5300,7 +5120,7 @@ export type PresenceStatusData = ClientPresenceStatus | 'invisible'; export type PresenceStatus = PresenceStatusData | 'offline'; -export type PrivacyLevel = keyof typeof PrivacyLevels; +export type StageInstancePrivacyLevelKey = keyof typeof StageInstancePrivacyLevel; export interface RateLimitData { timeout: number; @@ -5414,11 +5234,11 @@ export interface StartThreadOptions { export type Status = number; -export type StickerFormatType = keyof typeof StickerFormatTypes; +export type StickerFormatKey = keyof typeof StickerFormatType; export type StickerResolvable = Sticker | Snowflake; -export type StickerType = keyof typeof StickerTypes; +export type StickerKey = keyof typeof StickerType; export type SystemChannelFlagsString = | 'SUPPRESS_JOIN_NOTIFICATIONS' @@ -5437,7 +5257,7 @@ export type StageChannelResolvable = StageChannel | Snowflake; export interface StageInstanceEditOptions { topic?: string; - privacyLevel?: PrivacyLevel | number; + privacyLevel?: StageInstancePrivacyLevelKey | number; } export type SweeperKey = keyof SweeperDefinitions; @@ -5512,7 +5332,7 @@ export type ThreadAutoArchiveDuration = 60 | 1440 | 4320 | 10080 | 'MAX'; export type ThreadChannelResolvable = ThreadChannel | Snowflake; -export type ThreadChannelTypes = 'GUILD_NEWS_THREAD' | 'GUILD_PUBLIC_THREAD' | 'GUILD_PRIVATE_THREAD'; +export type ThreadChannelTypeKey = 'GuildNewsThread' | 'GuildPublicThread' | 'GuildPrivateThread'; export interface ThreadCreateOptions extends StartThreadOptions { startMessage?: MessageResolvable; @@ -5559,7 +5379,7 @@ export interface Vanity { uses: number; } -export type VerificationLevel = keyof typeof VerificationLevels; +export type GuildVerificationLevelKey = keyof typeof GuildVerificationLevel; export type VoiceBasedChannelTypes = VoiceBasedChannel['type']; @@ -5603,7 +5423,7 @@ export interface WebhookMessageOptions extends Omit InternalDiscordGatewayAdapterImplementerMethods; //#endregion + +// External +export { + ActivityType, + ApplicationCommandType, + ApplicationCommandOptionType, + ApplicationCommandPermissionType, + ButtonStyle, + ChannelType, + ComponentType, + GuildMFALevel, + GuildNSFWLevel, + GuildPremiumTier, + GuildScheduledEventEntityType, + GuildScheduledEventPrivacyLevel, + GuildScheduledEventStatus, + GuildVerificationLevel, + InteractionType, + InteractionResponseType, + InviteTargetType, + MessageType, + RESTJSONErrorCodes, + StageInstancePrivacyLevel, + StickerType, + StickerFormatType, + WebhookType, +} from 'discord-api-types/v9'; diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index fbca0337a..786b40e21 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -9,6 +9,7 @@ import type { APIRole, APIButtonComponent, APISelectMenuComponent, + ApplicationCommandOptionType, } from 'discord-api-types/v9'; import { AuditLogEvent } from 'discord-api-types/v9'; import { @@ -91,7 +92,6 @@ import { MessageSelectMenu, PartialDMChannel, } from '.'; -import type { ApplicationCommandOptionTypes } from './enums'; import { expectAssignable, expectDeprecated, expectNotAssignable, expectNotType, expectType } from 'tsd'; // Test type transformation: @@ -144,7 +144,7 @@ client.on('ready', async () => { await globalPermissionsManager?.add({ command: globalCommandId, guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); await globalPermissionsManager?.has({ command: globalCommandId, guild: testGuildId, permissionId: testGuildId }); await globalPermissionsManager?.fetch({ guild: testGuildId }); @@ -160,17 +160,17 @@ client.on('ready', async () => { await globalPermissionsManager?.set({ command: globalCommandId, guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); await globalPermissionsManager?.set({ guild: testGuildId, - fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }], + fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'Role', id: testGuildId, permission: true }] }], }); // @ts-expect-error await globalPermissionsManager?.add({ command: globalCommandId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); // @ts-expect-error await globalPermissionsManager?.has({ command: globalCommandId, permissionId: testGuildId }); @@ -187,23 +187,23 @@ client.on('ready', async () => { // @ts-expect-error await globalPermissionsManager?.set({ command: globalCommandId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); // @ts-expect-error await globalPermissionsManager?.set({ - fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }], + fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'Role', id: testGuildId, permission: true }] }], }); // @ts-expect-error await globalPermissionsManager?.set({ command: globalCommandId, guild: testGuildId, - fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }], + fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'Role', id: testGuildId, permission: true }] }], }); // @ts-expect-error await globalPermissionsManager?.add({ guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); // @ts-expect-error await globalPermissionsManager?.has({ guild: testGuildId, permissionId: testGuildId }); @@ -216,13 +216,13 @@ client.on('ready', async () => { // @ts-expect-error await globalPermissionsManager?.set({ guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); // Permissions from guild manager await guildPermissionsManager?.add({ command: globalCommandId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); await guildPermissionsManager?.has({ command: globalCommandId, permissionId: testGuildId }); await guildPermissionsManager?.fetch({}); @@ -232,17 +232,17 @@ client.on('ready', async () => { await guildPermissionsManager?.remove({ command: globalCommandId, roles: [testGuildId], users: [testUserId] }); await guildPermissionsManager?.set({ command: globalCommandId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); await guildPermissionsManager?.set({ - fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }], + fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'Role', id: testGuildId, permission: true }] }], }); await guildPermissionsManager?.add({ command: globalCommandId, // @ts-expect-error guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); // @ts-expect-error await guildPermissionsManager?.has({ command: globalCommandId, guild: testGuildId, permissionId: testGuildId }); @@ -265,16 +265,16 @@ client.on('ready', async () => { await guildPermissionsManager?.set({ command: globalCommandId, guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); await guildPermissionsManager?.set({ // @ts-expect-error guild: testGuildId, - fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }], + fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'Role', id: testGuildId, permission: true }] }], }); // @ts-expect-error - await guildPermissionsManager?.add({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }); + await guildPermissionsManager?.add({ permissions: [{ type: 'Role', id: testGuildId, permission: true }] }); // @ts-expect-error await guildPermissionsManager?.has({ permissionId: testGuildId }); // @ts-expect-error @@ -284,17 +284,17 @@ client.on('ready', async () => { // @ts-expect-error await guildPermissionsManager?.remove({ roles: [testGuildId], users: [testUserId] }); // @ts-expect-error - await guildPermissionsManager?.set({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }); + await guildPermissionsManager?.set({ permissions: [{ type: 'Role', id: testGuildId, permission: true }] }); // @ts-expect-error await guildPermissionsManager?.set({ command: globalCommandId, - fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }], + fullPermissions: [{ id: globalCommandId, permissions: [{ type: 'Role', id: testGuildId, permission: true }] }], }); // Permissions from cached global ApplicationCommand await globalCommand?.permissions.add({ guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); await globalCommand?.permissions.has({ guild: testGuildId, permissionId: testGuildId }); await globalCommand?.permissions.fetch({ guild: testGuildId }); @@ -303,14 +303,14 @@ client.on('ready', async () => { await globalCommand?.permissions.remove({ guild: testGuildId, roles: [testGuildId], users: [testUserId] }); await globalCommand?.permissions.set({ guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); await globalCommand?.permissions.add({ // @ts-expect-error command: globalCommandId, guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); // @ts-expect-error await globalCommand?.permissions.has({ command: globalCommandId, guild: testGuildId, permissionId: testGuildId }); @@ -331,11 +331,11 @@ client.on('ready', async () => { // @ts-expect-error command: globalCommandId, guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); // @ts-expect-error - await globalCommand?.permissions.add({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }); + await globalCommand?.permissions.add({ permissions: [{ type: 'Role', id: testGuildId, permission: true }] }); // @ts-expect-error await globalCommand?.permissions.has({ permissionId: testGuildId }); // @ts-expect-error @@ -347,21 +347,21 @@ client.on('ready', async () => { // @ts-expect-error await globalCommand?.permissions.remove({ roles: [testGuildId], users: [testUserId] }); // @ts-expect-error - await globalCommand?.permissions.set({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }); + await globalCommand?.permissions.set({ permissions: [{ type: 'Role', id: testGuildId, permission: true }] }); // Permissions from cached guild ApplicationCommand - await guildCommandFromGlobal?.permissions.add({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }); + await guildCommandFromGlobal?.permissions.add({ permissions: [{ type: 'Role', id: testGuildId, permission: true }] }); await guildCommandFromGlobal?.permissions.has({ permissionId: testGuildId }); await guildCommandFromGlobal?.permissions.fetch({}); await guildCommandFromGlobal?.permissions.remove({ roles: [testGuildId] }); await guildCommandFromGlobal?.permissions.remove({ users: [testUserId] }); await guildCommandFromGlobal?.permissions.remove({ roles: [testGuildId], users: [testUserId] }); - await guildCommandFromGlobal?.permissions.set({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }); + await guildCommandFromGlobal?.permissions.set({ permissions: [{ type: 'Role', id: testGuildId, permission: true }] }); await guildCommandFromGlobal?.permissions.add({ // @ts-expect-error command: globalCommandId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); // @ts-expect-error await guildCommandFromGlobal?.permissions.has({ command: guildCommandId, permissionId: testGuildId }); @@ -378,13 +378,13 @@ client.on('ready', async () => { await guildCommandFromGlobal?.permissions.set({ // @ts-expect-error command: guildCommandId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); await guildCommandFromGlobal?.permissions.add({ // @ts-expect-error guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); // @ts-expect-error await guildCommandFromGlobal?.permissions.has({ guild: testGuildId, permissionId: testGuildId }); @@ -397,21 +397,21 @@ client.on('ready', async () => { await guildCommandFromGlobal?.permissions.set({ // @ts-expect-error guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); - await guildCommandFromGuild?.permissions.add({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }); + await guildCommandFromGuild?.permissions.add({ permissions: [{ type: 'Role', id: testGuildId, permission: true }] }); await guildCommandFromGuild?.permissions.has({ permissionId: testGuildId }); await guildCommandFromGuild?.permissions.fetch({}); await guildCommandFromGuild?.permissions.remove({ roles: [testGuildId] }); await guildCommandFromGuild?.permissions.remove({ users: [testUserId] }); await guildCommandFromGuild?.permissions.remove({ roles: [testGuildId], users: [testUserId] }); - await guildCommandFromGuild?.permissions.set({ permissions: [{ type: 'ROLE', id: testGuildId, permission: true }] }); + await guildCommandFromGuild?.permissions.set({ permissions: [{ type: 'Role', id: testGuildId, permission: true }] }); await guildCommandFromGuild?.permissions.add({ // @ts-expect-error command: globalCommandId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); // @ts-expect-error await guildCommandFromGuild?.permissions.has({ command: guildCommandId, permissionId: testGuildId }); @@ -428,13 +428,13 @@ client.on('ready', async () => { await guildCommandFromGuild?.permissions.set({ // @ts-expect-error command: guildCommandId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); await guildCommandFromGuild?.permissions.add({ // @ts-expect-error guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); // @ts-expect-error await guildCommandFromGuild?.permissions.has({ guild: testGuildId, permissionId: testGuildId }); @@ -447,7 +447,7 @@ client.on('ready', async () => { await guildCommandFromGuild?.permissions.set({ // @ts-expect-error guild: testGuildId, - permissions: [{ type: 'ROLE', id: testGuildId, permission: true }], + permissions: [{ type: 'Role', id: testGuildId, permission: true }], }); client.application?.commands.permissions.set({ @@ -526,11 +526,11 @@ client.on('messageCreate', async message => { if (message.inGuild()) { expectAssignable>(message); - const component = await message.awaitMessageComponent({ componentType: 'BUTTON' }); + const component = await message.awaitMessageComponent({ componentType: 'Button' }); expectType>(component); expectType>(await component.reply({ fetchReply: true })); - const buttonCollector = message.createMessageComponentCollector({ componentType: 'BUTTON' }); + const buttonCollector = message.createMessageComponentCollector({ componentType: 'Button' }); expectType>>(buttonCollector); expectAssignable<(test: ButtonInteraction<'cached'>) => boolean | Promise>(buttonCollector.filter); expectType(message.channel); @@ -549,15 +549,15 @@ client.on('messageCreate', async message => { // Check collector creations. // Verify that buttons interactions are inferred. - const buttonCollector = message.createMessageComponentCollector({ componentType: 'BUTTON' }); - expectAssignable>(message.awaitMessageComponent({ componentType: 'BUTTON' })); - expectAssignable>(channel.awaitMessageComponent({ componentType: 'BUTTON' })); + const buttonCollector = message.createMessageComponentCollector({ componentType: 'Button' }); + expectAssignable>(message.awaitMessageComponent({ componentType: 'Button' })); + expectAssignable>(channel.awaitMessageComponent({ componentType: 'Button' })); expectAssignable>(buttonCollector); // Verify that select menus interaction are inferred. - const selectMenuCollector = message.createMessageComponentCollector({ componentType: 'SELECT_MENU' }); - expectAssignable>(message.awaitMessageComponent({ componentType: 'SELECT_MENU' })); - expectAssignable>(channel.awaitMessageComponent({ componentType: 'SELECT_MENU' })); + const selectMenuCollector = message.createMessageComponentCollector({ componentType: 'SelectMenu' }); + expectAssignable>(message.awaitMessageComponent({ componentType: 'SelectMenu' })); + expectAssignable>(channel.awaitMessageComponent({ componentType: 'SelectMenu' })); expectAssignable>(selectMenuCollector); // Verify that message component interactions are default collected types. @@ -586,7 +586,7 @@ client.on('messageCreate', async message => { }); message.createMessageComponentCollector({ - componentType: 'BUTTON', + componentType: 'Button', filter: i => { expectType(i); return true; @@ -594,7 +594,7 @@ client.on('messageCreate', async message => { }); message.createMessageComponentCollector({ - componentType: 'SELECT_MENU', + componentType: 'SelectMenu', filter: i => { expectType(i); return true; @@ -609,7 +609,7 @@ client.on('messageCreate', async message => { }); message.awaitMessageComponent({ - componentType: 'BUTTON', + componentType: 'Button', filter: i => { expectType(i); return true; @@ -617,7 +617,7 @@ client.on('messageCreate', async message => { }); message.awaitMessageComponent({ - componentType: 'SELECT_MENU', + componentType: 'SelectMenu', filter: i => { expectType(i); return true; @@ -645,7 +645,7 @@ client.on('messageCreate', async message => { }); channel.awaitMessageComponent({ - componentType: 'BUTTON', + componentType: 'Button', filter: i => { expectType>(i); return true; @@ -653,7 +653,7 @@ client.on('messageCreate', async message => { }); channel.awaitMessageComponent({ - componentType: 'SELECT_MENU', + componentType: 'SelectMenu', filter: i => { expectType>(i); return true; @@ -772,8 +772,8 @@ expectType(newsChannel.lastMessage); expectType(textChannel.lastMessage); expectDeprecated(storeChannel.clone()); -expectDeprecated(categoryChannel.createChannel('Store', { type: 'GUILD_STORE' })); -expectDeprecated(guild.channels.create('Store', { type: 'GUILD_STORE' })); +expectDeprecated(categoryChannel.createChannel('Store', { type: 'GuildStore' })); +expectDeprecated(guild.channels.create('Store', { type: 'GuildStore' })); notPropertyOf(user, 'lastMessage'); notPropertyOf(user, 'lastMessageId'); @@ -844,9 +844,7 @@ declare const applicationNonChoiceOptionData: ApplicationCommandOptionData & { declare const applicationSubGroupCommandData: ApplicationCommandSubGroupData; { - expectType<'SUB_COMMAND_GROUP' | ApplicationCommandOptionTypes.SUB_COMMAND_GROUP>( - applicationSubGroupCommandData.type, - ); + expectType<'SubcommandGroup' | ApplicationCommandOptionType.SubcommandGroup>(applicationSubGroupCommandData.type); expectType(applicationSubGroupCommandData.options); } @@ -857,25 +855,25 @@ expectType>(guildApplicationCommandManager.fetch('0' declare const categoryChannel: CategoryChannel; { - expectType>(categoryChannel.createChannel('name', { type: 'GUILD_VOICE' })); - expectType>(categoryChannel.createChannel('name', { type: 'GUILD_TEXT' })); - expectType>(categoryChannel.createChannel('name', { type: 'GUILD_NEWS' })); - expectType>(categoryChannel.createChannel('name', { type: 'GUILD_STORE' })); - expectType>(categoryChannel.createChannel('name', { type: 'GUILD_STAGE_VOICE' })); - expectType>(categoryChannel.createChannel('name', {})); - expectType>(categoryChannel.createChannel('name')); + expectType>(categoryChannel.createChannel('name', { type: 'GuildVoice' })); + expectType>(categoryChannel.createChannel('name', { type: 'GuildText' })); + expectType>(categoryChannel.createChannel('name', { type: 'GuildNews' })); + expectDeprecated(categoryChannel.createChannel('name', { type: 'GuildStore' })); + expectType>(categoryChannel.createChannel('name', { type: 'GuildStageVoice' })); + expectType>>(categoryChannel.createChannel('name', {})); + expectType>>(categoryChannel.createChannel('name')); } declare const guildChannelManager: GuildChannelManager; { type AnyChannel = TextChannel | VoiceChannel | CategoryChannel | NewsChannel | StoreChannel | StageChannel; - expectType>(guildChannelManager.create('name', { type: 'GUILD_VOICE' })); - expectType>(guildChannelManager.create('name', { type: 'GUILD_CATEGORY' })); - expectType>(guildChannelManager.create('name', { type: 'GUILD_TEXT' })); - expectType>(guildChannelManager.create('name', { type: 'GUILD_NEWS' })); - expectType>(guildChannelManager.create('name', { type: 'GUILD_STORE' })); - expectType>(guildChannelManager.create('name', { type: 'GUILD_STAGE_VOICE' })); + expectType>(guildChannelManager.create('name', { type: 'GuildVoice' })); + expectType>(guildChannelManager.create('name', { type: 'GuildCategory' })); + expectType>(guildChannelManager.create('name', { type: 'GuildText' })); + expectType>(guildChannelManager.create('name', { type: 'GuildNews' })); + expectType>(guildChannelManager.create('name', { type: 'GuildStore' })); + expectType>(guildChannelManager.create('name', { type: 'GuildStageVoice' })); expectType>>(guildChannelManager.fetch()); expectType>>(guildChannelManager.fetch(undefined, {})); @@ -1080,7 +1078,7 @@ client.on('interactionCreate', async interaction => { expectType(interaction.options.getRole('test', true)); } else if (interaction.inCachedGuild()) { const msg = await interaction.reply({ fetchReply: true }); - const btn = await msg.awaitMessageComponent({ componentType: 'BUTTON' }); + const btn = await msg.awaitMessageComponent({ componentType: 'Button' }); expectType>(msg); expectType>(btn); @@ -1167,79 +1165,79 @@ collector.on('end', (collection, reason) => { expectType>(shard.eval(c => c.readyTimestamp)); // Test audit logs -expectType>>(guild.fetchAuditLogs({ type: 'MEMBER_KICK' })); +expectType>>(guild.fetchAuditLogs({ type: 'MemberKick' })); expectAssignable>>( - guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.MEMBER_KICK }), + guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.MemberKick }), ); expectType>>(guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick })); -expectType>>(guild.fetchAuditLogs({ type: 'CHANNEL_CREATE' })); +expectType>>(guild.fetchAuditLogs({ type: 'ChannelCreate' })); expectAssignable>>( - guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.CHANNEL_CREATE }), + guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.ChannelCreate }), ); expectType>>( guild.fetchAuditLogs({ type: AuditLogEvent.ChannelCreate }), ); -expectType>>(guild.fetchAuditLogs({ type: 'INTEGRATION_UPDATE' })); +expectType>>(guild.fetchAuditLogs({ type: 'IntegrationUpdate' })); expectAssignable>>( - guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.INTEGRATION_UPDATE }), + guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.IntegrationUpdate }), ); expectType>>( guild.fetchAuditLogs({ type: AuditLogEvent.IntegrationUpdate }), ); -expectType>>(guild.fetchAuditLogs({ type: 'ALL' })); -expectType>>(guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.ALL })); -expectType>>(guild.fetchAuditLogs()); +expectType>>(guild.fetchAuditLogs({ type: 'All' })); +expectType>>(guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.All })); +expectType>>(guild.fetchAuditLogs()); -expectType | undefined>>( - guild.fetchAuditLogs({ type: 'MEMBER_KICK' }).then(al => al.entries.first()), +expectType | undefined>>( + guild.fetchAuditLogs({ type: 'MemberKick' }).then(al => al.entries.first()), ); -expectType | undefined>>( - guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.MEMBER_KICK }).then(al => al.entries.first()), +expectType | undefined>>( + guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.MemberKick }).then(al => al.entries.first()), ); -expectAssignable | undefined>>( +expectAssignable | undefined>>( guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }).then(al => al.entries.first()), ); -expectType | undefined>>( - guild.fetchAuditLogs({ type: 'ALL' }).then(al => al.entries.first()), +expectType | undefined>>( + guild.fetchAuditLogs({ type: 'All' }).then(al => al.entries.first()), ); -expectType | undefined>>( - guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.ALL }).then(al => al.entries.first()), +expectType | undefined>>( + guild.fetchAuditLogs({ type: GuildAuditLogs.Actions.All }).then(al => al.entries.first()), ); -expectType | undefined>>( +expectType | undefined>>( guild.fetchAuditLogs({ type: null }).then(al => al.entries.first()), ); -expectType | undefined>>( +expectType | undefined>>( guild.fetchAuditLogs().then(al => al.entries.first()), ); expectType>( - guild.fetchAuditLogs({ type: 'MEMBER_KICK' }).then(al => al.entries.first()?.extra), + guild.fetchAuditLogs({ type: 'MemberKick' }).then(al => al.entries.first()?.extra), ); expectType>( guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }).then(al => al.entries.first()?.extra), ); expectType>( - guild.fetchAuditLogs({ type: 'STAGE_INSTANCE_CREATE' }).then(al => al.entries.first()?.extra), + guild.fetchAuditLogs({ type: 'StageInstanceCreate' }).then(al => al.entries.first()?.extra), ); expectType>( - guild.fetchAuditLogs({ type: 'MESSAGE_DELETE' }).then(al => al.entries.first()?.extra), + guild.fetchAuditLogs({ type: 'MessageDelete' }).then(al => al.entries.first()?.extra), ); expectType>( - guild.fetchAuditLogs({ type: 'MEMBER_KICK' }).then(al => al.entries.first()?.target), + guild.fetchAuditLogs({ type: 'MemberKick' }).then(al => al.entries.first()?.target), ); expectType>( guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }).then(al => al.entries.first()?.target), ); expectType>( - guild.fetchAuditLogs({ type: 'STAGE_INSTANCE_CREATE' }).then(al => al.entries.first()?.target), + guild.fetchAuditLogs({ type: 'StageInstanceCreate' }).then(al => al.entries.first()?.target), ); expectType>( - guild.fetchAuditLogs({ type: 'MESSAGE_DELETE' }).then(al => al.entries.first()?.target), + guild.fetchAuditLogs({ type: 'MessageDelete' }).then(al => al.entries.first()?.target), ); expectType>( @@ -1255,7 +1253,7 @@ declare const NonThreadGuildBasedChannel: NonThreadGuildBasedChannel; declare const GuildTextBasedChannel: GuildTextBasedChannel; expectType(TextBasedChannel); -expectType<'DM' | 'GUILD_NEWS' | 'GUILD_TEXT' | 'GUILD_PUBLIC_THREAD' | 'GUILD_PRIVATE_THREAD' | 'GUILD_NEWS_THREAD'>( +expectType<'DM' | 'GuildNews' | 'GuildText' | 'GuildPublicThread' | 'GuildPrivateThread' | 'GuildNewsThread'>( TextBasedChannelTypes, ); expectType(VoiceBasedChannel);