necord 6.13.0 → 7.0.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 (219) hide show
  1. package/dist/commands/command.discovery.d.ts +3 -3
  2. package/dist/commands/command.discovery.js +2 -6
  3. package/dist/commands/commands.module.d.ts +4 -4
  4. package/dist/commands/commands.module.js +23 -22
  5. package/dist/commands/commands.service.d.ts +8 -7
  6. package/dist/commands/commands.service.js +24 -18
  7. package/dist/commands/context-menus/context-menu.discovery.d.ts +3 -3
  8. package/dist/commands/context-menus/context-menu.discovery.js +2 -6
  9. package/dist/commands/context-menus/context-menus.module.d.ts +4 -4
  10. package/dist/commands/context-menus/context-menus.module.js +16 -19
  11. package/dist/commands/context-menus/context-menus.service.d.ts +2 -2
  12. package/dist/commands/context-menus/context-menus.service.js +8 -11
  13. package/dist/commands/context-menus/decorators/context-menu.decorator.d.ts +1 -1
  14. package/dist/commands/context-menus/decorators/context-menu.decorator.js +4 -7
  15. package/dist/commands/context-menus/decorators/index.d.ts +4 -4
  16. package/dist/commands/context-menus/decorators/index.js +4 -7
  17. package/dist/commands/context-menus/decorators/message-command.decorator.d.ts +2 -2
  18. package/dist/commands/context-menus/decorators/message-command.decorator.js +3 -7
  19. package/dist/commands/context-menus/decorators/target.decorator.js +8 -11
  20. package/dist/commands/context-menus/decorators/user-command.decorator.d.ts +2 -2
  21. package/dist/commands/context-menus/decorators/user-command.decorator.js +3 -7
  22. package/dist/commands/context-menus/index.d.ts +4 -4
  23. package/dist/commands/context-menus/index.js +4 -7
  24. package/dist/commands/index.d.ts +5 -5
  25. package/dist/commands/index.js +5 -8
  26. package/dist/commands/slash-commands/autocomplete/autocomplete.interceptor.d.ts +1 -1
  27. package/dist/commands/slash-commands/autocomplete/autocomplete.interceptor.js +9 -12
  28. package/dist/commands/slash-commands/autocomplete/index.d.ts +1 -1
  29. package/dist/commands/slash-commands/autocomplete/index.js +1 -4
  30. package/dist/commands/slash-commands/decorators/index.d.ts +3 -3
  31. package/dist/commands/slash-commands/decorators/index.js +3 -6
  32. package/dist/commands/slash-commands/decorators/slash-command.decorator.d.ts +2 -2
  33. package/dist/commands/slash-commands/decorators/slash-command.decorator.js +6 -9
  34. package/dist/commands/slash-commands/decorators/subcommand-group.decorator.d.ts +3 -3
  35. package/dist/commands/slash-commands/decorators/subcommand-group.decorator.js +13 -17
  36. package/dist/commands/slash-commands/decorators/subcommand.decorator.d.ts +2 -2
  37. package/dist/commands/slash-commands/decorators/subcommand.decorator.js +6 -9
  38. package/dist/commands/slash-commands/index.d.ts +6 -6
  39. package/dist/commands/slash-commands/index.js +6 -9
  40. package/dist/commands/slash-commands/options/attachment-option.decorator.js +3 -6
  41. package/dist/commands/slash-commands/options/boolean-option.decorator.js +3 -6
  42. package/dist/commands/slash-commands/options/channel-option.decorator.js +3 -6
  43. package/dist/commands/slash-commands/options/index.d.ts +12 -12
  44. package/dist/commands/slash-commands/options/index.js +12 -15
  45. package/dist/commands/slash-commands/options/integer-option.decorator.js +3 -6
  46. package/dist/commands/slash-commands/options/member-option.decorator.js +3 -6
  47. package/dist/commands/slash-commands/options/mentionable-option.decorator.js +3 -6
  48. package/dist/commands/slash-commands/options/number-option.decorator.js +3 -6
  49. package/dist/commands/slash-commands/options/option.util.d.ts +2 -2
  50. package/dist/commands/slash-commands/options/option.util.js +5 -10
  51. package/dist/commands/slash-commands/options/options.decorator.js +22 -14
  52. package/dist/commands/slash-commands/options/role-option.decorator.js +3 -6
  53. package/dist/commands/slash-commands/options/string-option.decorator.js +3 -6
  54. package/dist/commands/slash-commands/options/user-option.decorator.js +3 -6
  55. package/dist/commands/slash-commands/slash-command.discovery.d.ts +5 -34
  56. package/dist/commands/slash-commands/slash-command.discovery.js +7 -10
  57. package/dist/commands/slash-commands/slash-commands.module.d.ts +4 -4
  58. package/dist/commands/slash-commands/slash-commands.module.js +17 -20
  59. package/dist/commands/slash-commands/slash-commands.service.d.ts +3 -3
  60. package/dist/commands/slash-commands/slash-commands.service.js +16 -16
  61. package/dist/context/decorators/context.decorator.js +4 -7
  62. package/dist/context/decorators/discovery.decorator.js +3 -6
  63. package/dist/context/decorators/index.d.ts +2 -2
  64. package/dist/context/decorators/index.js +2 -5
  65. package/dist/context/decorators/params.util.d.ts +1 -1
  66. package/dist/context/decorators/params.util.js +8 -8
  67. package/dist/context/index.d.ts +7 -7
  68. package/dist/context/index.js +7 -10
  69. package/dist/context/necord-arguments-host.d.ts +3 -3
  70. package/dist/context/necord-arguments-host.js +2 -6
  71. package/dist/context/necord-base.discovery.d.ts +6 -6
  72. package/dist/context/necord-base.discovery.js +3 -7
  73. package/dist/context/necord-context.interface.d.ts +1 -1
  74. package/dist/context/necord-context.interface.js +1 -2
  75. package/dist/context/necord-execution-context.d.ts +1 -1
  76. package/dist/context/necord-execution-context.js +2 -6
  77. package/dist/context/necord-params.factory.d.ts +3 -3
  78. package/dist/context/necord-params.factory.js +4 -8
  79. package/dist/context/necord-paramtype.enum.js +2 -5
  80. package/dist/index.d.ts +12 -12
  81. package/dist/index.js +12 -15
  82. package/dist/listeners/decorators/custom-listener.decorator.js +3 -6
  83. package/dist/listeners/decorators/index.d.ts +4 -4
  84. package/dist/listeners/decorators/index.js +4 -7
  85. package/dist/listeners/decorators/listener.decorator.d.ts +1 -1
  86. package/dist/listeners/decorators/listener.decorator.js +4 -7
  87. package/dist/listeners/decorators/on.decorator.d.ts +2 -2
  88. package/dist/listeners/decorators/on.decorator.js +4 -8
  89. package/dist/listeners/decorators/once.decorator.d.ts +2 -2
  90. package/dist/listeners/decorators/once.decorator.js +4 -8
  91. package/dist/listeners/handlers/base.handler.d.ts +1 -1
  92. package/dist/listeners/handlers/base.handler.js +7 -11
  93. package/dist/listeners/handlers/channel-update.handler.d.ts +2 -2
  94. package/dist/listeners/handlers/channel-update.handler.js +14 -17
  95. package/dist/listeners/handlers/guild-audit-log-entry-create.handler.d.ts +2 -2
  96. package/dist/listeners/handlers/guild-audit-log-entry-create.handler.js +19 -22
  97. package/dist/listeners/handlers/guild-member-update.handler.d.ts +14 -6
  98. package/dist/listeners/handlers/guild-member-update.handler.js +46 -39
  99. package/dist/listeners/handlers/guild-update.handler.d.ts +8 -4
  100. package/dist/listeners/handlers/guild-update.handler.js +34 -37
  101. package/dist/listeners/handlers/index.d.ts +11 -11
  102. package/dist/listeners/handlers/index.js +11 -14
  103. package/dist/listeners/handlers/message-update.handler.d.ts +2 -2
  104. package/dist/listeners/handlers/message-update.handler.js +19 -22
  105. package/dist/listeners/handlers/presence-update.handler.d.ts +2 -2
  106. package/dist/listeners/handlers/presence-update.handler.js +15 -18
  107. package/dist/listeners/handlers/role-update.handler.d.ts +5 -5
  108. package/dist/listeners/handlers/role-update.handler.js +24 -27
  109. package/dist/listeners/handlers/thread-update.handler.d.ts +6 -6
  110. package/dist/listeners/handlers/thread-update.handler.js +34 -37
  111. package/dist/listeners/handlers/user-update.handler.d.ts +6 -6
  112. package/dist/listeners/handlers/user-update.handler.js +34 -37
  113. package/dist/listeners/handlers/voice-state-update.handler.d.ts +2 -2
  114. package/dist/listeners/handlers/voice-state-update.handler.js +47 -34
  115. package/dist/listeners/index.d.ts +6 -6
  116. package/dist/listeners/index.js +6 -9
  117. package/dist/listeners/listener.discovery.d.ts +2 -2
  118. package/dist/listeners/listener.discovery.js +2 -6
  119. package/dist/listeners/listener.interface.d.ts +1 -1
  120. package/dist/listeners/listener.interface.js +1 -2
  121. package/dist/listeners/listeners.module.d.ts +4 -4
  122. package/dist/listeners/listeners.module.js +28 -28
  123. package/dist/listeners/scopes/async-custom-listener.context.d.ts +1 -1
  124. package/dist/listeners/scopes/async-custom-listener.context.js +6 -10
  125. package/dist/listeners/scopes/index.d.ts +1 -1
  126. package/dist/listeners/scopes/index.js +1 -4
  127. package/dist/message-components/decorators/button.decorator.js +3 -7
  128. package/dist/message-components/decorators/component-param.decorator.js +4 -7
  129. package/dist/message-components/decorators/index.d.ts +5 -5
  130. package/dist/message-components/decorators/index.js +5 -8
  131. package/dist/message-components/decorators/message-component.decorator.d.ts +1 -1
  132. package/dist/message-components/decorators/message-component.decorator.js +4 -7
  133. package/dist/message-components/decorators/select-menu.decorator.js +7 -15
  134. package/dist/message-components/decorators/selected.decorator.js +17 -20
  135. package/dist/message-components/index.d.ts +4 -4
  136. package/dist/message-components/index.js +4 -7
  137. package/dist/message-components/message-component.discovery.d.ts +1 -1
  138. package/dist/message-components/message-component.discovery.js +4 -8
  139. package/dist/message-components/message-components.module.d.ts +4 -4
  140. package/dist/message-components/message-components.module.js +16 -19
  141. package/dist/message-components/message-components.service.d.ts +2 -2
  142. package/dist/message-components/message-components.service.js +8 -11
  143. package/dist/modals/decorators/fields.decorator.js +4 -7
  144. package/dist/modals/decorators/index.d.ts +3 -3
  145. package/dist/modals/decorators/index.js +3 -6
  146. package/dist/modals/decorators/modal-param.decorator.js +4 -7
  147. package/dist/modals/decorators/modal.decorator.d.ts +1 -1
  148. package/dist/modals/decorators/modal.decorator.js +4 -7
  149. package/dist/modals/index.d.ts +4 -4
  150. package/dist/modals/index.js +4 -7
  151. package/dist/modals/modal.discovery.d.ts +1 -1
  152. package/dist/modals/modal.discovery.js +4 -8
  153. package/dist/modals/modals.module.d.ts +4 -4
  154. package/dist/modals/modals.module.js +16 -19
  155. package/dist/modals/modals.service.d.ts +2 -2
  156. package/dist/modals/modals.service.js +8 -11
  157. package/dist/necord-context.creator.d.ts +1 -1
  158. package/dist/necord-context.creator.js +29 -24
  159. package/dist/necord-explorer.service.d.ts +2 -2
  160. package/dist/necord-explorer.service.js +28 -21
  161. package/dist/necord-options.interface.d.ts +4 -0
  162. package/dist/necord-options.interface.js +1 -2
  163. package/dist/necord.module-definition.d.ts +1 -1
  164. package/dist/necord.module-definition.js +3 -7
  165. package/dist/necord.module.d.ts +4 -4
  166. package/dist/necord.module.js +35 -38
  167. package/dist/providers/channels.provider.d.ts +1 -1
  168. package/dist/providers/channels.provider.js +4 -7
  169. package/dist/providers/client.provider.js +6 -9
  170. package/dist/providers/guilds.provider.d.ts +1 -1
  171. package/dist/providers/guilds.provider.js +4 -7
  172. package/dist/providers/index.d.ts +8 -8
  173. package/dist/providers/index.js +8 -11
  174. package/dist/providers/rest.provider.js +4 -7
  175. package/dist/providers/shard.provider.d.ts +2 -2
  176. package/dist/providers/shard.provider.js +4 -7
  177. package/dist/providers/users.provider.d.ts +1 -1
  178. package/dist/providers/users.provider.js +4 -7
  179. package/dist/providers/voice.provider.d.ts +1 -1
  180. package/dist/providers/voice.provider.js +4 -7
  181. package/dist/providers/ws.provider.d.ts +1 -1
  182. package/dist/providers/ws.provider.js +4 -7
  183. package/dist/scopes/async.context.d.ts +1 -1
  184. package/dist/scopes/async.context.js +10 -14
  185. package/dist/scopes/index.d.ts +1 -1
  186. package/dist/scopes/index.js +1 -4
  187. package/dist/text-commands/decorators/arguments.decorator.js +5 -8
  188. package/dist/text-commands/decorators/index.d.ts +2 -2
  189. package/dist/text-commands/decorators/index.js +2 -5
  190. package/dist/text-commands/decorators/text-command.decorator.d.ts +1 -1
  191. package/dist/text-commands/decorators/text-command.decorator.js +4 -7
  192. package/dist/text-commands/index.d.ts +4 -4
  193. package/dist/text-commands/index.js +4 -7
  194. package/dist/text-commands/text-command.discovery.d.ts +3 -1
  195. package/dist/text-commands/text-command.discovery.js +5 -6
  196. package/dist/text-commands/text-commands.module.d.ts +6 -6
  197. package/dist/text-commands/text-commands.module.js +29 -24
  198. package/dist/text-commands/text-commands.service.d.ts +2 -2
  199. package/dist/text-commands/text-commands.service.js +16 -12
  200. package/package.json +42 -33
  201. package/.husky/commit-msg +0 -1
  202. package/.husky/pre-commit +0 -1
  203. package/.prettierrc +0 -8
  204. package/.release-it.json +0 -74
  205. package/CHANGELOG.md +0 -461
  206. package/coverage/clover.xml +0 -1794
  207. package/coverage/coverage-final.json +0 -113
  208. package/coverage/lcov-report/base.css +0 -224
  209. package/coverage/lcov-report/block-navigation.js +0 -87
  210. package/coverage/lcov-report/favicon.png +0 -0
  211. package/coverage/lcov-report/index.html +0 -431
  212. package/coverage/lcov-report/prettify.css +0 -1
  213. package/coverage/lcov-report/prettify.js +0 -2
  214. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  215. package/coverage/lcov-report/sorter.js +0 -210
  216. package/coverage/lcov.info +0 -3295
  217. package/eslint.config.mjs +0 -53
  218. package/jest.config.json +0 -16
  219. package/tsconfig.json +0 -30
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./decorators"), exports);
5
- tslib_1.__exportStar(require("./modal.discovery"), exports);
6
- tslib_1.__exportStar(require("./modals.module"), exports);
7
- tslib_1.__exportStar(require("./modals.service"), exports);
1
+ export * from './decorators/index.js';
2
+ export * from './modal.discovery.js';
3
+ export * from './modals.module.js';
4
+ export * from './modals.service.js';
@@ -1,5 +1,5 @@
1
- import { NecordBaseDiscovery } from '../context';
2
1
  import { ModalSubmitInteraction } from 'discord.js';
