@@ -6,6 +6,17 @@ const { Error, RangeError, TypeError } = require('../errors');
6
6
7
7
exports . UserAgent = `DiscordBot (${ Package . homepage } , ${ Package . version } ) Node.js/${ process . version } ` ;
8
8
9
+ /**
10
+ * The types of WebSocket error codes:
11
+ * * 1000: WS_CLOSE_REQUESTED
12
+ * * 1011: INTERNAL_ERROR
13
+ * * 4004: TOKEN_INVALID
14
+ * * 4010: SHARDING_INVALID
15
+ * * 4011: SHARDING_REQUIRED
16
+ * * 4013: INVALID_INTENTS
17
+ * * 4014: DISALLOWED_INTENTS
18
+ * @typedef {Object<number, string> } WSCodes
19
+ */
9
20
exports . WSCodes = {
10
21
1000 : 'WS_CLOSE_REQUESTED' ,
11
22
1011 : 'INTERNAL_ERROR' ,
@@ -41,7 +52,11 @@ function makeImageUrl(root, { format = 'webp', size } = {}) {
41
52
* `4096`
42
53
*/
43
54
44
- // https://discord.com/developers/docs/reference#image-formatting-cdn-endpoints
55
+ /**
56
+ * An object containing functions that return certain endpoints on the API.
57
+ * @typedef {Object<string, Function|string> } Endpoints
58
+ * @see {@link https://discord.com/developers/docs/reference#image-formatting-cdn-endpoints }
59
+ */
45
60
exports . Endpoints = {
46
61
CDN ( root ) {
47
62
return {
@@ -98,7 +113,7 @@ exports.Endpoints = {
98
113
* * WAITING_FOR_GUILDS: 6
99
114
* * IDENTIFYING: 7
100
115
* * RESUMING: 8
101
- * @typedef {number } Status
116
+ * @typedef {Object<string, number> } Status
102
117
*/
103
118
exports . Status = {
104
119
READY : 0 ,
@@ -112,6 +127,22 @@ exports.Status = {
112
127
RESUMING : 8 ,
113
128
} ;
114
129
130
+ /**
131
+ * The Opcodes sent to the Gateway:
132
+ * * DISPATCH: 0
133
+ * * HEARTBEAT: 1
134
+ * * IDENTIFY: 2
135
+ * * STATUS_UPDATE: 3
136
+ * * VOICE_STATE_UPDATE: 4
137
+ * * VOICE_GUILD_PING: 5
138
+ * * RESUME: 6
139
+ * * RECONNECT: 7
140
+ * * REQUEST_GUILD_MEMBERS: 8
141
+ * * INVALID_SESSION: 9
142
+ * * HELLO: 10
143
+ * * HEARTBEAT_ACK: 11
144
+ * @typedef {Object<string, number> } Opcodes
145
+ */
115
146
exports . Opcodes = {
116
147
DISPATCH : 0 ,
117
148
HEARTBEAT : 1 ,
@@ -127,23 +158,93 @@ exports.Opcodes = {
127
158
HEARTBEAT_ACK : 11 ,
128
159
} ;
129
160
161
+ /**
162
+ * The types of events emitted by the Client:
163
+ * * RATE_LIMIT: rateLimit
164
+ * * INVALID_REQUEST_WARNING: invalidRequestWarning
165
+ * * API_RESPONSE: apiResponse
166
+ * * API_REQUEST: apiRequest
167
+ * * CLIENT_READY: ready
168
+ * * APPLICATION_COMMAND_CREATE: applicationCommandCreate (deprecated)
169
+ * * APPLICATION_COMMAND_DELETE: applicationCommandDelete (deprecated)
170
+ * * APPLICATION_COMMAND_UPDATE: applicationCommandUpdate (deprecated)
171
+ * * GUILD_CREATE: guildCreate
172
+ * * GUILD_DELETE: guildDelete
173
+ * * GUILD_UPDATE: guildUpdate
174
+ * * GUILD_UNAVAILABLE: guildUnavailable
175
+ * * GUILD_MEMBER_ADD: guildMemberAdd
176
+ * * GUILD_MEMBER_REMOVE: guildMemberRemove
177
+ * * GUILD_MEMBER_UPDATE: guildMemberUpdate
178
+ * * GUILD_MEMBER_AVAILABLE: guildMemberAvailable
179
+ * * GUILD_MEMBERS_CHUNK: guildMembersChunk
180
+ * * GUILD_INTEGRATIONS_UPDATE: guildIntegrationsUpdate
181
+ * * GUILD_ROLE_CREATE: roleCreate
182
+ * * GUILD_ROLE_DELETE: roleDelete
183
+ * * INVITE_CREATE: inviteCreate
184
+ * * INVITE_DELETE: inviteDelete
185
+ * * GUILD_ROLE_UPDATE: roleUpdate
186
+ * * GUILD_EMOJI_CREATE: emojiCreate
187
+ * * GUILD_EMOJI_DELETE: emojiDelete
188
+ * * GUILD_EMOJI_UPDATE: emojiUpdate
189
+ * * GUILD_BAN_ADD: guildBanAdd
190
+ * * GUILD_BAN_REMOVE: guildBanRemove
191
+ * * CHANNEL_CREATE: channelCreate
192
+ * * CHANNEL_DELETE: channelDelete
193
+ * * CHANNEL_UPDATE: channelUpdate
194
+ * * CHANNEL_PINS_UPDATE: channelPinsUpdate
195
+ * * MESSAGE_CREATE: messageCreate
196
+ * * MESSAGE_DELETE: messageDelete
197
+ * * MESSAGE_UPDATE: messageUpdate
198
+ * * MESSAGE_BULK_DELETE: messageDeleteBulk
199
+ * * MESSAGE_REACTION_ADD: messageReactionAdd
200
+ * * MESSAGE_REACTION_REMOVE: messageReactionRemove
201
+ * * MESSAGE_REACTION_REMOVE_ALL: messageReactionRemoveAll
202
+ * * MESSAGE_REACTION_REMOVE_EMOJI: messageReactionRemoveEmoji
203
+ * * THREAD_CREATE: threadCreate
204
+ * * THREAD_DELETE: threadDelete
205
+ * * THREAD_UPDATE: threadUpdate
206
+ * * THREAD_LIST_SYNC: threadListSync
207
+ * * THREAD_MEMBER_UPDATE: threadMemberUpdate
208
+ * * THREAD_MEMBERS_UPDATE: threadMembersUpdate
209
+ * * USER_UPDATE: userUpdate
210
+ * * PRESENCE_UPDATE: presenceUpdate
211
+ * * VOICE_SERVER_UPDATE: voiceServerUpdate
212
+ * * VOICE_STATE_UPDATE: voiceStateUpdate
213
+ * * TYPING_START: typingStart
214
+ * * WEBHOOKS_UPDATE: webhookUpdate
215
+ * * INTERACTION_CREATE: interactionCreate
216
+ * * ERROR: error
217
+ * * WARN: warn
218
+ * * DEBUG: debug
219
+ * * CACHE_SWEEP: cacheSweep
220
+ * * SHARD_DISCONNECT: shardDisconnect
221
+ * * SHARD_ERROR: shardError
222
+ * * SHARD_RECONNECTING: shardReconnecting
223
+ * * SHARD_READY: shardReady
224
+ * * SHARD_RESUME: shardResume
225
+ * * INVALIDATED: invalidated
226
+ * * RAW: raw
227
+ * * STAGE_INSTANCE_CREATE: stageInstanceCreate
228
+ * * STAGE_INSTANCE_UPDATE: stageInstanceUpdate
229
+ * * STAGE_INSTANCE_DELETE: stageInstanceDelete
230
+ * * GUILD_STICKER_CREATE: stickerCreate
231
+ * * GUILD_STICKER_DELETE: stickerDelete
232
+ * * GUILD_STICKER_UPDATE: stickerUpdate
233
+ * * GUILD_SCHEDULED_EVENT_CREATE: guildScheduledEventCreate
234
+ * * GUILD_SCHEDULED_EVENT_UPDATE: guildScheduledEventUpdate
235
+ * * GUILD_SCHEDULED_EVENT_DELETE: guildScheduledEventDelete
236
+ * * GUILD_SCHEDULED_EVENT_USER_ADD: guildScheduledEventUserAdd
237
+ * * GUILD_SCHEDULED_EVENT_USER_REMOVE: guildScheduledEventUserRemove
238
+ * @typedef {Object<string, string> } Events
239
+ */
130
240
exports . Events = {
131
241
RATE_LIMIT : 'rateLimit' ,
132
242
INVALID_REQUEST_WARNING : 'invalidRequestWarning' ,
133
243
API_RESPONSE : 'apiResponse' ,
134
244
API_REQUEST : 'apiRequest' ,
135
245
CLIENT_READY : 'ready' ,
136
- /**
137
- * @deprecated See {@link https://github.com/discord/discord-api-docs/issues/3690 this issue} for more information.
138
- */
139
246
APPLICATION_COMMAND_CREATE : 'applicationCommandCreate' ,
140
- /**
141
- * @deprecated See {@link https://github.com/discord/discord-api-docs/issues/3690 this issue} for more information.
142
- */
143
247
APPLICATION_COMMAND_DELETE : 'applicationCommandDelete' ,
144
- /**
145
- * @deprecated See {@link https://github.com/discord/discord-api-docs/issues/3690 this issue} for more information.
146
- */
147
248
APPLICATION_COMMAND_UPDATE : 'applicationCommandUpdate' ,
148
249
GUILD_CREATE : 'guildCreate' ,
149
250
GUILD_DELETE : 'guildDelete' ,
@@ -214,6 +315,16 @@ exports.Events = {
214
315
GUILD_SCHEDULED_EVENT_USER_REMOVE : 'guildScheduledEventUserRemove' ,
215
316
} ;
216
317
318
+ /**
319
+ * The types of events emitted by a Shard:
320
+ * * CLOSE: close
321
+ * * DESTROYED: destroyed
322
+ * * INVALID_SESSION: invalidSession
323
+ * * READY: ready
324
+ * * RESUMED: resumed
325
+ * * ALL_READY: allReady
326
+ * @typedef {Object<string, string> } ShardEvents
327
+ */
217
328
exports . ShardEvents = {
218
329
CLOSE : 'close' ,
219
330
DESTROYED : 'destroyed' ,
@@ -607,11 +718,51 @@ exports.ThreadChannelTypes = ['GUILD_NEWS_THREAD', 'GUILD_PUBLIC_THREAD', 'GUILD
607
718
*/
608
719
exports . VoiceBasedChannelTypes = [ 'GUILD_VOICE' , 'GUILD_STAGE_VOICE' ] ;
609
720
721
+ /**
722
+ * The types of assets of an application:
723
+ * * SMALL: 1
724
+ * * BIG: 2
725
+ * @typedef {Object<string, number> } ClientApplicationAssetTypes
726
+ */
610
727
exports . ClientApplicationAssetTypes = {
611
728
SMALL : 1 ,
612
729
BIG : 2 ,
613
730
} ;
614
731
732
+ /**
733
+ * A commonly used color:
734
+ * * DEFAULT
735
+ * * WHITE
736
+ * * AQUA
737
+ * * GREEN
738
+ * * BLUE
739
+ * * YELLOW
740
+ * * PURPLE
741
+ * * LUMINOUS_VIVID_PINK
742
+ * * FUCHSIA
743
+ * * GOLD
744
+ * * ORANGE
745
+ * * RED
746
+ * * GREY
747
+ * * NAVY
748
+ * * DARK_AQUA
749
+ * * DARK_GREEN
750
+ * * DARK_BLUE
751
+ * * DARK_PURPLE
752
+ * * DARK_VIVID_PINK
753
+ * * DARK_GOLD
754
+ * * DARK_ORANGE
755
+ * * DARK_RED
756
+ * * DARK_GREY
757
+ * * DARKER_GREY
758
+ * * LIGHT_GREY
759
+ * * DARK_NAVY
760
+ * * BLURPLE
761
+ * * GREYPLE
762
+ * * DARK_BUT_NOT_BLACK
763
+ * * NOT_QUITE_BLACK
764
+ * @typedef {string } Color
765
+ */
615
766
exports . Colors = {
616
767
DEFAULT : 0x000000 ,
617
768
WHITE : 0xffffff ,
@@ -802,7 +953,7 @@ exports.VerificationLevels = createEnum(['NONE', 'LOW', 'MEDIUM', 'HIGH', 'VERY_
802
953
* * MESSAGE_ALREADY_HAS_THREAD
803
954
* * THREAD_LOCKED
804
955
* * MAXIMUM_ACTIVE_THREADS
805
- * * MAXIMUM_ACTIVE_ANNOUNCEMENT_THREAD
956
+ * * MAXIMUM_ACTIVE_ANNOUNCEMENT_THREADS
806
957
* * INVALID_JSON_FOR_UPLOADED_LOTTIE_FILE
807
958
* * UPLOADED_LOTTIES_CANNOT_CONTAIN_RASTERIZED_IMAGES
808
959
* * STICKER_MAXIMUM_FRAMERATE_EXCEEDED
@@ -1074,6 +1225,7 @@ exports.ApplicationCommandPermissionTypes = createEnum([null, 'ROLE', 'USER']);
1074
1225
* * APPLICATION_COMMAND
1075
1226
* * MESSAGE_COMPONENT
1076
1227
* * APPLICATION_COMMAND_AUTOCOMPLETE
1228
+ * * MODAL_SUBMIT
1077
1229
* @typedef {string } InteractionType
1078
1230
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type }
1079
1231
*/
@@ -1094,6 +1246,7 @@ exports.InteractionTypes = createEnum([
1094
1246
* * DEFERRED_MESSAGE_UPDATE
1095
1247
* * UPDATE_MESSAGE
1096
1248
* * APPLICATION_COMMAND_AUTOCOMPLETE_RESULT
1249
+ * * MODAL
1097
1250
* @typedef {string } InteractionResponseType
1098
1251
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type }
1099
1252
*/
@@ -1115,6 +1268,7 @@ exports.InteractionResponseTypes = createEnum([
1115
1268
* * ACTION_ROW
1116
1269
* * BUTTON
1117
1270
* * SELECT_MENU
1271
+ * * TEXT_INPUT
1118
1272
* @typedef {string } MessageComponentType
1119
1273
* @see {@link https://discord.com/developers/docs/interactions/message-components#component-object-component-types }
1120
1274
*/
@@ -1210,6 +1364,7 @@ exports.GuildScheduledEventStatuses = createEnum([null, 'SCHEDULED', 'ACTIVE', '
1210
1364
* @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types }
1211
1365
*/
1212
1366
exports . GuildScheduledEventEntityTypes = createEnum ( [ null , 'STAGE_INSTANCE' , 'VOICE' , 'EXTERNAL' ] ) ;
1367
+ /* eslint-enable max-len */
1213
1368
1214
1369
/**
1215
1370
* The camera video quality mode of a {@link VoiceChannel}:
@@ -1219,7 +1374,6 @@ exports.GuildScheduledEventEntityTypes = createEnum([null, 'STAGE_INSTANCE', 'VO
1219
1374
* @see {@link https://discord.com/developers/docs/resources/channel#channel-object-video-quality-modes }
1220
1375
*/
1221
1376
exports . VideoQualityModes = createEnum ( [ null , 'AUTO' , 'FULL' ] ) ;
1222
- /* eslint-enable max-len */
1223
1377
1224
1378
exports . _cleanupSymbol = Symbol ( 'djsCleanup' ) ;
1225
1379
@@ -1241,38 +1395,58 @@ function createEnum(keys) {
1241
1395
1242
1396
/**
1243
1397
* @typedef {Object } Constants Constants that can be used in an enum or object-like way.
1244
- * @property {ActivityType } ActivityTypes The type of an activity of a users presence.
1245
- * @property {APIError } APIErrors An error encountered while performing an API request.
1246
- * @property {ApplicationCommandOptionType } ApplicationCommandOptionTypes
1398
+ * @property {Object< ActivityType, number> } ActivityTypes The type of an activity of a users presence.
1399
+ * @property {Object< APIError, number> } APIErrors An error encountered while performing an API request.
1400
+ * @property {Object< ApplicationCommandOptionType, number> } ApplicationCommandOptionTypes
1247
1401
* The type of an {@link ApplicationCommandOption} object.
1248
- * @property {ApplicationCommandPermissionType } ApplicationCommandPermissionTypes
1402
+ * @property {Object< ApplicationCommandPermissionType, number> } ApplicationCommandPermissionTypes
1249
1403
* The type of an {@link ApplicationCommandPermissions} object.
1250
- * @property {ChannelType } ChannelTypes All available channel types.
1251
- * @property {DefaultMessageNotificationLevel } DefaultMessageNotificationLevels
1252
- * The value set for a guild's default message notifications.
1253
- * @property {ExplicitContentFilterLevel } ExplicitContentFilterLevels
1404
+ * @property {Object<ApplicationCommandType, number> } ApplicationCommandTypes
1405
+ * The type of an {@link ApplicationCommand} object.
1406
+ * @property {Object<ChannelType, number> } ChannelTypes All available channel types.
1407
+ * @property {ClientApplicationAssetTypes } ClientApplicationAssetTypes The types of an {@link ApplicationAsset} object.
1408
+ * @property {Object<Color, number> } Colors An object with regularly used colors.
1409
+ * @property {Object<DefaultMessageNotificationLevel, number> } DefaultMessageNotificationLevels
1410
+ * The value set for a guilds default message notifications.
1411
+ * @property {Endpoints } Endpoints Object containing functions that return certain endpoints on the API.
1412
+ * @property {Events } Events The types of events emitted by the Client.
1413
+ * @property {Object<ExplicitContentFilterLevel, number> } ExplicitContentFilterLevels
1254
1414
* The value set for the explicit content filter levels for a guild.
1255
- * @property {GuildScheduledEventStatus } GuildScheduledEventStatuses The status of a {@link GuildScheduledEvent} object.
1256
- * @property {GuildScheduledEventEntityType } GuildScheduledEventEntityTypes The entity type of a
1257
- * {@link GuildScheduledEvent} object.
1258
- * @property {GuildScheduledEventPrivacyLevel } GuildScheduledEventPrivacyLevels Privacy level of a
1259
- * {@link GuildScheduledEvent} object.
1260
- * @property {InteractionResponseType } InteractionResponseTypes The type of an interaction response.
1261
- * @property {InteractionType } InteractionTypes The type of an {@link Interaction} object.
1262
- * @property {MembershipState } MembershipStates The value set for a team member's membership state.
1263
- * @property {MessageButtonStyle } MessageButtonStyles The style of a message button.
1264
- * @property {MessageComponentType } MessageComponentTypes The type of a message component.
1265
- * @property {MFALevel } MFALevels The required MFA level for a guild.
1266
- * @property {NSFWLevel } NSFWLevels NSFW level of a guild.
1267
- * @property {OverwriteType } OverwriteTypes An overwrite type.
1268
- * @property {PartialType } PartialTypes The type of Structure allowed to be a partial.
1269
- * @property {PremiumTier } PremiumTiers The premium tier (Server Boost level) of a guild.
1270
- * @property {PrivacyLevel } PrivacyLevels Privacy level of a {@link StageInstance} object.
1415
+ * @property {Object<GuildScheduledEventEntityType, number> } GuildScheduledEventEntityTypes
1416
+ * The entity type of a {@link GuildScheduledEvent} object.
1417
+ * @property {Object<GuildScheduledEventPrivacyLevel, number> } GuildScheduledEventPrivacyLevels
1418
+ * Privacy level of a {@link GuildScheduledEvent} object.
1419
+ * @property {Object<GuildScheduledEventStatus, number> } GuildScheduledEventStatuses
1420
+ * The status of a {@link GuildScheduledEvent} object.
1421
+ * @property {Object<IntegrationExpireBehavior, number> } IntegrationExpireBehaviors
1422
+ * The behavior of expiring subscribers for Integrations.
1423
+ * @property {Object<InteractionResponseType, number> } InteractionResponseTypes The type of an interaction response.
1424
+ * @property {Object<InteractionType, number> } InteractionTypes The type of an {@link Interaction} object.
1425
+ * @property {InviteScope[] } InviteScopes The scopes of an invite.
1426
+ * @property {Object<MembershipState, number> } MembershipStates The value set for a team members membership state.
1427
+ * @property {Object<MessageButtonStyle, number> } MessageButtonStyles The style of a message button.
1428
+ * @property {Object<MessageComponentType, number> } MessageComponentTypes The type of a message component.
1429
+ * @property {Object<MFALevel, number> } MFALevels The required MFA level for a guild.
1430
+ * @property {Object<NSFWLevel, number> } NSFWLevels NSFW level of a guild.
1431
+ * @property {Opcodes } Opcodes The types of Opcodes sent to the Gateway.
1432
+ * @property {Object<OverwriteType, number> } OverwriteTypes An overwrite type.
1433
+ * @property {Object } Package The package.json of the library.
1434
+ * @property {Object<PartialType, PartialType> } PartialTypes The type of Structure allowed to be a partial.
1435
+ * @property {Object<PremiumTier, number> } PremiumTiers The premium tier (Server Boost level) of a guild.
1436
+ * @property {Object<PrivacyLevel, number> } PrivacyLevels Privacy level of a {@link StageInstance} object.
1437
+ * @property {ShardEvents } ShardEvents The type of events emitted by a Shard.
1271
1438
* @property {Status } Status The available statuses of the client.
1272
- * @property {StickerFormatType } StickerFormatTypes The value set for a sticker's format type.
1273
- * @property {StickerType } StickerTypes The value set for a sticker's type.
1274
- * @property {VerificationLevel } VerificationLevels The value set for the verification levels for a guild.
1275
- * @property {VideoQualityMode } VideoQualityModes The camera video quality mode for a {@link VoiceChannel}.
1276
- * @property {WebhookType } WebhookTypes The value set for a webhook's type.
1277
- * @property {WSEventType } WSEvents The type of a WebSocket message event.
1439
+ * @property {Object<StickerFormatType, number> } StickerFormatTypes The value set for a stickers format type.
1440
+ * @property {Object<StickerType, number> } StickerTypes The value set for a stickers type.
1441
+ * @property {SweeperKey[] } SweeperKeys The name of an item to be swept in Sweepers.
1442
+ * @property {SystemMessageType[] } SystemMessageTypes The types of messages that are `System`.
1443
+ * @property {Object<TextInputStyle, number> } TextInputStyles The style of a text input component.
1444
+ * @property {string } UserAgent The user agent used for requests.
1445
+ * @property {Object<VerificationLevel, number> } VerificationLevels
1446
+ * The value set for the verification levels for a guild.
1447
+ * @property {Object<VideoQualityMode, number> } VideoQualityModes
1448
+ * The camera video quality mode for a {@link VoiceChannel}.
1449
+ * @property {Object<WebhookType, number> } WebhookTypes The value set for a webhooks type.
1450
+ * @property {WSCodes } WSCodes The types of WebSocket error codes.
1451
+ * @property {Object<WSEventType, WSEventType> } WSEvents The type of a WebSocket message event.
1278
1452
*/
0 commit comments