oopscord.js 0.0.30 → 0.1.0

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.
Files changed (103) hide show
  1. package/LICENSE +674 -201
  2. package/README.md +212 -11
  3. package/dist/index.js +18 -1
  4. package/dist/index.js.map +1 -0
  5. package/dist/structures/Constants.d.ts +2 -2
  6. package/dist/structures/Constants.d.ts.map +1 -1
  7. package/dist/structures/Constants.js +6 -2
  8. package/dist/structures/Constants.js.map +1 -0
  9. package/dist/structures/DiscordApp.d.ts +28 -10
  10. package/dist/structures/DiscordApp.d.ts.map +1 -1
  11. package/dist/structures/DiscordApp.js +695 -316
  12. package/dist/structures/DiscordApp.js.map +1 -0
  13. package/dist/structures/Plugin.d.ts +68 -0
  14. package/dist/structures/Plugin.d.ts.map +1 -1
  15. package/dist/structures/Plugin.js +32 -1
  16. package/dist/structures/Plugin.js.map +1 -0
  17. package/dist/structures/PluginManager.d.ts +122 -0
  18. package/dist/structures/PluginManager.d.ts.map +1 -0
  19. package/dist/structures/PluginManager.js +371 -0
  20. package/dist/structures/PluginManager.js.map +1 -0
  21. package/dist/structures/components/BaseButton.d.ts +2 -5
  22. package/dist/structures/components/BaseButton.d.ts.map +1 -1
  23. package/dist/structures/components/BaseButton.js +21 -22
  24. package/dist/structures/components/BaseButton.js.map +1 -0
  25. package/dist/structures/components/BaseModal.d.ts +13 -21
  26. package/dist/structures/components/BaseModal.d.ts.map +1 -1
  27. package/dist/structures/components/BaseModal.js +98 -137
  28. package/dist/structures/components/BaseModal.js.map +1 -0
  29. package/dist/structures/components/BaseSelectMenu.d.ts +2 -5
  30. package/dist/structures/components/BaseSelectMenu.d.ts.map +1 -1
  31. package/dist/structures/components/BaseSelectMenu.js +35 -35
  32. package/dist/structures/components/BaseSelectMenu.js.map +1 -0
  33. package/dist/structures/components/Listener.js +6 -1
  34. package/dist/structures/components/Listener.js.map +1 -0
  35. package/dist/structures/components/index.js +21 -4
  36. package/dist/structures/components/index.js.map +1 -0
  37. package/dist/structures/decorators/CommandDecorator.d.ts +38 -37
  38. package/dist/structures/decorators/CommandDecorator.d.ts.map +1 -1
  39. package/dist/structures/decorators/CommandDecorator.js +206 -280
  40. package/dist/structures/decorators/CommandDecorator.js.map +1 -0
  41. package/dist/structures/decorators/Constants.d.ts +7 -5
  42. package/dist/structures/decorators/Constants.d.ts.map +1 -1
  43. package/dist/structures/decorators/Constants.js +37 -31
  44. package/dist/structures/decorators/Constants.js.map +1 -0
  45. package/dist/structures/decorators/DiscordModuleDecorator.d.ts +7 -2
  46. package/dist/structures/decorators/DiscordModuleDecorator.d.ts.map +1 -1
  47. package/dist/structures/decorators/DiscordModuleDecorator.js +16 -33
  48. package/dist/structures/decorators/DiscordModuleDecorator.js.map +1 -0
  49. package/dist/structures/decorators/EventDecorator.d.ts +3 -2
  50. package/dist/structures/decorators/EventDecorator.d.ts.map +1 -1
  51. package/dist/structures/decorators/EventDecorator.js +19 -11
  52. package/dist/structures/decorators/EventDecorator.js.map +1 -0
  53. package/dist/structures/decorators/ExecutionDecorator.d.ts +19 -0
  54. package/dist/structures/decorators/ExecutionDecorator.d.ts.map +1 -0
  55. package/dist/structures/decorators/ExecutionDecorator.js +23 -0
  56. package/dist/structures/decorators/ExecutionDecorator.js.map +1 -0
  57. package/dist/structures/decorators/InjectionMetadata.d.ts +35 -0
  58. package/dist/structures/decorators/InjectionMetadata.d.ts.map +1 -0
  59. package/dist/structures/decorators/InjectionMetadata.js +34 -0
  60. package/dist/structures/decorators/InjectionMetadata.js.map +1 -0
  61. package/dist/structures/decorators/InteractionHandlerDecorator.d.ts +17 -2
  62. package/dist/structures/decorators/InteractionHandlerDecorator.d.ts.map +1 -1
  63. package/dist/structures/decorators/InteractionHandlerDecorator.js +53 -8
  64. package/dist/structures/decorators/InteractionHandlerDecorator.js.map +1 -0
  65. package/dist/structures/decorators/MessageComponentDecorator.d.ts +24 -39
  66. package/dist/structures/decorators/MessageComponentDecorator.d.ts.map +1 -1
  67. package/dist/structures/decorators/MessageComponentDecorator.js +128 -122
  68. package/dist/structures/decorators/MessageComponentDecorator.js.map +1 -0
  69. package/dist/structures/decorators/Metadata.d.ts +16 -0
  70. package/dist/structures/decorators/Metadata.d.ts.map +1 -0
  71. package/dist/structures/decorators/Metadata.js +50 -0
  72. package/dist/structures/decorators/Metadata.js.map +1 -0
  73. package/dist/structures/decorators/PluginDecorator.d.ts +41 -0
  74. package/dist/structures/decorators/PluginDecorator.d.ts.map +1 -0
  75. package/dist/structures/decorators/PluginDecorator.js +36 -0
  76. package/dist/structures/decorators/PluginDecorator.js.map +1 -0
  77. package/dist/structures/decorators/UseDecorator.d.ts +44 -0
  78. package/dist/structures/decorators/UseDecorator.d.ts.map +1 -0
  79. package/dist/structures/decorators/UseDecorator.js +49 -0
  80. package/dist/structures/decorators/UseDecorator.js.map +1 -0
  81. package/dist/structures/decorators/index.d.ts +3 -0
  82. package/dist/structures/decorators/index.d.ts.map +1 -1
  83. package/dist/structures/decorators/index.js +26 -6
  84. package/dist/structures/decorators/index.js.map +1 -0
  85. package/dist/structures/index.d.ts +3 -1
  86. package/dist/structures/index.d.ts.map +1 -1
  87. package/dist/structures/index.js +26 -6
  88. package/dist/structures/index.js.map +1 -0
  89. package/dist/utils/Util.d.ts +2 -0
  90. package/dist/utils/Util.d.ts.map +1 -1
  91. package/dist/utils/Util.js +30 -11
  92. package/dist/utils/Util.js.map +1 -0
  93. package/dist/utils/cache.d.ts +4 -0
  94. package/dist/utils/cache.d.ts.map +1 -0
  95. package/dist/utils/cache.js +17 -0
  96. package/dist/utils/cache.js.map +1 -0
  97. package/dist/utils/customId.d.ts +12 -0
  98. package/dist/utils/customId.d.ts.map +1 -0
  99. package/dist/utils/customId.js +49 -0
  100. package/dist/utils/customId.js.map +1 -0
  101. package/package.json +64 -38
  102. package/bun.lock +0 -264
  103. package/tsdown.config.json +0 -3
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Use = Use;
4
+ exports.resolveUsed = resolveUsed;
5
+ const InjectionMetadata_1 = require("./InjectionMetadata");
6
+ /**
7
+ * Injects a shared instance of a class into an instance field, so classes can use what another class provides.
8
+ * The field type must accept the class type. It works in interaction handlers, listeners, event modules, the root
9
+ * module, plugins, and the classes injected this way.
10
+ *
11
+ * - A registered plugin (a plugin of that class, or a subclass) is injected as it is.
12
+ * - A support registered with `supports`, in `DiscordModule` or provided by a plugin through `PluginModule`, is
13
+ * injected as it is. Its own `@Use` fields are injected too, so supports may use each other.
14
+ * - Any other class needs no registration: it is created once per application with `(client, logger)`, when the
15
+ * application is created, and shared by everyone who uses it.
16
+ * - A `Plugin` subclass that is not registered fails startup, since a second copy without lifecycle is never wanted.
17
+ *
18
+ * While a plugin that a handler uses, or that provides a support it uses, is not enabled, the handler answers
19
+ * "This feature is currently disabled." and a listener's event handlers do not run. On a plugin, `@Use(Other)` also
20
+ * declares a dependency on `Other`, or on the plugin that provides it: that plugin is enabled first and disabled
21
+ * last, and circular uses fail at startup. Plugin fields are set after every plugin is registered and before any
22
+ * hook runs, so they are not available in constructors.
23
+ *
24
+ * Pass the class, or an arrow function returning it when two declarations refer to each other: a plugin that owns
25
+ * a handler through `@PluginModule` is usually declared after it, so the handler writes `@Use(() => Support)`.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * @Command({ name: "ticket", description: "Open a ticket" })
30
+ * class Ticket {
31
+ * @Use(TicketStore) store!: TicketStore;
32
+ * @Use(() => Support) support!: Support;
33
+ *
34
+ * @Run
35
+ * async run() { await this.support.open(await this.store.create()); }
36
+ * }
37
+ * ```
38
+ */
39
+ function Use(target) {
40
+ return (_value, context) => {
41
+ (0, InjectionMetadata_1.registerInjection)(context, { kind: "use", use: target });
42
+ };
43
+ }
44
+ /** Resolves what `@Use` was given: a class, or an arrow function returning one. @internal */
45
+ function resolveUsed(reference) {
46
+ // Class prototypes are not writable; the prototype of an ordinary function is, and an arrow function has none.
47
+ return Object.getOwnPropertyDescriptor(reference, "prototype")?.writable === false ? reference : reference();
48
+ }
49
+ //# sourceMappingURL=UseDecorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UseDecorator.js","sourceRoot":"","sources":["../../../src/structures/decorators/UseDecorator.ts"],"names":[],"mappings":";;AA4CA,kBAIC;AAGD,kCAGC;AAtDD,2DAAwD;AAWxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,SAAgB,GAAG,CAAmB,MAA2C;IAC7E,OAAO,CAAc,MAAiB,EAAE,OAAsF,EAAQ,EAAE;QACpI,IAAA,qCAAiB,EAAC,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC;AACN,CAAC;AAED,6FAA6F;AAC7F,SAAgB,WAAW,CAAC,SAAwC;IAChE,+GAA+G;IAC/G,OAAO,MAAM,CAAC,wBAAwB,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,SAAsB,CAAC,CAAC,CAAE,SAA6B,EAAE,CAAC;AACnJ,CAAC"}
@@ -4,4 +4,7 @@ export * from "./DiscordModuleDecorator";
4
4
  export * from "./InteractionHandlerDecorator";
