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,9 +1,9 @@
1
1
  import { ApplicationCommandSubCommandData, ApplicationCommandSubGroupData, AutocompleteInteraction, ChatInputApplicationCommandData, ChatInputCommandInteraction, Collection, CommandInteractionOptionResolver, Snowflake } from 'discord.js';
2
2
  import { APIApplicationCommandOptionBase } from 'discord-api-types/v10';
3
- import { CommandDiscovery } from '../command.discovery';
4
- export type RootCommandMeta = ChatInputApplicationCommandData & {
3
+ import { CommandDiscovery } from '../command.discovery.js';
4
+ export type RootCommandMeta = {
5
5
  guilds?: Snowflake[];
6
- };
6
+ } & ChatInputApplicationCommandData;
7
7
  export type SubcommandGroupMeta = ApplicationCommandSubGroupData;
8
8
  export type SubcommandMeta = ApplicationCommandSubCommandData;
9
9
  export type SlashCommandMeta = RootCommandMeta | SubcommandGroupMeta | SubcommandMeta;
@@ -34,7 +34,7 @@ export declare class SlashCommandDiscovery extends CommandDiscovery<SlashCommand
34
34
  * Returns the subcommand.
35
35
  * @param name
36
36
  */
37
- getSubcommand(name: string): SlashCommandDiscovery;
37
+ getSubcommand(name: string): SlashCommandDiscovery | undefined;
38
38
  /**
39
39
  * Returns the subcommands.
40
40
  */
@@ -60,34 +60,5 @@ export declare class SlashCommandDiscovery extends CommandDiscovery<SlashCommand
60
60
  /**
61
61
  * Returns the JSON representation of the discovery.
62
62
  */
63
- toJSON(): {
64
- options: any;
65
- description: string;
66
- descriptionLocalizations?: import("discord.js").LocalizationMap;
67
- type?: import("discord.js").ApplicationCommandType.ChatInput;
68
- name: string;
69
- nameLocalizations?: import("discord.js").LocalizationMap;
70
- dmPermission?: boolean;
71
- defaultMemberPermissions?: import("discord.js").PermissionResolvable | null;
72
- nsfw?: boolean;
73
- contexts?: readonly import("discord.js").InteractionContextType[];
74
- integrationTypes?: readonly import("discord.js").ApplicationIntegrationType[];
75
- guilds?: Snowflake[];
76
- } | {
77
- options: any;
78
- type: import("discord.js").ApplicationCommandOptionType.SubcommandGroup;
79
- name: string;
80
- description: string;
81
- descriptionLocalizations?: import("discord.js").LocalizationMap;
82
- nameLocalizations?: import("discord.js").LocalizationMap;
83
- autocomplete?: never;
84
- } | {
85
- options: any;
86
- type: import("discord.js").ApplicationCommandOptionType.Subcommand;
87
- name: string;
88
- description: string;
89
- descriptionLocalizations?: import("discord.js").LocalizationMap;
90
- nameLocalizations?: import("discord.js").LocalizationMap;
91
- autocomplete?: never;
92
- };
63
+ toJSON(): any;
93
64
  }
@@ -1,17 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SlashCommandDiscovery = void 0;
4
- const discord_js_1 = require("discord.js");
5
- const command_discovery_1 = require("../command.discovery");
6
- const options_1 = require("./options");
1
+ import { Collection } from 'discord.js';
2
+ import { CommandDiscovery } from '../command.discovery.js';
3
+ import { OPTIONS_METADATA } from './options/index.js';
7
4
  /**
8
5
  * Represents a slash command discovery.
9
6
  * @url https://necord.org/interactions/slash-commands
10
7
  */
