From 533c1c55a795f563b0ccb3e858449ccf40e97c53 Mon Sep 17 00:00:00 2001 From: Cinnamon <71698422+aiko-chan-ai@users.noreply.github.com> Date: Fri, 1 Jul 2022 10:32:37 +0700 Subject: [PATCH] docs(constants): document missing constants v13.9.0 #8168 --- src/util/Constants.js | 269 +++++++++++++++++++++++++++++++++++------- src/util/Util.js | 36 +----- typings/index.d.ts | 8 +- 3 files changed, 235 insertions(+), 78 deletions(-) diff --git a/src/util/Constants.js b/src/util/Constants.js index cc1004d..f35cb22 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -81,6 +81,17 @@ exports.localeObject = { exports.randomUA = () => listUserAgent[Math.floor(Math.random() * listUserAgent.length)]; +/** + * The types of WebSocket error codes: + * * 1000: WS_CLOSE_REQUESTED + * * 1011: INTERNAL_ERROR + * * 4004: TOKEN_INVALID + * * 4010: SHARDING_INVALID + * * 4011: SHARDING_REQUIRED + * * 4013: INVALID_INTENTS + * * 4014: DISALLOWED_INTENTS + * @typedef {Object} WSCodes + */ exports.WSCodes = { 1000: 'WS_CLOSE_REQUESTED', 1011: 'INTERNAL_ERROR', @@ -116,7 +127,11 @@ function makeImageUrl(root, { format = 'webp', size } = {}) { * `4096` */ -// https://discord.com/developers/docs/reference#image-formatting-cdn-endpoints +/** + * An object containing functions that return certain endpoints on the API. + * @typedef {Object} Endpoints + * @see {@link https://discord.com/developers/docs/reference#image-formatting-cdn-endpoints} + */ exports.Endpoints = { CDN(root) { return { @@ -173,7 +188,7 @@ exports.Endpoints = { * * WAITING_FOR_GUILDS: 6 * * IDENTIFYING: 7 * * RESUMING: 8 - * @typedef {number} Status + * @typedef {Object} Status */ exports.Status = { READY: 0, @@ -187,6 +202,34 @@ exports.Status = { RESUMING: 8, }; +/** + * The Opcodes sent to the Gateway: + * * DISPATCH: 0 + * * HEARTBEAT: 1 + * * IDENTIFY: 2 + * * STATUS_UPDATE: 3 + * * VOICE_STATE_UPDATE: 4 + * * VOICE_GUILD_PING: 5 + * * RESUME: 6 + * * RECONNECT: 7 + * * REQUEST_GUILD_MEMBERS: 8 + * * INVALID_SESSION: 9 + * * HELLO: 10 + * * HEARTBEAT_ACK: 11 + * * GUILD_SYNC: 12 [Unused] + * * DM_UPDATE: 13 # Send => used to get dm features + * * LAZY_REQUEST: 14 # Send => discord responds back with GUILD_MEMBER_LIST_UPDATE type SYNC... + * * LOBBY_CONNECT: 15 + * * LOBBY_DISCONNECT: 16 + * * LOBBY_VOICE_STATE_UPDATE: 17 # Receive + * * STREAM_CREATE: 18 + * * STREAM_DELETE: 19 + * * STREAM_WATCH: 20 + * * STREAM_PING: 21 # Send + * * STREAM_SET_PAUSED: 22 + * * REQUEST_APPLICATION_COMMANDS: 24 + * @typedef {Object} Opcodes + */ exports.Opcodes = { DISPATCH: 0, // # Receive => dispatches an event HEARTBEAT: 1, // # Send/Receive => used for ping checking @@ -215,23 +258,93 @@ exports.Opcodes = { REQUEST_APPLICATION_COMMANDS: 24, // # Send => request application/bot cmds (user, message, and slash cmds) }; +/** + * The types of events emitted by the Client: + * * RATE_LIMIT: rateLimit + * * INVALID_REQUEST_WARNING: invalidRequestWarning + * * API_RESPONSE: apiResponse + * * API_REQUEST: apiRequest + * * CLIENT_READY: ready + * * APPLICATION_COMMAND_CREATE: applicationCommandCreate (deprecated) + * * APPLICATION_COMMAND_DELETE: applicationCommandDelete (deprecated) + * * APPLICATION_COMMAND_UPDATE: applicationCommandUpdate (deprecated) + * * GUILD_CREATE: guildCreate + * * GUILD_DELETE: guildDelete + * * GUILD_UPDATE: guildUpdate + * * GUILD_UNAVAILABLE: guildUnavailable + * * GUILD_MEMBER_ADD: guildMemberAdd + * * GUILD_MEMBER_REMOVE: guildMemberRemove + * * GUILD_MEMBER_UPDATE: guildMemberUpdate + * * GUILD_MEMBER_AVAILABLE: guildMemberAvailable + * * GUILD_MEMBERS_CHUNK: guildMembersChunk + * * GUILD_INTEGRATIONS_UPDATE: guildIntegrationsUpdate + * * GUILD_ROLE_CREATE: roleCreate + * * GUILD_ROLE_DELETE: roleDelete + * * INVITE_CREATE: inviteCreate + * * INVITE_DELETE: inviteDelete + * * GUILD_ROLE_UPDATE: roleUpdate + * * GUILD_EMOJI_CREATE: emojiCreate + * * GUILD_EMOJI_DELETE: emojiDelete + * * GUILD_EMOJI_UPDATE: emojiUpdate + * * GUILD_BAN_ADD: guildBanAdd + * * GUILD_BAN_REMOVE: guildBanRemove + * * CHANNEL_CREATE: channelCreate + * * CHANNEL_DELETE: channelDelete + * * CHANNEL_UPDATE: channelUpdate + * * CHANNEL_PINS_UPDATE: channelPinsUpdate + * * MESSAGE_CREATE: messageCreate + * * MESSAGE_DELETE: messageDelete + * * MESSAGE_UPDATE: messageUpdate + * * MESSAGE_BULK_DELETE: messageDeleteBulk + * * MESSAGE_REACTION_ADD: messageReactionAdd + * * MESSAGE_REACTION_REMOVE: messageReactionRemove + * * MESSAGE_REACTION_REMOVE_ALL: messageReactionRemoveAll + * * MESSAGE_REACTION_REMOVE_EMOJI: messageReactionRemoveEmoji + * * THREAD_CREATE: threadCreate + * * THREAD_DELETE: threadDelete + * * THREAD_UPDATE: threadUpdate + * * THREAD_LIST_SYNC: threadListSync + * * THREAD_MEMBER_UPDATE: threadMemberUpdate + * * THREAD_MEMBERS_UPDATE: threadMembersUpdate + * * USER_UPDATE: userUpdate + * * PRESENCE_UPDATE: presenceUpdate + * * VOICE_SERVER_UPDATE: voiceServerUpdate + * * VOICE_STATE_UPDATE: voiceStateUpdate + * * TYPING_START: typingStart + * * WEBHOOKS_UPDATE: webhookUpdate + * * INTERACTION_CREATE: interactionCreate + * * ERROR: error + * * WARN: warn + * * DEBUG: debug + * * CACHE_SWEEP: cacheSweep + * * SHARD_DISCONNECT: shardDisconnect + * * SHARD_ERROR: shardError + * * SHARD_RECONNECTING: shardReconnecting + * * SHARD_READY: shardReady + * * SHARD_RESUME: shardResume + * * INVALIDATED: invalidated + * * RAW: raw + * * STAGE_INSTANCE_CREATE: stageInstanceCreate + * * STAGE_INSTANCE_UPDATE: stageInstanceUpdate + * * STAGE_INSTANCE_DELETE: stageInstanceDelete + * * GUILD_STICKER_CREATE: stickerCreate + * * GUILD_STICKER_DELETE: stickerDelete + * * GUILD_STICKER_UPDATE: stickerUpdate + * * GUILD_SCHEDULED_EVENT_CREATE: guildScheduledEventCreate + * * GUILD_SCHEDULED_EVENT_UPDATE: guildScheduledEventUpdate + * * GUILD_SCHEDULED_EVENT_DELETE: guildScheduledEventDelete + * * GUILD_SCHEDULED_EVENT_USER_ADD: guildScheduledEventUserAdd + * * GUILD_SCHEDULED_EVENT_USER_REMOVE: guildScheduledEventUserRemove + * @typedef {Object} Events + */ exports.Events = { RATE_LIMIT: 'rateLimit', INVALID_REQUEST_WARNING: 'invalidRequestWarning', API_RESPONSE: 'apiResponse', API_REQUEST: 'apiRequest', CLIENT_READY: 'ready', - /** - * @deprecated See {@link https://github.com/discord/discord-api-docs/issues/3690 this issue} for more information. - */ APPLICATION_COMMAND_CREATE: 'applicationCommandCreate', - /** - * @deprecated See {@link https://github.com/discord/discord-api-docs/issues/3690 this issue} for more information. - */ APPLICATION_COMMAND_DELETE: 'applicationCommandDelete', - /** - * @deprecated See {@link https://github.com/discord/discord-api-docs/issues/3690 this issue} for more information. - */ APPLICATION_COMMAND_UPDATE: 'applicationCommandUpdate', GUILD_CREATE: 'guildCreate', GUILD_DELETE: 'guildDelete', @@ -335,6 +448,16 @@ exports.Events = { UNHANDLED_PACKET: 'unhandledPacket', }; +/** + * The types of events emitted by a Shard: + * * CLOSE: close + * * DESTROYED: destroyed + * * INVALID_SESSION: invalidSession + * * READY: ready + * * RESUMED: resumed + * * ALL_READY: allReady + * @typedef {Object} ShardEvents + */ exports.ShardEvents = { CLOSE: 'close', DESTROYED: 'destroyed', @@ -730,11 +853,51 @@ exports.ThreadChannelTypes = ['GUILD_NEWS_THREAD', 'GUILD_PUBLIC_THREAD', 'GUILD */ exports.VoiceBasedChannelTypes = ['GUILD_VOICE', 'GUILD_STAGE_VOICE']; +/** + * The types of assets of an application: + * * SMALL: 1 + * * BIG: 2 + * @typedef {Object} ClientApplicationAssetTypes + */ exports.ClientApplicationAssetTypes = { SMALL: 1, BIG: 2, }; +/** + * A commonly used color: + * * DEFAULT + * * WHITE + * * AQUA + * * GREEN + * * BLUE + * * YELLOW + * * PURPLE + * * LUMINOUS_VIVID_PINK + * * FUCHSIA + * * GOLD + * * ORANGE + * * RED + * * GREY + * * NAVY + * * DARK_AQUA + * * DARK_GREEN + * * DARK_BLUE + * * DARK_PURPLE + * * DARK_VIVID_PINK + * * DARK_GOLD + * * DARK_ORANGE + * * DARK_RED + * * DARK_GREY + * * DARKER_GREY + * * LIGHT_GREY + * * DARK_NAVY + * * BLURPLE + * * GREYPLE + * * DARK_BUT_NOT_BLACK + * * NOT_QUITE_BLACK + * @typedef {string} Color + */ exports.Colors = { DEFAULT: 0x000000, WHITE: 0xffffff, @@ -925,7 +1088,7 @@ exports.VerificationLevels = createEnum(['NONE', 'LOW', 'MEDIUM', 'HIGH', 'VERY_ * * MESSAGE_ALREADY_HAS_THREAD * * THREAD_LOCKED * * MAXIMUM_ACTIVE_THREADS - * * MAXIMUM_ACTIVE_ANNOUNCEMENT_THREAD + * * MAXIMUM_ACTIVE_ANNOUNCEMENT_THREADS * * INVALID_JSON_FOR_UPLOADED_LOTTIE_FILE * * UPLOADED_LOTTIES_CANNOT_CONTAIN_RASTERIZED_IMAGES * * STICKER_MAXIMUM_FRAMERATE_EXCEEDED @@ -1198,6 +1361,7 @@ exports.ApplicationCommandPermissionTypes = createEnum([null, 'ROLE', 'USER']); * * APPLICATION_COMMAND * * MESSAGE_COMPONENT * * APPLICATION_COMMAND_AUTOCOMPLETE + * * MODAL_SUBMIT * @typedef {string} InteractionType * @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type} */ @@ -1218,6 +1382,7 @@ exports.InteractionTypes = createEnum([ * * DEFERRED_MESSAGE_UPDATE * * UPDATE_MESSAGE * * APPLICATION_COMMAND_AUTOCOMPLETE_RESULT + * * MODAL * @typedef {string} InteractionResponseType * @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type} */ @@ -1380,38 +1545,58 @@ 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 + * @property {Object} ActivityTypes The type of an activity of a users presence. + * @property {Object} APIErrors An error encountered while performing an API request. + * @property {Object} ApplicationCommandOptionTypes * The type of an {@link ApplicationCommandOption} object. - * @property {ApplicationCommandPermissionType} ApplicationCommandPermissionTypes + * @property {Object} 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 + * @property {Object} ApplicationCommandTypes + * The type of an {@link ApplicationCommand} object. + * @property {Object} ChannelTypes All available channel types. + * @property {ClientApplicationAssetTypes} ClientApplicationAssetTypes The types of an {@link ApplicationAsset} object. + * @property {Object} Colors An object with regularly used colors. + * @property {Object} DefaultMessageNotificationLevels + * The value set for a guilds default message notifications. + * @property {Endpoints} Endpoints Object containing functions that return certain endpoints on the API. + * @property {Events} Events The types of events emitted by the Client. + * @property {Object} 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 {Object} GuildScheduledEventEntityTypes + * The entity type of a {@link GuildScheduledEvent} object. + * @property {Object} GuildScheduledEventPrivacyLevels + * Privacy level of a {@link GuildScheduledEvent} object. + * @property {Object} GuildScheduledEventStatuses + * The status of a {@link GuildScheduledEvent} object. + * @property {Object} IntegrationExpireBehaviors + * The behavior of expiring subscribers for Integrations. + * @property {Object} InteractionResponseTypes The type of an interaction response. + * @property {Object} InteractionTypes The type of an {@link Interaction} object. + * @property {InviteScope[]} InviteScopes The scopes of an invite. + * @property {Object} MembershipStates The value set for a team members membership state. + * @property {Object} MessageButtonStyles The style of a message button. + * @property {Object} MessageComponentTypes The type of a message component. + * @property {Object} MFALevels The required MFA level for a guild. + * @property {Object} NSFWLevels NSFW level of a guild. + * @property {Opcodes} Opcodes The types of Opcodes sent to the Gateway. + * @property {Object} OverwriteTypes An overwrite type. + * @property {Object} Package The package.json of the library. + * @property {Object} PartialTypes The type of Structure allowed to be a partial. + * @property {Object} PremiumTiers The premium tier (Server Boost level) of a guild. + * @property {Object} PrivacyLevels Privacy level of a {@link StageInstance} object. + * @property {ShardEvents} ShardEvents The type of events emitted by a Shard. * @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 {VideoQualityMode} VideoQualityModes The camera video quality mode for a {@link VoiceChannel}. - * @property {WebhookType} WebhookTypes The value set for a webhook's type. - * @property {WSEventType} WSEvents The type of a WebSocket message event. + * @property {Object} StickerFormatTypes The value set for a stickers format type. + * @property {Object} StickerTypes The value set for a stickers type. + * @property {SweeperKey[]} SweeperKeys The name of an item to be swept in Sweepers. + * @property {SystemMessageType[]} SystemMessageTypes The types of messages that are `System`. + * @property {Object} TextInputStyles The style of a text input component. + * @property {string} UserAgent The user agent used for requests. + * @property {Object} VerificationLevels + * The value set for the verification levels for a guild. + * @property {Object} VideoQualityModes + * The camera video quality mode for a {@link VoiceChannel}. + * @property {Object} WebhookTypes The value set for a webhooks type. + * @property {WSCodes} WSCodes The types of WebSocket error codes. + * @property {Object} WSEvents The type of a WebSocket message event. */ diff --git a/src/util/Util.js b/src/util/Util.js index 721e7e4..10f757e 100644 --- a/src/util/Util.js +++ b/src/util/Util.js @@ -430,43 +430,11 @@ class Util extends null { } /** - * Can be a number, hex string, an RGB array like: +* Can be a number, hex string, a {@link Color}, or an RGB array like: * ```js * [255, 0, 255] // purple * ``` - * or one of the following strings: - * - `DEFAULT` - * - `WHITE` - * - `AQUA` - * - `GREEN` - * - `BLUE` - * - `YELLOW` - * - `PURPLE` - * - `LUMINOUS_VIVID_PINK` - * - `FUCHSIA` - * - `GOLD` - * - `ORANGE` - * - `RED` - * - `GREY` - * - `NAVY` - * - `DARK_AQUA` - * - `DARK_GREEN` - * - `DARK_BLUE` - * - `DARK_PURPLE` - * - `DARK_VIVID_PINK` - * - `DARK_GOLD` - * - `DARK_ORANGE` - * - `DARK_RED` - * - `DARK_GREY` - * - `DARKER_GREY` - * - `LIGHT_GREY` - * - `DARK_NAVY` - * - `BLURPLE` - * - `GREYPLE` - * - `DARK_BUT_NOT_BLACK` - * - `NOT_QUITE_BLACK` - * - `RANDOM` - * @typedef {string|number|number[]} ColorResolvable +* @typedef {string|Color|number|number[]} ColorResolvable */ /** diff --git a/typings/index.d.ts b/typings/index.d.ts index bba08ee..6859ec2 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -3904,7 +3904,7 @@ export interface APIErrors { MAXIMUM_SERVER_MEMBERS: 30019; MAXIMUM_NUMBER_OF_SERVER_CATEGORIES: 30030; GUILD_ALREADY_HAS_TEMPLATE: 30031; - MAXIMUM_THREAD_PARICIPANTS: 30033; + MAXIMUM_THREAD_PARTICIPANTS: 30033; MAXIMUM_NON_GUILD_MEMBERS_BANS: 30035; MAXIMUM_BAN_FETCHES: 30037; MAXIMUM_NUMBER_OF_UNCOMPLETED_GUILD_SCHEDULED_EVENTS_REACHED: 30038; @@ -3956,7 +3956,7 @@ export interface APIErrors { PAYMENT_SOURCE_REQUIRED: 50070; CANNOT_DELETE_COMMUNITY_REQUIRED_CHANNEL: 50074; INVALID_STICKER_SENT: 50081; - INVALID_THREAD_ARCHIVE_STATE: 50083; + INVALID_OPERATION_ON_ARCHIVED_THREAD: 50083; INVALID_THREAD_NOTIFICATION_SETTINGS: 50084; PARAMETER_EARLIER_THAN_CREATION: 50085; GUILD_NOT_AVAILABLE_IN_LOCATION: 50095; @@ -4914,6 +4914,7 @@ export interface ConstantsShardEvents { INVALID_SESSION: 'invalidSession'; READY: 'ready'; RESUMED: 'resumed'; + ALL_READY: 'allReady'; } export interface ConstantsStatus { @@ -4923,6 +4924,9 @@ export interface ConstantsStatus { IDLE: 3; NEARLY: 4; DISCONNECTED: 5; + WAITING_FOR_GUILDS: 6; + IDENTIFYING: 7; + RESUMING: 8; } export interface CreateGuildScheduledEventInviteURLOptions extends CreateInviteOptions {