5
5
  export * from "./MessageComponentDecorator";
6
6
  export * from "./EventDecorator";
7
+ export * from "./ExecutionDecorator";
8
+ export * from "./PluginDecorator";
9
+ export * from "./UseDecorator";
7
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/structures/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/structures/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC"}
@@ -1,6 +1,26 @@
1
- export * from "./CommandDecorator";
2
- export * from "./Constants";
3
- export * from "./DiscordModuleDecorator";
4
- export * from "./InteractionHandlerDecorator";
5
- export * from "./MessageComponentDecorator";
6
- export * from "./EventDecorator";
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./CommandDecorator"), exports);
18
+ __exportStar(require("./Constants"), exports);
19
+ __exportStar(require("./DiscordModuleDecorator"), exports);
20
+ __exportStar(require("./InteractionHandlerDecorator"), exports);
21
+ __exportStar(require("./MessageComponentDecorator"), exports);
22
+ __exportStar(require("./EventDecorator"), exports);
23
+ __exportStar(require("./ExecutionDecorator"), exports);
24
+ __exportStar(require("./PluginDecorator"), exports);
25
+ __exportStar(require("./UseDecorator"), exports);
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/structures/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,8CAA4B;AAC5B,2DAAyC;AACzC,gEAA8C;AAC9C,8DAA4C;AAC5C,mDAAiC;AACjC,uDAAqC;AACrC,oDAAkC;AAClC,iDAA+B"}
@@ -1,7 +1,9 @@
1
- import "reflect-metadata";
1
+ import "./decorators/Metadata";
2
2
  export * from "./decorators";
