necord 5.4.2 → 5.4.3

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 (163) hide show
  1. package/dist/commands/command.discovery.d.ts +8 -8
  2. package/dist/commands/command.discovery.js +13 -13
  3. package/dist/commands/commands.service.d.ts +15 -15
  4. package/dist/commands/commands.service.js +80 -80
  5. package/dist/commands/context-menus/context-menu.discovery.d.ts +11 -11
  6. package/dist/commands/context-menus/context-menu.discovery.js +19 -19
  7. package/dist/commands/context-menus/context-menus.service.d.ts +16 -16
  8. package/dist/commands/context-menus/context-menus.service.js +52 -52
  9. package/dist/commands/context-menus/decorators/context-menu.decorator.d.ts +2 -2
  10. package/dist/commands/context-menus/decorators/context-menu.decorator.js +8 -8
  11. package/dist/commands/context-menus/decorators/index.d.ts +4 -4
  12. package/dist/commands/context-menus/decorators/index.js +20 -20
  13. package/dist/commands/context-menus/decorators/message-command.decorator.d.ts +2 -2
  14. package/dist/commands/context-menus/decorators/message-command.decorator.js +7 -7
  15. package/dist/commands/context-menus/decorators/target.decorator.d.ts +7 -7
  16. package/dist/commands/context-menus/decorators/target.decorator.js +38 -38
  17. package/dist/commands/context-menus/decorators/user-command.decorator.d.ts +2 -2
  18. package/dist/commands/context-menus/decorators/user-command.decorator.js +7 -7
  19. package/dist/commands/context-menus/index.d.ts +3 -3
  20. package/dist/commands/context-menus/index.js +19 -19
  21. package/dist/commands/index.d.ts +4 -4
  22. package/dist/commands/index.js +20 -20
  23. package/dist/commands/slash-commands/autocomplete/autocomplete.interceptor.d.ts +7 -7
  24. package/dist/commands/slash-commands/autocomplete/autocomplete.interceptor.js +39 -39
  25. package/dist/commands/slash-commands/autocomplete/index.d.ts +1 -1
  26. package/dist/commands/slash-commands/autocomplete/index.js +17 -17
  27. package/dist/commands/slash-commands/decorators/index.d.ts +3 -3
  28. package/dist/commands/slash-commands/decorators/index.js +19 -19
  29. package/dist/commands/slash-commands/decorators/slash-command.decorator.d.ts +2 -2
  30. package/dist/commands/slash-commands/decorators/slash-command.decorator.js +9 -9
  31. package/dist/commands/slash-commands/decorators/subcommand-group.decorator.d.ts +2 -2
  32. package/dist/commands/slash-commands/decorators/subcommand-group.decorator.js +18 -18
  33. package/dist/commands/slash-commands/decorators/subcommand.decorator.d.ts +2 -2
  34. package/dist/commands/slash-commands/decorators/subcommand.decorator.js +9 -9
  35. package/dist/commands/slash-commands/index.d.ts +5 -5
  36. package/dist/commands/slash-commands/index.js +21 -21
  37. package/dist/commands/slash-commands/options/attachment-option.decorator.d.ts +7 -7
  38. package/dist/commands/slash-commands/options/attachment-option.decorator.js +6 -6
  39. package/dist/commands/slash-commands/options/boolean-option.decorator.d.ts +7 -7
  40. package/dist/commands/slash-commands/options/boolean-option.decorator.js +6 -6
  41. package/dist/commands/slash-commands/options/channel-option.decorator.d.ts +8 -8
  42. package/dist/commands/slash-commands/options/channel-option.decorator.js +6 -6
  43. package/dist/commands/slash-commands/options/index.d.ts +11 -11
  44. package/dist/commands/slash-commands/options/index.js +27 -27
  45. package/dist/commands/slash-commands/options/integer-option.decorator.d.ts +20 -20
  46. package/dist/commands/slash-commands/options/integer-option.decorator.js +6 -6
  47. package/dist/commands/slash-commands/options/member-option.decorator.d.ts +7 -7
  48. package/dist/commands/slash-commands/options/member-option.decorator.js +6 -6
  49. package/dist/commands/slash-commands/options/mentionable-option.decorator.d.ts +7 -7
  50. package/dist/commands/slash-commands/options/mentionable-option.decorator.js +6 -6
  51. package/dist/commands/slash-commands/options/number-option.decorator.d.ts +20 -20
  52. package/dist/commands/slash-commands/options/number-option.decorator.js +6 -6
  53. package/dist/commands/slash-commands/options/option.util.d.ts +5 -5
  54. package/dist/commands/slash-commands/options/option.util.js +21 -21
  55. package/dist/commands/slash-commands/options/options.decorator.d.ts +2 -2
  56. package/dist/commands/slash-commands/options/options.decorator.js +32 -32
  57. package/dist/commands/slash-commands/options/role-option.decorator.d.ts +7 -7
  58. package/dist/commands/slash-commands/options/role-option.decorator.js +6 -6
  59. package/dist/commands/slash-commands/options/string-option.decorator.d.ts +20 -20
  60. package/dist/commands/slash-commands/options/string-option.decorator.js +6 -6
  61. package/dist/commands/slash-commands/options/user-option.decorator.d.ts +7 -7
  62. package/dist/commands/slash-commands/options/user-option.decorator.js +6 -6
  63. package/dist/commands/slash-commands/slash-command.discovery.d.ts +20 -20
  64. package/dist/commands/slash-commands/slash-command.discovery.js +44 -44
  65. package/dist/commands/slash-commands/slash-commands.service.d.ts +19 -19
  66. package/dist/commands/slash-commands/slash-commands.service.js +84 -84
  67. package/dist/context/decorators/context.decorator.d.ts +2 -2
  68. package/dist/context/decorators/context.decorator.js +7 -7
  69. package/dist/context/decorators/discovery.decorator.d.ts +1 -1
  70. package/dist/context/decorators/discovery.decorator.js +6 -6
  71. package/dist/context/decorators/index.d.ts +2 -2
  72. package/dist/context/decorators/index.js +18 -18
  73. package/dist/context/decorators/params.util.d.ts +3 -3
  74. package/dist/context/decorators/params.util.js +12 -12
  75. package/dist/context/index.d.ts +7 -7
  76. package/dist/context/index.js +23 -23
  77. package/dist/context/necord-arguments-host.d.ts +13 -13
  78. package/dist/context/necord-arguments-host.js +22 -22
  79. package/dist/context/necord-base.discovery.d.ts +30 -30
  80. package/dist/context/necord-base.discovery.js +47 -47
  81. package/dist/context/necord-context.interface.d.ts +22 -22
  82. package/dist/context/necord-context.interface.js +2 -2
  83. package/dist/context/necord-execution-context.d.ts +6 -6
  84. package/dist/context/necord-execution-context.js +13 -13
  85. package/dist/context/necord-params.factory.d.ts +6 -6
  86. package/dist/context/necord-params.factory.js +19 -19
  87. package/dist/context/necord-paramtype.enum.d.ts +4 -4
  88. package/dist/context/necord-paramtype.enum.js +8 -8
  89. package/dist/index.d.ts +9 -9
  90. package/dist/index.js +25 -25
  91. package/dist/listeners/decorators/index.d.ts +3 -3
  92. package/dist/listeners/decorators/index.js +19 -19
  93. package/dist/listeners/decorators/listener.decorator.d.ts +2 -2
  94. package/dist/listeners/decorators/listener.decorator.js +8 -8
  95. package/dist/listeners/decorators/on.decorator.d.ts +2 -2
  96. package/dist/listeners/decorators/on.decorator.js +6 -6
  97. package/dist/listeners/decorators/once.decorator.d.ts +2 -2
  98. package/dist/listeners/decorators/once.decorator.js +6 -6
  99. package/dist/listeners/index.d.ts +3 -3
  100. package/dist/listeners/index.js +19 -19
  101. package/dist/listeners/listener.discovery.d.ts +11 -11
  102. package/dist/listeners/listener.discovery.js +19 -19
  103. package/dist/listeners/listener.interface.d.ts +90 -90
  104. package/dist/listeners/listener.interface.js +2 -2
  105. package/dist/listeners/listeners.service.d.ts +22 -22
  106. package/dist/listeners/listeners.service.js +237 -237
  107. package/dist/message-components/decorators/button.decorator.d.ts +1 -1
  108. package/dist/message-components/decorators/button.decorator.js +7 -7
  109. package/dist/message-components/decorators/component-param.decorator.d.ts +1 -1
  110. package/dist/message-components/decorators/component-param.decorator.js +17 -17
  111. package/dist/message-components/decorators/index.d.ts +6 -6
  112. package/dist/message-components/decorators/index.js +22 -22
  113. package/dist/message-components/decorators/message-component.decorator.d.ts +2 -2
  114. package/dist/message-components/decorators/message-component.decorator.js +8 -8
  115. package/dist/message-components/decorators/select-menu.decorator.d.ts +12 -12
  116. package/dist/message-components/decorators/select-menu.decorator.js +23 -23
  117. package/dist/message-components/decorators/selected.decorator.d.ts +10 -10
  118. package/dist/message-components/decorators/selected.decorator.js +40 -39
  119. package/dist/message-components/decorators/values.decorator.d.ts +7 -7
  120. package/dist/message-components/decorators/values.decorator.js +17 -17
  121. package/dist/message-components/index.d.ts +3 -3
  122. package/dist/message-components/index.js +19 -19
  123. package/dist/message-components/message-component.discovery.d.ts +14 -14
  124. package/dist/message-components/message-component.discovery.js +27 -27
  125. package/dist/message-components/message-components.service.d.ts +15 -15
  126. package/dist/message-components/message-components.service.js +55 -55
  127. package/dist/modals/decorators/fields.decorator.d.ts +1 -1
  128. package/dist/modals/decorators/fields.decorator.js +14 -14
  129. package/dist/modals/decorators/index.d.ts +3 -3
  130. package/dist/modals/decorators/index.js +19 -19
  131. package/dist/modals/decorators/modal-param.decorator.d.ts +1 -1
  132. package/dist/modals/decorators/modal-param.decorator.js +17 -17
  133. package/dist/modals/decorators/modal.decorator.d.ts +1 -1
  134. package/dist/modals/decorators/modal.decorator.js +8 -8
  135. package/dist/modals/index.d.ts +3 -3
  136. package/dist/modals/index.js +19 -19
  137. package/dist/modals/modal.discovery.d.ts +12 -12
  138. package/dist/modals/modal.discovery.js +24 -24
  139. package/dist/modals/modals.service.d.ts +14 -14
  140. package/dist/modals/modals.service.js +50 -50
  141. package/dist/necord-client.provider.d.ts +3 -3
  142. package/dist/necord-client.provider.js +10 -10
  143. package/dist/necord-explorer.service.d.ts +15 -15
  144. package/dist/necord-explorer.service.js +59 -59
  145. package/dist/necord-options.interface.d.ts +17 -17
  146. package/dist/necord-options.interface.js +2 -2
  147. package/dist/necord.constants.d.ts +11 -11
  148. package/dist/necord.constants.js +14 -14
  149. package/dist/necord.module.d.ts +14 -14
  150. package/dist/necord.module.js +123 -123
  151. package/dist/text-commands/decorators/arguments.decorator.d.ts +2 -2
  152. package/dist/text-commands/decorators/arguments.decorator.js +14 -14
  153. package/dist/text-commands/decorators/index.d.ts +2 -2
  154. package/dist/text-commands/decorators/index.js +18 -18
  155. package/dist/text-commands/decorators/text-command.decorator.d.ts +2 -2
  156. package/dist/text-commands/decorators/text-command.decorator.js +8 -8
  157. package/dist/text-commands/index.d.ts +3 -3
  158. package/dist/text-commands/index.js +19 -19
  159. package/dist/text-commands/text-command.discovery.d.ts +11 -11
  160. package/dist/text-commands/text-command.discovery.js +19 -19
  161. package/dist/text-commands/text-commands.service.d.ts +16 -16
  162. package/dist/text-commands/text-commands.service.js +72 -72
  163. package/package.json +8 -8
