@wolfstar/http-framework 3.0.0 → 3.1.1
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.
- package/README.md +54 -0
- package/dist/esm/index.d.ts +129 -30
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +123 -12
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -428,7 +428,7 @@ const preLoad = Symbol("HttpFrameworkPluginsPreLoad");
|
|
|
428
428
|
const postListen = Symbol("HttpFrameworkPluginsPostListen");
|
|
429
429
|
|
|
430
430
|
//#endregion
|
|
431
|
-
//#region \0@oxc-project+runtime@0.
|
|
431
|
+
//#region \0@oxc-project+runtime@0.142.0/helpers/esm/typeof.js
|
|
432
432
|
function _typeof(o) {
|
|
433
433
|
"@babel/helpers - typeof";
|
|
434
434
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -439,7 +439,7 @@ function _typeof(o) {
|
|
|
439
439
|
}
|
|
440
440
|
|
|
441
441
|
//#endregion
|
|
442
|
-
//#region \0@oxc-project+runtime@0.
|
|
442
|
+
//#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPrimitive.js
|
|
443
443
|
function toPrimitive(t, r) {
|
|
444
444
|
if ("object" != _typeof(t) || !t) return t;
|
|
445
445
|
var e = t[Symbol.toPrimitive];
|
|
@@ -452,14 +452,14 @@ function toPrimitive(t, r) {
|
|
|
452
452
|
}
|
|
453
453
|
|
|
454
454
|
//#endregion
|
|
455
|
-
//#region \0@oxc-project+runtime@0.
|
|
455
|
+
//#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPropertyKey.js
|
|
456
456
|
function toPropertyKey(t) {
|
|
457
457
|
var i = toPrimitive(t, "string");
|
|
458
458
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
459
459
|
}
|
|
460
460
|
|
|
461
461
|
//#endregion
|
|
462
|
-
//#region \0@oxc-project+runtime@0.
|
|
462
|
+
//#region \0@oxc-project+runtime@0.142.0/helpers/esm/defineProperty.js
|
|
463
463
|
function _defineProperty(e, r, t) {
|
|
464
464
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
465
465
|
value: t,
|
|
@@ -830,38 +830,38 @@ function getLinkedMethod(object) {
|
|
|
830
830
|
}
|
|
831
831
|
|
|
832
832
|
//#endregion
|
|
833
|
-
//#region \0@oxc-project+runtime@0.
|
|
833
|
+
//#region \0@oxc-project+runtime@0.142.0/helpers/esm/checkPrivateRedeclaration.js
|
|
834
834
|
function _checkPrivateRedeclaration(e, t) {
|
|
835
835
|
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
836
836
|
}
|
|
837
837
|
|
|
838
838
|
//#endregion
|
|
839
|
-
//#region \0@oxc-project+runtime@0.
|
|
839
|
+
//#region \0@oxc-project+runtime@0.142.0/helpers/esm/classPrivateMethodInitSpec.js
|
|
840
840
|
function _classPrivateMethodInitSpec(e, a) {
|
|
841
841
|
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
842
842
|
}
|
|
843
843
|
|
|
844
844
|
//#endregion
|
|
845
|
-
//#region \0@oxc-project+runtime@0.
|
|
845
|
+
//#region \0@oxc-project+runtime@0.142.0/helpers/esm/classPrivateFieldInitSpec.js
|
|
846
846
|
function _classPrivateFieldInitSpec(e, t, a) {
|
|
847
847
|
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
848
848
|
}
|
|
849
849
|
|
|
850
850
|
//#endregion
|
|
851
|
-
//#region \0@oxc-project+runtime@0.
|
|
851
|
+
//#region \0@oxc-project+runtime@0.142.0/helpers/esm/assertClassBrand.js
|
|
852
852
|
function _assertClassBrand(e, t, n) {
|
|
853
853
|
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
854
854
|
throw new TypeError("Private element is not present on this object");
|
|
855
855
|
}
|
|
856
856
|
|
|
857
857
|
//#endregion
|
|
858
|
-
//#region \0@oxc-project+runtime@0.
|
|
858
|
+
//#region \0@oxc-project+runtime@0.142.0/helpers/esm/classPrivateFieldSet2.js
|
|
859
859
|
function _classPrivateFieldSet2(s, a, r) {
|
|
860
860
|
return s.set(_assertClassBrand(s, a), r), r;
|
|
861
861
|
}
|
|
862
862
|
|
|
863
863
|
//#endregion
|
|
864
|
-
//#region \0@oxc-project+runtime@0.
|
|
864
|
+
//#region \0@oxc-project+runtime@0.142.0/helpers/esm/classPrivateFieldGet2.js
|
|
865
865
|
function _classPrivateFieldGet2(s, a) {
|
|
866
866
|
return s.get(_assertClassBrand(s, a));
|
|
867
867
|
}
|
|
@@ -1477,6 +1477,116 @@ async function _push(route, body, guildId) {
|
|
|
1477
1477
|
const applicationCommandRegistry = new ApplicationCommandRegistry();
|
|
1478
1478
|
container$1.applicationCommandRegistry = applicationCommandRegistry;
|
|
1479
1479
|
|
|
1480
|
+
//#endregion
|
|
1481
|
+
//#region src/lib/interactions/shared/CommandRegistry.ts
|
|
1482
|
+
var _target = /* @__PURE__ */ new WeakMap();
|
|
1483
|
+
/**
|
|
1484
|
+
* A per-command registry passed to {@linkcode Command.registerApplicationCommands}, allowing commands to be
|
|
1485
|
+
* registered imperatively, without relying on decorators.
|
|
1486
|
+
*
|
|
1487
|
+
* @remarks This is the decorator-free equivalent of {@link RegisterCommand}, {@link RegisterSubcommand},
|
|
1488
|
+
* {@link RegisterSubcommandGroup}, {@link RegisterMessageCommand}, {@link RegisterUserCommand}, and
|
|
1489
|
+
* {@link RestrictGuildIds}; both approaches can be used interchangeably as they share the same underlying
|
|
1490
|
+
* {@linkcode ApplicationCommandRegistryEntry}.
|
|
1491
|
+
* @since 3.1.0
|
|
1492
|
+
*/
|
|
1493
|
+
var CommandRegistry = class {
|
|
1494
|
+
constructor(target) {
|
|
1495
|
+
_classPrivateFieldInitSpec(this, _target, void 0);
|
|
1496
|
+
_classPrivateFieldSet2(_target, this, target);
|
|
1497
|
+
}
|
|
1498
|
+
/**
|
|
1499
|
+
* Registers the chat input (slash) command for this command.
|
|
1500
|
+
*
|
|
1501
|
+
* @since 3.1.0
|
|
1502
|
+
* @param data - The command data.
|
|
1503
|
+
* @returns This registry, for chaining.
|
|
1504
|
+
* @example
|
|
1505
|
+
* ```typescript
|
|
1506
|
+
* public override registerApplicationCommands(registry: Command.Registry) {
|
|
1507
|
+
* registry.registerChatInputCommand((builder) =>
|
|
1508
|
+
* builder.setName('ping').setDescription('A simple ping pong command')
|
|
1509
|
+
* );
|
|
1510
|
+
* }
|
|
1511
|
+
* ```
|
|
1512
|
+
*/
|
|
1513
|
+
registerChatInputCommand(data) {
|
|
1514
|
+
ensureChatInputCommandResolver(_classPrivateFieldGet2(_target, this)).setCommand(data);
|
|
1515
|
+
return this;
|
|
1516
|
+
}
|
|
1517
|
+
/**
|
|
1518
|
+
* Registers a subcommand for the chat input command of this command.
|
|
1519
|
+
*
|
|
1520
|
+
* @since 3.1.0
|
|
1521
|
+
* @param data - The subcommand data.
|
|
1522
|
+
* @param method - The name of the method that handles this subcommand.
|
|
1523
|
+
* @param groupName - The name of the subcommand group this subcommand belongs to, if any.
|
|
1524
|
+
* @returns This registry, for chaining.
|
|
1525
|
+
*/
|
|
1526
|
+
registerSubcommand(data, method, groupName) {
|
|
1527
|
+
ensureChatInputCommandResolver(_classPrivateFieldGet2(_target, this)).addSubcommand(data, method, groupName);
|
|
1528
|
+
return this;
|
|
1529
|
+
}
|
|
1530
|
+
/**
|
|
1531
|
+
* Registers a subcommand group for the chat input command of this command.
|
|
1532
|
+
*
|
|
1533
|
+
* @since 3.1.0
|
|
1534
|
+
* @param data - The subcommand group data.
|
|
1535
|
+
* @param method - The name of the method that handles this subcommand group, if any.
|
|
1536
|
+
* @returns This registry, for chaining.
|
|
1537
|
+
*/
|
|
1538
|
+
registerSubcommandGroup(data, method) {
|
|
1539
|
+
ensureChatInputCommandResolver(_classPrivateFieldGet2(_target, this)).addSubcommandGroup(data, method);
|
|
1540
|
+
return this;
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* Registers a context menu command for this command.
|
|
1544
|
+
*
|
|
1545
|
+
* @since 3.1.0
|
|
1546
|
+
* @param data - The command data.
|
|
1547
|
+
* @param type - The type of context menu command to register.
|
|
1548
|
+
* @param method - The name of the method that handles this context menu command, if any.
|
|
1549
|
+
* @returns This registry, for chaining.
|
|
1550
|
+
*/
|
|
1551
|
+
registerContextMenuCommand(data, type, method) {
|
|
1552
|
+
ensureContextMenuCommandResolver(_classPrivateFieldGet2(_target, this)).setCommand(data, type, method);
|
|
1553
|
+
return this;
|
|
1554
|
+
}
|
|
1555
|
+
/**
|
|
1556
|
+
* Registers a "Message" context menu command for this command.
|
|
1557
|
+
*
|
|
1558
|
+
* @since 3.1.0
|
|
1559
|
+
* @param data - The command data.
|
|
1560
|
+
* @param method - The name of the method that handles this context menu command, if any.
|
|
1561
|
+
* @returns This registry, for chaining.
|
|
1562
|
+
*/
|
|
1563
|
+
registerMessageCommand(data, method) {
|
|
1564
|
+
return this.registerContextMenuCommand(data, ApplicationCommandType.Message, method);
|
|
1565
|
+
}
|
|
1566
|
+
/**
|
|
1567
|
+
* Registers a "User" context menu command for this command.
|
|
1568
|
+
*
|
|
1569
|
+
* @since 3.1.0
|
|
1570
|
+
* @param data - The command data.
|
|
1571
|
+
* @param method - The name of the method that handles this context menu command, if any.
|
|
1572
|
+
* @returns This registry, for chaining.
|
|
1573
|
+
*/
|
|
1574
|
+
registerUserCommand(data, method) {
|
|
1575
|
+
return this.registerContextMenuCommand(data, ApplicationCommandType.User, method);
|
|
1576
|
+
}
|
|
1577
|
+
/**
|
|
1578
|
+
* Restricts this command to the given guild IDs, so it is only registered there instead of globally.
|
|
1579
|
+
*
|
|
1580
|
+
* @since 3.1.0
|
|
1581
|
+
* @param guildIds - The guild IDs to restrict this command to.
|
|
1582
|
+
* @returns This registry, for chaining.
|
|
1583
|
+
*/
|
|
1584
|
+
setGuildIds(guildIds) {
|
|
1585
|
+
restrictedGuildIdRegistry.set(_classPrivateFieldGet2(_target, this), guildIds);
|
|
1586
|
+
return this;
|
|
1587
|
+
}
|
|
1588
|
+
};
|
|
1589
|
+
|
|
1480
1590
|
//#endregion
|
|
1481
1591
|
//#region src/lib/utils/constants.ts
|
|
1482
1592
|
const ErrorMessages = {
|
|
@@ -2894,6 +3004,7 @@ var Command = class extends Piece$1 {
|
|
|
2894
3004
|
constructor(context, options = {}) {
|
|
2895
3005
|
super(context, options);
|
|
2896
3006
|
_defineProperty(this, "router", void 0);
|
|
3007
|
+
this.registerApplicationCommands?.(new CommandRegistry(this.constructor));
|
|
2897
3008
|
this.router = new CommandRouter(this);
|
|
2898
3009
|
}
|
|
2899
3010
|
/**
|
|
@@ -3340,7 +3451,7 @@ var Client = class Client extends AsyncEventEmitter {
|
|
|
3340
3451
|
plugin.hook.call(this, this.options);
|
|
3341
3452
|
this.emit("pluginLoaded", plugin.type, plugin.name);
|
|
3342
3453
|
}
|
|
3343
|
-
this.bodySizeLimit = options.bodySizeLimit ??
|
|
3454
|
+
this.bodySizeLimit = options.bodySizeLimit ?? 1048576;
|
|
3344
3455
|
this.httpReplyOnError = options.httpReplyOnError ?? true;
|
|
3345
3456
|
const discordPublicKey = options.discordPublicKey ?? process.env.DISCORD_PUBLIC_KEY;
|
|
3346
3457
|
if (!discordPublicKey) throw new Error("The discordPublicKey cannot be empty");
|
|
@@ -3479,5 +3590,5 @@ _defineProperty(Plugin, preLoad, void 0);
|
|
|
3479
3590
|
_defineProperty(Plugin, postListen, void 0);
|
|
3480
3591
|
|
|
3481
3592
|
//#endregion
|
|
3482
|
-
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, Plugin, PluginHook, PluginManager, RegisterCommand, RegisterMessageCommand, RegisterSubcommand, RegisterSubcommandGroup, RegisterUserCommand, RestrictGuildIds, Store, StoreRegistry, StringIdParser, UserContextMenuCommandInteraction, applicationCommandRegistry, container, extractTopLevelOptions, makeInteraction, postInitialization, postListen, preGenericsInitialization, preInitialization, preLoad, restrictedGuildIdRegistry, transformAutocompleteInteraction, transformInteraction, transformMessageInteraction, transformUserInteraction };
|
|
3593
|
+
export { AliasPiece, AliasStore, ApplicationCommandRegistry, ApplicationCommandRegistryEntry, AutocompleteInteraction, BaseInteraction, ChatInputCommandInteraction, Client, Command, CommandInteraction, CommandLoaderStrategy, CommandRegistry, 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, Plugin, PluginHook, PluginManager, RegisterCommand, RegisterMessageCommand, RegisterSubcommand, RegisterSubcommandGroup, RegisterUserCommand, RestrictGuildIds, Store, StoreRegistry, StringIdParser, UserContextMenuCommandInteraction, applicationCommandRegistry, container, extractTopLevelOptions, makeInteraction, postInitialization, postListen, preGenericsInitialization, preInitialization, preLoad, restrictedGuildIdRegistry, transformAutocompleteInteraction, transformInteraction, transformMessageInteraction, transformUserInteraction };
|
|
3483
3594
|
//# sourceMappingURL=index.js.map
|