3
3
  export * from "./components";
4
4
  export * from "./Constants";
5
5
  export * from "./DiscordApp";
6
6
  export * from "./Plugin";
7
+ export { PluginManager } from "./PluginManager";
8
+ export type { PluginInfo, PluginReference, PluginState } from "./PluginManager";
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/structures/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAE7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/structures/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAE/B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAE7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,6 +1,26 @@
1
- import "reflect-metadata";
2
- export * from "./decorators";
3
- export * from "./components";
4
- export * from "./Constants";
5
- export * from "./DiscordApp";
6
- export * from "./Plugin";
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.PluginManager = void 0;
18
+ require("./decorators/Metadata");
19
+ __exportStar(require("./decorators"), exports);
20
+ __exportStar(require("./components"), exports);
21
+ __exportStar(require("./Constants"), exports);
22
+ __exportStar(require("./DiscordApp"), exports);
23
+ __exportStar(require("./Plugin"), exports);
24
+ var PluginManager_1 = require("./PluginManager");
25
+ Object.defineProperty(exports, "PluginManager", { enumerable: true, get: function () { return PluginManager_1.PluginManager; } });
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/structures/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iCAA+B;AAE/B,+CAA6B;AAC7B,+CAA6B;AAE7B,8CAA4B;AAC5B,+CAA6B;AAC7B,2CAAyB;AACzB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA"}
@@ -4,5 +4,7 @@ export declare class Util {
4
4
  static mergeDefault<T extends {
5
5
  [key: PropertyKey]: any;
6
6
  }>(def: T, given: Partial<T>): T;
7
+ private static isPlainObject;
8
+ private static clone;
7
9
  }
