@wolfstar/http-framework 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3354 @@
1
+ import { AliasPiece, AliasStore, LoaderError, LoaderStrategy, MissingExportsError, Piece, Piece as Piece$1, Store, Store as Store$1, StoreRegistry, container, container as container$1 } from "@sapphire/pieces";
2
+ import { REST, makeURLSearchParams } from "@discordjs/rest";
3
+ import { isFunction, isNullish, isNullishOrEmpty } from "@sapphire/utilities";
4
+ import { AsyncEventEmitter } from "@vladfrangu/async_event_emitter";
5
+ import { ApplicationCommandOptionType, ApplicationCommandType, ComponentType, InteractionResponseType, InteractionType, Routes } from "discord-api-types/v10";
6
+ import { createServer } from "node:http";
7
+ import { Result, err, ok } from "@sapphire/result";
8
+ import { Collection } from "@discordjs/collection";
9
+ import { ContextMenuCommandBuilder, SlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from "@discordjs/builders";
10
+ import { isJSONEncodable } from "@discordjs/util";
11
+ import { webcrypto } from "node:crypto";
12
+ import { TextDecoder } from "node:util";
13
+
14
+ //#region src/lib/api/HttpCodes.ts
15
+ let HttpCodes = /* @__PURE__ */ function(HttpCodes) {
16
+ /**
17
+ * Standard response for successful HTTP requests. The actual response will
18
+ * depend on the request method used. In a GET request, the response will
19
+ * contain an entity corresponding to the requested resource. In a POST
20
+ * request, the response will contain an entity describing or containing the
21
+ * result of the action.
22
+ */
23
+ HttpCodes[HttpCodes["OK"] = 200] = "OK";
24
+ /**
25
+ * The request has been fulfilled, resulting in the creation of a new
26
+ * resource.
27
+ */
28
+ HttpCodes[HttpCodes["Created"] = 201] = "Created";
29
+ /**
30
+ * The request has been accepted for processing, but the processing has not
31
+ * been completed. The request might or might not be eventually acted upon,
32
+ * and may be disallowed when processing occurs.
33
+ */
34
+ HttpCodes[HttpCodes["Accepted"] = 202] = "Accepted";
35
+ /**
36
+ * The server is a transforming proxy (e.g. a Web accelerator) that received
37
+ * a 200 OK from its origin, but is returning a modified version of the
38
+ * origin's response.
39
+ */
40
+ HttpCodes[HttpCodes["NonAuthoritativeInformation"] = 203] = "NonAuthoritativeInformation";
41
+ /**
42
+ * The server successfully processed the request, and is not returning any
43
+ * content.
44
+ */
45
+ HttpCodes[HttpCodes["NoContent"] = 204] = "NoContent";
46
+ /**
47
+ * The server successfully processed the request, asks that the requester
48
+ * reset its document view, and is not returning any content.
49
+ */
50
+ HttpCodes[HttpCodes["ResetContent"] = 205] = "ResetContent";
51
+ /**
52
+ * (RFC 7233) The server is delivering only part of the resource (byte
53
+ * serving) due to a range header sent by the client. The range header is
54
+ * used by HTTP clients to enable resuming of interrupted downloads, or
55
+ * split a download into multiple simultaneous streams.
56
+ */
57
+ HttpCodes[HttpCodes["PartialContent"] = 206] = "PartialContent";
58
+ /**
59
+ * (WebDAV; RFC 4918) The message body that follows is by default an XML
60
+ * message and can contain a number of separate response codes, depending on
61
+ * how many sub-requests were made.
62
+ */
63
+ HttpCodes[HttpCodes["MultiStatus"] = 207] = "MultiStatus";
64
+ /**
65
+ * (WebDAV; RFC 5842) The members of a DAV binding have already been
66
+ * enumerated in a preceding part of the (multistatus) response, and are not
67
+ * being included again.
68
+ */
69
+ HttpCodes[HttpCodes["AlreadyReported"] = 208] = "AlreadyReported";
70
+ /**
71
+ * (RFC 3229) The server has fulfilled a request for the resource, and the
72
+ * response is a representation of the result of one or more
73
+ * instance-manipulations applied to the current instance.
74
+ */
75
+ HttpCodes[HttpCodes["IMUsed"] = 226] = "IMUsed";
76
+ /**
77
+ * Indicates multiple options for the resource from which the client may
78
+ * choose (via agent-driven content negotiation). For example, this code
79
+ * could be used to present multiple video format options, to list files
80
+ * with different filename extensions, or to suggest word-sense
81
+ * disambiguation.
82
+ */
83
+ HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices";
84
+ /**
85
+ * This and all future requests should be directed to the given URI.
86
+ */
87
+ HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently";
88
+ /**
89
+ * (Previously "Moved temporarily") Tells the client to look at (browse to)
90
+ * another URL. 302 has been superseded by 303 and 307. This is an example
91
+ * of industry practice contradicting the standard. The HTTP/1.0
92
+ * specification (RFC 1945) required the client to perform a temporary
93
+ * redirect (the original describing phrase was "Moved Temporarily"), but
94
+ * popular browsers implemented 302 with the functionality of a 303 See
95
+ * Other. Therefore, HTTP/1.1 added status codes 303 and 307 to distinguish
96
+ * between the two behaviours. However, some Web applications and frameworks
97
+ * use the 302 status code as if it were the 303.
98
+ */
99
+ HttpCodes[HttpCodes["Found"] = 302] = "Found";
100
+ /**
101
+ * The response to the request can be found under another URI using the GET
102
+ * method. When received in response to a POST (or PUT/DELETE), the client
103
+ * should presume that the server has received the data and should issue a
104
+ * new GET request to the given URI.
105
+ */
106
+ HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther";
107
+ /**
108
+ * (RFC 7232) Indicates that the resource has not been modified since the
109
+ * version specified by the request headers If-Modified-Since or
110
+ * If-None-Match. In such case, there is no need to retransmit the resource
111
+ * since the client still has a previously-downloaded copy.
112
+ */
113
+ HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified";
114
+ /**
115
+ * The requested resource is available only through a proxy, the address for
116
+ * which is provided in the response. For security reasons, many HTTP
117
+ * clients (such as Mozilla Firefox and Internet Explorer) do not obey this
118
+ * status code.
119
+ */
120
+ HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy";
121
+ /**
122
+ * No longer used. Originally meant "Subsequent requests should use the
123
+ * specified proxy.".
124
+ */
125
+ HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy";
126
+ /**
127
+ * In this case, the request should be repeated with another URI; however,
128
+ * future requests should still use the original URI. In contrast to how 302
129
+ * was historically implemented, the request method is not allowed to be
130
+ * changed when reissuing the original request. For example, a POST request
131
+ * should be repeated using another POST request.
132
+ */
133
+ HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect";
134
+ /**
135
+ * (RFC 7538) The request and all future requests should be repeated using
136
+ * another URI. 307 and 308 parallel the behaviors of 302 and 301, but do
137
+ * not allow the HTTP method to change. So, for example, submitting a form
138
+ * to a permanently redirected resource may continue smoothly.
139
+ */
140
+ HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect";
141
+ /**
142
+ * The server cannot or will not process the request due to an apparent
143
+ * client error (e.g., malformed request syntax, size too large, invalid
144
+ * request message framing, or deceptive request routing).
145
+ */
146
+ HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest";
147
+ /**
148
+ * (RFC 7235) Similar to 403 Forbidden, but specifically for use when
149
+ * authentication is required and has failed or has not yet been provided.
150
+ * The response must include a WWW-Authenticate header field containing a
151
+ * challenge applicable to the requested resource. See Basic access
152
+ * authentication and Digest access authentication. 401 semantically means
153
+ * "unauthorised", the user does not have valid authentication credentials
154
+ * for the target resource.
155
+ */
156
+ HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized";
157
+ /**
158
+ * Reserved for future use. The original intention was that this code might
159
+ * be used as part of some form of digital cash or micropayment scheme, as
160
+ * proposed, for example, by GNU Taler, but that has not yet happened, and
161
+ * this code is not widely used. Google Developers API uses this status if a
162
+ * particular developer has exceeded the daily limit on requests. Sipgate
163
+ * uses this code if an account does not have sufficient funds to start a
164
+ * call. Shopify uses this code when the store has not paid their fees and
165
+ * is temporarily disabled. Stripe uses this code for failed payments where
166
+ * parameters were correct, for example blocked fraudulent payments.
167
+ */
168
+ HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired";
169
+ /**
170
+ * The request contained valid data and was understood by the server, but
171
+ * the server is refusing action. This may be due to the user not having the
172
+ * necessary permissions for a resource or needing an account of some sort,
173
+ * or attempting a prohibited action (e.g. creating a duplicate record
174
+ * where only one is allowed). This code is also typically used if the
175
+ * request provided authentication by answering the WWW-Authenticate header
176
+ * field challenge, but the server did not accept that authentication. The
177
+ * request should not be repeated.
178
+ */
179
+ HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden";
180
+ /**
181
+ * The requested resource could not be found but may be available in the
182
+ * future. Subsequent requests by the client are permissible.
183
+ */
184
+ HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound";
185
+ /**
186
+ * A request method is not supported for the requested resource; for example,
187
+ * a GET request on a form that requires data to be presented via POST, or a
188
+ * PUT request on a read-only resource.
189
+ */
190
+ HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed";
191
+ /**
192
+ * The requested resource is capable of generating only content not
193
+ * acceptable according to the Accept headers sent in the request. See Content negotiation.
194
+ */
195
+ HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable";
196
+ /**
197
+ * (RFC 7235) The client must first authenticate itself with the proxy.
198
+ */
199
+ HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
200
+ /**
201
+ * The server timed out waiting for the request. According to HTTP
202
+ * specifications: "The client did not produce a request within the time
203
+ * that the server was prepared to wait. The client MAY repeat the request
204
+ * without modifications at any later time."
205
+ */
206
+ HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
207
+ /**
208
+ * Indicates that the request could not be processed because of conflict in
209
+ * the current state of the resource, such as an edit conflict between
210
+ * multiple simultaneous updates.
211
+ */
212
+ HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
213
+ /**
214
+ * Indicates that the resource requested is no longer available and will not
215
+ * be available again. This should be used when a resource has been
216
+ * intentionally removed and the resource should be purged. Upon receiving a
217
+ * 410 status code, the client should not request the resource in the future.
218
+ * Clients such as search engines should remove the resource from their
219
+ * indices. Most use cases do not require clients and search engines to
220
+ * purge the resource, and a "404 Not Found" may be used instead.
221
+ */
222
+ HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
223
+ /**
224
+ * The request did not specify the length of its content, which is required
225
+ * by the requested resource.
226
+ */
227
+ HttpCodes[HttpCodes["LengthRequired"] = 411] = "LengthRequired";
228
+ /**
229
+ * (RFC 7232) The server does not meet one of the preconditions that the
230
+ * requester put on the request header fields.
231
+ */
232
+ HttpCodes[HttpCodes["PreconditionFailed"] = 412] = "PreconditionFailed";
233
+ /**
234
+ * (RFC 7231) The request is larger than the server is willing or able to
235
+ * process. Previously called "Request Entity Too Large".
236
+ */
237
+ HttpCodes[HttpCodes["PayloadTooLarge"] = 413] = "PayloadTooLarge";
238
+ /**
239
+ * (RFC 7231) The URI provided was too long for the server to process. Often
240
+ * the result of too much data being encoded as a query-string of a GET
241
+ * request, in which case it should be converted to a POST request. Called
242
+ * "Request-URI Too Long" previously.
243
+ */
244
+ HttpCodes[HttpCodes["URITooLong"] = 414] = "URITooLong";
245
+ /**
246
+ * (RFC 7231) The request entity has a media type which the server or
247
+ * resource does not support. For example, the client uploads an image as
248
+ * image/svg+xml, but the server requires that images use a different format.
249
+ */
250
+ HttpCodes[HttpCodes["UnsupportedMediaType"] = 415] = "UnsupportedMediaType";
251
+ /**
252
+ * (RFC 7233) The client has asked for a portion of the file (byte serving),
253
+ * but the server cannot supply that portion. For example, if the client
254
+ * asked for a part of the file that lies beyond the end of the file. Called
255
+ * "Requested Range Not Satisfiable" previously.
256
+ */
257
+ HttpCodes[HttpCodes["RangeNotSatisfiable"] = 416] = "RangeNotSatisfiable";
258
+ /**
259
+ * The server cannot meet the requirements of the Expect request-header
260
+ * field.
261
+ */
262
+ HttpCodes[HttpCodes["ExpectationFailed"] = 417] = "ExpectationFailed";
263
+ /**
264
+ * (RFC 2324, RFC 7168) This code was defined in 1998 as one of the
265
+ * traditional IETF April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot
266
+ * Control Protocol, and is not expected to be implemented by actual HTTP
267
+ * servers. The RFC specifies this code should be returned by teapots
268
+ * requested to brew coffee. This HTTP status is used as an Easter egg in
269
+ * some websites, such as Google.com's I'm a teapot easter egg.
270
+ */
271
+ HttpCodes[HttpCodes["IAmATeapot"] = 418] = "IAmATeapot";
272
+ /**
273
+ * Returned by the Twitter Search and Trends API when the client is being rate limited.
274
+ * The text is a quote from 'Demolition Man' and the '420' code is likely a reference
275
+ * to this number's association with marijuana. Other services may wish to implement
276
+ * the 429 Too Many Requests response code instead.
277
+ */
278
+ HttpCodes[HttpCodes["EnhanceYourCalm"] = 420] = "EnhanceYourCalm";
279
+ /**
280
+ * (RFC 7540) The request was directed at a server that is not able to
281
+ * produce a response (for example because of connection reuse).
282
+ */
283
+ HttpCodes[HttpCodes["MisdirectedRequest"] = 421] = "MisdirectedRequest";
284
+ /**
285
+ * (WebDAV; RFC 4918) The request was well-formed but was unable to be
286
+ * followed due to semantic errors.
287
+ */
288
+ HttpCodes[HttpCodes["UnprocessableEntity"] = 422] = "UnprocessableEntity";
289
+ /**
290
+ * (WebDAV; RFC 4918) The resource that is being accessed is locked.
291
+ */
292
+ HttpCodes[HttpCodes["Locked"] = 423] = "Locked";
293
+ /**
294
+ * (WebDAV; RFC 4918) The request failed because it depended on another
295
+ * request and that request failed (e.g., a PROPPATCH).
296
+ */
297
+ HttpCodes[HttpCodes["FailedDependency"] = 424] = "FailedDependency";
298
+ /**
299
+ * (RFC 8470) Indicates that the server is unwilling to risk processing a
300
+ * request that might be replayed.
301
+ */
302
+ HttpCodes[HttpCodes["TooEarly"] = 425] = "TooEarly";
303
+ /**
304
+ * The client should switch to a different protocol such as TLS/1.0, given
305
+ * in the Upgrade header field.
306
+ */
307
+ HttpCodes[HttpCodes["UpgradeRequired"] = 426] = "UpgradeRequired";
308
+ /**
309
+ * (RFC 6585) The origin server requires the request to be conditional.
310
+ * Intended to prevent the 'lost update' problem, where a client GETs a
311
+ * resource's state, modifies it, and PUTs it back to the server, when
312
+ * meanwhile a third party has modified the state on the server, leading to
313
+ * a conflict.
314
+ */
315
+ HttpCodes[HttpCodes["PreconditionRequired"] = 428] = "PreconditionRequired";
316
+ /**
317
+ * (RFC 6585) The user has sent too many requests in a given amount of time.
318
+ * Intended for use with rate-limiting schemes.
319
+ */
320
+ HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests";
321
+ /**
322
+ * (RFC 6585) The server is unwilling to process the request because either
323
+ * an individual header field, or all the header fields collectively, are
324
+ * too large.
325
+ */
326
+ HttpCodes[HttpCodes["RequestHeaderFieldsTooLarge"] = 431] = "RequestHeaderFieldsTooLarge";
327
+ /**
328
+ * (RFC 7725) A server operator has received a legal demand to deny access
329
+ * to a resource or to a set of resources that includes the requested
330
+ * resource. The code 451 was chosen as a reference to the novel Fahrenheit
331
+ * 451 (see the Acknowledgements in the RFC).
332
+ */
333
+ HttpCodes[HttpCodes["UnavailableForLegalReasons"] = 451] = "UnavailableForLegalReasons";
334
+ /**
335
+ * A generic error message, given when an unexpected condition was
336
+ * encountered and no more specific message is suitable.
337
+ */
338
+ HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
339
+ /**
340
+ * The server either does not recognize the request method, or it lacks the
341
+ * ability to fulfil the request. Usually this implies future availability
342
+ * (e.g., a new feature of a web-service API).
343
+ */
344
+ HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
345
+ /**
346
+ * The server was acting as a gateway or proxy and received an invalid
347
+ * response from the upstream server.
348
+ */
349
+ HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
350
+ /**
351
+ * The server cannot handle the request (because it is overloaded or down
352
+ * for maintenance). Generally, this is a temporary state.
353
+ */
354
+ HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable";
355
+ /**
356
+ * The server was acting as a gateway or proxy and did not receive a timely
357
+ * response from the upstream server.
358
+ */
359
+ HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout";
360
+ /**
361
+ * The server does not support the HTTP protocol version used in the request.
362
+ */
363
+ HttpCodes[HttpCodes["HTTPVersionNotSupported"] = 505] = "HTTPVersionNotSupported";
364
+ /**
365
+ * (RFC 2295) Transparent content negotiation for the request results in a
366
+ * circular reference.
367
+ */
368
+ HttpCodes[HttpCodes["VariantAlsoNegotiates"] = 506] = "VariantAlsoNegotiates";
369
+ /**
370
+ * (WebDAV; RFC 4918) The server is unable to store the representation
371
+ * needed to complete the request.
372
+ */
373
+ HttpCodes[HttpCodes["InsufficientStorage"] = 507] = "InsufficientStorage";
374
+ /**
375
+ * (WebDAV; RFC 5842) The server detected an infinite loop while processing
376
+ * the request (sent instead of 208 Already Reported).
377
+ */
378
+ HttpCodes[HttpCodes["LoopDetected"] = 508] = "LoopDetected";
379
+ /**
380
+ * (RFC 2774) Further extensions to the request are required for the server
381
+ * to fulfil it.
382
+ */
383
+ HttpCodes[HttpCodes["NotExtended"] = 510] = "NotExtended";
384
+ /**
385
+ * (RFC 6585) The client needs to authenticate to gain network access.
386
+ * Intended for use by intercepting proxies used to control access to the
387
+ * network (e.g., "captive portals" used to require agreement to Terms of
388
+ * Service before granting full Internet access via a Wi-Fi hotspot).
389
+ */
390
+ HttpCodes[HttpCodes["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
391
+ return HttpCodes;
392
+ }({});
393
+
394
+ //#endregion
395
+ //#region src/lib/components/StringIdParser.ts
396
+ var StringIdParser = class {
397
+ run(customId) {
398
+ if (customId.length === 0) return null;
399
+ const index = customId.indexOf(".");
400
+ if (index === -1) return {
401
+ name: customId,
402
+ content: null
403
+ };
404
+ return {
405
+ name: customId.slice(0, index),
406
+ content: customId.slice(index + 1).split(".").map((contentEntry) => contentEntry || null)
407
+ };
408
+ }
409
+ };
410
+
411
+ //#endregion
412
+ //#region src/lib/interactions/decorators/_shared.ts
413
+ function ensureChatInputCommandResolver(target) {
414
+ return container$1.applicationCommandRegistry.ensure(target).makeChatInput();
415
+ }
416
+ function ensureContextMenuCommandResolver(target) {
417
+ return container$1.applicationCommandRegistry.ensure(target).makeContextMenu();
418
+ }
419
+
420
+ //#endregion
421
+ //#region src/lib/interactions/decorators/RegisterCommand.ts
422
+ /**
423
+ * Registers a command for the chat input.
424
+ *
425
+ * @template Options - The options type for the command.
426
+ * @param data - The command data.
427
+ * @example
428
+ * ```typescript
429
+ * import { Command, RegisterCommand } from '@wolfstar/http-framework';
430
+ *
431
+ * (at)RegisterCommand({
432
+ * name: 'ping',
433
+ * description: 'A simple ping pong command'
434
+ * })
435
+ * export class UserCommand extends Command {
436
+ * public async run(interaction: Command.ChatInputInteraction) {
437
+ * return interaction.reply('Pong!');
438
+ * }
439
+ * }
440
+ * ```
441
+ */
442
+ function RegisterCommand(data) {
443
+ return function decorate(target) {
444
+ ensureChatInputCommandResolver(target).setCommand(data);
445
+ };
446
+ }
447
+
448
+ //#endregion
449
+ //#region src/lib/interactions/decorators/RegisterMessageCommand.ts
450
+ /**
451
+ * Registers a message command.
452
+ *
453
+ * @template Options - The options type for the command.
454
+ * @param data - The command to register.
455
+ * @returns A method decorator function, does not override the method.
456
+ * @example
457
+ * ```typescript
458
+ * export class UserCommand extends Command {
459
+ * (at)RegisterMessageCommand(createData())
460
+ * public run(interaction: Command.MessageInteraction, data: TransformedArguments.Message) {
461
+ * // ...
462
+ * }
463
+ * }
464
+ * ```
465
+ */
466
+ function RegisterMessageCommand(data) {
467
+ return function decorate(target, method) {
468
+ ensureContextMenuCommandResolver(target.constructor).setCommand(data, ApplicationCommandType.Message, method);
469
+ };
470
+ }
471
+
472
+ //#endregion
473
+ //#region src/lib/interactions/decorators/RegisterSubcommand.ts
474
+ /**
475
+ * Registers a subcommand for a chat input command.
476
+ *
477
+ * @remarks This decorator must be used in conjunction with {@link RegisterSubcommand}.
478
+ * @param data - The subcommand data.
479
+ * @param subCommandGroupName - Optional name of the subcommand group.
480
+ * @returns A decorator function that adds the subcommand to the target command.
481
+ * @example
482
+ * ```typescript
483
+ * import { Command, RegisterCommand, RegisterSubcommand, RegisterSubcommandGroup } from '@wolfstar/http-framework';
484
+ *
485
+ * (at)RegisterCommand({
486
+ * name: 'ping',
487
+ * description: 'A simple ping pong command'
488
+ * })
489
+ * export class UserCommand extends Command {
490
+ * (at)RegisterSubcommand({
491
+ * name: 'subcommand',
492
+ * description: 'A simple subcommand'
493
+ * })
494
+ * public async run(interaction: Command.ChatInputInteraction) {
495
+ * return interaction.reply('Pong!');
496
+ * }
497
+ * }
498
+ * ```
499
+ */
500
+ function RegisterSubcommand(data, subCommandGroupName) {
501
+ return function decorate(target, method) {
502
+ ensureChatInputCommandResolver(target.constructor).addSubcommand(data, method, subCommandGroupName);
503
+ };
504
+ }
505
+
506
+ //#endregion
507
+ //#region src/lib/interactions/decorators/RegisterSubcommandGroup.ts
508
+ /**
509
+ * Registers a subcommand group for a chat input command.
510
+ *
511
+ * @remarks This decorator must be used in conjunction with {@link RegisterSubcommand}.
512
+ * @template Options - The options type for the command.
513
+ * @param data - The subcommand group data.
514
+ * @example
515
+ * ```typescript
516
+ * import { Command, RegisterCommand, RegisterSubcommand, RegisterSubcommandGroup } from '@wolfstar/http-framework';
517
+ *
518
+ * (at)RegisterCommand({
519
+ * name: 'ping',
520
+ * description: 'A simple ping pong command'
521
+ * })
522
+ * export class UserCommand extends Command {
523
+ * (at)RegisterSubcommandGroup({
524
+ * name: 'subcommand-group',
525
+ * description: 'A simple subcommand group'
526
+ * })
527
+ * (at)RegisterSubcommand(
528
+ * { name: 'subcommand', description: 'A simple subcommand' },
529
+ * 'subcommand-group'
530
+ * )
531
+ * public async run(interaction: Command.ChatInputInteraction) {
532
+ * return interaction.reply('Pong!');
533
+ * }
534
+ * }
535
+ * ```
536
+ */
537
+ function RegisterSubcommandGroup(data) {
538
+ return function decorate(target, method) {
539
+ ensureChatInputCommandResolver(target.constructor).addSubcommandGroup(data, method);
540
+ };
541
+ }
542
+
543
+ //#endregion
544
+ //#region src/lib/interactions/decorators/RegisterUserCommand.ts
545
+ /**
546
+ * Registers a user command.
547
+ *
548
+ * @template Options - The options type for the command.
549
+ * @param data - The command to register.
550
+ * @returns A method decorator function, does not override the method.
551
+ * @example
552
+ * ```typescript
553
+ * export class UserCommand extends Command {
554
+ * (at)RegisterUserCommand(createData())
555
+ * public run(interaction: Command.UserInteraction, data: TransformedArguments.User) {
556
+ * // ...
557
+ * }
558
+ * }
559
+ * ```
560
+ */
561
+ function RegisterUserCommand(data) {
562
+ return function decorate(target, method) {
563
+ ensureContextMenuCommandResolver(target.constructor).setCommand(data, ApplicationCommandType.User, method);
564
+ };
565
+ }
566
+
567
+ //#endregion
568
+ //#region src/lib/interactions/decorators/RestrictGuildIds.ts
569
+ const restrictedGuildIdRegistry = new Collection();
570
+ /**
571
+ * Decorator that restricts the guild IDs for a command.
572
+ *
573
+ * @param guildIds An array of guild IDs to restrict the command to.
574
+ * @returns A decorator function.
575
+ * @example
576
+ * ```typescript
577
+ * import { Command, RegisterCommand, RestrictGuildIds } from '@wolfstar/http-framework';
578
+ *
579
+ * (at)RegisterCommand({
580
+ * name: 'ping',
581
+ * description: 'A simple ping pong command'
582
+ * })
583
+ * (at)RestrictGuildIds(['123456789012345678', '123456789012345679'])
584
+ * export class UserCommand extends Command {
585
+ * public async run(interaction: Command.ChatInputInteraction) {
586
+ * return interaction.reply('Pong!');
587
+ * }
588
+ * }
589
+ * ```
590
+ */
591
+ function RestrictGuildIds(guildIds) {
592
+ return function decorate(target) {
593
+ restrictedGuildIdRegistry.set(target, guildIds);
594
+ };
595
+ }
596
+
597
+ //#endregion
598
+ //#region src/lib/interactions/resolvers/InteractionOptions.ts
599
+ function transformInteraction(resolved, options) {
600
+ const extracted = extractTopLevelOptions(options);
601
+ return {
602
+ subCommand: extracted.subCommand?.name ?? null,
603
+ subCommandGroup: extracted.subCommandGroup?.name ?? null,
604
+ ...transformArguments(resolved, extracted.options)
605
+ };
606
+ }
607
+ function transformAutocompleteInteraction(resolved, options) {
608
+ const extracted = extractTopLevelOptions(options);
609
+ const focused = extracted.options.find((option) => option.focused);
610
+ return {
611
+ subCommand: extracted.subCommand?.name ?? null,
612
+ subCommandGroup: extracted.subCommandGroup?.name ?? null,
613
+ focused: typeof focused === "undefined" ? null : focused.name,
614
+ ...transformArguments(resolved, extracted.options)
615
+ };
616
+ }
617
+ function extractTopLevelOptions(options) {
618
+ if (options.length) {
619
+ const [firstOption] = options;
620
+ if (firstOption.type === ApplicationCommandOptionType.SubcommandGroup) {
621
+ const subCommand = firstOption.options[0];
622
+ return {
623
+ subCommandGroup: firstOption,
624
+ subCommand,
625
+ options: subCommand.options ?? []
626
+ };
627
+ }
628
+ if (firstOption.type === ApplicationCommandOptionType.Subcommand) return {
629
+ subCommandGroup: null,
630
+ subCommand: firstOption,
631
+ options: firstOption.options ?? []
632
+ };
633
+ }
634
+ return {
635
+ subCommandGroup: null,
636
+ subCommand: null,
637
+ options
638
+ };
639
+ }
640
+ function transformArguments(resolved, options) {
641
+ return Object.fromEntries(options.map((option) => [option.name, transformArgument(resolved, option)]));
642
+ }
643
+ function transformArgument(resolved, option) {
644
+ switch (option.type) {
645
+ case ApplicationCommandOptionType.Attachment: return resolved.attachments?.[option.value] ?? { id: option.value };
646
+ case ApplicationCommandOptionType.Channel: return resolved.channels?.[option.value] ?? { id: option.value };
647
+ case ApplicationCommandOptionType.Mentionable: return transformMentionable(resolved, option);
648
+ case ApplicationCommandOptionType.Role: return resolved.roles?.[option.value] ?? { id: option.value };
649
+ case ApplicationCommandOptionType.User: return {
650
+ id: option.value,
651
+ user: resolved.users?.[option.value] ?? null,
652
+ member: resolved.members?.[option.value] ?? null
653
+ };
654
+ default: return option.value;
655
+ }
656
+ }
657
+ function transformMentionable(resolved, option) {
658
+ const id = option.value;
659
+ const user = resolved.users?.[id];
660
+ if (user) return {
661
+ id,
662
+ user,
663
+ member: resolved.members?.[id] ?? null
664
+ };
665
+ const channel = resolved.channels?.[id];
666
+ if (channel) return {
667
+ id,
668
+ channel
669
+ };
670
+ const role = resolved.roles?.[id];
671
+ if (role) return {
672
+ id,
673
+ role
674
+ };
675
+ return { id };
676
+ }
677
+ function transformUserInteraction(data) {
678
+ return {
679
+ id: data.target_id,
680
+ user: data.resolved.users[data.target_id],
681
+ member: data.resolved.members?.[data.target_id] ?? null
682
+ };
683
+ }
684
+ function transformMessageInteraction(data) {
685
+ return {
686
+ id: data.target_id,
687
+ message: data.resolved.messages[data.target_id]
688
+ };
689
+ }
690
+
691
+ //#endregion
692
+ //#region src/lib/interactions/shared/link.ts
693
+ const linkSymbol = Symbol("decorated-command.method.link");
694
+ /**
695
+ * Links the specified object with a name.
696
+ *
697
+ * @template T - The type of the object.
698
+ * @param object - The object to link.
699
+ * @param name - The name to link the object with.
700
+ * @returns The linked object.
701
+ * @internal
702
+ */
703
+ function linkMethod(object, name) {
704
+ Object.defineProperty(object, linkSymbol, { value: name });
705
+ return object;
706
+ }
707
+ /**
708
+ * Retrieves the linked method from the given object.
709
+ *
710
+ * @param object - The object from which to retrieve the method.
711
+ * @returns The name of the linked method as a string, or `null` if not found.
712
+ * @internal
713
+ */
714
+ function getLinkedMethod(object) {
715
+ return Reflect.get(object, linkSymbol) ?? null;
716
+ }
717
+
718
+ //#endregion
719
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/checkPrivateRedeclaration.js
720
+ function _checkPrivateRedeclaration(e, t) {
721
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
722
+ }
723
+
724
+ //#endregion
725
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/classPrivateMethodInitSpec.js
726
+ function _classPrivateMethodInitSpec(e, a) {
727
+ _checkPrivateRedeclaration(e, a), a.add(e);
728
+ }
729
+
730
+ //#endregion
731
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/classPrivateFieldInitSpec.js
732
+ function _classPrivateFieldInitSpec(e, t, a) {
733
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
734
+ }
735
+
736
+ //#endregion
737
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/assertClassBrand.js
738
+ function _assertClassBrand(e, t, n) {
739
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
740
+ throw new TypeError("Private element is not present on this object");
741
+ }
742
+
743
+ //#endregion
744
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/classPrivateFieldSet2.js
745
+ function _classPrivateFieldSet2(s, a, r) {
746
+ return s.set(_assertClassBrand(s, a), r), r;
747
+ }
748
+
749
+ //#endregion
750
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/classPrivateFieldGet2.js
751
+ function _classPrivateFieldGet2(s, a) {
752
+ return s.get(_assertClassBrand(s, a));
753
+ }
754
+
755
+ //#endregion
756
+ //#region src/lib/interactions/resolvers/ChatInputCommandResolver.ts
757
+ var _data$1 = /* @__PURE__ */ new WeakMap();
758
+ var _commandData$1 = /* @__PURE__ */ new WeakMap();
759
+ var _subcommandGroupData = /* @__PURE__ */ new WeakMap();
760
+ var _subcommandData = /* @__PURE__ */ new WeakMap();
761
+ var _ChatInputCommandResolver_brand = /* @__PURE__ */ new WeakSet();
762
+ /**
763
+ * The command resolver for chat input commands.
764
+ * @internal
765
+ */
766
+ var ChatInputCommandResolver = class {
767
+ constructor() {
768
+ _classPrivateMethodInitSpec(this, _ChatInputCommandResolver_brand);
769
+ _classPrivateFieldInitSpec(this, _data$1, null);
770
+ _classPrivateFieldInitSpec(this, _commandData$1, null);
771
+ _classPrivateFieldInitSpec(this, _subcommandGroupData, []);
772
+ _classPrivateFieldInitSpec(this, _subcommandData, []);
773
+ }
774
+ /**
775
+ * Sets the command data for the ChatInputCommandResolver.
776
+ *
777
+ * @param data - The command data to set.
778
+ * @returns The instance of ChatInputCommandResolver.
779
+ */
780
+ setCommand(data) {
781
+ _classPrivateFieldSet2(_commandData$1, this, data);
782
+ return this;
783
+ }
784
+ /**
785
+ * Adds a subcommand group to the ChatInputCommandResolver.
786
+ *
787
+ * @param data - The data of the subcommand group.
788
+ * @param method - The method associated with the subcommand group (optional).
789
+ * @returns The updated ChatInputCommandResolver instance.
790
+ */
791
+ addSubcommandGroup(data, method) {
792
+ _classPrivateFieldGet2(_subcommandGroupData, this).push([method ?? null, data]);
793
+ return this;
794
+ }
795
+ /**
796
+ * Adds a subcommand to the ChatInputCommandResolver.
797
+ *
798
+ * @param data - The data of the subcommand.
799
+ * @param method - The method of the subcommand (optional).
800
+ * @param groupName - The group name of the subcommand (optional).
801
+ * @returns The updated ChatInputCommandResolver instance.
802
+ */
803
+ addSubcommand(data, method, groupName) {
804
+ _classPrivateFieldGet2(_subcommandData, this).push([
805
+ method ?? null,
806
+ groupName ?? null,
807
+ data
808
+ ]);
809
+ return this;
810
+ }
811
+ /**
812
+ * Converts the ChatInputCommandResolver instance to a JSON representation.
813
+ *
814
+ * @returns The JSON representation of the ChatInputCommandResolver instance.
815
+ */
816
+ toJSON() {
817
+ return _classPrivateFieldGet2(_data$1, this) ?? _classPrivateFieldSet2(_data$1, this, _assertClassBrand(_ChatInputCommandResolver_brand, this, _resolve$1).call(this));
818
+ }
819
+ };
820
+ /**
821
+ * Resolves the chat input command.
822
+ *
823
+ * @returns The resolved command.
824
+ */
825
+ function _resolve$1() {
826
+ const command = _assertClassBrand(_ChatInputCommandResolver_brand, this, _normalizeCommand).call(this, _classPrivateFieldGet2(_commandData$1, this));
827
+ _assertClassBrand(_ChatInputCommandResolver_brand, this, _resolveSubcommandGroups).call(this, command);
828
+ _assertClassBrand(_ChatInputCommandResolver_brand, this, _resolveSubcommands).call(this, command);
829
+ return command;
830
+ }
831
+ /**
832
+ * Resolves the subcommand groups for the given command.
833
+ *
834
+ * @param command The resolved command.
835
+ */
836
+ function _resolveSubcommandGroups(command) {
837
+ if (_classPrivateFieldGet2(_subcommandGroupData, this).length === 0) return;
838
+ command.options ??= [];
839
+ for (const [method, entry] of _classPrivateFieldGet2(_subcommandGroupData, this)) {
840
+ let data = _assertClassBrand(_ChatInputCommandResolver_brand, this, _normalizeSubcommandGroup).call(this, entry);
841
+ const index = command.options.findIndex((option) => option.name === data.name);
842
+ if (index === -1) command.options.push(data);
843
+ else {
844
+ data = _assertClassBrand(_ChatInputCommandResolver_brand, this, _mergeOption).call(this, command.options[index], data);
845
+ command.options[index] = data;
846
+ }
847
+ if (method) linkMethod(data, method);
848
+ }
849
+ }
850
+ /**
851
+ * Resolves the subcommands for a given command.
852
+ *
853
+ * @param command - The resolved command object.
854
+ */
855
+ function _resolveSubcommands(command) {
856
+ if (_classPrivateFieldGet2(_subcommandData, this).length === 0) return;
857
+ command.options ??= [];
858
+ for (const [method, groupName, entry] of _classPrivateFieldGet2(_subcommandData, this)) {
859
+ let data = _assertClassBrand(_ChatInputCommandResolver_brand, this, _normalizeSubcommand).call(this, entry);
860
+ let parent;
861
+ if (groupName === null) parent = command;
862
+ else {
863
+ const group = command.options.find((option) => option.name === groupName);
864
+ if (group === void 0) throw new Error(`The command '${command.name}' has no subcommand group named '${groupName}'`);
865
+ if (group.type !== ApplicationCommandOptionType.SubcommandGroup) throw new Error(`The command '${command.name}' has an option named '${groupName}' that is not a group`);
866
+ parent = group;
867
+ }
868
+ parent.options ??= [];
869
+ const index = parent.options.findIndex((option) => option.name === data.name);
870
+ if (index === -1) parent.options.push(data);
871
+ else {
872
+ data = _assertClassBrand(_ChatInputCommandResolver_brand, this, _mergeOption).call(this, parent.options[index], data);
873
+ parent.options[index] = data;
874
+ }
875
+ if (!method) continue;
876
+ const dataMethod = getLinkedMethod(data);
877
+ if (dataMethod) {
878
+ if (dataMethod !== method) throw new Error(`The command '${command.name}' has a subcommand named '${data.name}' that was already linked to '${dataMethod}'`);
879
+ } else linkMethod(data, method);
880
+ }
881
+ }
882
+ /**
883
+ * Normalizes the command data and returns the resolved command.
884
+ *
885
+ * @param data The command data to be normalized.
886
+ * @returns The resolved command.
887
+ * @throws An `Error` if the command data is null or undefined.
888
+ */
889
+ function _normalizeCommand(data) {
890
+ if (isNullish(data)) throw new Error("Could not normalize command data");
891
+ if (isFunction(data)) {
892
+ const builder = new SlashCommandBuilder();
893
+ data = data(builder) ?? builder;
894
+ }
895
+ return {
896
+ type: ApplicationCommandType.ChatInput,
897
+ ...isJSONEncodable(data) ? data.toJSON() : data
898
+ };
899
+ }
900
+ /**
901
+ * Normalizes the subcommand group data and returns the resolved subcommand group.
902
+ *
903
+ * @param data - The subcommand group data to be normalized.
904
+ * @returns The normalized subcommand group.
905
+ */
906
+ function _normalizeSubcommandGroup(data) {
907
+ if (isFunction(data)) {
908
+ const builder = new SlashCommandSubcommandGroupBuilder();
909
+ data = data(builder) ?? builder;
910
+ }
911
+ return {
912
+ type: ApplicationCommandOptionType.SubcommandGroup,
913
+ ...isJSONEncodable(data) ? data.toJSON() : data
914
+ };
915
+ }
916
+ /**
917
+ * Normalizes the subcommand data and returns the resolved subcommand.
918
+ *
919
+ * @param data - The subcommand data to be normalized.
920
+ * @returns The resolved subcommand.
921
+ */
922
+ function _normalizeSubcommand(data) {
923
+ if (isFunction(data)) {
924
+ const builder = new SlashCommandSubcommandBuilder();
925
+ data = data(builder) ?? builder;
926
+ }
927
+ return {
928
+ type: ApplicationCommandOptionType.Subcommand,
929
+ ...isJSONEncodable(data) ? data.toJSON() : data
930
+ };
931
+ }
932
+ /**
933
+ * Merges two arrays of {@linkcode APIApplicationCommandOption} objects.
934
+ *
935
+ * - If the 'existing' array is empty or undefined, the 'data' array is returned.
936
+ * - If the 'data' array is empty or undefined, the 'existing' array is returned.
937
+ * - If both arrays have elements, the options with the same name are merged.
938
+ *
939
+ * @param existing The existing array of {@linkcode APIApplicationCommandOption} objects.
940
+ * @param data The data array of {@linkcode APIApplicationCommandOption} objects.
941
+ * @returns The merged array of {@linkcode APIApplicationCommandOption} objects.
942
+ */
943
+ function _mergeOptions(existing, data) {
944
+ if (!existing?.length) return data ?? [];
945
+ if (!data?.length) return existing;
946
+ const entries = new Map(existing.map((option) => [option.name, option]));
947
+ for (const option of data) entries.set(option.name, _assertClassBrand(_ChatInputCommandResolver_brand, this, _mergeOption).call(this, entries.get(option.name), option));
948
+ return [...entries.values()];
949
+ }
950
+ /**
951
+ * Merges two {@linkcode APIApplicationCommandOption} objects.
952
+ *
953
+ * - If the `existing` option is not provided, the `data` option is returned.
954
+ * - If the types of the existing and data options do not match, a {@link TypeError} is thrown.
955
+ * - If both existing and data options have 'options' property, the options are recursively merged.
956
+ * - Otherwise, the options are shallow merged.
957
+ * - If a method is present in either the data or existing option, it is linked to the merged option.
958
+ *
959
+ * @param existing - The existing {@linkcode APIApplicationCommandOption} object.
960
+ * @param data - The data {@linkcode APIApplicationCommandOption} object.
961
+ * @returns The merged {@linkcode APIApplicationCommandOption} object.
962
+ */
963
+ function _mergeOption(existing, data) {
964
+ if (!existing) return data;
965
+ if (existing.type !== data.type) {
966
+ const existingType = ApplicationCommandOptionType[existing.type];
967
+ const dataType = ApplicationCommandOptionType[data.type];
968
+ throw new TypeError(`Mismatching types, expected '${existingType}', but received '${dataType}'`);
969
+ }
970
+ const merged = "options" in existing && "options" in data ? {
971
+ ...existing,
972
+ ...data,
973
+ options: _assertClassBrand(_ChatInputCommandResolver_brand, this, _mergeOptions).call(this, existing.options, data.options)
974
+ } : {
975
+ ...existing,
976
+ ...data
977
+ };
978
+ const method = getLinkedMethod(data) ?? getLinkedMethod(existing);
979
+ return method ? linkMethod(merged, method) : merged;
980
+ }
981
+
982
+ //#endregion
983
+ //#region src/lib/interactions/resolvers/ContextMenuCommandResolver.ts
984
+ var _data = /* @__PURE__ */ new WeakMap();
985
+ var _commandData = /* @__PURE__ */ new WeakMap();
986
+ var _commandType = /* @__PURE__ */ new WeakMap();
987
+ var _commandMethod = /* @__PURE__ */ new WeakMap();
988
+ var _ContextMenuCommandResolver_brand = /* @__PURE__ */ new WeakSet();
989
+ /**
990
+ * The command resolver for context menu commands.
991
+ * @internal
992
+ */
993
+ var ContextMenuCommandResolver = class {
994
+ constructor() {
995
+ _classPrivateMethodInitSpec(this, _ContextMenuCommandResolver_brand);
996
+ _classPrivateFieldInitSpec(this, _data, null);
997
+ _classPrivateFieldInitSpec(this, _commandData, null);
998
+ _classPrivateFieldInitSpec(this, _commandType, null);
999
+ _classPrivateFieldInitSpec(this, _commandMethod, null);
1000
+ }
1001
+ /**
1002
+ * Sets the command data, type, and method for the context menu command resolver.
1003
+ *
1004
+ * @param data - The command data.
1005
+ * @param type - The command type.
1006
+ * @param method - The command method (optional).
1007
+ * @returns The updated context menu command resolver.
1008
+ */
1009
+ setCommand(data, type, method) {
1010
+ _classPrivateFieldSet2(_commandData, this, data);
1011
+ _classPrivateFieldSet2(_commandType, this, type);
1012
+ _classPrivateFieldSet2(_commandMethod, this, method ?? null);
1013
+ return this;
1014
+ }
1015
+ /**
1016
+ * Converts the {@linkcode ContextMenuCommandResolver} instance to a JSON representation.
1017
+ *
1018
+ * @returns The JSON representation of the {@linkcode ContextMenuCommandResolver} instance.
1019
+ */
1020
+ toJSON() {
1021
+ return _classPrivateFieldGet2(_data, this) ?? _classPrivateFieldSet2(_data, this, _assertClassBrand(_ContextMenuCommandResolver_brand, this, _resolve).call(this));
1022
+ }
1023
+ };
1024
+ /**
1025
+ * Resolves the context menu command.
1026
+ *
1027
+ * @returns The resolved command.
1028
+ */
1029
+ function _resolve() {
1030
+ const data = _classPrivateFieldGet2(_commandData, this);
1031
+ const type = _classPrivateFieldGet2(_commandType, this);
1032
+ if (isNullish(data) || isNullish(type)) throw new Error("Could not normalize command data");
1033
+ const resolved = _assertClassBrand(_ContextMenuCommandResolver_brand, this, _normalizeContextMenuCommand).call(this, data, type);
1034
+ return _classPrivateFieldGet2(_commandMethod, this) ? linkMethod(resolved, _classPrivateFieldGet2(_commandMethod, this)) : resolved;
1035
+ }
1036
+ /**
1037
+ * Normalizes the context menu command.
1038
+ *
1039
+ * @param data - The command data.
1040
+ * @param type - The command type.
1041
+ * @returns The normalized context menu command.
1042
+ */
1043
+ function _normalizeContextMenuCommand(data, type) {
1044
+ if (isFunction(data)) {
1045
+ const builder = new ContextMenuCommandBuilder().setType(type);
1046
+ data = data(builder) ?? builder;
1047
+ }
1048
+ return {
1049
+ type,
1050
+ ...isJSONEncodable(data) ? data.toJSON() : data
1051
+ };
1052
+ }
1053
+
1054
+ //#endregion
1055
+ //#region src/lib/interactions/shared/ApplicationCommandRegistryEntry.ts
1056
+ var _chatInput = /* @__PURE__ */ new WeakMap();
1057
+ var _contextMenu = /* @__PURE__ */ new WeakMap();
1058
+ var _ids = /* @__PURE__ */ new WeakMap();
1059
+ /**
1060
+ * Represents an entry in the application command registry.
1061
+ *
1062
+ * This class provides methods to manage and manipulate application command data.
1063
+ *
1064
+ * @since 2.0.0
1065
+ */
1066
+ var ApplicationCommandRegistryEntry = class {
1067
+ constructor() {
1068
+ _classPrivateFieldInitSpec(this, _chatInput, null);
1069
+ _classPrivateFieldInitSpec(this, _contextMenu, []);
1070
+ _classPrivateFieldInitSpec(this, _ids, new Collection());
1071
+ }
1072
+ /**
1073
+ * Retrieves the loaded global ID of the {@linkcode ApplicationCommandRegistryEntry}.
1074
+ *
1075
+ * @since 2.0.0
1076
+ * @returns The loaded global ID of the {@linkcode ApplicationCommandRegistryEntry}, or `null` if it's not set.
1077
+ */
1078
+ getGlobalId() {
1079
+ return _classPrivateFieldGet2(_ids, this).get(null) ?? null;
1080
+ }
1081
+ /**
1082
+ * Sets the loaded global ID for the {@linkcode ApplicationCommandRegistryEntry}.
1083
+ *
1084
+ * @since 2.0.0
1085
+ * @param value - The Snowflake value to set as the global ID.
1086
+ * @returns The updated {@linkcode ApplicationCommandRegistryEntry} instance.
1087
+ */
1088
+ setGlobalId(value) {
1089
+ _classPrivateFieldGet2(_ids, this).set(null, value);
1090
+ return this;
1091
+ }
1092
+ /**
1093
+ * Retrieves the loaded guild ID associated with the given guild ID.
1094
+ *
1095
+ * @since 2.0.0
1096
+ * @param guildId The guild ID to retrieve.
1097
+ * @returns The associated guild ID, or null if not found.
1098
+ */
1099
+ getGuildId(guildId) {
1100
+ return _classPrivateFieldGet2(_ids, this).get(guildId) ?? null;
1101
+ }
1102
+ /**
1103
+ * Sets the loaded guild ID for the registry entry.
1104
+ *
1105
+ * @since 2.0.0
1106
+ * @param guildId - The guild ID to set.
1107
+ * @param value - The value to associate with the guild ID.
1108
+ * @returns The updated registry entry.
1109
+ */
1110
+ setGuildId(guildId, value) {
1111
+ _classPrivateFieldGet2(_ids, this).set(guildId, value);
1112
+ return this;
1113
+ }
1114
+ /**
1115
+ * Gets the chat input command resolver.
1116
+ *
1117
+ * @since 2.0.0
1118
+ * @returns The chat input command resolver or `null` if not set.
1119
+ */
1120
+ get chatInput() {
1121
+ return _classPrivateFieldGet2(_chatInput, this);
1122
+ }
1123
+ /**
1124
+ * Gets the context menu commands associated with this registry entry.
1125
+ *
1126
+ * @since 2.0.0
1127
+ * @returns An array of {@linkcode ContextMenuCommandResolver} objects representing the context menu commands.
1128
+ */
1129
+ get contextMenu() {
1130
+ return _classPrivateFieldGet2(_contextMenu, this);
1131
+ }
1132
+ /**
1133
+ * Converts the {@linkcode ApplicationCommandRegistryEntry} to a JSON representation.
1134
+ *
1135
+ * @since 2.0.0
1136
+ * @returns An array of Command objects in JSON format.
1137
+ */
1138
+ toJSON() {
1139
+ return _classPrivateFieldGet2(_chatInput, this) === null ? _classPrivateFieldGet2(_contextMenu, this).map((command) => command.toJSON()) : [_classPrivateFieldGet2(_chatInput, this).toJSON(), ..._classPrivateFieldGet2(_contextMenu, this).map((command) => command.toJSON())];
1140
+ }
1141
+ /**
1142
+ * Creates a chat input command resolver.
1143
+ * If the resolver has already been created, it returns the existing instance.
1144
+ *
1145
+ * @since 2.0.0
1146
+ * @returns The chat input command resolver.
1147
+ * @internal
1148
+ */
1149
+ makeChatInput() {
1150
+ return _classPrivateFieldGet2(_chatInput, this) ?? _classPrivateFieldSet2(_chatInput, this, new ChatInputCommandResolver());
1151
+ }
1152
+ /**
1153
+ * Creates a context menu command resolver and adds it to the context menu.
1154
+ *
1155
+ * @since 2.0.0
1156
+ * @returns The created context menu command resolver.
1157
+ * @internal
1158
+ */
1159
+ makeContextMenu() {
1160
+ const resolver = new ContextMenuCommandResolver();
1161
+ _classPrivateFieldGet2(_contextMenu, this).push(resolver);
1162
+ return resolver;
1163
+ }
1164
+ };
1165
+
1166
+ //#endregion
1167
+ //#region src/lib/interactions/shared/ApplicationCommandRegistry.ts
1168
+ var _entries = /* @__PURE__ */ new WeakMap();
1169
+ var _rest = /* @__PURE__ */ new WeakMap();
1170
+ var _clientId = /* @__PURE__ */ new WeakMap();
1171
+ var _authPrefix = /* @__PURE__ */ new WeakMap();
1172
+ var _ApplicationCommandRegistry_brand = /* @__PURE__ */ new WeakSet();
1173
+ /**
1174
+ * Represents a registry for application commands.
1175
+ *
1176
+ * @remarks This registry is globally available through {@linkcode container.applicationCommandRegistry}.
1177
+ * @since 2.0.0
1178
+ */
1179
+ var ApplicationCommandRegistry = class {
1180
+ constructor() {
1181
+ _classPrivateMethodInitSpec(this, _ApplicationCommandRegistry_brand);
1182
+ _classPrivateFieldInitSpec(this, _entries, new Collection());
1183
+ _classPrivateFieldInitSpec(this, _rest, null);
1184
+ _classPrivateFieldInitSpec(this, _clientId, null);
1185
+ _classPrivateFieldInitSpec(this, _authPrefix, "Bot");
1186
+ }
1187
+ get store() {
1188
+ return container$1.stores.get("commands");
1189
+ }
1190
+ /**
1191
+ * Sets up the application command registry with the provided options.
1192
+ *
1193
+ * @since 2.0.0
1194
+ * @param options - The setup options for the application command registry.
1195
+ * @returns The updated instance of the application command registry.
1196
+ */
1197
+ setup(options) {
1198
+ _classPrivateFieldSet2(_rest, this, options.rest);
1199
+ _classPrivateFieldSet2(_clientId, this, options.clientId);
1200
+ _classPrivateFieldSet2(_authPrefix, this, options.authPrefix ?? "Bot");
1201
+ return this;
1202
+ }
1203
+ /**
1204
+ * Retrieves the {@linkcode ApplicationCommandRegistryEntry} associated with the specified command class.
1205
+ *
1206
+ * @since 2.0.0
1207
+ * @template Options - The options type of the command class.
1208
+ * @param target - The command class to retrieve the entry for.
1209
+ * @returns The {@linkcode ApplicationCommandRegistryEntry} associated with the command class, or null if not found.
1210
+ */
1211
+ get(target) {
1212
+ return _classPrivateFieldGet2(_entries, this).get(target) ?? null;
1213
+ }
1214
+ /**
1215
+ * Deletes a command from the registry.
1216
+ *
1217
+ * @since 2.0.0
1218
+ * @template Options - The options type for the command.
1219
+ * @param target - The command to delete.
1220
+ * @returns True if the command was successfully deleted, false otherwise.
1221
+ */
1222
+ delete(target) {
1223
+ return _classPrivateFieldGet2(_entries, this).delete(target);
1224
+ }
1225
+ /**
1226
+ * Retrieves or creates an {@linkcode ApplicationCommandRegistryEntry} for the specified command class.
1227
+ *
1228
+ * @since 2.0.0
1229
+ * @template Options - The options type for the command.
1230
+ * @param target - The command class to ensure registration for.
1231
+ * @returns The application command registry entry for the command.
1232
+ */
1233
+ ensure(target) {
1234
+ return _classPrivateFieldGet2(_entries, this).ensure(target, () => new ApplicationCommandRegistryEntry());
1235
+ }
1236
+ /**
1237
+ * Converts the {@linkcode ApplicationCommandRegistryEntry} objects to an array of command objects in JSON format.
1238
+ *
1239
+ * @since 2.0.0
1240
+ * @returns An array of Command objects in JSON format.
1241
+ */
1242
+ toJSON() {
1243
+ return _classPrivateFieldGet2(_entries, this).map((entry) => entry.toJSON()).flat(1);
1244
+ }
1245
+ /**
1246
+ * Loads the commands from the specified base user directory.
1247
+ *
1248
+ * @since 2.0.0
1249
+ * @param baseUserDirectory - The base user directory to load the commands from, define it as `null` to not register
1250
+ * a path for the file system loader.
1251
+ * @returns A promise that resolves when all the commands are loaded.
1252
+ */
1253
+ loadCommands(baseUserDirectory) {
1254
+ if (baseUserDirectory !== null) container$1.stores.registerPath(baseUserDirectory);
1255
+ return this.store.loadAll();
1256
+ }
1257
+ /**
1258
+ * Retrieves the loaded chat input commands from the application command registry.
1259
+ *
1260
+ * @since 2.0.0
1261
+ * @returns A collection of chat input commands.
1262
+ */
1263
+ getLoadedChatInputCommands() {
1264
+ const collection = new Collection();
1265
+ for (const registryEntry of _classPrivateFieldGet2(_entries, this).values()) if (registryEntry.chatInput) collection.set(registryEntry.chatInput.toJSON().name, registryEntry);
1266
+ return collection;
1267
+ }
1268
+ /**
1269
+ * Retrieves the loaded context menu commands.
1270
+ *
1271
+ * @since 2.0.0
1272
+ * @returns A collection of context menu commands.
1273
+ */
1274
+ getLoadedContextMenuCommands() {
1275
+ const collection = new Collection();
1276
+ for (const registryEntry of _classPrivateFieldGet2(_entries, this).values()) for (const entry of registryEntry.contextMenu) collection.set(entry.toJSON().name, registryEntry);
1277
+ return collection;
1278
+ }
1279
+ /**
1280
+ * Retrieves the loaded global commands from the application command registry.
1281
+ *
1282
+ * @since 2.0.0
1283
+ * @returns An array of loaded global commands.
1284
+ */
1285
+ getLoadedGlobalCommands() {
1286
+ return _classPrivateFieldGet2(_entries, this).filter((_, command) => !restrictedGuildIdRegistry.get(command)?.length).map((entry) => entry.toJSON()).flat(1);
1287
+ }
1288
+ /**
1289
+ * Retrieves the loaded guild commands from the application command registry.
1290
+ *
1291
+ * @since 2.0.0
1292
+ * @returns A collection of guild commands, where the key is the guild ID and the value is an array of commands.
1293
+ */
1294
+ getLoadedGuildCommands() {
1295
+ const collection = new Collection();
1296
+ for (const [command, guildIds] of restrictedGuildIdRegistry) {
1297
+ if (guildIds.length === 0) continue;
1298
+ const entry = _classPrivateFieldGet2(_entries, this).get(command);
1299
+ if (!entry) continue;
1300
+ const commands = entry.toJSON();
1301
+ for (const guildId of guildIds) collection.ensure(guildId, () => []).push(...commands);
1302
+ }
1303
+ return collection;
1304
+ }
1305
+ /**
1306
+ * Registers all the non guild-restricted commands globally.
1307
+ *
1308
+ * @since 2.0.0
1309
+ * @returns The raw result from registering the commands globally.
1310
+ */
1311
+ pushGlobalCommands() {
1312
+ return _assertClassBrand(_ApplicationCommandRegistry_brand, this, _push).call(this, Routes.applicationCommands(this.clientId), this.getLoadedGlobalCommands(), null);
1313
+ }
1314
+ /**
1315
+ * Registers all the non guild-restricted commands in a single guild.
1316
+ *
1317
+ * @since 2.0.0
1318
+ * @param guildId The guild to register the commands at.
1319
+ * @returns The raw result from registering the commands in the specified guild.
1320
+ */
1321
+ pushGlobalCommandsInGuild(guildId) {
1322
+ return _assertClassBrand(_ApplicationCommandRegistry_brand, this, _push).call(this, Routes.applicationGuildCommands(this.clientId, guildId), this.getLoadedGlobalCommands(), guildId);
1323
+ }
1324
+ /**
1325
+ * Registers all the commands including guild-restricted ones in a single guild.
1326
+ *
1327
+ * @param guildId The guild to register the commands at.
1328
+ * @returns The raw result from registering the commands in the specified guild.
1329
+ */
1330
+ pushAllCommandsInGuild(guildId) {
1331
+ return _assertClassBrand(_ApplicationCommandRegistry_brand, this, _push).call(this, Routes.applicationGuildCommands(this.clientId, guildId), this.toJSON(), guildId);
1332
+ }
1333
+ /**
1334
+ * Registers all the guild-restricted commands in their respective guilds.
1335
+ *
1336
+ * @returns The settled promises from all the guild command registrations.
1337
+ */
1338
+ pushGuildRestrictedCommands() {
1339
+ const promises = this.getLoadedGuildCommands().map((commands, guildId) => _assertClassBrand(_ApplicationCommandRegistry_brand, this, _push).call(this, Routes.applicationGuildCommands(this.clientId, guildId), commands, guildId));
1340
+ return Promise.allSettled(promises);
1341
+ }
1342
+ get clientId() {
1343
+ if (_classPrivateFieldGet2(_clientId, this) === null) throw new Error("The ApplicationCommandRegistry has not been setup yet.");
1344
+ return _classPrivateFieldGet2(_clientId, this);
1345
+ }
1346
+ };
1347
+ async function _push(route, body, guildId) {
1348
+ if (_classPrivateFieldGet2(_rest, this) === null) throw new Error("The ApplicationCommandRegistry has not been setup yet.");
1349
+ const entries = await _classPrivateFieldGet2(_rest, this).put(route, {
1350
+ body,
1351
+ authPrefix: _classPrivateFieldGet2(_authPrefix, this)
1352
+ });
1353
+ if (entries.length === 0) return entries;
1354
+ const { router } = this.store;
1355
+ for (const entry of entries) {
1356
+ const registry = (entry.type === ApplicationCommandType.ChatInput ? router.getChatInput(entry.name) : router.getContextMenu(entry.name))?.registry;
1357
+ if (!registry) continue;
1358
+ if (guildId === null) registry.setGlobalId(entry.id);
1359
+ else registry.setGuildId(guildId, entry.id);
1360
+ }
1361
+ return entries;
1362
+ }
1363
+ const applicationCommandRegistry = new ApplicationCommandRegistry();
1364
+ container$1.applicationCommandRegistry = applicationCommandRegistry;
1365
+
1366
+ //#endregion
1367
+ //#region src/lib/utils/constants.ts
1368
+ const ErrorMessages = {
1369
+ InternalError: JSON.stringify({ message: "Received an internal error" }),
1370
+ InvalidBodySize: JSON.stringify({ message: "Request body exceeds maximum body size" }),
1371
+ InvalidContentLengthInteger: JSON.stringify({ message: "Content-Length is not an integer number" }),
1372
+ InvalidContentLengthNegative: JSON.stringify({ message: "Content-Length must not be zero or negative" }),
1373
+ InvalidContentLengthTooBig: JSON.stringify({ message: "Content-Length is superior to the server's body size limit" }),
1374
+ InvalidCustomId: JSON.stringify({ message: "Could not parse the `custom_id` field" }),
1375
+ InvalidSignature: JSON.stringify({ message: "Received invalid signature" }),
1376
+ MissingBodyData: JSON.stringify({ message: "Missing body data" }),
1377
+ MissingCommandName: JSON.stringify({ message: "Missing command name" }),
1378
+ MissingSignatureInformation: JSON.stringify({ message: "Missing signature information" }),
1379
+ NotFound: JSON.stringify({ message: "Not found" }),
1380
+ UnknownCommandHandler: JSON.stringify({ message: "Unknown command handler" }),
1381
+ UnknownCommandName: JSON.stringify({ message: "Unknown command name" }),
1382
+ UnknownHandlerName: JSON.stringify({ message: "Unknown handler name" }),
1383
+ UnknownInteractionType: JSON.stringify({ message: "Received unknown interaction type" }),
1384
+ UnsupportedHttpMethod: JSON.stringify({ message: "Unsupported HTTP method" })
1385
+ };
1386
+ const Payloads = { Pong: JSON.stringify({ type: InteractionResponseType.Pong }) };
1387
+
1388
+ //#endregion
1389
+ //#region src/lib/interactions/structures/common/symbols.ts
1390
+ const Data = Symbol("data");
1391
+ const Response = Symbol("response");
1392
+
1393
+ //#endregion
1394
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
1395
+ function _typeof(o) {
1396
+ "@babel/helpers - typeof";
1397
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
1398
+ return typeof o;
1399
+ } : function(o) {
1400
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
1401
+ }, _typeof(o);
1402
+ }
1403
+
1404
+ //#endregion
1405
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
1406
+ function toPrimitive(t, r) {
1407
+ if ("object" != _typeof(t) || !t) return t;
1408
+ var e = t[Symbol.toPrimitive];
1409
+ if (void 0 !== e) {
1410
+ var i = e.call(t, r || "default");
1411
+ if ("object" != _typeof(i)) return i;
1412
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1413
+ }
1414
+ return ("string" === r ? String : Number)(t);
1415
+ }
1416
+
1417
+ //#endregion
1418
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
1419
+ function toPropertyKey(t) {
1420
+ var i = toPrimitive(t, "string");
1421
+ return "symbol" == _typeof(i) ? i : i + "";
1422
+ }
1423
+
1424
+ //#endregion
1425
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
1426
+ function _defineProperty(e, r, t) {
1427
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
1428
+ value: t,
1429
+ enumerable: !0,
1430
+ configurable: !0,
1431
+ writable: !0
1432
+ }) : e[r] = t, e;
1433
+ }
1434
+
1435
+ //#endregion
1436
+ //#region src/lib/interactions/structures/interactions/base/BaseInteraction.ts
1437
+ var BaseInteraction = class {
1438
+ constructor(response, data) {
1439
+ _defineProperty(this, Data, void 0);
1440
+ _defineProperty(this, Response, void 0);
1441
+ this[Data] = data;
1442
+ this[Response] = response;
1443
+ }
1444
+ get replied() {
1445
+ return this[Response].writableEnded;
1446
+ }
1447
+ /**
1448
+ * The ID of the interaction.
1449
+ */
1450
+ get id() {
1451
+ return this[Data].id;
1452
+ }
1453
+ /**
1454
+ * The type of the interaction.
1455
+ */
1456
+ get type() {
1457
+ return this[Data].type;
1458
+ }
1459
+ /**
1460
+ * Bitwise set of permissions the app or bot has within the channel the interaction was sent from.
1461
+ */
1462
+ get app_permissions() {
1463
+ return this[Data].app_permissions;
1464
+ }
1465
+ /**
1466
+ * Bitwise set of permissions the app or bot has within the channel the interaction was sent from.
1467
+ *
1468
+ * @seealso {@link app_permissions} for the raw data.
1469
+ */
1470
+ get applicationPermissions() {
1471
+ return typeof this.app_permissions === "string" ? BigInt(this.app_permissions) : void 0;
1472
+ }
1473
+ /**
1474
+ * The ID of the application the interaction is for.
1475
+ */
1476
+ get application_id() {
1477
+ return this[Data].application_id;
1478
+ }
1479
+ /**
1480
+ * The ID of the application the interaction is for.
1481
+ *
1482
+ * @seealso {@link application_id} for the raw data.
1483
+ */
1484
+ get applicationId() {
1485
+ return this.application_id;
1486
+ }
1487
+ /**
1488
+ * Mapping of installation contexts that the interaction was authorized for
1489
+ * to related user or guild IDs.
1490
+ */
1491
+ get authorizing_integration_owners() {
1492
+ return this[Data].authorizing_integration_owners;
1493
+ }
1494
+ /**
1495
+ * Mapping of installation contexts that the interaction was authorized for
1496
+ * to related user or guild IDs.
1497
+ *
1498
+ * @seealso {@link authorizing_integration_owners} for the raw data.
1499
+ */
1500
+ get authorizingIntegrationOwners() {
1501
+ return this.authorizing_integration_owners;
1502
+ }
1503
+ /**
1504
+ * The channel of the interaction.
1505
+ */
1506
+ get channel() {
1507
+ return this[Data].channel;
1508
+ }
1509
+ /**
1510
+ * The channel the interaction was sent from.
1511
+ * @deprecated Use {@link channel}.id instead.
1512
+ */
1513
+ get channel_id() {
1514
+ return this.channel?.id;
1515
+ }
1516
+ /**
1517
+ * The channel the interaction was sent from.
1518
+ * @deprecated Use {@link channel}.id instead.
1519
+ *
1520
+ * @seealso {@link channel_id} for the raw data.
1521
+ */
1522
+ get channelId() {
1523
+ return this.channel?.id;
1524
+ }
1525
+ /**
1526
+ * Context where the interaction was triggered from.
1527
+ */
1528
+ get context() {
1529
+ return this[Data].context;
1530
+ }
1531
+ /**
1532
+ * The command data payload.
1533
+ */
1534
+ get data() {
1535
+ return this[Data].data;
1536
+ }
1537
+ /**
1538
+ * For monetized apps, any entitlements for the invoking user, representing
1539
+ * access to premium SKUs.
1540
+ */
1541
+ get entitlements() {
1542
+ return this[Data].entitlements;
1543
+ }
1544
+ /**
1545
+ * The guild the interaction was sent from.
1546
+ */
1547
+ get guild_id() {
1548
+ return this[Data].guild_id;
1549
+ }
1550
+ /**
1551
+ * The guild the interaction was sent from.
1552
+ *
1553
+ * @seealso {@link guild_id} for the raw data.
1554
+ */
1555
+ get guildId() {
1556
+ return this.guild_id;
1557
+ }
1558
+ /**
1559
+ * The guild's preferred locale, if invoked in a guild.
1560
+ */
1561
+ get guild_locale() {
1562
+ return this[Data].guild_locale;
1563
+ }
1564
+ /**
1565
+ * The guild's preferred locale, if invoked in a guild.
1566
+ *
1567
+ * @seealso {@link guild_locale} for the raw data.
1568
+ */
1569
+ get guildLocale() {
1570
+ return this.guild_locale;
1571
+ }
1572
+ /**
1573
+ * The selected language of the invoking user.
1574
+ */
1575
+ get locale() {
1576
+ return this[Data].locale;
1577
+ }
1578
+ /**
1579
+ * Guild member data for the invoking user, including permissions.
1580
+ *
1581
+ * **This is only sent when an interaction is invoked in a guild**.
1582
+ */
1583
+ get member() {
1584
+ return this[Data].member;
1585
+ }
1586
+ /**
1587
+ * A continuation token for responding to the interaction.
1588
+ */
1589
+ get token() {
1590
+ return this[Data].token;
1591
+ }
1592
+ /**
1593
+ * User object for the invoking user.
1594
+ */
1595
+ get user() {
1596
+ return this[Data].member?.user ?? this[Data].user;
1597
+ }
1598
+ /**
1599
+ * Read-only property, always `1`.
1600
+ */
1601
+ get version() {
1602
+ return this[Data].version;
1603
+ }
1604
+ /**
1605
+ * Determines whether or not the interaction was sent from a guild.
1606
+ * @returns The casted interaction type.
1607
+ */
1608
+ inGuild() {
1609
+ return !isNullish(this.guild_id);
1610
+ }
1611
+ /**
1612
+ * Fetches the channel the interaction was sent from.
1613
+ * @returns The fetched channel.
1614
+ * @remarks **This requires REST to have a token.**
1615
+ * @seealso {@link channel}.
1616
+ */
1617
+ async fetchChannel() {
1618
+ if (isNullishOrEmpty(this.channel)) return err(/* @__PURE__ */ new Error("The interaction was not sent from a channel"));
1619
+ return resultFromDiscord(container$1.rest.get(Routes.channel(this.channel.id)));
1620
+ }
1621
+ /**
1622
+ * Fetches the channel the interaction was sent from.
1623
+ * @returns The fetched channel.
1624
+ * @remarks **This requires REST to have a token.**
1625
+ */
1626
+ async fetchGuild() {
1627
+ if (isNullishOrEmpty(this.guildId)) return err(/* @__PURE__ */ new Error("The interaction was not sent from a guild"));
1628
+ return resultFromDiscord(container$1.rest.get(Routes.guild(this.guildId)));
1629
+ }
1630
+ _sendReply(data) {
1631
+ const response = this[Response];
1632
+ if (response.writableEnded) throw new Error("Cannot send response, the request has already been replied.");
1633
+ response.statusCode = 200;
1634
+ return new Promise((resolve) => {
1635
+ response.on("close", () => {
1636
+ resolve();
1637
+ });
1638
+ response.end(JSON.stringify(data));
1639
+ });
1640
+ }
1641
+ };
1642
+
1643
+ //#endregion
1644
+ //#region src/lib/interactions/structures/interactions/AutocompleteInteraction.ts
1645
+ var AutocompleteInteraction = class extends BaseInteraction {
1646
+ /**
1647
+ * Responds to the interaction with an autocomplete result.
1648
+ * @param data The data to be sent.
1649
+ */
1650
+ reply(data) {
1651
+ const body = {
1652
+ type: InteractionResponseType.ApplicationCommandAutocompleteResult,
1653
+ data
1654
+ };
1655
+ return this._sendReply(body);
1656
+ }
1657
+ /**
1658
+ * Responds to the interaction with an empty autocomplete result.
1659
+ */
1660
+ replyEmpty() {
1661
+ return this.reply({ choices: [] });
1662
+ }
1663
+ };
1664
+
1665
+ //#endregion
1666
+ //#region src/lib/interactions/structures/interactions/base/CommandInteraction.ts
1667
+ var CommandInteraction = class extends BaseInteraction {
1668
+ /**
1669
+ * Responds to the interaction with a message.
1670
+ * @param data The data to be sent.
1671
+ */
1672
+ async reply(data) {
1673
+ const body = {
1674
+ type: InteractionResponseType.ChannelMessageWithSource,
1675
+ data
1676
+ };
1677
+ await this._sendReply(body);
1678
+ return new PartialMessage(this);
1679
+ }
1680
+ /**
1681
+ * ACK an interaction and edit a response later. The user sees a loading state.
1682
+ * @param data The data to be sent, if any.
1683
+ */
1684
+ async defer(data) {
1685
+ const body = {
1686
+ type: InteractionResponseType.DeferredChannelMessageWithSource,
1687
+ data
1688
+ };
1689
+ await this._sendReply(body);
1690
+ return new PartialMessage(this);
1691
+ }
1692
+ /**
1693
+ * Responds to the interaction with a popup modal.
1694
+ * @param data The data to be sent.
1695
+ */
1696
+ showModal(data) {
1697
+ const body = {
1698
+ type: InteractionResponseType.Modal,
1699
+ data
1700
+ };
1701
+ return this._sendReply(body);
1702
+ }
1703
+ /**
1704
+ * Sends a follow-up message.
1705
+ * @param data The data to be sent.
1706
+ */
1707
+ async followup({ files, ...body }) {
1708
+ return (await resultFromDiscord(container$1.rest.post(Routes.webhook(this.applicationId, this.token), {
1709
+ body,
1710
+ files,
1711
+ auth: false
1712
+ }))).map((message) => new Message(this, message));
1713
+ }
1714
+ };
1715
+
1716
+ //#endregion
1717
+ //#region src/lib/interactions/structures/interactions/base/MessageComponentInteraction.ts
1718
+ var MessageComponentInteraction = class extends BaseInteraction {
1719
+ /**
1720
+ * The message the interaction was attached to.
1721
+ */
1722
+ get message() {
1723
+ return this[Data].message;
1724
+ }
1725
+ /**
1726
+ * ACK a button interaction and update it to a loading state.
1727
+ */
1728
+ async deferUpdate() {
1729
+ const body = { type: InteractionResponseType.DeferredMessageUpdate };
1730
+ await this._sendReply(body);
1731
+ return new PartialMessage(this);
1732
+ }
1733
+ /**
1734
+ * ACK an interaction and edit a response later. The user sees a loading state.
1735
+ * @param data The data to be sent, if any.
1736
+ */
1737
+ async update(data) {
1738
+ const body = {
1739
+ type: InteractionResponseType.UpdateMessage,
1740
+ data
1741
+ };
1742
+ await this._sendReply(body);
1743
+ return new PartialMessage(this);
1744
+ }
1745
+ /**
1746
+ * Responds to the interaction with a message.
1747
+ * @param data The data to be sent.
1748
+ */
1749
+ async reply(data) {
1750
+ const body = {
1751
+ type: InteractionResponseType.ChannelMessageWithSource,
1752
+ data
1753
+ };
1754
+ await this._sendReply(body);
1755
+ return new PartialMessage(this);
1756
+ }
1757
+ /**
1758
+ * ACK an interaction and edit a response later. The user sees a loading state.
1759
+ * @param data The data to be sent, if any.
1760
+ */
1761
+ async defer(data) {
1762
+ const body = {
1763
+ type: InteractionResponseType.DeferredChannelMessageWithSource,
1764
+ data
1765
+ };
1766
+ await this._sendReply(body);
1767
+ return new PartialMessage(this);
1768
+ }
1769
+ /**
1770
+ * Responds to the interaction with a popup modal.
1771
+ * @param data The data to be sent.
1772
+ */
1773
+ showModal(data) {
1774
+ const body = {
1775
+ type: InteractionResponseType.Modal,
1776
+ data
1777
+ };
1778
+ return this._sendReply(body);
1779
+ }
1780
+ /**
1781
+ * Sends a follow-up message.
1782
+ * @param data The data to be sent.
1783
+ */
1784
+ async followup({ files, ...body }) {
1785
+ return (await resultFromDiscord(container$1.rest.post(Routes.webhook(this.applicationId, this.token), {
1786
+ body,
1787
+ files,
1788
+ auth: false
1789
+ }))).map((message) => new Message(this, message));
1790
+ }
1791
+ };
1792
+
1793
+ //#endregion
1794
+ //#region src/lib/interactions/structures/interactions/ChatInputCommandInteraction.ts
1795
+ var ChatInputCommandInteraction = class extends CommandInteraction {};
1796
+
1797
+ //#endregion
1798
+ //#region src/lib/interactions/structures/interactions/MessageComponentButtonInteraction.ts
1799
+ var MessageComponentButtonInteraction = class extends MessageComponentInteraction {};
1800
+
1801
+ //#endregion
1802
+ //#region src/lib/interactions/structures/interactions/MessageComponentChannelSelectInteraction.ts
1803
+ var MessageComponentChannelSelectInteraction = class extends MessageComponentInteraction {
1804
+ /**
1805
+ * Gets the IDs of the selected channels.
1806
+ */
1807
+ get ids() {
1808
+ return this.data.values;
1809
+ }
1810
+ /**
1811
+ * Creates a collection with all the selected channels.
1812
+ *
1813
+ * @seealso {@link MessageComponentChannelSelectInteraction.keys}.
1814
+ * @seealso {@link MessageComponentChannelSelectInteraction.values}.
1815
+ * @seealso {@link MessageComponentChannelSelectInteraction.entries}.
1816
+ */
1817
+ get channels() {
1818
+ return new Collection(this.entries());
1819
+ }
1820
+ /**
1821
+ * Returns an iterator of the selected channel IDs.
1822
+ *
1823
+ * @seealso {@link MessageComponentChannelSelectInteraction.ids}.
1824
+ */
1825
+ *keys() {
1826
+ yield* this.ids;
1827
+ }
1828
+ /**
1829
+ * Returns an iterator of the selected channels.
1830
+ *
1831
+ * @seealso {@link MessageComponentChannelSelectInteraction.channels}.
1832
+ * @seealso {@link MessageComponentChannelSelectInteraction.keys}.
1833
+ * @seealso {@link MessageComponentChannelSelectInteraction.entries}.
1834
+ */
1835
+ *values() {
1836
+ const { resolved } = this.data;
1837
+ for (const id of this.ids) yield resolved.channels[id];
1838
+ }
1839
+ /**
1840
+ * Returns an iterator of [ID, Channel] pairs.
1841
+ *
1842
+ * @seealso {@link MessageComponentChannelSelectInteraction.channels}.
1843
+ * @seealso {@link MessageComponentChannelSelectInteraction.keys}.
1844
+ * @seealso {@link MessageComponentChannelSelectInteraction.values}.
1845
+ */
1846
+ *entries() {
1847
+ for (const value of this.values()) yield [value.id, value];
1848
+ }
1849
+ };
1850
+
1851
+ //#endregion
1852
+ //#region src/lib/interactions/structures/interactions/MessageComponentMentionableSelectInteraction.ts
1853
+ var MessageComponentMentionableSelectInteraction = class extends MessageComponentInteraction {
1854
+ /**
1855
+ * Gets the IDs of the selected users and roles.
1856
+ */
1857
+ get ids() {
1858
+ return this.data.values;
1859
+ }
1860
+ /**
1861
+ * Creates a collection with all the selected users.
1862
+ *
1863
+ * @seealso {@link MessageComponentMentionableSelectInteraction.keys}.
1864
+ * @seealso {@link MessageComponentMentionableSelectInteraction.values}.
1865
+ * @seealso {@link MessageComponentMentionableSelectInteraction.entries}.
1866
+ */
1867
+ get users() {
1868
+ const output = new Collection();
1869
+ const { users, members } = this.data.resolved;
1870
+ if (users) for (const user of Object.values(users)) output.set(user.id, {
1871
+ id: user.id,
1872
+ user,
1873
+ member: members?.[user.id] ?? null
1874
+ });
1875
+ return output;
1876
+ }
1877
+ /**
1878
+ * Creates a collection with all the selected roles.
1879
+ *
1880
+ * @note The collection will always be empty if the interaction came from direct messages.
1881
+ * @seealso {@link MessageComponentMentionableSelectInteraction.keys}.
1882
+ * @seealso {@link MessageComponentMentionableSelectInteraction.values}.
1883
+ * @seealso {@link MessageComponentMentionableSelectInteraction.entries}.
1884
+ */
1885
+ get roles() {
1886
+ const output = new Collection();
1887
+ const { roles } = this.data.resolved;
1888
+ if (roles) for (const role of Object.values(roles)) output.set(role.id, role);
1889
+ return output;
1890
+ }
1891
+ /**
1892
+ * Creates a collection with all the selected users, members, and roles.
1893
+ *
1894
+ * @note The collection will always be empty if the interaction came from direct messages.
1895
+ * @seealso {@link MessageComponentMentionableSelectInteraction.keys}.
1896
+ * @seealso {@link MessageComponentMentionableSelectInteraction.values}.
1897
+ * @seealso {@link MessageComponentMentionableSelectInteraction.entries}.
1898
+ */
1899
+ get mentionables() {
1900
+ return new Collection(this.entries());
1901
+ }
1902
+ /**
1903
+ * Returns an iterator of the selected users and roles IDs.
1904
+ *
1905
+ * @seealso {@link MessageComponentMentionableSelectInteraction.ids}.
1906
+ */
1907
+ *keys() {
1908
+ yield* this.ids;
1909
+ }
1910
+ /**
1911
+ * Returns an iterator of the selected users, members, and roles.
1912
+ *
1913
+ * @seealso {@link MessageComponentMentionableSelectInteraction.users}.
1914
+ * @seealso {@link MessageComponentMentionableSelectInteraction.roles}.
1915
+ * @seealso {@link MessageComponentMentionableSelectInteraction.keys}.
1916
+ * @seealso {@link MessageComponentMentionableSelectInteraction.entries}.
1917
+ */
1918
+ *values() {
1919
+ const { resolved } = this.data;
1920
+ for (const id of this.ids) {
1921
+ const user = resolved.users?.[id];
1922
+ if (user) {
1923
+ yield {
1924
+ id,
1925
+ user,
1926
+ member: resolved.members?.[id] ?? null
1927
+ };
1928
+ continue;
1929
+ }
1930
+ const role = resolved.roles?.[id];
1931
+ if (role) {
1932
+ yield {
1933
+ id,
1934
+ role
1935
+ };
1936
+ continue;
1937
+ }
1938
+ yield { id };
1939
+ }
1940
+ }
1941
+ /**
1942
+ * Returns an iterator of [ID, Mentionable] pairs.
1943
+ *
1944
+ * @seealso {@link MessageComponentMentionableSelectInteraction.users}.
1945
+ * @seealso {@link MessageComponentMentionableSelectInteraction.roles}.
1946
+ * @seealso {@link MessageComponentMentionableSelectInteraction.keys}.
1947
+ * @seealso {@link MessageComponentMentionableSelectInteraction.values}.
1948
+ */
1949
+ *entries() {
1950
+ for (const value of this.values()) yield [value.id, value];
1951
+ }
1952
+ };
1953
+
1954
+ //#endregion
1955
+ //#region src/lib/interactions/structures/interactions/MessageComponentRoleSelectInteraction.ts
1956
+ var MessageComponentRoleSelectInteraction = class extends MessageComponentInteraction {
1957
+ /**
1958
+ * Gets the IDs of the selected roles.
1959
+ */
1960
+ get ids() {
1961
+ return this.data.values;
1962
+ }
1963
+ /**
1964
+ * Creates a collection with all the selected roles.
1965
+ *
1966
+ * @seealso {@link MessageComponentRoleSelectInteraction.keys}.
1967
+ * @seealso {@link MessageComponentRoleSelectInteraction.values}.
1968
+ * @seealso {@link MessageComponentRoleSelectInteraction.entries}.
1969
+ */
1970
+ get roles() {
1971
+ return new Collection(this.entries());
1972
+ }
1973
+ /**
1974
+ * Returns an iterator of the selected role IDs.
1975
+ *
1976
+ * @seealso {@link MessageComponentRoleSelectInteraction.ids}.
1977
+ */
1978
+ *keys() {
1979
+ yield* this.ids;
1980
+ }
1981
+ /**
1982
+ * Returns an iterator of the selected channels.
1983
+ *
1984
+ * @seealso {@link MessageComponentRoleSelectInteraction.roles}.
1985
+ * @seealso {@link MessageComponentRoleSelectInteraction.keys}.
1986
+ * @seealso {@link MessageComponentRoleSelectInteraction.entries}.
1987
+ */
1988
+ *values() {
1989
+ const { resolved } = this.data;
1990
+ for (const id of this.ids) yield resolved.roles[id];
1991
+ }
1992
+ /**
1993
+ * Returns an iterator of [ID, Role] pairs.
1994
+ *
1995
+ * @seealso {@link MessageComponentRoleSelectInteraction.roles}.
1996
+ * @seealso {@link MessageComponentRoleSelectInteraction.keys}.
1997
+ * @seealso {@link MessageComponentRoleSelectInteraction.values}.
1998
+ */
1999
+ *entries() {
2000
+ for (const value of this.values()) yield [value.id, value];
2001
+ }
2002
+ };
2003
+
2004
+ //#endregion
2005
+ //#region src/lib/interactions/structures/interactions/MessageComponentStringSelectInteraction.ts
2006
+ var MessageComponentStringSelectInteraction = class extends MessageComponentInteraction {
2007
+ get values() {
2008
+ return this.data.values ?? [];
2009
+ }
2010
+ };
2011
+
2012
+ //#endregion
2013
+ //#region src/lib/interactions/structures/interactions/MessageComponentUserSelectInteraction.ts
2014
+ var MessageComponentUserSelectInteraction = class extends MessageComponentInteraction {
2015
+ /**
2016
+ * Gets the IDs of the selected users.
2017
+ */
2018
+ get ids() {
2019
+ return this.data.values;
2020
+ }
2021
+ /**
2022
+ * Creates a collection with all the selected users.
2023
+ *
2024
+ * @seealso {@link MessageComponentChannelSelectInteraction.keys}.
2025
+ * @seealso {@link MessageComponentChannelSelectInteraction.values}.
2026
+ * @seealso {@link MessageComponentChannelSelectInteraction.entries}.
2027
+ */
2028
+ get users() {
2029
+ return new Collection(this.entries());
2030
+ }
2031
+ /**
2032
+ * Returns an iterator of the selected user IDs.
2033
+ *
2034
+ * @seealso {@link MessageComponentUserSelectInteraction.ids}.
2035
+ */
2036
+ *keys() {
2037
+ yield* this.ids;
2038
+ }
2039
+ /**
2040
+ * Returns an iterator of the selected users.
2041
+ *
2042
+ * @seealso {@link MessageComponentUserSelectInteraction.users}.
2043
+ * @seealso {@link MessageComponentUserSelectInteraction.keys}.
2044
+ * @seealso {@link MessageComponentUserSelectInteraction.entries}.
2045
+ */
2046
+ *values() {
2047
+ const { resolved } = this.data;
2048
+ for (const id of this.ids) yield {
2049
+ id,
2050
+ user: resolved.users[id],
2051
+ member: resolved.members?.[id] ?? null
2052
+ };
2053
+ }
2054
+ /**
2055
+ * Returns an iterator of [ID, User] pairs.
2056
+ *
2057
+ * @seealso {@link MessageComponentUserSelectInteraction.channels}.
2058
+ * @seealso {@link MessageComponentUserSelectInteraction.keys}.
2059
+ * @seealso {@link MessageComponentUserSelectInteraction.values}.
2060
+ */
2061
+ *entries() {
2062
+ for (const value of this.values()) yield [value.user.id, value];
2063
+ }
2064
+ };
2065
+
2066
+ //#endregion
2067
+ //#region src/lib/interactions/structures/interactions/MessageContextMenuCommandInteraction.ts
2068
+ var MessageContextMenuCommandInteraction = class extends CommandInteraction {};
2069
+
2070
+ //#endregion
2071
+ //#region src/lib/interactions/structures/interactions/ModalSubmitInteraction.ts
2072
+ var ModalSubmitInteraction = class extends BaseInteraction {
2073
+ /**
2074
+ * The message the interaction was attached to, if any.
2075
+ */
2076
+ get message() {
2077
+ return this[Data].message;
2078
+ }
2079
+ /**
2080
+ * ACK a button interaction and update it to a loading state.
2081
+ */
2082
+ async deferUpdate() {
2083
+ const body = { type: InteractionResponseType.DeferredMessageUpdate };
2084
+ await this._sendReply(body);
2085
+ return new PartialMessage(this);
2086
+ }
2087
+ /**
2088
+ * ACK an interaction and edit a response later. The user sees a loading state.
2089
+ * @param data The data to be sent, if any.
2090
+ */
2091
+ async update(data) {
2092
+ const body = {
2093
+ type: InteractionResponseType.UpdateMessage,
2094
+ data
2095
+ };
2096
+ await this._sendReply(body);
2097
+ return new PartialMessage(this);
2098
+ }
2099
+ /**
2100
+ * Responds to the interaction with a message.
2101
+ * @param data The data to be sent.
2102
+ */
2103
+ async reply(data) {
2104
+ const body = {
2105
+ type: InteractionResponseType.ChannelMessageWithSource,
2106
+ data
2107
+ };
2108
+ await this._sendReply(body);
2109
+ return new PartialMessage(this);
2110
+ }
2111
+ /**
2112
+ * ACK an interaction and edit a response later. The user sees a loading state.
2113
+ * @param data The data to be sent, if any.
2114
+ */
2115
+ async defer(data) {
2116
+ const body = {
2117
+ type: InteractionResponseType.DeferredChannelMessageWithSource,
2118
+ data
2119
+ };
2120
+ await this._sendReply(body);
2121
+ return new PartialMessage(this);
2122
+ }
2123
+ /**
2124
+ * Sends a follow-up message.
2125
+ * @param data The data to be sent.
2126
+ */
2127
+ async followup({ files, ...body }) {
2128
+ return (await resultFromDiscord(container$1.rest.post(Routes.webhook(this.applicationId, this.token), {
2129
+ body,
2130
+ files,
2131
+ auth: false
2132
+ }))).map((message) => new Message(this, message));
2133
+ }
2134
+ };
2135
+
2136
+ //#endregion
2137
+ //#region src/lib/interactions/structures/interactions/UserContextMenuCommandInteraction.ts
2138
+ var UserContextMenuCommandInteraction = class extends CommandInteraction {};
2139
+
2140
+ //#endregion
2141
+ //#region src/lib/interactions/utils/util.ts
2142
+ function makeInteraction(response, interaction) {
2143
+ switch (interaction.type) {
2144
+ case InteractionType.ApplicationCommand: switch (interaction.data.type) {
2145
+ case ApplicationCommandType.ChatInput: return new ChatInputCommandInteraction(response, interaction);
2146
+ case ApplicationCommandType.User: return new UserContextMenuCommandInteraction(response, interaction);
2147
+ case ApplicationCommandType.Message: return new MessageContextMenuCommandInteraction(response, interaction);
2148
+ case ApplicationCommandType.PrimaryEntryPoint: throw new Error("PrimaryEntryPoint is not supported");
2149
+ }
2150
+ case InteractionType.MessageComponent: switch (interaction.data.component_type) {
2151
+ case ComponentType.Button: return new MessageComponentButtonInteraction(response, interaction);
2152
+ case ComponentType.ChannelSelect: return new MessageComponentChannelSelectInteraction(response, interaction);
2153
+ case ComponentType.MentionableSelect: return new MessageComponentMentionableSelectInteraction(response, interaction);
2154
+ case ComponentType.RoleSelect: return new MessageComponentRoleSelectInteraction(response, interaction);
2155
+ case ComponentType.StringSelect: return new MessageComponentStringSelectInteraction(response, interaction);
2156
+ case ComponentType.UserSelect: return new MessageComponentUserSelectInteraction(response, interaction);
2157
+ }
2158
+ case InteractionType.ApplicationCommandAutocomplete: return new AutocompleteInteraction(response, interaction);
2159
+ case InteractionType.ModalSubmit: return new ModalSubmitInteraction(response, interaction);
2160
+ }
2161
+ }
2162
+ /**
2163
+ * Handles a received error. This function must only be called if the HTTP
2164
+ * interaction was not replied to.
2165
+ *
2166
+ * This function has a special case for string errors, which are translated to a
2167
+ * regular message with content as the error.
2168
+ *
2169
+ * When an error is thrown, the error is emitted in client, and a generic error
2170
+ * message is sent back to Discord.
2171
+ * @param response The HTTP request we can response to.
2172
+ * @param error The error to handle.
2173
+ * @returns The response object.
2174
+ */
2175
+ function handleError(response, error) {
2176
+ container$1.client.emit("error", error);
2177
+ if (!container$1.client.httpReplyOnError || response.closed) return response;
2178
+ response.statusCode = 500;
2179
+ return response.end(ErrorMessages.InternalError);
2180
+ }
2181
+ function resultFromDiscord(promise) {
2182
+ return Result.fromAsync(promise);
2183
+ }
2184
+
2185
+ //#endregion
2186
+ //#region src/lib/interactions/structures/Message.ts
2187
+ var PartialMessage = class {
2188
+ constructor(interaction) {
2189
+ _defineProperty(this, "interaction", void 0);
2190
+ this.interaction = interaction;
2191
+ }
2192
+ /**
2193
+ * The ID of the message.
2194
+ */
2195
+ get id() {
2196
+ return "@original";
2197
+ }
2198
+ /**
2199
+ * The thread, if the message started one.
2200
+ */
2201
+ get thread() {}
2202
+ /**
2203
+ * Retrieves the message from Discord, returns a clone of the instance.
2204
+ */
2205
+ async get() {
2206
+ return (await resultFromDiscord(container$1.rest.get(Routes.webhookMessage(this.interaction.applicationId, this.interaction.token, this.id), {
2207
+ auth: false,
2208
+ query: makeURLSearchParams({ thread_id: this.thread?.id })
2209
+ }))).map((data) => new Message(this.interaction, data));
2210
+ }
2211
+ /**
2212
+ * Updates the message, returns a clone of the instance.
2213
+ * @param data The data to be sent.
2214
+ */
2215
+ async update({ files, ...body }) {
2216
+ return (await resultFromDiscord(container$1.rest.patch(Routes.webhookMessage(this.interaction.applicationId, this.interaction.token, this.id), {
2217
+ body,
2218
+ files,
2219
+ auth: false,
2220
+ query: makeURLSearchParams({ thread_id: this.thread?.id })
2221
+ }))).map((data) => new Message(this.interaction, data));
2222
+ }
2223
+ /**
2224
+ * Deletes the message.
2225
+ */
2226
+ async delete() {
2227
+ return (await resultFromDiscord(container$1.rest.delete(Routes.webhookMessage(this.interaction.applicationId, this.interaction.token, this.id), {
2228
+ auth: false,
2229
+ query: makeURLSearchParams({ thread_id: this.thread?.id })
2230
+ }))).map(() => this);
2231
+ }
2232
+ };
2233
+ var Message = class extends PartialMessage {
2234
+ constructor(interaction, data) {
2235
+ super(interaction);
2236
+ _defineProperty(this, Data, void 0);
2237
+ this[Data] = data;
2238
+ }
2239
+ /**
2240
+ * The ID of the message.
2241
+ *
2242
+ * @raw
2243
+ */
2244
+ get id() {
2245
+ return this[Data].id;
2246
+ }
2247
+ /**
2248
+ * The ID of the channel the message is from.
2249
+ *
2250
+ * @raw
2251
+ * @seealso {@link channelId} for the camelCase property.
2252
+ */
2253
+ get channel_id() {
2254
+ return this[Data].channel_id;
2255
+ }
2256
+ /**
2257
+ * The ID of the channel the message is from.
2258
+ */
2259
+ get channelId() {
2260
+ return this.channel_id;
2261
+ }
2262
+ /**
2263
+ * The author of this message (only a valid user in the case where the message is generated by a user or bot user)
2264
+ *
2265
+ * If the message is generated by a webhook, the author object corresponds to the webhook's id,
2266
+ * username, and avatar. You can tell if a message is generated by a webhook by checking for the {@link webhookId} property
2267
+ *
2268
+ * @raw
2269
+ * @seealso {@link https://discord.com/developers/docs/resources/user#user-object}
2270
+ */
2271
+ get author() {
2272
+ return this[Data].author;
2273
+ }
2274
+ /**
2275
+ * The contents of the message.
2276
+ *
2277
+ * @raw
2278
+ */
2279
+ get content() {
2280
+ return this[Data].content;
2281
+ }
2282
+ /**
2283
+ * The timestamp the message was sent at.
2284
+ *
2285
+ * @raw
2286
+ * @seealso {@link createdTimestamp} for the parsed timestamp.
2287
+ * @seealso {@link createdAt} for the Date instance created from the parsed timestamp.
2288
+ */
2289
+ get timestamp() {
2290
+ return this[Data].timestamp;
2291
+ }
2292
+ /**
2293
+ * The timestamp the message was sent at.
2294
+ *
2295
+ * @seealso {@link timestamp} for the raw data.
2296
+ */
2297
+ get createdTimestamp() {
2298
+ return Date.parse(this.timestamp);
2299
+ }
2300
+ /**
2301
+ * The {@link Date} version of {@link createdTimestamp}.
2302
+ */
2303
+ get createdAt() {
2304
+ return new Date(this.createdTimestamp);
2305
+ }
2306
+ /**
2307
+ * The timestamp the message was edited at, `null` if it was never edited.
2308
+ *
2309
+ * @raw
2310
+ * @seealso {@link editedTimestamp} for the parsed timestamp.
2311
+ * @seealso {@link editedAt} for the Date instance created from the parsed timestamp.
2312
+ */
2313
+ get edited_timestamp() {
2314
+ return this[Data].edited_timestamp;
2315
+ }
2316
+ /**
2317
+ * The timestamp the message was edited at, `null` if it was never edited.
2318
+ */
2319
+ get editedTimestamp() {
2320
+ const value = this.edited_timestamp;
2321
+ return isNullishOrEmpty(value) ? null : Date.parse(value);
2322
+ }
2323
+ /**
2324
+ * The {@link Date} version of {@link editedTimestamp}.
2325
+ */
2326
+ get editedAt() {
2327
+ const value = this.editedTimestamp;
2328
+ return isNullishOrEmpty(value) ? null : new Date(value);
2329
+ }
2330
+ /**
2331
+ * Whether or not the message is a TTS message.
2332
+ *
2333
+ * @raw
2334
+ */
2335
+ get tts() {
2336
+ return this[Data].tts;
2337
+ }
2338
+ /**
2339
+ * Whether or not the message mentioned everyone.
2340
+ *
2341
+ * @raw
2342
+ * @seealso {@link mention_everyone} for the camelCase property.
2343
+ */
2344
+ get mention_everyone() {
2345
+ return this[Data].mention_everyone;
2346
+ }
2347
+ /**
2348
+ * Whether or not the message mentioned everyone.
2349
+ *
2350
+ * @seealso {@link mention_everyone} for the raw data.
2351
+ */
2352
+ get mentionEveryone() {
2353
+ return this.mention_everyone;
2354
+ }
2355
+ /**
2356
+ * The users specifically mentioned in the message.
2357
+ *
2358
+ * @raw
2359
+ * @seealso {@link https://discord.com/developers/docs/resources/user#user-object}
2360
+ */
2361
+ get mentions() {
2362
+ return this[Data].mentions;
2363
+ }
2364
+ /**
2365
+ * The roles specifically mentioned in the message.
2366
+ *
2367
+ * @raw
2368
+ * @seealso {@link https://discord.com/developers/docs/topics/permissions#role-object}
2369
+ */
2370
+ get mention_roles() {
2371
+ return this[Data].mention_roles;
2372
+ }
2373
+ /**
2374
+ * The roles specifically mentioned in the message.
2375
+ *
2376
+ * @seealso {@link https://discord.com/developers/docs/topics/permissions#role-object}
2377
+ * @seealso {@link mention_roles} for the raw data.
2378
+ */
2379
+ get mentionRoles() {
2380
+ return this.mention_roles;
2381
+ }
2382
+ /**
2383
+ * The channels specifically mentioned in this message.
2384
+ *
2385
+ * Not all channel mentions in a message will appear in {@link mentionChannels}:
2386
+ * - Only textual channels that are visible to everyone in a lurkable guild will ever be included.
2387
+ * - Only crossposted messages (via Channel Following) currently include {@link mentionChannels} at all.
2388
+ *
2389
+ * @raw
2390
+ * @seealso {@link mentionChannels} for the camelCase property with an empty array default.
2391
+ * @seealso {@link https://discord.com/developers/docs/resources/channel#channel-mention-object}
2392
+ */
2393
+ get mention_channels() {
2394
+ return this[Data].mention_channels;
2395
+ }
2396
+ /**
2397
+ * The channels specifically mentioned in this message.
2398
+ *
2399
+ * Not all channel mentions in a message will appear in {@link mentionChannels}:
2400
+ * - Only textual channels that are visible to everyone in a lurkable guild will ever be included.
2401
+ * - Only crossposted messages (via Channel Following) currently include {@link mentionChannels} at all.
2402
+ *
2403
+ * @seealso {@link https://discord.com/developers/docs/resources/channel#channel-mention-object}
2404
+ */
2405
+ get mentionChannels() {
2406
+ return this[Data].mention_channels ?? [];
2407
+ }
2408
+ /**
2409
+ * A nonce that can be used for optimistic message sending (up to 25 characters).
2410
+ *
2411
+ * @raw
2412
+ */
2413
+ get nonce() {
2414
+ return this[Data].nonce;
2415
+ }
2416
+ /**
2417
+ * Whether or not the message is pinned.
2418
+ *
2419
+ * @raw
2420
+ */
2421
+ get pinned() {
2422
+ return this[Data].pinned;
2423
+ }
2424
+ /**
2425
+ * The attached files.
2426
+ *
2427
+ * @seealso {@link https://discord.com/developers/docs/resources/channel#attachment-object}
2428
+ */
2429
+ get attachments() {
2430
+ return this[Data].attachments;
2431
+ }
2432
+ /**
2433
+ * The embedded content.
2434
+ *
2435
+ * @seealso {@link https://discord.com/developers/docs/resources/channel#embed-object}
2436
+ */
2437
+ get embeds() {
2438
+ return this[Data].embeds;
2439
+ }
2440
+ /**
2441
+ * The reactions the message has.
2442
+ *
2443
+ * @seealso {@link https://discord.com/developers/docs/resources/channel#reaction-object}
2444
+ */
2445
+ get reactions() {
2446
+ return this[Data].reactions ?? [];
2447
+ }
2448
+ /**
2449
+ * The webhook ID.
2450
+ */
2451
+ get webhook_id() {
2452
+ return this[Data].webhook_id;
2453
+ }
2454
+ /**
2455
+ * The webhook ID.
2456
+ *
2457
+ * @seealso {@link webhook_id} for the raw data.
2458
+ */
2459
+ get webhookId() {
2460
+ return this.webhook_id ?? null;
2461
+ }
2462
+ /**
2463
+ * The message's type.
2464
+ *
2465
+ * @seealso {@link https://discord.com/developers/docs/resources/channel#message-object-message-types}
2466
+ */
2467
+ get type() {
2468
+ return this[Data].type;
2469
+ }
2470
+ /**
2471
+ * The thread, if the message started one.
2472
+ */
2473
+ get thread() {
2474
+ return this[Data].thread;
2475
+ }
2476
+ /**
2477
+ * The message flags combined as a bitfield.
2478
+ *
2479
+ * @seealso {@link https://discord.com/developers/docs/resources/channel#message-object-message-flags}
2480
+ * @seealso {@link https://en.wikipedia.org/wiki/Bit_field}
2481
+ */
2482
+ get flags() {
2483
+ return this[Data].flags;
2484
+ }
2485
+ /**
2486
+ * The message's components, such as buttons, action rows, or other interactive components.
2487
+ */
2488
+ get components() {
2489
+ return this[Data].components ?? [];
2490
+ }
2491
+ /**
2492
+ * The stickers the message contains, if any.
2493
+ */
2494
+ get sticker_items() {
2495
+ return this[Data].sticker_items;
2496
+ }
2497
+ /**
2498
+ * The stickers the message contains, if any.
2499
+ *
2500
+ * @seealso {@link sticker_items} for the raw data.
2501
+ */
2502
+ get stickerItems() {
2503
+ return this.sticker_items ?? [];
2504
+ }
2505
+ };
2506
+
2507
+ //#endregion
2508
+ //#region src/lib/errors/ChatInputRouterError.ts
2509
+ /**
2510
+ * Represents an error that is thrown when a {@link ChatInputRouter} encounters an error.
2511
+ * @since 2.0.0
2512
+ */
2513
+ var ChatInputRouterError = class extends Error {
2514
+ constructor(key, command, group, subcommand) {
2515
+ super(ChatInputRouterErrors[key](command.name, group?.name ?? "", subcommand?.name ?? ""));
2516
+ _defineProperty(this, "key", void 0);
2517
+ _defineProperty(this, "command", void 0);
2518
+ _defineProperty(this, "group", void 0);
2519
+ _defineProperty(this, "subcommand", void 0);
2520
+ this.key = key;
2521
+ this.command = command;
2522
+ this.group = group ?? null;
2523
+ this.subcommand = subcommand ?? null;
2524
+ }
2525
+ /**
2526
+ * The path of the command that was being processed when the error was thrown.
2527
+ * @since 2.0.0
2528
+ */
2529
+ get path() {
2530
+ return `${this.command.name}${this.group ? `/${this.group.name}` : ""}${this.subcommand ? `/${this.subcommand.name}` : ""}`;
2531
+ }
2532
+ };
2533
+ const ChatInputRouterErrors = {
2534
+ DuplicatedSubcommandGroup: (command, subcommandGroup) => `Duplicated subcommand group named '${subcommandGroup}' in command '${command}'`,
2535
+ DuplicatedSubcommand: (command, subcommandGroup, subcommand) => `Duplicated subcommand named '${subcommand}' in subcommand group '${subcommandGroup}' in command '${command}'`,
2536
+ SubcommandGroupLinkInvalid: (command, subcommandGroup) => `Subcommand group named '${subcommandGroup}' in command '${command}' is not linked to a method`,
2537
+ SubcommandLinkInvalid: (command, subcommandGroup, subcommand) => `Subcommand named '${subcommand}' ${subcommandGroup ? `in subcommand group '${subcommandGroup}' ` : ""}in command '${command}' is not linked to a method`
2538
+ };
2539
+
2540
+ //#endregion
2541
+ //#region src/lib/interactions/router/CommandRouterSubcommand.ts
2542
+ var _subcommandMapping$1 = /* @__PURE__ */ new WeakMap();
2543
+ /**
2544
+ * Represents a subcommand in a command router.
2545
+ *
2546
+ * @template Options - The options type for the command.
2547
+ * @internal
2548
+ */
2549
+ var CommandRouterSubcommand = class {
2550
+ constructor() {
2551
+ _classPrivateFieldInitSpec(this, _subcommandMapping$1, null);
2552
+ }
2553
+ /**
2554
+ * Checks if the subcommand is a subcommand group.
2555
+ *
2556
+ * @returns True if the subcommand is a subcommand group, false otherwise.
2557
+ */
2558
+ isSubcommandGroup() {
2559
+ return false;
2560
+ }
2561
+ /**
2562
+ * Checks if the subcommand is a subcommand.
2563
+ *
2564
+ * @returns True if the subcommand is a subcommand, false otherwise.
2565
+ */
2566
+ isSubcommand() {
2567
+ return true;
2568
+ }
2569
+ /**
2570
+ * Throws an error indicating that the subcommand is a subcommand group.
2571
+ *
2572
+ * @throws Error - Cannot assert subcommand on a subcommand group.
2573
+ */
2574
+ assertSubcommandGroup() {
2575
+ throw new Error("Cannot assert subcommand on a subcommand group");
2576
+ }
2577
+ /**
2578
+ * Asserts that the subcommand is a subcommand.
2579
+ *
2580
+ * @returns The current subcommand instance.
2581
+ */
2582
+ assertSubcommand() {
2583
+ return this;
2584
+ }
2585
+ /**
2586
+ * Gets the subcommand mapping.
2587
+ *
2588
+ * @returns The subcommand mapping.
2589
+ */
2590
+ getSubcommandMapping() {
2591
+ return _classPrivateFieldGet2(_subcommandMapping$1, this);
2592
+ }
2593
+ /**
2594
+ * Sets the subcommand mapping.
2595
+ *
2596
+ * @param command - The command instance.
2597
+ * @param subcommand - The subcommand option.
2598
+ * @param method - The method name.
2599
+ * @returns The current subcommand instance.
2600
+ * @throws ChatInputRouterError - Throws an error if the method is not a function.
2601
+ */
2602
+ setSubcommandMapping(command, subcommand, method) {
2603
+ if (!isFunction(Reflect.get(command, method))) throw new ChatInputRouterError("SubcommandLinkInvalid", command, null, subcommand);
2604
+ _classPrivateFieldSet2(_subcommandMapping$1, this, method);
2605
+ return this;
2606
+ }
2607
+ };
2608
+
2609
+ //#endregion
2610
+ //#region src/lib/interactions/router/CommandRouterSubcommandGroup.ts
2611
+ var _subcommandGroupMapping = /* @__PURE__ */ new WeakMap();
2612
+ var _subcommandMapping = /* @__PURE__ */ new WeakMap();
2613
+ /**
2614
+ * Represents a subcommand group in a command router.
2615
+ *
2616
+ * @template Options - The options type for the command.
2617
+ * @internal
2618
+ */
2619
+ var CommandRouterSubcommandGroup = class {
2620
+ constructor() {
2621
+ _classPrivateFieldInitSpec(this, _subcommandGroupMapping, null);
2622
+ _classPrivateFieldInitSpec(this, _subcommandMapping, new Collection());
2623
+ }
2624
+ /**
2625
+ * Checks if this instance is a subcommand group.
2626
+ *
2627
+ * @returns True if this instance is a subcommand group, false otherwise.
2628
+ */
2629
+ isSubcommandGroup() {
2630
+ return true;
2631
+ }
2632
+ /**
2633
+ * Checks if this instance is a subcommand.
2634
+ *
2635
+ * @returns True if this instance is a subcommand, false otherwise.
2636
+ */
2637
+ isSubcommand() {
2638
+ return false;
2639
+ }
2640
+ /**
2641
+ * Asserts that this instance is a subcommand group.
2642
+ *
2643
+ * @returns The current instance.
2644
+ */
2645
+ assertSubcommandGroup() {
2646
+ return this;
2647
+ }
2648
+ /**
2649
+ * Throws an error indicating that this instance cannot be asserted as a subcommand.
2650
+ * @throws Error - An error indicating that subcommand cannot be asserted on a subcommand group.
2651
+ */
2652
+ assertSubcommand() {
2653
+ throw new Error("Cannot assert subcommand on a subcommand group");
2654
+ }
2655
+ /**
2656
+ * Gets the subcommand group mapping.
2657
+ *
2658
+ * @returns The subcommand group mapping.
2659
+ */
2660
+ getSubcommandGroupMapping() {
2661
+ return _classPrivateFieldGet2(_subcommandGroupMapping, this);
2662
+ }
2663
+ /**
2664
+ * Gets the subcommand mapping for the specified subcommand.
2665
+ *
2666
+ * @param subcommand - The name of the subcommand.
2667
+ * @returns The subcommand mapping.
2668
+ */
2669
+ getSubcommandMapping(subcommand) {
2670
+ return _classPrivateFieldGet2(_subcommandMapping, this).get(subcommand) ?? null;
2671
+ }
2672
+ /**
2673
+ * Sets the subcommand group mapping.
2674
+ *
2675
+ * @param command - The command instance.
2676
+ * @param group - The subcommand group option.
2677
+ * @param method - The method name.
2678
+ * @returns The current instance.
2679
+ * @throws ChatInputRouterError - If the method is not a function on the command instance.
2680
+ */
2681
+ setSubcommandGroupMapping(command, group, method) {
2682
+ if (!isFunction(Reflect.get(command, method))) throw new ChatInputRouterError("SubcommandGroupLinkInvalid", command, group, null);
2683
+ _classPrivateFieldSet2(_subcommandGroupMapping, this, method);
2684
+ return this;
2685
+ }
2686
+ /**
2687
+ * Sets the subcommand mapping.
2688
+ *
2689
+ * @param command - The command instance.
2690
+ * @param group - The subcommand group option.
2691
+ * @param subcommand - The subcommand option.
2692
+ * @param method - The method name.
2693
+ * @returns The current instance.
2694
+ * @throws ChatInputRouterError - If the method is not a function on the command instance.
2695
+ */
2696
+ setSubcommandMapping(command, group, subcommand, method) {
2697
+ if (!isFunction(Reflect.get(command, method))) throw new ChatInputRouterError("SubcommandLinkInvalid", command, group, subcommand);
2698
+ _classPrivateFieldGet2(_subcommandMapping, this).set(subcommand.name, method);
2699
+ return this;
2700
+ }
2701
+ };
2702
+
2703
+ //#endregion
2704
+ //#region src/lib/interactions/router/CommandRouter.ts
2705
+ var _command = /* @__PURE__ */ new WeakMap();
2706
+ var _chatInputName = /* @__PURE__ */ new WeakMap();
2707
+ var _chatInputRouter = /* @__PURE__ */ new WeakMap();
2708
+ var _messageContextMenuRouter = /* @__PURE__ */ new WeakMap();
2709
+ var _userContextMenuRouter = /* @__PURE__ */ new WeakMap();
2710
+ var _CommandRouter_brand = /* @__PURE__ */ new WeakSet();
2711
+ /**
2712
+ * Represents a command router that handles routing of interactions for a specific command.
2713
+ *
2714
+ * @since 2.0.0
2715
+ * @template Options - The options type for the command.
2716
+ */
2717
+ var CommandRouter = class {
2718
+ constructor(command) {
2719
+ _classPrivateMethodInitSpec(this, _CommandRouter_brand);
2720
+ _classPrivateFieldInitSpec(this, _command, void 0);
2721
+ _classPrivateFieldInitSpec(this, _chatInputName, null);
2722
+ _classPrivateFieldInitSpec(this, _chatInputRouter, new Collection());
2723
+ _classPrivateFieldInitSpec(this, _messageContextMenuRouter, new Collection());
2724
+ _classPrivateFieldInitSpec(this, _userContextMenuRouter, new Collection());
2725
+ _classPrivateFieldSet2(_command, this, command);
2726
+ const entry = container$1.applicationCommandRegistry.get(command.constructor);
2727
+ if (entry === null) console.warn(`CommandRouter: No entry found for command '${command.name}'`);
2728
+ else {
2729
+ _assertClassBrand(_CommandRouter_brand, this, _populateChatInputRouter).call(this, entry.chatInput);
2730
+ _assertClassBrand(_CommandRouter_brand, this, _populateContextMenuRouter).call(this, entry.contextMenu);
2731
+ }
2732
+ }
2733
+ /**
2734
+ * The name of the registered chat input command for this command, if any.
2735
+ *
2736
+ * @since 2.0.0
2737
+ */
2738
+ get chatInputName() {
2739
+ return _classPrivateFieldGet2(_chatInputName, this);
2740
+ }
2741
+ /**
2742
+ * The names of the registered context menu commands for this command, if any.
2743
+ *
2744
+ * @since 2.0.0
2745
+ */
2746
+ get contextMenuNames() {
2747
+ return [..._classPrivateFieldGet2(_messageContextMenuRouter, this).keys(), ..._classPrivateFieldGet2(_userContextMenuRouter, this).keys()];
2748
+ }
2749
+ /**
2750
+ * Routes a chat input interaction based on the provided data.
2751
+ *
2752
+ * @since 2.0.0
2753
+ * @param data - The data of the chat input interaction.
2754
+ * @returns The mapped command name or `null` if no mapping is found.
2755
+ */
2756
+ routeChatInputInteraction(data) {
2757
+ if (!data.options?.length) return "chatInputRun";
2758
+ const [firstOption] = data.options;
2759
+ if (firstOption.type === ApplicationCommandOptionType.Subcommand) {
2760
+ const entry = _classPrivateFieldGet2(_chatInputRouter, this).get(firstOption.name);
2761
+ return entry?.isSubcommand() ? entry.getSubcommandMapping() : null;
2762
+ }
2763
+ if (firstOption.type === ApplicationCommandOptionType.SubcommandGroup) {
2764
+ const entry = _classPrivateFieldGet2(_chatInputRouter, this).get(firstOption.name);
2765
+ return entry?.isSubcommandGroup() ? entry.getSubcommandMapping(firstOption.options[0].name) ?? entry.getSubcommandGroupMapping() : null;
2766
+ }
2767
+ return "chatInputRun";
2768
+ }
2769
+ /**
2770
+ * Routes a context menu interaction based on the provided data.
2771
+ *
2772
+ * @since 2.0.0
2773
+ * @param data - The data for the context menu interaction.
2774
+ * @returns The result of the context menu interaction, or null if no result is found.
2775
+ */
2776
+ routeContextMenuInteraction(data) {
2777
+ return _assertClassBrand(_CommandRouter_brand, this, _getContextMenuCollection).call(this, data.type)?.get(data.name) ?? null;
2778
+ }
2779
+ };
2780
+ function _populateChatInputRouter(entry) {
2781
+ if (entry === null) return;
2782
+ const data = entry.toJSON();
2783
+ _classPrivateFieldSet2(_chatInputName, this, data.name);
2784
+ if (!data.options?.length) return;
2785
+ const command = _classPrivateFieldGet2(_command, this);
2786
+ const chatInputRouter = _classPrivateFieldGet2(_chatInputRouter, this);
2787
+ for (const option of data.options) if (option.type === ApplicationCommandOptionType.SubcommandGroup) {
2788
+ const entry = chatInputRouter.ensure(option.name, () => new CommandRouterSubcommandGroup()).assertSubcommandGroup();
2789
+ const subcommandGroupMethod = getLinkedMethod(option);
2790
+ if (subcommandGroupMethod) entry.setSubcommandGroupMapping(command, option, subcommandGroupMethod);
2791
+ for (const subOption of option.options ?? []) {
2792
+ const subcommandMethod = getLinkedMethod(subOption);
2793
+ if (subcommandMethod) entry.setSubcommandMapping(command, option, subOption, subcommandMethod);
2794
+ }
2795
+ } else if (option.type === ApplicationCommandOptionType.Subcommand) {
2796
+ const entry = chatInputRouter.ensure(option.name, () => new CommandRouterSubcommand()).assertSubcommand();
2797
+ const subcommandMethod = getLinkedMethod(option);
2798
+ if (subcommandMethod) entry.setSubcommandMapping(command, option, subcommandMethod);
2799
+ }
2800
+ }
2801
+ function _populateContextMenuRouter(entries) {
2802
+ const command = _classPrivateFieldGet2(_command, this);
2803
+ for (const entry of entries) {
2804
+ const data = entry.toJSON();
2805
+ const method = getLinkedMethod(data);
2806
+ if (!method) continue;
2807
+ if (isFunction(Reflect.get(command, method))) _assertClassBrand(_CommandRouter_brand, this, _getContextMenuCollection).call(this, data.type)?.set(data.name, method);
2808
+ else throw new Error(`Context menu command named "${data.name}" is not linked to a method`);
2809
+ }
2810
+ }
2811
+ function _getContextMenuCollection(type) {
2812
+ switch (type) {
2813
+ case ApplicationCommandType.Message: return _classPrivateFieldGet2(_messageContextMenuRouter, this);
2814
+ case ApplicationCommandType.User: return _classPrivateFieldGet2(_userContextMenuRouter, this);
2815
+ default: return null;
2816
+ }
2817
+ }
2818
+
2819
+ //#endregion
2820
+ //#region src/lib/structures/Command.ts
2821
+ var Command = class extends Piece$1 {
2822
+ constructor(context, options = {}) {
2823
+ super(context, options);
2824
+ _defineProperty(this, "router", void 0);
2825
+ this.router = new CommandRouter(this);
2826
+ }
2827
+ /**
2828
+ * Gets the registry for this command.
2829
+ *
2830
+ * @returns The registry for this command, or `null` if it is not registered.
2831
+ */
2832
+ get registry() {
2833
+ return this.container.applicationCommandRegistry.get(this.constructor) ?? null;
2834
+ }
2835
+ chatInputRun() {
2836
+ throw new Error(`The method 'chatInputRun' has not been implemented in ${this.name}.`);
2837
+ }
2838
+ autocompleteRun() {
2839
+ throw new Error(`The method 'autocompleteRun' has not been implemented in ${this.name}.`);
2840
+ }
2841
+ };
2842
+
2843
+ //#endregion
2844
+ //#region src/lib/structures/CommandLoaderStrategy.ts
2845
+ /**
2846
+ * Represents a strategy for loading and unloading commands.
2847
+ *
2848
+ * @since 2.0.0
2849
+ */
2850
+ var CommandLoaderStrategy = class extends LoaderStrategy {
2851
+ /**
2852
+ * Called when a command is loaded.
2853
+ *
2854
+ * @since 2.0.0
2855
+ * @param store - The command store.
2856
+ * @param piece - The command being loaded.
2857
+ * @returns The loaded command.
2858
+ */
2859
+ onLoad(store, piece) {
2860
+ if (piece.router.chatInputName) store.router.addChatInputMapping(piece.router.chatInputName, piece);
2861
+ for (const name of piece.router.contextMenuNames) store.router.addContextMenuMapping(name, piece);
2862
+ return piece;
2863
+ }
2864
+ /**
2865
+ * Called when a command is unloaded.
2866
+ *
2867
+ * @since 2.0.0
2868
+ * @param store - The command store.
2869
+ * @param piece - The command being unloaded.
2870
+ * @returns The unloaded command.
2871
+ */
2872
+ onUnload(store, piece) {
2873
+ if (piece.router.chatInputName) store.router.removeChatInputMapping(piece.router.chatInputName);
2874
+ for (const name of piece.router.contextMenuNames) store.router.removeContextMenuMapping(name);
2875
+ return piece;
2876
+ }
2877
+ };
2878
+
2879
+ //#endregion
2880
+ //#region src/lib/structures/CommandStoreRouter.ts
2881
+ var _chatInputMappings = /* @__PURE__ */ new WeakMap();
2882
+ var _contextMenuMappings = /* @__PURE__ */ new WeakMap();
2883
+ /**
2884
+ * Represents a router for mapping commands to chat inputs and context menus.
2885
+ *
2886
+ * @since 2.0.0
2887
+ */
2888
+ var CommandStoreRouter = class {
2889
+ constructor() {
2890
+ _classPrivateFieldInitSpec(this, _chatInputMappings, new Collection());
2891
+ _classPrivateFieldInitSpec(this, _contextMenuMappings, new Collection());
2892
+ }
2893
+ /**
2894
+ * Gets the command associated with the given interaction.
2895
+ *
2896
+ * @since 2.0.0
2897
+ * @param interaction - The interaction object.
2898
+ * @returns The command associated with the interaction, or null if not found.
2899
+ */
2900
+ get(interaction) {
2901
+ return interaction.data.type === ApplicationCommandType.ChatInput ? this.getChatInput(interaction.data.name) : this.getContextMenu(interaction.data.name);
2902
+ }
2903
+ /**
2904
+ * Gets the chat input command with the specified name.
2905
+ *
2906
+ * @since 2.0.0
2907
+ * @param name - The name of the chat input command.
2908
+ * @returns The chat input command with the specified name, or null if not found.
2909
+ */
2910
+ getChatInput(name) {
2911
+ return _classPrivateFieldGet2(_chatInputMappings, this).get(name) ?? null;
2912
+ }
2913
+ /**
2914
+ * Gets the context menu command with the specified name.
2915
+ *
2916
+ * @since 2.0.0
2917
+ * @param name - The name of the context menu command.
2918
+ * @returns The context menu command with the specified name, or null if not found.
2919
+ */
2920
+ getContextMenu(name) {
2921
+ return _classPrivateFieldGet2(_contextMenuMappings, this).get(name) ?? null;
2922
+ }
2923
+ /**
2924
+ * Adds a chat input mapping.
2925
+ *
2926
+ * @since 2.0.0
2927
+ * @param name - The name of the mapping.
2928
+ * @param command - The command to be mapped.
2929
+ * @internal
2930
+ */
2931
+ addChatInputMapping(name, command) {
2932
+ _classPrivateFieldGet2(_chatInputMappings, this).set(name, command);
2933
+ }
2934
+ /**
2935
+ * Adds a context menu mapping.
2936
+ *
2937
+ * @since 2.0.0
2938
+ * @param name - The name of the mapping.
2939
+ * @param command - The command to be mapped.
2940
+ * @internal
2941
+ */
2942
+ addContextMenuMapping(name, command) {
2943
+ _classPrivateFieldGet2(_contextMenuMappings, this).set(name, command);
2944
+ }
2945
+ /**
2946
+ * Removes a chat input mapping.
2947
+ *
2948
+ * @since 2.0.0
2949
+ * @param name - The name of the mapping to be removed.
2950
+ * @returns True if the mapping was successfully removed, false otherwise.
2951
+ * @internal
2952
+ */
2953
+ removeChatInputMapping(name) {
2954
+ return _classPrivateFieldGet2(_chatInputMappings, this).delete(name);
2955
+ }
2956
+ /**
2957
+ * Removes a context menu mapping.
2958
+ *
2959
+ * @since 2.0.0
2960
+ * @param name - The name of the mapping to be removed.
2961
+ * @returns True if the mapping was successfully removed, false otherwise.
2962
+ * @internal
2963
+ */
2964
+ removeContextMenuMapping(name) {
2965
+ return _classPrivateFieldGet2(_contextMenuMappings, this).delete(name);
2966
+ }
2967
+ };
2968
+
2969
+ //#endregion
2970
+ //#region src/lib/structures/CommandStore.ts
2971
+ var _CommandStore_brand = /* @__PURE__ */ new WeakSet();
2972
+ var CommandStore = class extends Store$1 {
2973
+ constructor() {
2974
+ super(Command, {
2975
+ name: "commands",
2976
+ strategy: new CommandLoaderStrategy()
2977
+ });
2978
+ _classPrivateMethodInitSpec(this, _CommandStore_brand);
2979
+ _defineProperty(this, "router", new CommandStoreRouter());
2980
+ }
2981
+ /**
2982
+ * Runs an application command.
2983
+ *
2984
+ * @since 1.0.0
2985
+ * @param response - The server response object.
2986
+ * @param interaction - The API application command interaction object.
2987
+ * @returns A promise that resolves to the server response.
2988
+ */
2989
+ async runApplicationCommand(response, interaction) {
2990
+ const command = this.router.get(interaction);
2991
+ if (!command) {
2992
+ container$1.client.emit("commandNameUnknown", interaction, response);
2993
+ response.statusCode = 501;
2994
+ return response.end(ErrorMessages.UnknownCommandName);
2995
+ }
2996
+ const context = {
2997
+ command,
2998
+ interaction,
2999
+ response
3000
+ };
3001
+ const method = _assertClassBrand(_CommandStore_brand, this, _routeCommandMethodName).call(this, command, interaction.data);
3002
+ if (!method) {
3003
+ container$1.client.emit("commandMethodUnknown", context);
3004
+ response.statusCode = 501;
3005
+ return response.end(ErrorMessages.UnknownCommandHandler);
3006
+ }
3007
+ container$1.client.emit("commandRun", context);
3008
+ (await Result.fromAsync(() => _assertClassBrand(_CommandStore_brand, this, _runCommandMethod).call(this, command, method, makeInteraction(response, interaction)))).inspect((value) => container$1.client.emit("commandSuccess", context, value)).inspectErr((error) => (container$1.client.emit("commandError", error, context), handleError(response, error)));
3009
+ container$1.client.emit("commandFinish", context);
3010
+ return response;
3011
+ }
3012
+ /**
3013
+ * Runs the application command autocomplete.
3014
+ *
3015
+ * @since 1.0.0
3016
+ * @param response - The server response object.
3017
+ * @param interaction - The API application command autocomplete interaction object.
3018
+ * @returns A promise that resolves to the server response.
3019
+ */
3020
+ async runApplicationCommandAutocomplete(response, interaction) {
3021
+ if (!interaction.data?.name) {
3022
+ container$1.client.emit("commandNameMissing", interaction, response);
3023
+ response.statusCode = 400;
3024
+ return response.end(ErrorMessages.MissingCommandName);
3025
+ }
3026
+ const command = this.router.getChatInput(interaction.data.name);
3027
+ if (!command) {
3028
+ container$1.client.emit("commandNameUnknown", interaction, response);
3029
+ response.statusCode = 501;
3030
+ return response.end(ErrorMessages.UnknownCommandName);
3031
+ }
3032
+ const context = {
3033
+ command,
3034
+ interaction,
3035
+ response
3036
+ };
3037
+ const options = transformAutocompleteInteraction(interaction.data.resolved ?? {}, interaction.data.options);
3038
+ container$1.client.emit("autocompleteRun", context);
3039
+ (await Result.fromAsync(() => command.autocompleteRun(makeInteraction(response, interaction), options))).inspect((value) => container$1.client.emit("autocompleteSuccess", context, value)).inspectErr((error) => (container$1.client.emit("autocompleteError", error, context), handleError(response, error)));
3040
+ container$1.client.emit("autocompleteFinish", context);
3041
+ return response;
3042
+ }
3043
+ };
3044
+ /**
3045
+ * Executes a command method on a command object.
3046
+ *
3047
+ * @since 1.0.0
3048
+ * @param command - The command object.
3049
+ * @param method - The name of the method to execute.
3050
+ * @param interaction - The application command interaction.
3051
+ * @returns A promise that resolves to the result of the method execution.
3052
+ */
3053
+ function _runCommandMethod(command, method, interaction) {
3054
+ return Reflect.apply(Reflect.get(command, method), command, [interaction, _assertClassBrand(_CommandStore_brand, this, _createArguments).call(this, interaction.data)]);
3055
+ }
3056
+ /**
3057
+ * Determines the method name to route a command based on the type of interaction data.
3058
+ *
3059
+ * @since 1.0.0
3060
+ * @param command - The command object.
3061
+ * @param data - The interaction data.
3062
+ * @returns The method name to route the command, or null if no method is found.
3063
+ * @throws Error - If the interaction data type is not recognized.
3064
+ */
3065
+ function _routeCommandMethodName(command, data) {
3066
+ switch (data.type) {
3067
+ case ApplicationCommandType.ChatInput: return command.router.routeChatInputInteraction(data);
3068
+ case ApplicationCommandType.User:
3069
+ case ApplicationCommandType.Message: return command.router.routeContextMenuInteraction(data);
3070
+ default: throw new Error("Unreachable");
3071
+ }
3072
+ }
3073
+ /**
3074
+ * Creates arguments based on the provided {@linkcode APIApplicationCommandInteractionData}.
3075
+ *
3076
+ * @since 1.0.0
3077
+ * @param data The {@linkcode APIApplicationCommandInteractionData} object.
3078
+ * @returns The transformed arguments based on the interaction data.
3079
+ * @throws Error - If the {@linkcode ApplicationCommandType} is unsupported.
3080
+ */
3081
+ function _createArguments(data) {
3082
+ switch (data.type) {
3083
+ case ApplicationCommandType.ChatInput: return transformInteraction(data.resolved ?? {}, data.options ?? []);
3084
+ case ApplicationCommandType.User: return transformUserInteraction(data);
3085
+ case ApplicationCommandType.Message: return transformMessageInteraction(data);
3086
+ default: throw new Error("Unknown ApplicationCommandType");
3087
+ }
3088
+ }
3089
+
3090
+ //#endregion
3091
+ //#region src/lib/structures/InteractionHandler.ts
3092
+ var InteractionHandler = class extends Piece$1 {
3093
+ constructor(context, options = {}) {
3094
+ super(context, options);
3095
+ }
3096
+ };
3097
+
3098
+ //#endregion
3099
+ //#region src/lib/structures/InteractionHandlerStore.ts
3100
+ var InteractionHandlerStore = class extends Store$1 {
3101
+ constructor() {
3102
+ super(InteractionHandler, { name: "interaction-handlers" });
3103
+ }
3104
+ async runHandler(response, interaction) {
3105
+ const parsed = container$1.idParser.run(interaction.data.custom_id);
3106
+ if (parsed === null) {
3107
+ container$1.client.emit("interactionHandlerNameInvalid", interaction, response);
3108
+ response.statusCode = 400;
3109
+ return response.end(ErrorMessages.InvalidCustomId);
3110
+ }
3111
+ const handler = this.get(parsed.name);
3112
+ if (!handler) {
3113
+ container$1.client.emit("interactionHandlerNameUnknown", interaction, response);
3114
+ response.statusCode = 501;
3115
+ return response.end(ErrorMessages.UnknownHandlerName);
3116
+ }
3117
+ const context = {
3118
+ handler,
3119
+ interaction,
3120
+ response
3121
+ };
3122
+ container$1.client.emit("interactionHandlerRun", context);
3123
+ (await Result.fromAsync(() => handler.run(makeInteraction(response, interaction), parsed.content))).inspect((value) => container$1.client.emit("interactionHandlerSuccess", context, value)).inspectErr((error) => (container$1.client.emit("interactionHandlerError", error, context), handleError(response, error)));
3124
+ container$1.client.emit("interactionHandlerFinish", context);
3125
+ return response;
3126
+ }
3127
+ };
3128
+
3129
+ //#endregion
3130
+ //#region src/lib/structures/Listener.ts
3131
+ var Listener = class extends Piece$1 {
3132
+ constructor(context, options) {
3133
+ super(context, options);
3134
+ _defineProperty(this, "emitter", void 0);
3135
+ _defineProperty(this, "event", void 0);
3136
+ _defineProperty(this, "_listener", void 0);
3137
+ this.emitter = typeof options.emitter === "string" ? this.container[options.emitter] : options.emitter ?? this.container.client;
3138
+ this.event = options.event ?? this.name;
3139
+ this._listener = this.run.bind(this);
3140
+ }
3141
+ };
3142
+
3143
+ //#endregion
3144
+ //#region src/lib/structures/ListenerLoaderStrategy.ts
3145
+ /**
3146
+ * Represents a strategy for loading and unloading listeners.
3147
+ *
3148
+ * @since 2.1.0
3149
+ */
3150
+ var ListenerLoaderStrategy = class extends LoaderStrategy {
3151
+ /**
3152
+ * Called when a listener is loaded.
3153
+ *
3154
+ * @since 2.1.0
3155
+ * @param store - The listener store.
3156
+ * @param piece - The listener being loaded.
3157
+ * @returns The loaded listener.
3158
+ */
3159
+ onLoad(_store, piece) {
3160
+ const emitter = piece.emitter;
3161
+ const maxListeners = emitter.getMaxListeners();
3162
+ if (maxListeners !== 0) emitter.setMaxListeners(maxListeners + 1);
3163
+ emitter.on(piece.event, piece["_listener"]);
3164
+ }
3165
+ /**
3166
+ * Called when a listener is unloaded.
3167
+ *
3168
+ * @since 2.1.0
3169
+ * @param store - The listener store.
3170
+ * @param piece - The listener being unloaded.
3171
+ * @returns The unloaded listener.
3172
+ */
3173
+ onUnload(_store, piece) {
3174
+ const emitter = piece.emitter;
3175
+ const maxListeners = emitter.getMaxListeners();
3176
+ if (maxListeners !== 0) emitter.setMaxListeners(maxListeners - 1);
3177
+ emitter.off(piece.event, piece["_listener"]);
3178
+ }
3179
+ };
3180
+
3181
+ //#endregion
3182
+ //#region src/lib/structures/ListenerStore.ts
3183
+ var ListenerStore = class extends Store$1 {
3184
+ constructor() {
3185
+ super(Listener, {
3186
+ name: "listeners",
3187
+ strategy: new ListenerLoaderStrategy()
3188
+ });
3189
+ }
3190
+ };
3191
+
3192
+ //#endregion
3193
+ //#region src/lib/utils/security.ts
3194
+ const AlgorithmName = "Ed25519";
3195
+ function headerToString(header) {
3196
+ return typeof header === "string" ? header : header[0];
3197
+ }
3198
+ function makeKey(key) {
3199
+ return webcrypto.subtle.importKey("raw", Buffer.from(key, "hex"), { name: AlgorithmName }, true, ["verify"]);
3200
+ }
3201
+ /**
3202
+ * Validates a payload from Discord against its signature and key.
3203
+ * @param body The request body.
3204
+ * @param signature The value of the `x-signature-ed25519` header.
3205
+ * @param signature The value of the `x-signature-timestamp` header.
3206
+ * @param key The public key from the Discord developer dashboard, generated by {@link makeKey}
3207
+ */
3208
+ async function verifyBody(body, signature, timestamp, key) {
3209
+ const signatureData = Buffer.from(headerToString(signature), "hex");
3210
+ const data = Buffer.isBuffer(body) ? Buffer.concat([Buffer.from(headerToString(timestamp)), body]) : Buffer.from(`${headerToString(timestamp)}${body}`);
3211
+ return webcrypto.subtle.verify(AlgorithmName, key, signatureData, Buffer.from(data));
3212
+ }
3213
+
3214
+ //#endregion
3215
+ //#region src/lib/utils/streams.ts
3216
+ /**
3217
+ * Safely reads the {@link IncomingMessage incoming message}'s body as a string.
3218
+ * @param request The incoming message to get the data from.
3219
+ * @returns The string, if it's within the body size limit.
3220
+ */
3221
+ async function getSafeTextBody(request) {
3222
+ let limit = container$1.client.bodySizeLimit;
3223
+ if (!isNullishOrEmpty(request.headers["content-length"])) {
3224
+ const parsed = Number(request.headers["content-length"]);
3225
+ if (!Number.isSafeInteger(parsed)) return err(ErrorMessages.InvalidContentLengthInteger);
3226
+ if (parsed <= 0) return err(ErrorMessages.InvalidContentLengthNegative);
3227
+ if (parsed > limit) return err(ErrorMessages.InvalidContentLengthTooBig);
3228
+ limit = parsed;
3229
+ }
3230
+ const decoder = new TextDecoder();
3231
+ let output = "";
3232
+ for await (const chunk of request) {
3233
+ const part = typeof chunk === "string" ? chunk : decoder.decode(chunk, { stream: true });
3234
+ if (part.length + output.length > limit) return err(ErrorMessages.InvalidBodySize);
3235
+ output += part;
3236
+ }
3237
+ const part = decoder.decode(void 0, { stream: false });
3238
+ if (part.length + output.length > limit) return err(ErrorMessages.InvalidBodySize);
3239
+ output += part;
3240
+ return ok(output);
3241
+ }
3242
+
3243
+ //#endregion
3244
+ //#region src/lib/Client.ts
3245
+ container$1.stores.register(new CommandStore());
3246
+ container$1.stores.register(new InteractionHandlerStore());
3247
+ container$1.stores.register(new ListenerStore());
3248
+ var _discordPublicKey = /* @__PURE__ */ new WeakMap();
3249
+ var Client = class extends AsyncEventEmitter {
3250
+ constructor(options = {}) {
3251
+ super();
3252
+ _defineProperty(this, "server", void 0);
3253
+ _defineProperty(this, "id", void 0);
3254
+ _defineProperty(this, "bodySizeLimit", void 0);
3255
+ _defineProperty(this, "httpReplyOnError", void 0);
3256
+ _classPrivateFieldInitSpec(this, _discordPublicKey, void 0);
3257
+ this.bodySizeLimit = options.bodySizeLimit ?? 1024 * 1024;
3258
+ this.httpReplyOnError = options.httpReplyOnError ?? true;
3259
+ const discordPublicKey = options.discordPublicKey ?? process.env.DISCORD_PUBLIC_KEY;
3260
+ if (!discordPublicKey) throw new Error("The discordPublicKey cannot be empty");
3261
+ _classPrivateFieldSet2(_discordPublicKey, this, discordPublicKey);
3262
+ container$1.rest = new REST(options.restOptions);
3263
+ const token = options.discordToken ?? process.env.DISCORD_TOKEN;
3264
+ if (!token) throw new Error("The discordToken cannot be empty");
3265
+ this.id = options.clientId ?? process.env.DISCORD_CLIENT_ID ?? Buffer.from(token.split(".")[0], "base64").toString();
3266
+ container$1.client = this;
3267
+ container$1.rest.setToken(token);
3268
+ container$1.idParser ??= new StringIdParser();
3269
+ container$1.applicationCommandRegistry.setup({
3270
+ clientId: this.id,
3271
+ rest: container$1.rest,
3272
+ authPrefix: options.authPrefix
3273
+ });
3274
+ }
3275
+ /**
3276
+ * Gets the application command registry.
3277
+ *
3278
+ * @since 2.0.0
3279
+ * @returns The application command registry.
3280
+ */
3281
+ get registry() {
3282
+ return container$1.applicationCommandRegistry;
3283
+ }
3284
+ /**
3285
+ * Loads all the commands.
3286
+ * @param options The load options.
3287
+ */
3288
+ async load(options = {}) {
3289
+ if (options.baseUserDirectory !== null) container$1.stores.registerPath(options.baseUserDirectory);
3290
+ await container$1.stores.load();
3291
+ }
3292
+ /**
3293
+ * Starts the HTTP server, listening for HTTP interactions.
3294
+ * @param options The listen options.
3295
+ */
3296
+ async listen({ serverOptions, postPath, port, address, ...listenOptions }) {
3297
+ const key = await makeKey(_classPrivateFieldGet2(_discordPublicKey, this));
3298
+ const path = postPath ?? process.env.HTTP_POST_PATH ?? "/";
3299
+ this.server = createServer(serverOptions ?? {});
3300
+ this.server.on("request", (request, response) => void this.handleRawHttpMessage(request, response, path, key));
3301
+ return new Promise((resolve) => this.server.listen({
3302
+ ...listenOptions,
3303
+ port,
3304
+ host: address
3305
+ }, resolve));
3306
+ }
3307
+ async handleRawHttpMessage(request, response, path, key) {
3308
+ response.setHeader("Content-Type", "application/json");
3309
+ if (request.url !== path) {
3310
+ response.statusCode = 404;
3311
+ return response.end(ErrorMessages.NotFound);
3312
+ }
3313
+ if (request.method !== "POST") {
3314
+ response.statusCode = 405;
3315
+ return response.end(ErrorMessages.UnsupportedHttpMethod);
3316
+ }
3317
+ const signature = request.headers["x-signature-ed25519"];
3318
+ const timestamp = request.headers["x-signature-timestamp"];
3319
+ if (isNullishOrEmpty(signature) || isNullishOrEmpty(timestamp)) {
3320
+ response.statusCode = 401;
3321
+ return response.end(ErrorMessages.MissingSignatureInformation);
3322
+ }
3323
+ const result = await getSafeTextBody(request);
3324
+ if (result.isErr()) {
3325
+ response.statusCode = 400;
3326
+ return response.end(result.unwrapErr());
3327
+ }
3328
+ const body = result.unwrap();
3329
+ if (!await verifyBody(body, signature, timestamp, key)) {
3330
+ response.statusCode = 401;
3331
+ return response.end(ErrorMessages.InvalidSignature);
3332
+ }
3333
+ return this.handleHttpMessage(JSON.parse(body), response);
3334
+ }
3335
+ async handleHttpMessage(interaction, response) {
3336
+ if (interaction.type === InteractionType.Ping) {
3337
+ response.statusCode = 200;
3338
+ return response.end(Payloads.Pong);
3339
+ }
3340
+ switch (interaction.type) {
3341
+ case InteractionType.ApplicationCommand: return container$1.stores.get("commands").runApplicationCommand(response, interaction);
3342
+ case InteractionType.ApplicationCommandAutocomplete: return container$1.stores.get("commands").runApplicationCommandAutocomplete(response, interaction);
3343
+ case InteractionType.MessageComponent:
3344
+ case InteractionType.ModalSubmit: return container$1.stores.get("interaction-handlers").runHandler(response, interaction);
3345
+ default:
3346
+ response.statusCode = 501;
3347
+ return response.end(ErrorMessages.UnknownInteractionType);
3348
+ }
3349
+ }
3350
+ };
3351
+
3352
+ //#endregion
3353
+ export { AliasPiece, AliasStore, ApplicationCommandRegistry, ApplicationCommandRegistryEntry, AutocompleteInteraction, BaseInteraction, ChatInputCommandInteraction, Client, Command, CommandInteraction, CommandLoaderStrategy, CommandRouter, CommandStore, CommandStoreRouter, HttpCodes, InteractionHandler, InteractionHandlerStore, Listener, ListenerLoaderStrategy, ListenerStore, LoaderError, Message, MessageComponentButtonInteraction, MessageComponentChannelSelectInteraction, MessageComponentInteraction, MessageComponentMentionableSelectInteraction, MessageComponentRoleSelectInteraction, MessageComponentStringSelectInteraction as MessageComponentSelectMenuInteraction, MessageComponentStringSelectInteraction, MessageComponentUserSelectInteraction, MessageContextMenuCommandInteraction, MissingExportsError, ModalSubmitInteraction, PartialMessage, Piece, RegisterCommand, RegisterMessageCommand, RegisterSubcommand, RegisterSubcommandGroup, RegisterUserCommand, RestrictGuildIds, Store, StoreRegistry, StringIdParser, UserContextMenuCommandInteraction, applicationCommandRegistry, container, extractTopLevelOptions, makeInteraction, restrictedGuildIdRegistry, transformAutocompleteInteraction, transformInteraction, transformMessageInteraction, transformUserInteraction };
3354
+ //# sourceMappingURL=index.js.map