2
+ import { NecordBaseDiscovery } from '../context/index.js';
3
3
  export interface ModalMeta {
4
4
  customId: string;
5
5
  }
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ModalDiscovery = void 0;
4
- const context_1 = require("../context");
5
- const path_to_regexp_1 = require("path-to-regexp");
1
+ import { match } from 'path-to-regexp';
2
+ import { NecordBaseDiscovery } from '../context/index.js';
6
3
  /**
7
4
  * Represents a modal discovery.
8
5
  */
9
- class ModalDiscovery extends context_1.NecordBaseDiscovery {
6
+ export class ModalDiscovery extends NecordBaseDiscovery {
10
7
  constructor() {
11
8
  super(...arguments);
12
- this.matcher = (0, path_to_regexp_1.match)(this.meta.customId);
9
+ this.matcher = match(this.meta.customId);
13
10
  }
14
11
  getCustomId() {
15
12
  return this.meta.customId;
@@ -24,4 +21,3 @@ class ModalDiscovery extends context_1.NecordBaseDiscovery {
24
21
  return this.meta;
25
22
  }
26
23
  }
27
- exports.ModalDiscovery = ModalDiscovery;
@@ -1,9 +1,9 @@
1
1
  import { OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
2
- import { ModalsService } from './modals.service';
3
2
  import { Client } from 'discord.js';
4
- import { NecordExplorerService } from '../necord-explorer.service';
5
- import { ModalDiscovery } from './modal.discovery';
6
- export declare class ModalsModule implements OnModuleInit, OnApplicationBootstrap {
3
+ import { NecordExplorerService } from '../necord-explorer.service.js';
4
+ import { ModalDiscovery } from './modal.discovery.js';
5
+ import { ModalsService } from './modals.service.js';
6
+ export declare class ModalsModule implements OnApplicationBootstrap, OnModuleInit {
7
7
  private readonly client;
8
8
  private readonly explorerService;
9
9
  private readonly modalsService;
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ModalsModule = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@nestjs/common");
6
- const modals_service_1 = require("./modals.service");
7
- const decorators_1 = require("./decorators");
8
- const discord_js_1 = require("discord.js");
9
- const necord_explorer_service_1 = require("../necord-explorer.service");
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Global, Module } from '@nestjs/common';
3
+ import { Client } from 'discord.js';
4
+ import { NecordExplorerService } from '../necord-explorer.service.js';
5
+ import { ModalsService } from './modals.service.js';
6
+ import { Modal } from './decorators/index.js';
10
7
  let ModalsModule = class ModalsModule {
11
8
  constructor(client, explorerService, modalsService) {
12
9
  this.client = client;
@@ -15,7 +12,7 @@ let ModalsModule = class ModalsModule {
15
12
  }
16
13
  onModuleInit() {
17
14
  return this.explorerService
18
- .explore(decorators_1.Modal.KEY)
15
+ .explore(Modal.KEY)
19
16
  .forEach(modal => this.modalsService.add(modal));
20
17
  }
21
18
  onApplicationBootstrap() {
@@ -26,14 +23,14 @@ let ModalsModule = class ModalsModule {
26
23
  });
27
24
  }
28
25
  };
29
- exports.ModalsModule = ModalsModule;
30
- exports.ModalsModule = ModalsModule = tslib_1.__decorate([
31
- (0, common_1.Global)(),
32
- (0, common_1.Module)({
33
- providers: [modals_service_1.ModalsService],
34
- exports: [modals_service_1.ModalsService]
26
+ ModalsModule = __decorate([
27
+ Global(),
28
+ Module({
29
+ providers: [ModalsService],
30
+ exports: [ModalsService]
35
31
  }),
36
- tslib_1.__metadata("design:paramtypes", [discord_js_1.Client,
37
- necord_explorer_service_1.NecordExplorerService,
38
- modals_service_1.ModalsService])
32
+ __metadata("design:paramtypes", [Client,
33
+ NecordExplorerService,
34
+ ModalsService])
39
35
  ], ModalsModule);
36
+ export { ModalsModule };
@@ -1,5 +1,5 @@
1
1
  import { Collection } from 'discord.js';
2
- import { ModalDiscovery } from './modal.discovery';
2
+ import { ModalDiscovery } from './modal.discovery.js';
3
3
  /**
4
4
  * Service that manages modals.
5
5
  */
@@ -7,6 +7,6 @@ export declare class ModalsService {
7
7
  private readonly logger;
8
8
  readonly cache: Collection<string, ModalDiscovery>;
9
9
  add(modal: ModalDiscovery): void;
10
- get(customId: string): ModalDiscovery;
10
+ get(customId: string): ModalDiscovery | undefined;
11
11
  remove(customId: string): void;
12
12
  }
@@ -1,17 +1,14 @@
1
- "use strict";
2
1
  var ModalsService_1;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.ModalsService = void 0;
5
- const tslib_1 = require("tslib");
6
- const common_1 = require("@nestjs/common");
7
- const discord_js_1 = require("discord.js");
2
+ import { __decorate } from "tslib";
3
+ import { Injectable, Logger } from '@nestjs/common';
4
+ import { Collection } from 'discord.js';
8
5
  /**
9
6
  * Service that manages modals.
10
7
  */
11
8
  let ModalsService = ModalsService_1 = class ModalsService {
12
9
  constructor() {
13
- this.logger = new common_1.Logger(ModalsService_1.name);
14
- this.cache = new discord_js_1.Collection();
10
+ this.logger = new Logger(ModalsService_1.name);
11
+ this.cache = new Collection();
15
12
  }
16
13
  add(modal) {
17
14
  const id = modal.getCustomId();
@@ -31,7 +28,7 @@ let ModalsService = ModalsService_1 = class ModalsService {
31
28
  this.cache.delete(customId);
32
29
  }
33
30
  };
34
- exports.ModalsService = ModalsService;
35
- exports.ModalsService = ModalsService = ModalsService_1 = tslib_1.__decorate([
36
- (0, common_1.Injectable)()
31
+ ModalsService = ModalsService_1 = __decorate([
32
+ Injectable()
37
33
  ], ModalsService);
34
+ export { ModalsService };
@@ -4,6 +4,6 @@ export declare class NecordContextCreator {
4
4
  private readonly externalContextCreator;
5
5
  private readonly necordParamsFactory;
6
6
  constructor(externalContextCreator: ExternalContextCreator);
7
- bind(wrapper: InstanceWrapper, methodName: string): (...args: any[]) => Promise<any>;
7
+ bind(wrapper: InstanceWrapper, methodName: string): ((...args: any[]) => Promise<any>) | undefined;
8
8
  private createContextCallback;
9
9
  }
@@ -1,52 +1,57 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NecordContextCreator = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@nestjs/common");
6
- const core_1 = require("@nestjs/core");
7
- const external_context_creator_1 = require("@nestjs/core/helpers/external-context-creator");
8
- const context_1 = require("./context");
9
- const constants_1 = require("@nestjs/common/constants");
10
- const constants_2 = require("@nestjs/core/injector/constants");
11
- const scopes_1 = require("./scopes");
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { ExternalContextCreator } from '@nestjs/core/helpers/external-context-creator';
3
+ import { STATIC_CONTEXT } from '@nestjs/core/injector/constants';
4
+ import { ROUTE_ARGS_METADATA } from '@nestjs/common/constants';
5
+ import { ModuleRef } from '@nestjs/core';
6
+ import { Injectable } from '@nestjs/common';
7
+ import { NecordParamsFactory, NecordParamType } from './context/index.js';
8
+ import { AsyncContext } from './scopes/index.js';
12
9
  let NecordContextCreator = class NecordContextCreator {
13
10
  constructor(externalContextCreator) {
14
11
  this.externalContextCreator = externalContextCreator;
15
- this.necordParamsFactory = new context_1.NecordParamsFactory();
12
+ this.necordParamsFactory = new NecordParamsFactory();
16
13
  }
17
14
  bind(wrapper, methodName) {
18
15
  const instance = wrapper.instance;
19
16
  if (wrapper.isDependencyTreeStatic() && !wrapper.isTransient) {
20
17
  return this.createContextCallback(instance, methodName);
21
18
  }
22
- const { instance: moduleRef } = wrapper.host.getProviderByKey(core_1.ModuleRef);
19
+ const host = wrapper.host;
20
+ if (!host) {
21
+ throw new Error('A request-scoped provider must have a Nest module host.');
22
+ }
23
+ const { instance: moduleRef } = host.getProviderByKey(ModuleRef);
23
24
  return async (...args) => {
24
- const necordContext = this.necordParamsFactory.exchangeKeyForValue(context_1.NecordParamType.CONTEXT, undefined, args);
25
- const context = scopes_1.AsyncContext.of(necordContext) ?? new scopes_1.AsyncContext();
26
- if (!scopes_1.AsyncContext.isAttached(necordContext)) {
25
+ const necordContext = this.necordParamsFactory.exchangeKeyForValue(NecordParamType.CONTEXT, undefined, args);
26
+ const context = AsyncContext.of(necordContext) ?? new AsyncContext();
27
+ if (!AsyncContext.isAttached(necordContext)) {
27
28
  moduleRef.registerRequestByContextId(necordContext, context.id);
28
29
  context.attachTo(necordContext);
29
30
  }
31
+ if (!wrapper.metatype) {
32
+ throw new Error('A request-scoped provider must have a metatype.');
33
+ }
30
34
  const requestScopedInstance = await moduleRef.resolve(wrapper.metatype, context.id, {
31
35
  strict: true
32
36
  });
33
37
  const contextCallback = this.createContextCallback(requestScopedInstance, methodName, context.id, wrapper.id);
34
- return contextCallback(...args);
38
+ return contextCallback?.(...args);
35
39
  };
36
40
  }
37
- createContextCallback(instance, methodName, contextId = constants_2.STATIC_CONTEXT, wrapperId) {
41
+ createContextCallback(instance, methodName, contextId = STATIC_CONTEXT, wrapperId) {
38
42
  if (!instance || typeof instance[methodName] !== 'function') {
39
43
  return;
40
44
  }
41
45
  const prototype = Object.getPrototypeOf(instance);
42
- if (!prototype || !prototype[methodName]) {
46
+ const handler = prototype?.[methodName];
47
+ if (typeof handler !== 'function') {
43
48
  return;
44
49
  }
45
- return this.externalContextCreator.create(instance, prototype[methodName], methodName, constants_1.ROUTE_ARGS_METADATA, this.necordParamsFactory, contextId, wrapperId, { guards: true, filters: true, interceptors: true }, 'necord');
50
+ return this.externalContextCreator.create(instance, handler, methodName, ROUTE_ARGS_METADATA, this.necordParamsFactory, contextId, wrapperId, { guards: true, filters: true, interceptors: true }, 'necord');
46
51
  }
47
52
  };
48
- exports.NecordContextCreator = NecordContextCreator;
49
- exports.NecordContextCreator = NecordContextCreator = tslib_1.__decorate([
50
- (0, common_1.Injectable)(),
51
- tslib_1.__metadata("design:paramtypes", [external_context_creator_1.ExternalContextCreator])
53
+ NecordContextCreator = __decorate([
54
+ Injectable(),
55
+ __metadata("design:paramtypes", [ExternalContextCreator])
52
56
  ], NecordContextCreator);
57
+ export { NecordContextCreator };
@@ -1,6 +1,6 @@
1
- import { NecordBaseDiscovery } from './context';
2
1
  import { DiscoveryService, MetadataScanner, Reflector } from '@nestjs/core';
3
- import { NecordContextCreator } from './necord-context.creator';
2
+ import { NecordContextCreator } from './necord-context.creator.js';
3
+ import { NecordBaseDiscovery } from './context/index.js';
4
4
  /**
5
5
  * Represents a explorer service.
6
6
  * This service is used to explore the application and retrieve the discovery items.
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NecordExplorerService = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@nestjs/common");
6
- const core_1 = require("@nestjs/core");
7
- const necord_context_creator_1 = require("./necord-context.creator");
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { DiscoveryService, MetadataScanner, Reflector } from '@nestjs/core';
3
+ import { Injectable } from '@nestjs/common';
4
+ import { NecordContextCreator } from './necord-context.creator.js';
8
5
  /**
9
6
  * Represents a explorer service.
10
7
  * This service is used to explore the application and retrieve the discovery items.
@@ -25,26 +22,36 @@ let NecordExplorerService = class NecordExplorerService {
25
22
  return this.flatMap(wrapper => this.filterProperties(wrapper, metadataKey));
26
23
  }
27
24
  flatMap(callback) {
28
- return this.wrappers.flatMap(callback).filter(Boolean);
25
+ return this.wrappers.flatMap(callback).filter((item) => Boolean(item));
29
26
  }
30
27
  filterProperties(wrapper, metadataKey) {
31
28
  const { instance } = wrapper;
29
+ if (!instance) {
30
+ return [];
31
+ }
32
32
  const prototype = Object.getPrototypeOf(instance);
33
- return this.metadataScanner.getAllMethodNames(prototype).map(methodName => {
34
- const item = this.reflector.get(metadataKey, instance[methodName]);
33
+ return this.metadataScanner.getAllMethodNames(prototype).flatMap(methodName => {
34
+ const handler = instance[methodName];
35
+ if (typeof handler !== 'function') {
36
+ return [];
37
+ }
38
+ const item = this.reflector.get(metadataKey, handler);
35
39
  if (!item)
36
- return;
37
- item.setDiscoveryMeta({ class: instance.constructor, handler: instance[methodName] });
38
- item.setContextCallback(this.necordContextCreator.bind(wrapper, methodName));
39
- return item;
40
+ return [];
41
+ const contextCallback = this.necordContextCreator.bind(wrapper, methodName);
42
+ if (!contextCallback)
43
+ return [];
44
+ item.setDiscoveryMeta({ class: instance.constructor, handler });
45
+ item.setContextCallback(contextCallback);
46
+ return [item];
40
47
  });
41
48
  }
42
49
  };
43
- exports.NecordExplorerService = NecordExplorerService;
44
- exports.NecordExplorerService = NecordExplorerService = tslib_1.__decorate([
45
- (0, common_1.Injectable)(),
46
- tslib_1.__metadata("design:paramtypes", [core_1.Reflector,
47
- core_1.DiscoveryService,
48
- core_1.MetadataScanner,
49
- necord_context_creator_1.NecordContextCreator])
50
+ NecordExplorerService = __decorate([
51
+ Injectable(),
52
+ __metadata("design:paramtypes", [Reflector,
53
+ DiscoveryService,
54
+ MetadataScanner,
55
+ NecordContextCreator])
50
56
  ], NecordExplorerService);
57
+ export { NecordExplorerService };
@@ -12,6 +12,10 @@ export interface NecordModuleOptions extends DiscordClientOptions {
12
12
  * If you are using TextCommand, you can specify the prefix here. It can be a string for a static prefix, or a function which returns a string based off the message being sent. If using a function, it can be asynchronous.
13
13
  */
14
14
  prefix?: string | Function;
15
+ /**
16
+ * Allows text commands to be used without a prefix when enabled.
17
+ */
18
+ allowTextCommandsWithoutPrefix?: boolean;
15
19
  /**
16
20
  * As discord caches application commands for up to an hour, it is recommended to specify a development guild when doing development.
17
21
  *
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1,2 @@
1
- import { NecordModuleOptions } from './necord-options.interface';
1
+ import { NecordModuleOptions } from './necord-options.interface.js';
2
2
  export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<NecordModuleOptions, "forRoot", "createNecordOptions", {}>, NECORD_MODULE_OPTIONS: string | symbol, OPTIONS_TYPE: NecordModuleOptions & Partial<{}>, ASYNC_OPTIONS_TYPE: import("@nestjs/common").ConfigurableModuleAsyncOptions<NecordModuleOptions, "createNecordOptions"> & Partial<{}>;
@@ -1,9 +1,5 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.ASYNC_OPTIONS_TYPE = exports.OPTIONS_TYPE = exports.NECORD_MODULE_OPTIONS = exports.ConfigurableModuleClass = void 0;
5
- const common_1 = require("@nestjs/common");
6
- _a = new common_1.ConfigurableModuleBuilder()
1
+ import { ConfigurableModuleBuilder } from '@nestjs/common';
2
+ export const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN: NECORD_MODULE_OPTIONS, OPTIONS_TYPE, ASYNC_OPTIONS_TYPE } = new ConfigurableModuleBuilder()
7
3
  .setClassMethodName('forRoot')
8
4
  .setFactoryMethodName('createNecordOptions')
9
- .build(), exports.ConfigurableModuleClass = _a.ConfigurableModuleClass, exports.NECORD_MODULE_OPTIONS = _a.MODULE_OPTIONS_TOKEN, exports.OPTIONS_TYPE = _a.OPTIONS_TYPE, exports.ASYNC_OPTIONS_TYPE = _a.ASYNC_OPTIONS_TYPE;
5
+ .build();
@@ -1,11 +1,11 @@
1
- import { Client } from 'discord.js';
2
1
  import { OnApplicationBootstrap, OnApplicationShutdown } from '@nestjs/common';
3
- import { NecordModuleOptions } from './necord-options.interface';
4
- import { ConfigurableModuleClass } from './necord.module-definition';
2
+ import { Client } from 'discord.js';
3
+ import { ConfigurableModuleClass } from './necord.module-definition.js';
4
+ import { NecordModuleOptions } from './necord-options.interface.js';
5
5
  export declare class NecordModule extends ConfigurableModuleClass implements OnApplicationBootstrap, OnApplicationShutdown {
6
6
  private readonly client;
7
7
  private readonly options;
8
8
  constructor(client: Client, options: NecordModuleOptions);
9
9
  onApplicationBootstrap(): Promise<string>;
10
- onApplicationShutdown(signal?: string): Promise<void>;
10
+ onApplicationShutdown(_signal?: string): Promise<void>;
11
11
  }
@@ -1,21 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NecordModule = void 0;
4
- const tslib_1 = require("tslib");
5
- const discord_js_1 = require("discord.js");
6
- const common_1 = require("@nestjs/common");
7
- const necord_module_definition_1 = require("./necord.module-definition");
8
- const text_commands_1 = require("./text-commands");
9
- const modals_1 = require("./modals");
10
- const message_components_1 = require("./message-components");
11
- const ProvidersMap = tslib_1.__importStar(require("./providers"));
12
- const listeners_1 = require("./listeners");
13
- const necord_explorer_service_1 = require("./necord-explorer.service");
14
- const commands_1 = require("./commands");
15
- const core_1 = require("@nestjs/core");
16
- const necord_context_creator_1 = require("./necord-context.creator");
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { Global, Inject, Module } from '@nestjs/common';
3
+ import { DiscoveryModule } from '@nestjs/core';
4
+ import { Client } from 'discord.js';
5
+ import { ConfigurableModuleClass, NECORD_MODULE_OPTIONS } from './necord.module-definition.js';
6
+ import { MessageComponentsModule } from './message-components/index.js';
7
+ import { NecordExplorerService } from './necord-explorer.service.js';
8
+ import { NecordContextCreator } from './necord-context.creator.js';
9
+ import { TextCommandsModule } from './text-commands/index.js';
10
+ import { ListenersModule } from './listeners/index.js';
11
+ import * as ProvidersMap from './providers/index.js';
12
+ import { CommandsModule } from './commands/index.js';
13
+ import { ModalsModule } from './modals/index.js';
17
14
  const Providers = Object.values(ProvidersMap);
18
- let NecordModule = class NecordModule extends necord_module_definition_1.ConfigurableModuleClass {
15
+ let NecordModule = class NecordModule extends ConfigurableModuleClass {
19
16
  constructor(client, options) {
20
17
  super();
21
18
  this.client = client;
@@ -24,34 +21,34 @@ let NecordModule = class NecordModule extends necord_module_definition_1.Configu
24
21
  onApplicationBootstrap() {
25
22
  return this.client.login(this.options.token);
26
23
  }
27
- onApplicationShutdown(signal) {
24
+ onApplicationShutdown(_signal) {
28
25
  return this.client.destroy();
29
26
  }
30
27
  };
31
- exports.NecordModule = NecordModule;
32
- exports.NecordModule = NecordModule = tslib_1.__decorate([
33
- (0, common_1.Global)(),
34
- (0, common_1.Module)({
28
+ NecordModule = __decorate([
29
+ Global(),
30
+ Module({
35
31
  imports: [
36
- core_1.DiscoveryModule,
37
- commands_1.CommandsModule,
38
- listeners_1.ListenersModule,
39
- message_components_1.MessageComponentsModule,
40
- modals_1.ModalsModule,
41
- text_commands_1.TextCommandsModule
32
+ DiscoveryModule,
33
+ CommandsModule,
34
+ ListenersModule,
35
+ MessageComponentsModule,
36
+ ModalsModule,
37
+ TextCommandsModule
42
38
  ],
43
- providers: [necord_explorer_service_1.NecordExplorerService, necord_context_creator_1.NecordContextCreator, ...Providers],
39
+ providers: [NecordExplorerService, NecordContextCreator, ...Providers],
44
40
  exports: [
45
- commands_1.CommandsModule,
46
- listeners_1.ListenersModule,
47
- message_components_1.MessageComponentsModule,
48
- modals_1.ModalsModule,
49
- text_commands_1.TextCommandsModule,
50
- necord_explorer_service_1.NecordExplorerService,
41
+ CommandsModule,
42
+ ListenersModule,
43
+ MessageComponentsModule,
44
+ ModalsModule,
45
+ TextCommandsModule,
46
+ NecordExplorerService,
51
47
  ...Providers,
52
- necord_module_definition_1.NECORD_MODULE_OPTIONS
48
+ NECORD_MODULE_OPTIONS
53
49
  ]
54
50
  }),
55
- tslib_1.__param(1, (0, common_1.Inject)(necord_module_definition_1.NECORD_MODULE_OPTIONS)),
56
- tslib_1.__metadata("design:paramtypes", [discord_js_1.Client, Object])
51
+ __param(1, Inject(NECORD_MODULE_OPTIONS)),
52
+ __metadata("design:paramtypes", [Client, Object])
57
53
  ], NecordModule);
54
+ export { NecordModule };
@@ -1,3 +1,3 @@
1
- import { Provider } from '@nestjs/common';
2
1
  import { ChannelManager } from 'discord.js';
2
+ import { Provider } from '@nestjs/common';
3
3
  export declare const ChannelsProvider: Provider<ChannelManager>;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ChannelsProvider = void 0;
4
- const discord_js_1 = require("discord.js");
5
- exports.ChannelsProvider = {
6
- provide: discord_js_1.ChannelManager,
1
+ import { ChannelManager, Client } from 'discord.js';
2
+ export const ChannelsProvider = {
3
+ provide: ChannelManager,
7
4
  useFactory: (client) => client.channels,
8
- inject: [discord_js_1.Client]
5
+ inject: [Client]
9
6
  };
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClientProvider = void 0;
4
- const discord_js_1 = require("discord.js");
5
- const necord_module_definition_1 = require("../necord.module-definition");
6
- exports.ClientProvider = {
7
- provide: discord_js_1.Client,
8
- useFactory: (options) => new discord_js_1.Client(options),
9
- inject: [necord_module_definition_1.NECORD_MODULE_OPTIONS]
1
+ import { Client } from 'discord.js';
2
+ import { NECORD_MODULE_OPTIONS } from '../necord.module-definition.js';
3
+ export const ClientProvider = {
4
+ provide: Client,
5
+ useFactory: (options) => new Client(options),
6
+ inject: [NECORD_MODULE_OPTIONS]
10
7
  };
@@ -1,3 +1,3 @@
1
- import { Provider } from '@nestjs/common';
2
1
  import { GuildManager } from 'discord.js';
2
+ import { Provider } from '@nestjs/common';
3
3
  export declare const GuildsProvider: Provider<GuildManager>;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GuildsProvider = void 0;
4
- const discord_js_1 = require("discord.js");
5
- exports.GuildsProvider = {
6
- provide: discord_js_1.GuildManager,
1
+ import { Client, GuildManager } from 'discord.js';
2
+ export const GuildsProvider = {
3
+ provide: GuildManager,
7
4
  useFactory: (client) => client.guilds,
8
- inject: [discord_js_1.Client]
5
+ inject: [Client]
9
6
  };
@@ -1,8 +1,8 @@
1
- export * from './channels.provider';
2
- export * from './client.provider';
3
- export * from './guilds.provider';
4
- export * from './rest.provider';
5
- export * from './shard.provider';
6
- export * from './users.provider';
7
- export * from './voice.provider';
8
- export * from './ws.provider';
1
+ export * from './channels.provider.js';
2
+ export * from './client.provider.js';
3
+ export * from './guilds.provider.js';
4
+ export * from './rest.provider.js';
5
+ export * from './shard.provider.js';
6
+ export * from './users.provider.js';
7
+ export * from './voice.provider.js';
8
+ export * from './ws.provider.js';
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./channels.provider"), exports);
5
- tslib_1.__exportStar(require("./client.provider"), exports);
6
- tslib_1.__exportStar(require("./guilds.provider"), exports);
7
- tslib_1.__exportStar(require("./rest.provider"), exports);
8
- tslib_1.__exportStar(require("./shard.provider"), exports);
9
- tslib_1.__exportStar(require("./users.provider"), exports);
10
- tslib_1.__exportStar(require("./voice.provider"), exports);
11
- tslib_1.__exportStar(require("./ws.provider"), exports);
1
+ export * from './channels.provider.js';
2
+ export * from './client.provider.js';
3
+ export * from './guilds.provider.js';
4
+ export * from './rest.provider.js';
5
+ export * from './shard.provider.js';
6
+ export * from './users.provider.js';
7
+ export * from './voice.provider.js';
8
+ export * from './ws.provider.js';
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RestProvider = void 0;
4
- const discord_js_1 = require("discord.js");
5
- exports.RestProvider = {
6
- provide: discord_js_1.REST,
1
+ import { Client, REST } from 'discord.js';
2
+ export const RestProvider = {
3
+ provide: REST,
7
4
  useFactory: (client) => client.rest,
8
- inject: [discord_js_1.Client]
5
+ inject: [Client]
9
6
  };
@@ -1,3 +1,3 @@
1
- import { Provider } from '@nestjs/common';
2
1
  import { ShardClientUtil } from 'discord.js';
3
- export declare const ShardProvider: Provider<ShardClientUtil>;
2
+ import { Provider } from '@nestjs/common';
3
+ export declare const ShardProvider: Provider<null | ShardClientUtil>;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ShardProvider = void 0;
4
- const discord_js_1 = require("discord.js");
5
- exports.ShardProvider = {
6
- provide: discord_js_1.ShardClientUtil,
1
+ import { Client, ShardClientUtil } from 'discord.js';
2
+ export const ShardProvider = {
3
+ provide: ShardClientUtil,
7
4
  useFactory: (client) => client.shard,
8
- inject: [discord_js_1.Client]
5
+ inject: [Client]
9
6
  };
@@ -1,3 +1,3 @@
1
- import { Provider } from '@nestjs/common';
2
1
  import { UserManager } from 'discord.js';
2
+ import { Provider } from '@nestjs/common';
3
3
  export declare const UsersProvider: Provider<UserManager>;