8
10
  //# sourceMappingURL=Util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../src/utils/Util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AAEjH,qBAAa,IAAI;IACb,MAAM,CAAC,0BAA0B,CAAC,OAAO,EAAE,wBAAwB,GAAG,iBAAiB,GAAG,OAAO,IAAI,wBAAwB;IAI7H,MAAM,CAAC,YAAY,CAAC,CAAC,SAAS;QAAE,CAAC,GAAG,EAAE,WAAW,GAAG,GAAG,CAAA;KAAE,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;CAa3F"}
1
+ {"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../src/utils/Util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AAEjH,qBAAa,IAAI;IACb,MAAM,CAAC,0BAA0B,CAAC,OAAO,EAAE,wBAAwB,GAAG,iBAAiB,GAAG,OAAO,IAAI,wBAAwB;IAI7H,MAAM,CAAC,YAAY,CAAC,CAAC,SAAS;QAAE,CAAC,GAAG,EAAE,WAAW,GAAG,GAAG,CAAA;KAAE,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IAexF,OAAO,CAAC,MAAM,CAAC,aAAa;IAK5B,OAAO,CAAC,MAAM,CAAC,KAAK;CAKvB"}
@@ -1,19 +1,38 @@
1
- import { ButtonStyle } from "discord-api-types/v10";
2
- export class Util {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Util = void 0;
4
+ const v10_1 = require("discord-api-types/v10");
5
+ class Util {
3
6
  static isInteractionButtonOptions(options) {
4
- return options.style != ButtonStyle.Link;
7
+ return options.style != v10_1.ButtonStyle.Link;
5
8
  }
6
9
  static mergeDefault(def, given) {
7
- if (!given)
8
- return def;
9
- for (const key in def) {
10
- if (!Object.hasOwn(given, key) || given[key] === undefined) {
11
- given[key] = def[key];
10
+ const result = { ...def };
11
+ for (const key of new Set([...Object.keys(def), ...Object.keys(given ?? {})])) {
12
+ const value = given?.[key] === undefined ? def[key] : given[key];
13
+ if (Array.isArray(value)) {
14
+ result[key] = value.map(item => this.clone(item));
12
15
  }
13
- else if (given[key] === Object(given[key])) {
14
- given[key] = this.mergeDefault(def[key], given[key]);
16
+ else if (this.isPlainObject(value)) {
17
+ result[key] = this.mergeDefault(this.isPlainObject(def[key]) ? def[key] : {}, value);
18
+ }
19
+ else {
20
+ result[key] = value;
15
21
  }
16
22
  }
17
- return given;
23
+ return result;
24
+ }
25
+ static isPlainObject(value) {
26
+ return value !== null && typeof value === "object" &&
27
+ (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
28
+ }
29
+ static clone(value) {
30
+ if (Array.isArray(value))
31
+ return value.map(item => this.clone(item));
32
+ if (this.isPlainObject(value))
33
+ return this.mergeDefault({}, value);
34
+ return value;
18
35
  }
19
36
  }
37
+ exports.Util = Util;
38
+ //# sourceMappingURL=Util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Util.js","sourceRoot":"","sources":["../../src/utils/Util.ts"],"names":[],"mappings":";;;AAAA,+CAAoD;AAGpD,MAAa,IAAI;IACb,MAAM,CAAC,0BAA0B,CAAC,OAAqD;QACnF,OAAO,OAAO,CAAC,KAAK,IAAI,iBAAW,CAAC,IAAI,CAAC;IAC7C,CAAC;IAED,MAAM,CAAC,YAAY,CAAwC,GAAM,EAAE,KAAiB;QAChF,MAAM,MAAM,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC;QAC1B,KAAK,MAAM,GAAG,IAAI,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5E,MAAM,KAAK,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,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AAC;QACnE,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AA9BD,oBA8BC"}
@@ -0,0 +1,4 @@
1
+ import { CacheFactory } from "discord.js";
2
+ /** Preserves managers whose caches Discord.js requires for normal operation. */
3
+ export declare function createUncachedFactory(): CacheFactory;
4
+ //# sourceMappingURL=cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/utils/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAiC,MAAM,YAAY,CAAC;AAEzE,gFAAgF;AAChF,wBAAgB,qBAAqB,IAAI,YAAY,CASpD"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createUncachedFactory = createUncachedFactory;
4
+ const discord_js_1 = require("discord.js");
5
+ /** Preserves managers whose caches Discord.js requires for normal operation. */
6
+ function createUncachedFactory() {
7
+ const required = new Set(["GuildManager", "ChannelManager", "GuildChannelManager", "RoleManager", "PermissionOverwriteManager"]);
8
+ return manager => {
9
+ if (required.has(manager.name))
10
+ return new discord_js_1.Collection();
11
+ if (manager.name === "GuildMemberManager") {
12
+ return new discord_js_1.LimitedCollection({ maxSize: 0, keepOverLimit: (member) => member.id === member.client.user?.id });
13
+ }
14
+ return new discord_js_1.LimitedCollection({ maxSize: 0 });
15
+ };
16
+ }
17
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/utils/cache.ts"],"names":[],"mappings":";;AAGA,sDASC;AAZD,2CAAyE;AAEzE,gFAAgF;AAChF,SAAgB,qBAAqB;IACjC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,aAAa,EAAE,4BAA4B,CAAC,CAAC,CAAC;IACjI,OAAO,OAAO,CAAC,EAAE;QACb,IAAI,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,uBAAU,EAAE,CAAC;QACxD,IAAI,OAAO,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;YACxC,OAAO,IAAI,8BAAiB,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,MAAW,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QACvH,CAAC;QACD,OAAO,IAAI,8BAAiB,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IACjD,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,12 @@
1
+ export interface CustomIdRoute {
2
+ segments: {
3
+ name?: string;
4
+ literal?: string;
5
+ }[];
6
+ names: string[];
7
+ match(value: string): Record<string, string> | undefined;
8
+ }
9
+ /** Parses whole-segment parameters; no regular expression supplied by callers is executed. */
10
+ export declare function compileCustomId(pattern: string): CustomIdRoute;
11
+ export declare function customIdRoutesOverlap(a: CustomIdRoute, b: CustomIdRoute): boolean;
12
+ //# sourceMappingURL=customId.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customId.d.ts","sourceRoot":"","sources":["../../src/utils/customId.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC1B,QAAQ,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAChD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;CAC5D;AAED,8FAA8F;AAC9F,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CA+B9D;AAED,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,GAAG,OAAO,CAGjF"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.compileCustomId = compileCustomId;
4
+ exports.customIdRoutesOverlap = customIdRoutesOverlap;
5
+ /** Parses whole-segment parameters; no regular expression supplied by callers is executed. */
6
+ function compileCustomId(pattern) {
7
+ if (typeof pattern !== "string" || !pattern || pattern.length > 100)
8
+ throw new TypeError("Custom ID patterns must contain 1-100 characters.");
9
+ const names = [];
10
+ const segments = pattern.split(":").map(segment => {
11
+ const parameter = /^\{([A-Za-z_][A-Za-z0-9_]*)\}$/.exec(segment);
12
+ if (parameter) {
13
+ if (names.includes(parameter[1]))
14
+ throw new TypeError("Duplicate custom ID parameter " + parameter[1]);
15
+ names.push(parameter[1]);
16
+ return { name: parameter[1] };
17
+ }
18
+ if (!segment || /[{}]/.test(segment))
19
+ throw new TypeError("Parameters must occupy a whole colon-separated custom ID segment.");
20
+ return { literal: segment };
21
+ });
22
+ if (!names.length)
23
+ throw new TypeError("Custom ID patterns require at least one parameter.");
24
+ return {
25
+ segments,
26
+ names,
27
+ match(value) {
28
+ const parts = value.split(":");
29
+ if (parts.length !== segments.length || value.length > 100)
30
+ return undefined;
31
+ const parameters = {};
32
+ for (let index = 0; index < segments.length; index++) {
33
+ const segment = segments[index];
34
+ if (segment.name) {
35
+ if (!parts[index])
36
+ return undefined;
37
+ Object.defineProperty(parameters, segment.name, { value: parts[index], enumerable: true });
38
+ }
39
+ else if (segment.literal !== parts[index])
40
+ return undefined;
41
+ }
42
+ return parameters;
43
+ }
44
+ };
45
+ }
46
+ function customIdRoutesOverlap(a, b) {
47
+ return a.segments.length === b.segments.length && a.segments.every((segment, index) => segment.name !== undefined || b.segments[index].name !== undefined || segment.literal === b.segments[index].literal);
48
+ }
49
+ //# sourceMappingURL=customId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customId.js","sourceRoot":"","sources":["../../src/utils/customId.ts"],"names":[],"mappings":";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GAAG;gBAAE,OAAO,SAAS,CAAC;YAC7E,MAAM,UAAU,GAA2B,EAAE,CAAC;YAC9C,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;gBACnD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAChC,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;oBACf,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;wBAAE,OAAO,SAAS,CAAC;oBACpC,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC/F,CAAC;qBAAM,IAAI,OAAO,CAAC,OAAO,KAAK,KAAK,CAAC,KAAK,CAAC;oBAAE,OAAO,SAAS,CAAC;YAClE,CAAC;YACD,OAAO,UAAU,CAAC;QACtB,CAAC;KACJ,CAAC;AACN,CAAC;AAED,SAAgB,qBAAqB,CAAC,CAAgB,EAAE,CAAgB;IACpE,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAClF,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,CAAC,OAAO,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC;AAC7H,CAAC"}
package/package.json CHANGED
@@ -1,38 +1,64 @@
1
- {
2
- "name": "oopscord.js",
3
- "version": "0.0.30",
4
- "description": "An easy way to make discord apps in typescript.",
5
- "main": "dist",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1",
8
- "prepublishOnly": "tsc"
9
- },
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://github.com/Team-ThinkCord/oopscord.js.git"
13
- },
14
- "keywords": [
15
- "discord",
16
- "discord.js",
17
- "command",
18
- "handler",
19
- "commandhandler"
20
- ],
21
- "author": "Team-ThinkCord",
22
- "license": "Apache-2.0",
23
- "bugs": {
24
- "url": "https://github.com/Team-ThinkCord/tDis/issues"
25
- },
26
- "homepage": "https://github.com/Team-ThinkCord/tDis#readme",
27
- "private": false,
28
- "dependencies": {
29
- "reflect-metadata": "^0.1.14"
30
- },
31
- "devDependencies": {
32
- "@types/node": "^20.19.35",
33
- "discord.js": "14.26.4",
34
- "typescript": "^5.8.3",
35
- "vitest": "^4.0.18",
36
- "yarn": "^1.22.21"
37
- }
38
- }
1
+ {
2
+ "name": "oopscord.js",
3
+ "version": "0.1.0",
4
+ "description": "An easy way to make discord apps in typescript.",
5
+ "main": "./dist/index.js",
6
+ "scripts": {
7
+ "build": "tsc",
8
+ "typecheck": "tsc --noEmit && tsc --project tsconfig.tests.json",
9
+ "test": "vitest run",
10
+ "test:watch": "vitest",
11
+ "test:package": "npm run build && node scripts/check-package.cjs",
12
+ "prepublishOnly": "npm run typecheck && npm test && npm run test:package"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/Team-ThinkCord/oopscord.js.git"
17
+ },
18
+ "keywords": [
19
+ "discord",
20
+ "discord.js",
21
+ "command",
22
+ "handler",
23
+ "commandhandler"
24
+ ],
25
+ "author": "Team-ThinkCord",
26
+ "license": "GPL-3.0",
27
+ "bugs": {
28
+ "url": "https://github.com/Team-ThinkCord/oopscord.js/issues"
29
+ },
30
+ "homepage": "https://github.com/Team-ThinkCord/oopscord.js#readme",
31
+ "private": false,
32
+ "dependencies": {
33
+ "discord-api-types": "^0.38.62",
34
+ "huruhuru": "0.0.2"
35
+ },
36
+ "devDependencies": {
37
+ "@types/node": "^20.19.35",
38
+ "discord.js": "14.28.1",
39
+ "typedoc": "^0.28.19",
40
+ "typescript": "^5.8.3",
41
+ "vitest": "^4.0.18",
42
+ "yarn": "^1.22.21"
43
+ },
44
+ "type": "commonjs",
45
+ "types": "./dist/index.d.ts",
46
+ "exports": {
47
+ ".": {
48
+ "types": "./dist/index.d.ts",
49
+ "import": "./dist/index.js",
50
+ "require": "./dist/index.js"
51
+ }
52
+ },
53
+ "files": [
54
+ "dist",
55
+ "README.md",
56
+ "LICENSE"
57
+ ],
58
+ "engines": {
59
+ "node": ">=20.19.0"
60
+ },
61
+ "peerDependencies": {
62
+ "discord.js": "^14.28.1"
63
+ }
64
+ }