11
- class SlashCommandDiscovery extends command_discovery_1.CommandDiscovery {
8
+ export class SlashCommandDiscovery extends CommandDiscovery {
12
9
  constructor() {
13
10
  super(...arguments);
14
- this.subcommands = new discord_js_1.Collection();
11
+ this.subcommands = new Collection();
15
12
  }
16
13
  /**
17
14
  * Returns the command description.
@@ -50,7 +47,8 @@ class SlashCommandDiscovery extends command_discovery_1.CommandDiscovery {
50
47
  * Returns raw options from metadata.
51
48
  */
52
49
  getRawOptions() {
53
- return this.reflector.get(options_1.OPTIONS_METADATA, this.getHandler()) ?? {};
50
+ const handler = this.getHandler();
51
+ return handler ? (this.reflector.get(OPTIONS_METADATA, handler) ?? {}) : {};
54
52
  }
55
53
  /**
56
54
  * Returns the options.
@@ -92,4 +90,3 @@ class SlashCommandDiscovery extends command_discovery_1.CommandDiscovery {
92
90
  };
93
91
  }
94
92
  }
95
- exports.SlashCommandDiscovery = SlashCommandDiscovery;
@@ -1,9 +1,9 @@
1
1
  import { OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
2
- import { SlashCommandsService } from './slash-commands.service';
3
2
  import { Client } from 'discord.js';
4
- import { NecordExplorerService } from '../../necord-explorer.service';
5
- import { SlashCommandDiscovery } from './slash-command.discovery';
6
- export declare class SlashCommandsModule implements OnModuleInit, OnApplicationBootstrap {
3
+ import { NecordExplorerService } from '../../necord-explorer.service.js';
4
+ import { SlashCommandDiscovery } from './slash-command.discovery.js';
5
+ import { SlashCommandsService } from './slash-commands.service.js';
6
+ export declare class SlashCommandsModule implements OnApplicationBootstrap, OnModuleInit {
7
7
  private readonly client;
8
8
  private readonly explorerService;
9
9
  private readonly slashCommandsService;
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SlashCommandsModule = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@nestjs/common");
6
- const slash_commands_service_1 = require("./slash-commands.service");
7
- const discord_js_1 = require("discord.js");
8
- const necord_explorer_service_1 = require("../../necord-explorer.service");
9
- const decorators_1 = require("./decorators");
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 { SlashCommandsService } from './slash-commands.service.js';
6
+ import { SlashCommand, Subcommand } from './decorators/index.js';
10
7
  let SlashCommandsModule = class SlashCommandsModule {
11
8
  constructor(client, explorerService, slashCommandsService) {
12
9
  this.client = client;
@@ -15,10 +12,10 @@ let SlashCommandsModule = class SlashCommandsModule {
15
12
  }
16
13
  onModuleInit() {
17
14
  this.explorerService
18
- .explore(decorators_1.SlashCommand.KEY)
15
+ .explore(SlashCommand.KEY)
19
16
  .forEach(command => this.slashCommandsService.add(command));
20
17
  return this.explorerService
21
- .explore(decorators_1.Subcommand.KEY)
18
+ .explore(Subcommand.KEY)
22
19
  .forEach(subcommand => this.slashCommandsService.addSubCommand(subcommand));
23
20
  }
24
21
  onApplicationBootstrap() {
@@ -29,14 +26,14 @@ let SlashCommandsModule = class SlashCommandsModule {
29
26
  });
30
27
  }
31
28
  };
32
- exports.SlashCommandsModule = SlashCommandsModule;
33
- exports.SlashCommandsModule = SlashCommandsModule = tslib_1.__decorate([
34
- (0, common_1.Global)(),
35
- (0, common_1.Module)({
36
- providers: [slash_commands_service_1.SlashCommandsService],
37
- exports: [slash_commands_service_1.SlashCommandsService]
29
+ SlashCommandsModule = __decorate([
30
+ Global(),
31
+ Module({
32
+ providers: [SlashCommandsService],
33
+ exports: [SlashCommandsService]
38
34
  }),
39
- tslib_1.__metadata("design:paramtypes", [discord_js_1.Client,
40
- necord_explorer_service_1.NecordExplorerService,
41
- slash_commands_service_1.SlashCommandsService])
35
+ __metadata("design:paramtypes", [Client,
36
+ NecordExplorerService,
37
+ SlashCommandsService])
42
38
  ], SlashCommandsModule);
39
+ export { SlashCommandsModule };
@@ -1,6 +1,6 @@
1
- import { SlashCommandDiscovery } from './slash-command.discovery';
2
- import { Collection } from 'discord.js';
3
1
  import { Reflector } from '@nestjs/core';
2
+ import { Collection } from 'discord.js';
3
+ import { SlashCommandDiscovery } from './slash-command.discovery.js';
4
4
  /**
5
5
  * Represents a service that manages slash commands.
6
6
  * @url https://necord.org/interactions/slash-commands
@@ -11,7 +11,7 @@ export declare class SlashCommandsService {
11
11
  readonly cache: Collection<string, SlashCommandDiscovery>;
12
12
  constructor(reflector: Reflector);
13
13
  add(command: SlashCommandDiscovery): void;
14
- get(commandName: string): SlashCommandDiscovery;
14
+ get(commandName: string): SlashCommandDiscovery | undefined;
15
15
  remove(commandName: string): boolean;
16
16
  addSubCommand(subCommand: SlashCommandDiscovery): void;
17
17
  }
@@ -1,12 +1,9 @@
1
- "use strict";
2
1
  var SlashCommandsService_1;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.SlashCommandsService = void 0;
5
- const tslib_1 = require("tslib");
6
- const common_1 = require("@nestjs/common");
7
- const discord_js_1 = require("discord.js");
8
- const core_1 = require("@nestjs/core");
9
- const decorators_1 = require("./decorators");
2
+ import { __decorate, __metadata } from "tslib";
3
+ import { Injectable, Logger } from '@nestjs/common';
4
+ import { Reflector } from '@nestjs/core';
5
+ import { Collection } from 'discord.js';
6
+ import { SlashCommand, SubcommandGroup } from './decorators/index.js';
10
7
  /**
11
8
  * Represents a service that manages slash commands.
12
9
  * @url https://necord.org/interactions/slash-commands
@@ -14,8 +11,8 @@ const decorators_1 = require("./decorators");
14
11
  let SlashCommandsService = SlashCommandsService_1 = class SlashCommandsService {
15
12
  constructor(reflector) {
16
13
  this.reflector = reflector;
17
- this.logger = new common_1.Logger(SlashCommandsService_1.name);
18
- this.cache = new discord_js_1.Collection();
14
+ this.logger = new Logger(SlashCommandsService_1.name);
15
+ this.cache = new Collection();
19
16
  }
20
17
  add(command) {
21
18
  if (this.cache.has(command.getName())) {
@@ -30,8 +27,11 @@ let SlashCommandsService = SlashCommandsService_1 = class SlashCommandsService {
30
27
  return this.cache.delete(commandName);
31
28
  }
32
29
  addSubCommand(subCommand) {
33
- let rootCommand = this.reflector.get(decorators_1.SlashCommand.KEY, subCommand.getClass());
34
- let subCommandGroup = this.reflector.get(decorators_1.SubcommandGroup.KEY, subCommand.getClass());
30
+ let rootCommand = this.reflector.get(SlashCommand.KEY, subCommand.getClass());
31
+ let subCommandGroup = this.reflector.get(SubcommandGroup.KEY, subCommand.getClass());
32
+ if (!rootCommand) {
33
+ throw new Error('A subcommand must belong to a root slash command.');
34
+ }
35
35
  rootCommand = this.cache.ensure(rootCommand.getName(), () => rootCommand);
36
36
  if (subCommandGroup) {
37
37
  subCommandGroup = rootCommand.ensureSubcommand(subCommandGroup);
@@ -42,8 +42,8 @@ let SlashCommandsService = SlashCommandsService_1 = class SlashCommandsService {
42
42
  }
43
43
  }
44
44
  };
45
- exports.SlashCommandsService = SlashCommandsService;
46
- exports.SlashCommandsService = SlashCommandsService = SlashCommandsService_1 = tslib_1.__decorate([
47
- (0, common_1.Injectable)(),
48
- tslib_1.__metadata("design:paramtypes", [core_1.Reflector])
45
+ SlashCommandsService = SlashCommandsService_1 = __decorate([
46
+ Injectable(),
47
+ __metadata("design:paramtypes", [Reflector])
49
48
  ], SlashCommandsService);
49
+ export { SlashCommandsService };
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Ctx = exports.Context = void 0;
4
- const necord_paramtype_enum_1 = require("../necord-paramtype.enum");
5
- const params_util_1 = require("./params.util");
1
+ import { NecordParamType } from '../necord-paramtype.enum.js';
2
+ import { createNecordParamDecorator } from './params.util.js';
6
3
  /**
7
4
  * Context decorator that marks a argument as a context.
8
5
  * This decorator is used to retrieve the context.
9
6
  * @returns The decorated argument.
10
7
  * @url https://necord.org/start/#context
11
8
  */
12
- exports.Context = (0, params_util_1.createNecordParamDecorator)(necord_paramtype_enum_1.NecordParamType.CONTEXT);
13
- exports.Ctx = exports.Context;
9
+ export const Context = createNecordParamDecorator(NecordParamType.CONTEXT);
10
+ export const Ctx = Context;
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Discovery = void 0;
4
- const necord_paramtype_enum_1 = require("../necord-paramtype.enum");
5
- const params_util_1 = require("./params.util");
1
+ import { NecordParamType } from '../necord-paramtype.enum.js';
2
+ import { createNecordParamDecorator } from './params.util.js';
6
3
  /**
7
4
  * Context decorator that marks a argument as a discovery.
8
5
  * This decorator is used to retrieve the discovery.
9
6
  * @returns The decorated argument.
10
7
  */
11
- exports.Discovery = (0, params_util_1.createNecordParamDecorator)(necord_paramtype_enum_1.NecordParamType.DISCOVERY);
8
+ export const Discovery = createNecordParamDecorator(NecordParamType.DISCOVERY);
@@ -1,2 +1,2 @@
1
- export * from './context.decorator';
2
- export * from './discovery.decorator';
1
+ export * from './context.decorator.js';
2
+ export * from './discovery.decorator.js';
@@ -1,5 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./context.decorator"), exports);
5
- tslib_1.__exportStar(require("./discovery.decorator"), exports);
1
+ export * from './context.decorator.js';
2
+ export * from './discovery.decorator.js';
@@ -1,3 +1,3 @@
1
- import { NecordParamType } from '../necord-paramtype.enum';
2
1
  import { PipeTransform, Type } from '@nestjs/common';
2
+ import { NecordParamType } from '../necord-paramtype.enum.js';
3
3
  export declare function createNecordParamDecorator(type: NecordParamType): (...pipes: (Type<PipeTransform> | PipeTransform)[]) => ParameterDecorator;
@@ -1,11 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createNecordParamDecorator = createNecordParamDecorator;
4
- const common_1 = require("@nestjs/common");
5
- const constants_1 = require("@nestjs/common/constants");
6
- function createNecordParamDecorator(type) {
1
+ import { assignMetadata } from '@nestjs/common';
2
+ import { ROUTE_ARGS_METADATA } from '@nestjs/common/constants';
3
+ export function createNecordParamDecorator(type) {
7
4
  return (...pipes) => (target, key, index) => {
8
- const args = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, target.constructor, key) || {};
9
- Reflect.defineMetadata(constants_1.ROUTE_ARGS_METADATA, (0, common_1.assignMetadata)(args, type, index, undefined, ...pipes), target.constructor, key);
5
+ if (key === undefined) {
6
+ return;
7
+ }
8
+ const args = Reflect.getMetadata(ROUTE_ARGS_METADATA, target.constructor, key) || {};
9
+ Reflect.defineMetadata(ROUTE_ARGS_METADATA, assignMetadata(args, type, index, undefined, ...pipes), target.constructor, key);
10
10
  };
11
11
  }
@@ -1,7 +1,7 @@
1
- export * from './decorators';
2
- export * from './necord-arguments-host';
3
- export * from './necord-base.discovery';
4
- export * from './necord-context.interface';
5
- export * from './necord-execution-context';
6
- export * from './necord-params.factory';
7
- export * from './necord-paramtype.enum';
1
+ export * from './decorators/index.js';
2
+ export * from './necord-arguments-host.js';
3
+ export * from './necord-base.discovery.js';
4
+ export * from './necord-context.interface.js';
5
+ export * from './necord-execution-context.js';
6
+ export * from './necord-params.factory.js';
7
+ export * from './necord-paramtype.enum.js';
@@ -1,10 +1,7 @@
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("./necord-arguments-host"), exports);
6
- tslib_1.__exportStar(require("./necord-base.discovery"), exports);
7
- tslib_1.__exportStar(require("./necord-context.interface"), exports);
8
- tslib_1.__exportStar(require("./necord-execution-context"), exports);
9
- tslib_1.__exportStar(require("./necord-params.factory"), exports);
10
- tslib_1.__exportStar(require("./necord-paramtype.enum"), exports);
1
+ export * from './decorators/index.js';
2
+ export * from './necord-arguments-host.js';
3
+ export * from './necord-base.discovery.js';
4
+ export * from './necord-context.interface.js';
5
+ export * from './necord-execution-context.js';
6
+ export * from './necord-params.factory.js';
7
+ export * from './necord-paramtype.enum.js';
@@ -1,9 +1,9 @@
1
1
  import { ExecutionContextHost } from '@nestjs/core/helpers/execution-context-host';
2
2
  import { ArgumentsHost } from '@nestjs/common';
3
- import { NecordContextType } from './necord-execution-context';
4
3
  import { ClientEvents } from 'discord.js';
5
- import { NecordBaseDiscovery } from '../context';
6
- import { ContextOf } from './necord-context.interface';
4
+ import { NecordContextType } from './necord-execution-context.js';
5
+ import { ContextOf } from './necord-context.interface.js';
6
+ import { NecordBaseDiscovery } from '../context/index.js';
7
7
  export declare class NecordArgumentsHost extends ExecutionContextHost {
8
8
  static create(context: ArgumentsHost): NecordArgumentsHost;
9
9
  getType<TContext extends string = NecordContextType>(): TContext;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NecordArgumentsHost = void 0;
4
- const execution_context_host_1 = require("@nestjs/core/helpers/execution-context-host");
5
- class NecordArgumentsHost extends execution_context_host_1.ExecutionContextHost {
1
+ import { ExecutionContextHost } from '@nestjs/core/helpers/execution-context-host';
2
+ export class NecordArgumentsHost extends ExecutionContextHost {
6
3
  static create(context) {
7
4
  const type = context.getType();
8
5
  const necContext = new NecordArgumentsHost(context.getArgs());
@@ -19,4 +16,3 @@ class NecordArgumentsHost extends execution_context_host_1.ExecutionContextHost
19
16
  return this.getArgByIndex(1);
20
17
  }
21
18
  }
22
- exports.NecordArgumentsHost = NecordArgumentsHost;
@@ -1,9 +1,9 @@
1
1
  import { Reflector } from '@nestjs/core';
2
- import { ContextMenuDiscovery, SlashCommandDiscovery } from '../commands';
3
- import { MessageComponentDiscovery } from '../message-components';
4
- import { ListenerDiscovery } from '../listeners';
5
- import { TextCommandDiscovery } from '../text-commands';
6
- import { ModalDiscovery } from '../modals';
2
+ import { ContextMenuDiscovery, SlashCommandDiscovery } from '../commands/index.js';
3
+ import { MessageComponentDiscovery } from '../message-components/index.js';
4
+ import { TextCommandDiscovery } from '../text-commands/index.js';
5
+ import { ListenerDiscovery } from '../listeners/index.js';
6
+ import { ModalDiscovery } from '../modals/index.js';
7
7
  interface DiscoveredItem {
8
8
  class: any;
9
9
  handler?: (...args: any[]) => any;
@@ -15,7 +15,7 @@ export declare abstract class NecordBaseDiscovery<T = any> {
15
15
  protected contextCallback: Function;
16
16
  constructor(meta: T);
17
17
  getClass(): any;
18
- getHandler(): (...args: any[]) => any;
18
+ getHandler(): ((...args: any[]) => any) | undefined;
19
19
  setDiscoveryMeta(meta: DiscoveredItem): void;
20
20
  setContextCallback(fn: Function): void;
21
21
  execute(context?: any): any;
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NecordBaseDiscovery = void 0;
4
- const core_1 = require("@nestjs/core");
5
- class NecordBaseDiscovery {
1
+ import { Reflector } from '@nestjs/core';
2
+ export class NecordBaseDiscovery {
6
3
  constructor(meta) {
7
4
  this.meta = meta;
8
- this.reflector = new core_1.Reflector();
5
+ this.reflector = new Reflector();
9
6
  }
10
7
  getClass() {
11
8
  return this.discovery?.class;
@@ -41,4 +38,3 @@ class NecordBaseDiscovery {
41
38
  return false;
42
39
  }
43
40
  }
44
- exports.NecordBaseDiscovery = NecordBaseDiscovery;
@@ -1,5 +1,5 @@
1
1
  import { AutocompleteInteraction, ButtonInteraction, ChannelSelectMenuInteraction, ChatInputCommandInteraction, MentionableSelectMenuInteraction, Message, MessageContextMenuCommandInteraction, ModalSubmitInteraction, RoleSelectMenuInteraction, StringSelectMenuInteraction, UserContextMenuCommandInteraction, UserSelectMenuInteraction } from 'discord.js';
2
- import { NecordEvents } from '../listeners';
2
+ import { NecordEvents } from '../listeners/index.js';
3
3
  export type AutocompleteContext = [AutocompleteInteraction];
4
4
  export type SlashCommandContext = [ChatInputCommandInteraction];
5
5
  export type TextCommandContext = [Message];
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { ContextType, ExecutionContext } from '@nestjs/common';
2
- import { NecordArgumentsHost } from './necord-arguments-host';
2
+ import { NecordArgumentsHost } from './necord-arguments-host.js';
3
3
  export type NecordContextType = 'necord' | ContextType;
4
4
  export declare class NecordExecutionContext extends NecordArgumentsHost {
5
5
  static create(context: ExecutionContext): NecordExecutionContext;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NecordExecutionContext = void 0;
4
- const necord_arguments_host_1 = require("./necord-arguments-host");
5
- class NecordExecutionContext extends necord_arguments_host_1.NecordArgumentsHost {
1
+ import { NecordArgumentsHost } from './necord-arguments-host.js';
2
+ export class NecordExecutionContext extends NecordArgumentsHost {
6
3
  static create(context) {
7
4
  const type = context.getType();
8
5
  const necContext = new NecordExecutionContext(context.getArgs(), context.getClass(), context.getHandler());
@@ -10,4 +7,3 @@ class NecordExecutionContext extends necord_arguments_host_1.NecordArgumentsHost
10
7
  return necContext;
11
8
  }
12
9
  }
13
- exports.NecordExecutionContext = NecordExecutionContext;
@@ -1,7 +1,7 @@
1
1
  import { ParamsFactory } from '@nestjs/core/helpers/external-context-creator';
2
- import { NecordParamType } from './necord-paramtype.enum';
3
- import { NecordBaseDiscovery } from '../context';
4
2
  import { ParamData } from '@nestjs/common';
3
+ import { NecordParamType } from './necord-paramtype.enum.js';
4
+ import { NecordBaseDiscovery } from '../context/index.js';
5
5
  export declare class NecordParamsFactory implements ParamsFactory {
6
- exchangeKeyForValue(type: NecordParamType, data: ParamData, args: [Array<any>, NecordBaseDiscovery]): any;
6
+ exchangeKeyForValue(type: NecordParamType, data: ParamData | undefined, args?: [Array<any>, NecordBaseDiscovery]): any;
7
7
  }
@@ -1,19 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NecordParamsFactory = void 0;
4
- const necord_paramtype_enum_1 = require("./necord-paramtype.enum");
5
- class NecordParamsFactory {
1
+ import { NecordParamType } from './necord-paramtype.enum.js';
2
+ export class NecordParamsFactory {
6
3
  exchangeKeyForValue(type, data, args) {
7
4
  if (!args)
8
5
  return null;
9
6
  switch (type) {
10
- case necord_paramtype_enum_1.NecordParamType.CONTEXT:
7
+ case NecordParamType.CONTEXT:
11
8
  return args[0];
12
- case necord_paramtype_enum_1.NecordParamType.DISCOVERY:
9
+ case NecordParamType.DISCOVERY:
13
10
  return args[1];
14
11
  default:
15
12
  return null;
16
13
  }
17
14
  }
18
15
  }
19
- exports.NecordParamsFactory = NecordParamsFactory;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NecordParamType = void 0;
4
- var NecordParamType;
1
+ export var NecordParamType;
5
2
  (function (NecordParamType) {
6
3
  NecordParamType[NecordParamType["CONTEXT"] = 0] = "CONTEXT";
7
4
  NecordParamType[NecordParamType["DISCOVERY"] = 1] = "DISCOVERY";
8
- })(NecordParamType || (exports.NecordParamType = NecordParamType = {}));
5
+ })(NecordParamType || (NecordParamType = {}));
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- export * from './commands';
2
- export * from './context';
3
- export * from './listeners';
4
- export * from './message-components';
5
- export * from './modals';
6
- export * from './providers';
7
- export * from './scopes';
8
- export * from './text-commands';
9
- export * from './necord.module';
10
- export * from './necord.module-definition';
11
- export * from './necord-explorer.service';
12
- export * from './necord-options.interface';
1
+ export * from './commands/index.js';
2
+ export * from './context/index.js';
3
+ export * from './listeners/index.js';
4
+ export * from './message-components/index.js';
5
+ export * from './modals/index.js';
6
+ export * from './necord-explorer.service.js';
7
+ export * from './necord-options.interface.js';
8
+ export * from './necord.module-definition.js';
9
+ export * from './necord.module.js';
10
+ export * from './providers/index.js';
11
+ export * from './scopes/index.js';
12
+ export * from './text-commands/index.js';
package/dist/index.js CHANGED
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./commands"), exports);
5
- tslib_1.__exportStar(require("./context"), exports);
6
- tslib_1.__exportStar(require("./listeners"), exports);
7
- tslib_1.__exportStar(require("./message-components"), exports);
8
- tslib_1.__exportStar(require("./modals"), exports);
9
- tslib_1.__exportStar(require("./providers"), exports);
10
- tslib_1.__exportStar(require("./scopes"), exports);
11
- tslib_1.__exportStar(require("./text-commands"), exports);
12
- tslib_1.__exportStar(require("./necord.module"), exports);
13
- tslib_1.__exportStar(require("./necord.module-definition"), exports);
14
- tslib_1.__exportStar(require("./necord-explorer.service"), exports);
15
- tslib_1.__exportStar(require("./necord-options.interface"), exports);
1
+ export * from './commands/index.js';
2
+ export * from './context/index.js';
3
+ export * from './listeners/index.js';
4
+ export * from './message-components/index.js';
5
+ export * from './modals/index.js';
6
+ export * from './necord-explorer.service.js';
7
+ export * from './necord-options.interface.js';
8
+ export * from './necord.module-definition.js';
9
+ export * from './necord.module.js';
10
+ export * from './providers/index.js';
11
+ export * from './scopes/index.js';
12
+ export * from './text-commands/index.js';
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CustomListenerHandler = exports.CustomListener = void 0;
4
- const core_1 = require("@nestjs/core");
1
+ import { DiscoveryService, Reflector } from '@nestjs/core';
5
2
  /**
6
3
  * Decorator that marks a class as a custom listener.
7
4
  * @param event The event name.
8
5
  * @returns The decorated class.
9
6
  * @url https://necord.org/listeners
10
7
  */
11
- exports.CustomListener = core_1.DiscoveryService.createDecorator();
8
+ export const CustomListener = DiscoveryService.createDecorator();
12
9
  /**
13
10
  * Decorator that marks a method as a custom listener handler.
14
11
  * @returns The decorated method.
15
12
  */
16
- exports.CustomListenerHandler = core_1.Reflector.createDecorator({
13
+ export const CustomListenerHandler = Reflector.createDecorator({
17
14
  transform: () => true
18
15
  });
@@ -1,4 +1,4 @@
1
- export * from './custom-listener.decorator';
2
- export * from './listener.decorator';
3
- export * from './on.decorator';
4
- export * from './once.decorator';
1
+ export * from './custom-listener.decorator.js';
2
+ export * from './listener.decorator.js';
3
+ export * from './on.decorator.js';
4
+ export * from './once.decorator.js';
@@ -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("./custom-listener.decorator"), exports);
5
- tslib_1.__exportStar(require("./listener.decorator"), exports);
6
- tslib_1.__exportStar(require("./on.decorator"), exports);
7
- tslib_1.__exportStar(require("./once.decorator"), exports);
1
+ export * from './custom-listener.decorator.js';
2
+ export * from './listener.decorator.js';
3
+ export * from './on.decorator.js';
4
+ export * from './once.decorator.js';