@@ -1,44 +1,44 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SlashCommandDiscovery = void 0;
4
- const necord_constants_1 = require("../../necord.constants");
5
- const command_discovery_1 = require("../command.discovery");
6
- class SlashCommandDiscovery extends command_discovery_1.CommandDiscovery {
7
- constructor() {
8
- super(...arguments);
9
- this.subcommands = new Map();
10
- }
11
- getDescription() {
12
- return this.meta.description;
13
- }
14
- setCommand(command) {
15
- this.subcommands.set(command.getName(), command);
16
- }
17
- getRawOptions() {
18
- var _a;
19
- return (_a = this.reflector.get(necord_constants_1.OPTIONS_METADATA, this.getHandler())) !== null && _a !== void 0 ? _a : {};
20
- }
21
- getOptions() {
22
- if (this.subcommands.size >= 1) {
23
- return [...this.subcommands.values()].map(subcommand => subcommand.toJSON());
24
- }
25
- return Object.values(this.getRawOptions());
26
- }
27
- execute(interaction, depth = 1) {
28
- var _a, _b;
29
- if (this.subcommands.size >= 1) {
30
- const commandName = depth === 2
31
- ? interaction.options.getSubcommand(true)
32
- : (_a = interaction.options.getSubcommandGroup(false)) !== null && _a !== void 0 ? _a : interaction.options.getSubcommand(true);
33
- return (_b = this.subcommands.get(commandName)) === null || _b === void 0 ? void 0 : _b.execute(interaction, depth + 1);
34
- }
35
- return super.execute([interaction]);
36
- }
37
- isSlashCommand() {
38
- return true;
39
- }
40
- toJSON() {
41
- return Object.assign(Object.assign({}, this.meta), { options: this.getOptions() });
42
- }
43
- }
44
- exports.SlashCommandDiscovery = SlashCommandDiscovery;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SlashCommandDiscovery = void 0;
4
+ const necord_constants_1 = require("../../necord.constants");
5
+ const command_discovery_1 = require("../command.discovery");
6
+ class SlashCommandDiscovery extends command_discovery_1.CommandDiscovery {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.subcommands = new Map();
10
+ }
11
+ getDescription() {
12
+ return this.meta.description;
13
+ }
14
+ setCommand(command) {
15
+ this.subcommands.set(command.getName(), command);
16
+ }
17
+ getRawOptions() {
18
+ var _a;
19
+ return (_a = this.reflector.get(necord_constants_1.OPTIONS_METADATA, this.getHandler())) !== null && _a !== void 0 ? _a : {};
20
+ }
21
+ getOptions() {
22
+ if (this.subcommands.size >= 1) {
23
+ return [...this.subcommands.values()].map(subcommand => subcommand.toJSON());
24
+ }
25
+ return Object.values(this.getRawOptions());
26
+ }
27
+ execute(interaction, depth = 1) {
28
+ var _a, _b;
29
+ if (this.subcommands.size >= 1) {
30
+ const commandName = depth === 2
31
+ ? interaction.options.getSubcommand(true)
32
+ : (_a = interaction.options.getSubcommandGroup(false)) !== null && _a !== void 0 ? _a : interaction.options.getSubcommand(true);
33
+ return (_b = this.subcommands.get(commandName)) === null || _b === void 0 ? void 0 : _b.execute(interaction, depth + 1);
34
+ }
35
+ return super.execute([interaction]);
36
+ }
37
+ isSlashCommand() {
38
+ return true;
39
+ }
40
+ toJSON() {
41
+ return Object.assign(Object.assign({}, this.meta), { options: this.getOptions() });
42
+ }
43
+ }
44
+ exports.SlashCommandDiscovery = SlashCommandDiscovery;
@@ -1,19 +1,19 @@
1
- import { OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
2
- import { SlashCommandDiscovery } from './slash-command.discovery';
3
- import { Client } from 'discord.js';
4
- import { ExplorerService } from '../../necord-explorer.service';
5
- import { CommandDiscovery } from '../command.discovery';
6
- import { Reflector } from '@nestjs/core';
7
- export declare class SlashCommandsService implements OnModuleInit, OnApplicationBootstrap {
8
- private readonly client;
9
- private readonly explorerService;
10
- private readonly reflector;
11
- private readonly slashCommands;
12
- constructor(client: Client, explorerService: ExplorerService<SlashCommandDiscovery>, reflector: Reflector);
13
- onModuleInit(): Promise<void>;
14
- onApplicationBootstrap(): Client<boolean>;
15
- getCommands(): CommandDiscovery[];
16
- add(command: SlashCommandDiscovery): void;
17
- addSubCommand(subCommand: SlashCommandDiscovery): void;
18
- remove(commandName: string): boolean;
19
- }
1
+ import { OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
2
+ import { SlashCommandDiscovery } from './slash-command.discovery';
3
+ import { Client } from 'discord.js';
4
+ import { ExplorerService } from '../../necord-explorer.service';
5
+ import { CommandDiscovery } from '../command.discovery';
6
+ import { Reflector } from '@nestjs/core';
7
+ export declare class SlashCommandsService implements OnModuleInit, OnApplicationBootstrap {
8
+ private readonly client;
9
+ private readonly explorerService;
10
+ private readonly reflector;
11
+ private readonly slashCommands;
12
+ constructor(client: Client, explorerService: ExplorerService<SlashCommandDiscovery>, reflector: Reflector);
13
+ onModuleInit(): Promise<void>;
14
+ onApplicationBootstrap(): Client<boolean>;
15
+ getCommands(): CommandDiscovery[];
16
+ add(command: SlashCommandDiscovery): void;
17
+ addSubCommand(subCommand: SlashCommandDiscovery): void;
18
+ remove(commandName: string): boolean;
19
+ }
@@ -1,84 +1,84 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
- return new (P || (P = Promise))(function (resolve, reject) {
14
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
- step((generator = generator.apply(thisArg, _arguments || [])).next());
18
- });
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.SlashCommandsService = void 0;
22
- const common_1 = require("@nestjs/common");
23
- const discord_js_1 = require("discord.js");
24
- const necord_constants_1 = require("../../necord.constants");
25
- const necord_explorer_service_1 = require("../../necord-explorer.service");
26
- const core_1 = require("@nestjs/core");
27
- let SlashCommandsService = class SlashCommandsService {
28
- constructor(client, explorerService, reflector) {
29
- this.client = client;
30
- this.explorerService = explorerService;
31
- this.reflector = reflector;
32
- this.slashCommands = new Map();
33
- }
34
- onModuleInit() {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- this.explorerService.explore(necord_constants_1.SLASH_COMMAND_METADATA).forEach(command => this.add(command));
37
- return this.explorerService
38
- .explore(necord_constants_1.SUBCOMMAND_METADATA)
39
- .forEach(subcommand => this.addSubCommand(subcommand));
40
- });
41
- }
42
- onApplicationBootstrap() {
43
- return this.client.on('interactionCreate', i => {
44
- var _a;
45
- if (!i.isChatInputCommand() &&
46
- i.type !== discord_js_1.InteractionType.ApplicationCommandAutocomplete)
47
- return;
48
- return (_a = this.slashCommands.get(i.commandName)) === null || _a === void 0 ? void 0 : _a.execute(i);
49
- });
50
- }
51
- getCommands() {
52
- return [...this.slashCommands.values()];
53
- }
54
- add(command) {
55
- this.slashCommands.set(command.getName(), command);
56
- }
57
- addSubCommand(subCommand) {
58
- const rootCommand = this.reflector.get(necord_constants_1.SLASH_COMMAND_METADATA, subCommand.getClass());
59
- const subCommandGroup = this.reflector.get(necord_constants_1.SUBCOMMAND_GROUP_METADATA, subCommand.getClass());
60
- if (!rootCommand) {
61
- throw new ReferenceError(`can't register subcommand "${subCommand.getName()}" w/o root command`);
62
- }
63
- if (subCommandGroup) {
64
- subCommandGroup.setCommand(subCommand);
65
- rootCommand.setCommand(subCommandGroup);
66
- }
67
- else {
68
- rootCommand.setCommand(subCommand);
69
- }
70
- if (!this.slashCommands.has(rootCommand.getName())) {
71
- this.slashCommands.set(rootCommand.getName(), rootCommand);
72
- }
73
- }
74
- remove(commandName) {
75
- return this.slashCommands.delete(commandName);
76
- }
77
- };
78
- SlashCommandsService = __decorate([
79
- (0, common_1.Injectable)(),
80
- __metadata("design:paramtypes", [discord_js_1.Client,
81
- necord_explorer_service_1.ExplorerService,
82
- core_1.Reflector])
83
- ], SlashCommandsService);
84
- exports.SlashCommandsService = SlashCommandsService;
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.SlashCommandsService = void 0;
22
+ const common_1 = require("@nestjs/common");
23
+ const discord_js_1 = require("discord.js");
24
+ const necord_constants_1 = require("../../necord.constants");
25
+ const necord_explorer_service_1 = require("../../necord-explorer.service");
26
+ const core_1 = require("@nestjs/core");
27
+ let SlashCommandsService = class SlashCommandsService {
28
+ constructor(client, explorerService, reflector) {
29
+ this.client = client;
30
+ this.explorerService = explorerService;
31
+ this.reflector = reflector;
32
+ this.slashCommands = new Map();
33
+ }
34
+ onModuleInit() {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ this.explorerService.explore(necord_constants_1.SLASH_COMMAND_METADATA).forEach(command => this.add(command));
37
+ return this.explorerService
38
+ .explore(necord_constants_1.SUBCOMMAND_METADATA)
39
+ .forEach(subcommand => this.addSubCommand(subcommand));
40
+ });
41
+ }
42
+ onApplicationBootstrap() {
43
+ return this.client.on('interactionCreate', i => {
44
+ var _a;
45
+ if (!i.isChatInputCommand() &&
46
+ i.type !== discord_js_1.InteractionType.ApplicationCommandAutocomplete)
47
+ return;
48
+ return (_a = this.slashCommands.get(i.commandName)) === null || _a === void 0 ? void 0 : _a.execute(i);
49
+ });
50
+ }
51
+ getCommands() {
52
+ return [...this.slashCommands.values()];
53
+ }
54
+ add(command) {
55
+ this.slashCommands.set(command.getName(), command);
56
+ }
57
+ addSubCommand(subCommand) {
58
+ const rootCommand = this.reflector.get(necord_constants_1.SLASH_COMMAND_METADATA, subCommand.getClass());
59
+ const subCommandGroup = this.reflector.get(necord_constants_1.SUBCOMMAND_GROUP_METADATA, subCommand.getClass());
60
+ if (!rootCommand) {
61
+ throw new ReferenceError(`can't register subcommand "${subCommand.getName()}" w/o root command`);
62
+ }
63
+ if (subCommandGroup) {
64
+ subCommandGroup.setCommand(subCommand);
65
+ rootCommand.setCommand(subCommandGroup);
66
+ }
67
+ else {
68
+ rootCommand.setCommand(subCommand);
69
+ }
70
+ if (!this.slashCommands.has(rootCommand.getName())) {
71
+ this.slashCommands.set(rootCommand.getName(), rootCommand);
72
+ }
73
+ }
74
+ remove(commandName) {
75
+ return this.slashCommands.delete(commandName);
76
+ }
77
+ };
78
+ SlashCommandsService = __decorate([
79
+ (0, common_1.Injectable)(),
80
+ __metadata("design:paramtypes", [discord_js_1.Client,
81
+ necord_explorer_service_1.ExplorerService,
82
+ core_1.Reflector])
83
+ ], SlashCommandsService);
84
+ exports.SlashCommandsService = SlashCommandsService;
@@ -1,2 +1,2 @@
1
- export declare const Context: (...pipes: (import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
2
- export declare const Ctx: (...pipes: (import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
1
+ export declare const Context: (...pipes: (import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
2
+ export declare const Ctx: (...pipes: (import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
@@ -1,7 +1,7 @@
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");
6
- exports.Context = (0, params_util_1.createNecordParamDecorator)(necord_paramtype_enum_1.NecordParamType.CONTEXT);
7
- exports.Ctx = exports.Context;
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");
6
+ exports.Context = (0, params_util_1.createNecordParamDecorator)(necord_paramtype_enum_1.NecordParamType.CONTEXT);
7
+ exports.Ctx = exports.Context;
@@ -1 +1 @@
1
- export declare const Discovery: (...pipes: (import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
1
+ export declare const Discovery: (...pipes: (import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
@@ -1,6 +1,6 @@
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");
6
- exports.Discovery = (0, params_util_1.createNecordParamDecorator)(necord_paramtype_enum_1.NecordParamType.DISCOVERY);
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");
6
+ exports.Discovery = (0, params_util_1.createNecordParamDecorator)(necord_paramtype_enum_1.NecordParamType.DISCOVERY);
@@ -1,2 +1,2 @@
1
- export * from './context.decorator';
2
- export * from './discovery.decorator';
1
+ export * from './context.decorator';
2
+ export * from './discovery.decorator';
@@ -1,18 +1,18 @@
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("./context.decorator"), exports);
18
- __exportStar(require("./discovery.decorator"), exports);
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("./context.decorator"), exports);
18
+ __exportStar(require("./discovery.decorator"), exports);
@@ -1,3 +1,3 @@
1
- import { NecordParamType } from '../necord-paramtype.enum';
2
- import { PipeTransform, Type } from '@nestjs/common';
3
- export declare function createNecordParamDecorator(type: NecordParamType): (...pipes: (Type<PipeTransform> | PipeTransform)[]) => ParameterDecorator;
1
+ import { NecordParamType } from '../necord-paramtype.enum';
2
+ import { PipeTransform, Type } from '@nestjs/common';
3
+ export declare function createNecordParamDecorator(type: NecordParamType): (...pipes: (Type<PipeTransform> | PipeTransform)[]) => ParameterDecorator;
@@ -1,12 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createNecordParamDecorator = void 0;
4
- const common_1 = require("@nestjs/common");
5
- const constants_1 = require("@nestjs/common/constants");
6
- function createNecordParamDecorator(type) {
7
- 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);
10
- };
11
- }
12
- exports.createNecordParamDecorator = createNecordParamDecorator;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createNecordParamDecorator = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const constants_1 = require("@nestjs/common/constants");
6
+ function createNecordParamDecorator(type) {
7
+ 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);
10
+ };
11
+ }
12
+ exports.createNecordParamDecorator = createNecordParamDecorator;
@@ -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';
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,23 +1,23 @@
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("./decorators"), exports);
18
- __exportStar(require("./necord-arguments-host"), exports);
19
- __exportStar(require("./necord-base.discovery"), exports);
20
- __exportStar(require("./necord-context.interface"), exports);
21
- __exportStar(require("./necord-execution-context"), exports);
22
- __exportStar(require("./necord-params.factory"), exports);
23
- __exportStar(require("./necord-paramtype.enum"), exports);
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("./decorators"), exports);
18
+ __exportStar(require("./necord-arguments-host"), exports);
19
+ __exportStar(require("./necord-base.discovery"), exports);
20
+ __exportStar(require("./necord-context.interface"), exports);
21
+ __exportStar(require("./necord-execution-context"), exports);
22
+ __exportStar(require("./necord-params.factory"), exports);
23
+ __exportStar(require("./necord-paramtype.enum"), exports);
@@ -1,13 +1,13 @@
1
- import { ExecutionContextHost } from '@nestjs/core/helpers/execution-context-host';
2
- import { ArgumentsHost } from '@nestjs/common';
3
- import { NecordContextType } from './necord-execution-context';
4
- import { ClientEvents } from 'discord.js';
5
- import { NecordBaseDiscovery } from '../context';
6
- import { ContextOf } from './necord-context.interface';
7
- export declare class NecordArgumentsHost extends ExecutionContextHost {
8
- static create(context: ArgumentsHost): NecordArgumentsHost;
9
- getType<TContext extends string = NecordContextType>(): TContext;
10
- getContext<T extends keyof ClientEvents>(): ContextOf<T>;
11
- getContext<T>(): T;
12
- getDiscovery(): NecordBaseDiscovery;
13
- }
1
+ import { ExecutionContextHost } from '@nestjs/core/helpers/execution-context-host';
2
+ import { ArgumentsHost } from '@nestjs/common';
3
+ import { NecordContextType } from './necord-execution-context';
4
+ import { ClientEvents } from 'discord.js';
5
+ import { NecordBaseDiscovery } from '../context';
6
+ import { ContextOf } from './necord-context.interface';
7
+ export declare class NecordArgumentsHost extends ExecutionContextHost {
8
+ static create(context: ArgumentsHost): NecordArgumentsHost;
9
+ getType<TContext extends string = NecordContextType>(): TContext;
10
+ getContext<T extends keyof ClientEvents>(): ContextOf<T>;
11
+ getContext<T>(): T;
12
+ getDiscovery(): NecordBaseDiscovery;
13
+ }
@@ -1,22 +1,22 @@
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 {
6
- static create(context) {
7
- const type = context.getType();
8
- const necContext = new NecordArgumentsHost(context.getArgs());
9
- necContext.setType(type);
10
- return necContext;
11
- }
12
- getType() {
13
- return super.getType();
14
- }
15
- getContext() {
16
- return this.getArgByIndex(0);
17
- }
18
- getDiscovery() {
19
- return this.getArgByIndex(1);
20
- }
21
- }
22
- exports.NecordArgumentsHost = NecordArgumentsHost;
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 {
6
+ static create(context) {
7
+ const type = context.getType();
8
+ const necContext = new NecordArgumentsHost(context.getArgs());
9
+ necContext.setType(type);
10
+ return necContext;
11
+ }
12
+ getType() {
13
+ return super.getType();
14
+ }
15
+ getContext() {
16
+ return this.getArgByIndex(0);
17
+ }
18
+ getDiscovery() {
19
+ return this.getArgByIndex(1);
20
+ }
21
+ }
22
+ exports.NecordArgumentsHost = NecordArgumentsHost;
@@ -1,30 +1,30 @@
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';
7
- interface DiscoveredItem {
8
- class: any;
9
- handler?: (...args: any[]) => any;
10
- }
11
- export declare abstract class NecordBaseDiscovery<T = any> {
12
- protected readonly meta: T;
13
- protected readonly reflector: Reflector;
14
- protected discovery: DiscoveredItem;
15
- protected contextCallback: Function;
16
- constructor(meta: T);
17
- getClass(): any;
18
- getHandler(): (...args: any[]) => any;
19
- setDiscoveryMeta(meta: DiscoveredItem): void;
20
- setContextCallback(fn: Function): void;
21
- execute(context?: any): any;
22
- isContextMenu(): this is ContextMenuDiscovery;
23
- isSlashCommand(): this is SlashCommandDiscovery;
24
- isMessageComponent(): this is MessageComponentDiscovery;
25
- isListener(): this is ListenerDiscovery;
26
- isTextCommand(): this is TextCommandDiscovery;
27
- isModal(): this is ModalDiscovery;
28
- abstract toJSON(): Record<string, any>;
29
- }
30
- export {};
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';
7
+ interface DiscoveredItem {
8
+ class: any;
9
+ handler?: (...args: any[]) => any;
10
+ }
11
+ export declare abstract class NecordBaseDiscovery<T = any> {
12
+ protected readonly meta: T;
13
+ protected readonly reflector: Reflector;
14
+ protected discovery: DiscoveredItem;
15
+ protected contextCallback: Function;
16
+ constructor(meta: T);
17
+ getClass(): any;
18
+ getHandler(): (...args: any[]) => any;
19
+ setDiscoveryMeta(meta: DiscoveredItem): void;
20
+ setContextCallback(fn: Function): void;
21
+ execute(context?: any): any;
22
+ isContextMenu(): this is ContextMenuDiscovery;
23
+ isSlashCommand(): this is SlashCommandDiscovery;
24
+ isMessageComponent(): this is MessageComponentDiscovery;
25
+ isListener(): this is ListenerDiscovery;
26
+ isTextCommand(): this is TextCommandDiscovery;
27
+ isModal(): this is ModalDiscovery;
28
+ abstract toJSON(): Record<string, any>;
29
+ }
30
+ export {};