necord 5.3.1 → 5.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/commands/commands.service.d.ts +1 -0
  3. package/dist/commands/commands.service.js +9 -3
  4. package/dist/commands/context-menus/context-menus.service.d.ts +3 -1
  5. package/dist/commands/context-menus/context-menus.service.js +7 -1
  6. package/dist/commands/slash-commands/slash-commands.service.d.ts +3 -0
  7. package/dist/commands/slash-commands/slash-commands.service.js +27 -20
  8. package/dist/context/necord-context.interface.d.ts +12 -1
  9. package/dist/message-components/decorators/index.d.ts +1 -0
  10. package/dist/message-components/decorators/index.js +1 -0
  11. package/dist/message-components/decorators/select-menu.decorator.d.ts +11 -0
  12. package/dist/message-components/decorators/select-menu.decorator.js +18 -2
  13. package/dist/message-components/decorators/selected.decorator.d.ts +10 -0
  14. package/dist/message-components/decorators/selected.decorator.js +39 -0
  15. package/dist/message-components/decorators/values.decorator.d.ts +6 -0
  16. package/dist/message-components/decorators/values.decorator.js +8 -1
  17. package/dist/message-components/message-component.discovery.d.ts +1 -1
  18. package/dist/message-components/message-components.service.d.ts +4 -1
  19. package/dist/message-components/message-components.service.js +13 -4
  20. package/dist/modals/modals.service.d.ts +2 -0
  21. package/dist/modals/modals.service.js +9 -5
  22. package/dist/necord-options.interface.d.ts +1 -0
  23. package/dist/necord.module.js +9 -1
  24. package/dist/text-commands/text-commands.service.d.ts +2 -0
  25. package/dist/text-commands/text-commands.service.js +7 -1
  26. package/package.json +7 -7
package/CHANGELOG.md CHANGED
@@ -1,6 +1,18 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ # [5.4.0](https://github.com/necordjs/necord/compare/v5.3.1...v5.4.0) - (2022-11-29)
5
+
6
+ ## Refactor
7
+
8
+ - Some improvments ([665c8e2](https://github.com/necordjs/necord/commit/665c8e277fc5d7d481e5740069fa51b4ebf7be84))
9
+
10
+ # [5.3.1](https://github.com/necordjs/necord/compare/v5.3.0...v5.3.1) - (2022-11-26)
11
+
12
+ ## Features
13
+
14
+ - Target decorators for message, user, member ([47ccc2a](https://github.com/necordjs/necord/commit/47ccc2a7968c726c990ba5b66f54c267681bb777))
15
+
4
16
  # [5.3.0](https://github.com/necordjs/necord/compare/v5.2.0...v5.3.0) - (2022-09-17)
5
17
 
6
18
  ## Features
@@ -11,4 +11,5 @@ export declare class CommandsService implements OnModuleInit {
11
11
  private readonly logger;
12
12
  constructor(client: Client, options: NecordModuleOptions, contextMenusService: ContextMenusService, slashCommandsService: SlashCommandsService);
13
13
  onModuleInit(): Client<boolean>;
14
+ register(client: Client): Promise<void>;
14
15
  }
@@ -37,8 +37,14 @@ let CommandsService = CommandsService_1 = class CommandsService {
37
37
  this.logger = new common_1.Logger(CommandsService_1.name);
38
38
  }
39
39
  onModuleInit() {
40
- return this.client.once('ready', (client) => __awaiter(this, void 0, void 0, function* () {
41
- var _a, _b;
40
+ if (this.options.skipRegistration) {
41
+ return;
42
+ }
43
+ return this.client.once('ready', (client) => __awaiter(this, void 0, void 0, function* () { return this.register(client); }));
44
+ }
45
+ register(client) {
46
+ var _a, _b;
47
+ return __awaiter(this, void 0, void 0, function* () {
42
48
  if (client.application.partial) {
43
49
  yield client.application.fetch();
44
50
  }
@@ -62,7 +68,7 @@ let CommandsService = CommandsService_1 = class CommandsService {
62
68
  yield clientCommands.set(commands.flatMap(command => command.toJSON()), guild);
63
69
  }
64
70
  this.logger.log(`Successfully reloaded application commands.`);
65
- }));
71
+ });
66
72
  }
67
73
  };
68
74
  CommandsService = CommandsService_1 = __decorate([
@@ -1,5 +1,5 @@
1
1
  import { OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
2
- import { ContextMenuDiscovery } from './context-menu.discovery';
2
+ import { ContextMenuDiscovery, ContextMenuMeta } from './context-menu.discovery';
3
3
  import { Client } from 'discord.js';
4
4
  import { ExplorerService } from '../../necord-explorer.service';
5
5
  import { CommandDiscovery } from '../command.discovery';
@@ -11,4 +11,6 @@ export declare class ContextMenusService implements OnModuleInit, OnApplicationB
11
11
  onModuleInit(): void;
12
12
  onApplicationBootstrap(): Client<boolean>;
13
13
  getCommands(): CommandDiscovery[];
14
+ add(contextMenu: ContextMenuDiscovery): void;
15
+ remove(type: ContextMenuMeta['type'], name: ContextMenuMeta['name']): boolean;
14
16
  }
@@ -23,7 +23,7 @@ let ContextMenusService = class ContextMenusService {
23
23
  onModuleInit() {
24
24
  return this.explorerService
25
25
  .explore(necord_constants_1.CONTEXT_MENU_METADATA)
26
- .forEach(contextMenu => this.contextMenus.set(contextMenu.getType().toString().concat(':', contextMenu.getName()), contextMenu));
26
+ .forEach(contextMenu => this.add(contextMenu));
27
27
  }
28
28
  onApplicationBootstrap() {
29
29
  return this.client.on('interactionCreate', interaction => {
@@ -37,6 +37,12 @@ let ContextMenusService = class ContextMenusService {
37
37
  getCommands() {
38
38
  return [...this.contextMenus.values()];
39
39
  }
40
+ add(contextMenu) {
41
+ this.contextMenus.set(contextMenu.getType().toString().concat(':', contextMenu.getName()), contextMenu);
42
+ }
43
+ remove(type, name) {
44
+ return this.contextMenus.delete(type.toString().concat(':', name));
45
+ }
40
46
  };
41
47
  ContextMenusService = __decorate([
42
48
  (0, common_1.Injectable)(),
@@ -13,4 +13,7 @@ export declare class SlashCommandsService implements OnModuleInit, OnApplication
13
13
  onModuleInit(): Promise<void>;
14
14
  onApplicationBootstrap(): Client<boolean>;
15
15
  getCommands(): CommandDiscovery[];
16
+ add(command: SlashCommandDiscovery): void;
17
+ addSubCommand(subCommand: SlashCommandDiscovery): void;
18
+ remove(commandName: string): boolean;
16
19
  }
@@ -33,26 +33,10 @@ let SlashCommandsService = class SlashCommandsService {
33
33
  }
34
34
  onModuleInit() {
35
35
  return __awaiter(this, void 0, void 0, function* () {
36
- this.explorerService
37
- .explore(necord_constants_1.SLASH_COMMAND_METADATA)
38
- .forEach(command => this.slashCommands.set(command.getName(), command));
39
- return this.explorerService.explore(necord_constants_1.SUBCOMMAND_METADATA).forEach(subcommand => {
40
- const rootCommand = this.reflector.get(necord_constants_1.SLASH_COMMAND_METADATA, subcommand.getClass());
41
- const subCommandGroup = this.reflector.get(necord_constants_1.SUBCOMMAND_GROUP_METADATA, subcommand.getClass());
42
- if (!rootCommand) {
43
- throw new ReferenceError(`can't register subcommand "${subcommand.getName()}" w/o root command`);
44
- }
45
- if (subCommandGroup) {
46
- subCommandGroup.setCommand(subcommand);
47
- rootCommand.setCommand(subCommandGroup);
48
- }
49
- else {
50
- rootCommand.setCommand(subcommand);
51
- }
52
- if (!this.slashCommands.has(rootCommand.getName())) {
53
- this.slashCommands.set(rootCommand.getName(), rootCommand);
54
- }
55
- });
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));
56
40
  });
57
41
  }
58
42
  onApplicationBootstrap() {
@@ -67,6 +51,29 @@ let SlashCommandsService = class SlashCommandsService {
67
51
  getCommands() {
68
52
  return [...this.slashCommands.values()];
69
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
+ }
70
77
  };
71
78
  SlashCommandsService = __decorate([
72
79
  (0, common_1.Injectable)(),
@@ -1,4 +1,4 @@
1
- import { AutocompleteInteraction, ButtonInteraction, ChatInputCommandInteraction, Message, MessageContextMenuCommandInteraction, ModalSubmitInteraction, SelectMenuInteraction, UserContextMenuCommandInteraction } from 'discord.js';
1
+ import { AutocompleteInteraction, ButtonInteraction, ChannelSelectMenuInteraction, ChatInputCommandInteraction, MentionableSelectMenuInteraction, Message, MessageContextMenuCommandInteraction, ModalSubmitInteraction, RoleSelectMenuInteraction, SelectMenuInteraction, StringSelectMenuInteraction, UserContextMenuCommandInteraction, UserSelectMenuInteraction } from 'discord.js';
2
2
  import { NecordEvents } from '../listeners/listener.interface';
3
3
  export type AutocompleteContext = [AutocompleteInteraction];
4
4
  export type SlashCommandContext = [ChatInputCommandInteraction];
@@ -7,5 +7,16 @@ export type MessageCommandContext = [MessageContextMenuCommandInteraction];
7
7
  export type UserCommandContext = [UserContextMenuCommandInteraction];
8
8
  export type ModalContext = [ModalSubmitInteraction];
9
9
  export type ButtonContext = [ButtonInteraction];
10
+ /**
11
+ * @deprecated since v5.4 - old name for `StringSelectContext`. Will be removed in v6. Discord now uses new select menus
12
+ * @see {@link https://discord.js.org/#/docs/discord.js/main/class/SelectMenuInteraction DiscordJS docs}
13
+ * @see {@link https://discord.com/developers/docs/interactions/message-components#select-menus Discord API docs}
14
+ * @see {@link https://discord.com/developers/docs/interactions/message-components#component-object-component-types ComponentType}
15
+ */
10
16
  export type SelectMenuContext = [SelectMenuInteraction];
17
+ export type StringSelectContext = [StringSelectMenuInteraction];
18
+ export type ChannelSelectContext = [ChannelSelectMenuInteraction];
19
+ export type RoleSelectContext = [RoleSelectMenuInteraction];
20
+ export type UserSelectContext = [UserSelectMenuInteraction];
21
+ export type MentionableSelectContext = [MentionableSelectMenuInteraction];
11
22
  export type ContextOf<K extends keyof E, E = NecordEvents> = E[K];
@@ -3,3 +3,4 @@ export * from './component-param.decorator';
3
3
  export * from './message-component.decorator';
4
4
  export * from './select-menu.decorator';
5
5
  export * from './values.decorator';
6
+ export * from './selected.decorator';
@@ -19,3 +19,4 @@ __exportStar(require("./component-param.decorator"), exports);
19
19
  __exportStar(require("./message-component.decorator"), exports);
20
20
  __exportStar(require("./select-menu.decorator"), exports);
21
21
  __exportStar(require("./values.decorator"), exports);
22
+ __exportStar(require("./selected.decorator"), exports);
@@ -1 +1,12 @@
1
+ /**
2
+ * @deprecated since 5.4 - This is the old name for StringSelect. Will be deleted in v6. Discord now uses new select menus
3
+ * @see {@link https://discord.js.org/#/docs/discord.js/main/class/SelectMenuInteraction DiscordJS docs}
4
+ * @see {@link https://discord.com/developers/docs/interactions/message-components#select-menus Discord API docs}
5
+ * @see {@link https://discord.com/developers/docs/interactions/message-components#component-object-component-types ComponentType}
6
+ */
1
7
  export declare const SelectMenu: (customId: string) => import("@nestjs/common").CustomDecorator<string>;
8
+ export declare const StringSelect: (customId: string) => import("@nestjs/common").CustomDecorator<string>;
9
+ export declare const ChannelSelect: (customId: string) => import("@nestjs/common").CustomDecorator<string>;
10
+ export declare const UserSelect: (customId: string) => import("@nestjs/common").CustomDecorator<string>;
11
+ export declare const MentionableSelect: (customId: string) => import("@nestjs/common").CustomDecorator<string>;
12
+ export declare const RoleSelect: (customId: string) => import("@nestjs/common").CustomDecorator<string>;
@@ -1,7 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SelectMenu = void 0;
3
+ exports.RoleSelect = exports.MentionableSelect = exports.UserSelect = exports.ChannelSelect = exports.StringSelect = exports.SelectMenu = void 0;
4
4
  const discord_js_1 = require("discord.js");
5
5
  const message_component_decorator_1 = require("./message-component.decorator");
6
- const SelectMenu = (customId) => (0, message_component_decorator_1.MessageComponent)({ customId, type: discord_js_1.ComponentType.SelectMenu });
6
+ /**
7
+ * @deprecated since 5.4 - This is the old name for StringSelect. Will be deleted in v6. Discord now uses new select menus
8
+ * @see {@link https://discord.js.org/#/docs/discord.js/main/class/SelectMenuInteraction DiscordJS docs}
9
+ * @see {@link https://discord.com/developers/docs/interactions/message-components#select-menus Discord API docs}
10
+ * @see {@link https://discord.com/developers/docs/interactions/message-components#component-object-component-types ComponentType}
11
+ */
12
+ const SelectMenu = (customId) => (0, message_component_decorator_1.MessageComponent)({ customId, type: discord_js_1.ComponentType.SelectMenu }); // TODO: Remove in v6
7
13
  exports.SelectMenu = SelectMenu;
14
+ const StringSelect = (customId) => (0, message_component_decorator_1.MessageComponent)({ customId, type: discord_js_1.ComponentType.StringSelect });
15
+ exports.StringSelect = StringSelect;
16
+ const ChannelSelect = (customId) => (0, message_component_decorator_1.MessageComponent)({ customId, type: discord_js_1.ComponentType.ChannelSelect });
17
+ exports.ChannelSelect = ChannelSelect;
18
+ const UserSelect = (customId) => (0, message_component_decorator_1.MessageComponent)({ customId, type: discord_js_1.ComponentType.UserSelect });
19
+ exports.UserSelect = UserSelect;
20
+ const MentionableSelect = (customId) => (0, message_component_decorator_1.MessageComponent)({ customId, type: discord_js_1.ComponentType.MentionableSelect });
21
+ exports.MentionableSelect = MentionableSelect;
22
+ const RoleSelect = (customId) => (0, message_component_decorator_1.MessageComponent)({ customId, type: discord_js_1.ComponentType.RoleSelect });
23
+ exports.RoleSelect = RoleSelect;
@@ -0,0 +1,10 @@
1
+ import { ChannelSelectMenuInteraction, MentionableSelectMenuInteraction, RoleSelectMenuInteraction, UserSelectMenuInteraction } from 'discord.js';
2
+ export declare const SelectedStrings: (...dataOrPipes: any[]) => ParameterDecorator;
3
+ export declare const SelectedChannels: (...dataOrPipes: any[]) => ParameterDecorator;
4
+ export type ISelectedChannels = ChannelSelectMenuInteraction['channels'];
5
+ export declare const SelectedUsers: (...dataOrPipes: any[]) => ParameterDecorator;
6
+ export type ISelectedUsers = UserSelectMenuInteraction['users'] | MentionableSelectMenuInteraction['users'];
7
+ export declare const SelectedMembers: (...dataOrPipes: any[]) => ParameterDecorator;
8
+ export type ISelectedMembers = UserSelectMenuInteraction['members'] | MentionableSelectMenuInteraction['members'];
9
+ export declare const SelectedRoles: (...dataOrPipes: any[]) => ParameterDecorator;
10
+ export type ISelectedRoles = RoleSelectMenuInteraction['roles'] | MentionableSelectMenuInteraction['roles'];
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SelectedRoles = exports.SelectedMembers = exports.SelectedUsers = exports.SelectedChannels = exports.SelectedStrings = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const context_1 = require("../../context");
6
+ exports.SelectedStrings = (0, common_1.createParamDecorator)((_, ctx) => {
7
+ const necordContext = context_1.NecordExecutionContext.create(ctx);
8
+ const [interaction] = necordContext.getContext();
9
+ return interaction.isStringSelectMenu() ? interaction.values : [];
10
+ });
11
+ exports.SelectedChannels = (0, common_1.createParamDecorator)((_, ctx) => {
12
+ const necordContext = context_1.NecordExecutionContext.create(ctx);
13
+ const [interaction] = necordContext.getContext();
14
+ return interaction.isChannelSelectMenu() ? interaction.channels : [];
15
+ });
16
+ exports.SelectedUsers = (0, common_1.createParamDecorator)((_, ctx) => {
17
+ const necordContext = context_1.NecordExecutionContext.create(ctx);
18
+ const [interaction] = necordContext.getContext();
19
+ if (interaction.isUserSelectMenu() || interaction.isMentionableSelectMenu()) {
20
+ return interaction.users;
21
+ }
22
+ return [];
23
+ });
24
+ exports.SelectedMembers = (0, common_1.createParamDecorator)((_, ctx) => {
25
+ const necordContext = context_1.NecordExecutionContext.create(ctx);
26
+ const [interaction] = necordContext.getContext();
27
+ if (interaction.isUserSelectMenu() || interaction.isMentionableSelectMenu()) {
28
+ return interaction.users;
29
+ }
30
+ return [];
31
+ });
32
+ exports.SelectedRoles = (0, common_1.createParamDecorator)((_, ctx) => {
33
+ const necordContext = context_1.NecordExecutionContext.create(ctx);
34
+ const [interaction] = necordContext.getContext();
35
+ if (interaction.isRoleSelectMenu() || interaction.isMentionableSelectMenu()) {
36
+ return interaction.roles;
37
+ }
38
+ return [];
39
+ });
@@ -1 +1,7 @@
1
+ /**
2
+ * @deprecated since v5.4 - old name for `@SelectedStrings`. Will be removed in v6. Discord now uses new select menus
3
+ * @see {@link https://discord.js.org/#/docs/discord.js/main/class/SelectMenuInteraction DiscordJS docs}
4
+ * @see {@link https://discord.com/developers/docs/interactions/message-components#select-menus Discord API docs}
5
+ * @see {@link https://discord.com/developers/docs/interactions/message-components#component-object-component-types ComponentType}
6
+ */
1
7
  export declare const Values: (...dataOrPipes: any[]) => ParameterDecorator;
@@ -3,8 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Values = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
5
  const context_1 = require("../../context");
6
+ // TODO: Remove in v6
7
+ /**
8
+ * @deprecated since v5.4 - old name for `@SelectedStrings`. Will be removed in v6. Discord now uses new select menus
9
+ * @see {@link https://discord.js.org/#/docs/discord.js/main/class/SelectMenuInteraction DiscordJS docs}
10
+ * @see {@link https://discord.com/developers/docs/interactions/message-components#select-menus Discord API docs}
11
+ * @see {@link https://discord.com/developers/docs/interactions/message-components#component-object-component-types ComponentType}
12
+ */
6
13
  exports.Values = (0, common_1.createParamDecorator)((_, ctx) => {
7
14
  const necordContext = context_1.NecordExecutionContext.create(ctx);
8
15
  const [interaction] = necordContext.getContext();
9
- return interaction.isSelectMenu() ? interaction.values : [];
16
+ return interaction.isStringSelectMenu() ? interaction.values : [];
10
17
  });
@@ -1,7 +1,7 @@
1
1
  import { ComponentType, MessageComponentInteraction, MessageComponentType } from 'discord.js';
2
2
  import { NecordBaseDiscovery } from '../context';
3
3
  export interface MessageComponentMeta {
4
- type: Exclude<MessageComponentType, ComponentType.ActionRow>;
4
+ type: Exclude<MessageComponentType, ComponentType.ActionRow | ComponentType.TextInput>;
5
5
  customId: string;
6
6
  }
7
7
  export declare class MessageComponentDiscovery extends NecordBaseDiscovery<MessageComponentMeta> {
@@ -1,7 +1,7 @@
1
1
  import { OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
2
2
  import { Client } from 'discord.js';
3
3
  import { ExplorerService } from '../necord-explorer.service';
4
- import { MessageComponentDiscovery } from './message-component.discovery';
4
+ import { MessageComponentDiscovery, MessageComponentMeta } from './message-component.discovery';
5
5
  export declare class MessageComponentsService implements OnModuleInit, OnApplicationBootstrap {
6
6
  private readonly client;
7
7
  private readonly explorerService;
@@ -9,4 +9,7 @@ export declare class MessageComponentsService implements OnModuleInit, OnApplica
9
9
  constructor(client: Client, explorerService: ExplorerService<MessageComponentDiscovery>);
10
10
  onModuleInit(): void;
11
11
  onApplicationBootstrap(): Client<boolean>;
12
+ private componentName;
13
+ add(component: MessageComponentDiscovery): void;
14
+ remove(type: MessageComponentMeta['type'], customId: MessageComponentMeta['customId']): void;
12
15
  }
@@ -18,25 +18,34 @@ let MessageComponentsService = class MessageComponentsService {
18
18
  constructor(client, explorerService) {
19
19
  this.client = client;
20
20
  this.explorerService = explorerService;
21
- this.components = [];
21
+ this.components = new Map();
22
22
  }
23
23
  onModuleInit() {
24
24
  return this.explorerService
25
25
  .explore(necord_constants_1.MESSAGE_COMPONENT_METADATA)
26
- .forEach(component => this.components.push(component));
26
+ .forEach(component => this.add(component));
27
27
  }
28
28
  onApplicationBootstrap() {
29
29
  return this.client.on('interactionCreate', interaction => {
30
30
  if (interaction.type !== discord_js_1.InteractionType.MessageComponent)
31
31
  return;
32
- const name = [interaction.componentType, interaction.customId].join('_');
33
- for (const component of this.components) {
32
+ const name = this.componentName(interaction.componentType, interaction.customId);
33
+ for (const component of this.components.values()) {
34
34
  if (component.matcher(name)) {
35
35
  return component.execute(interaction);
36
36
  }
37
37
  }
38
38
  });
39
39
  }
40
+ componentName(type, customId) {
41
+ return [type, customId].join('_');
42
+ }
43
+ add(component) {
44
+ this.components.set(this.componentName(component.getType(), component.getCustomId()), component);
45
+ }
46
+ remove(type, customId) {
47
+ this.components.delete(this.componentName(type, customId));
48
+ }
40
49
  };
41
50
  MessageComponentsService = __decorate([
42
51
  (0, common_1.Injectable)(),
@@ -9,4 +9,6 @@ export declare class ModalsService implements OnModuleInit, OnApplicationBootstr
9
9
  constructor(client: Client, explorerService: ExplorerService<ModalDiscovery>);
10
10
  onModuleInit(): void;
11
11
  onApplicationBootstrap(): Client<boolean>;
12
+ add(modal: ModalDiscovery): void;
13
+ remove(customId: string): void;
12
14
  }
@@ -18,25 +18,29 @@ let ModalsService = class ModalsService {
18
18
  constructor(client, explorerService) {
19
19
  this.client = client;
20
20
  this.explorerService = explorerService;
21
- this.modals = [];
21
+ this.modals = new Map();
22
22
  }
23
23
  onModuleInit() {
24
- return this.explorerService
25
- .explore(necord_constants_1.MODAL_METADATA)
26
- .forEach(modal => this.modals.push(modal));
24
+ return this.explorerService.explore(necord_constants_1.MODAL_METADATA).forEach(modal => this.add(modal));
27
25
  }
28
26
  onApplicationBootstrap() {
29
27
  return this.client.on('interactionCreate', interaction => {
30
28
  if (interaction.type !== discord_js_1.InteractionType.ModalSubmit)
31
29
  return;
32
30
  const name = interaction.customId;
33
- for (const modal of this.modals) {
31
+ for (const modal of this.modals.values()) {
34
32
  if (modal.matcher(name)) {
35
33
  return modal.execute(interaction);
36
34
  }
37
35
  }
38
36
  });
39
37
  }
38
+ add(modal) {
39
+ this.modals.set(modal.getCustomId(), modal);
40
+ }
41
+ remove(customId) {
42
+ this.modals.delete(customId);
43
+ }
40
44
  };
41
45
  ModalsService = __decorate([
42
46
  (0, common_1.Injectable)(),
@@ -4,6 +4,7 @@ export interface NecordModuleOptions extends DiscordClientOptions {
4
4
  token: string;
5
5
  prefix?: string | Function;
6
6
  development?: Snowflake[] | false;
7
+ skipRegistration?: boolean;
7
8
  }
8
9
  export interface NecordOptionsFactory {
9
10
  createNecordOptions(): Promise<NecordModuleOptions> | NecordModuleOptions;
@@ -107,7 +107,15 @@ NecordModule = NecordModule_1 = __decorate([
107
107
  listeners_1.ListenersService,
108
108
  commands_1.SlashCommandsService
109
109
  ],
110
- exports: [necord_client_provider_1.NecordClientProvider]
110
+ exports: [
111
+ necord_client_provider_1.NecordClientProvider,
112
+ commands_1.CommandsService,
113
+ commands_1.SlashCommandsService,
114
+ commands_1.ContextMenusService,
115
+ message_components_1.MessageComponentsService,
116
+ modals_1.ModalsService,
117
+ text_commands_1.TextCommandsService
118
+ ]
111
119
  }),
112
120
  __param(1, (0, common_1.Inject)(necord_constants_1.NECORD_MODULE_OPTIONS)),
113
121
  __metadata("design:paramtypes", [discord_js_1.Client, Object])
@@ -11,4 +11,6 @@ export declare class TextCommandsService implements OnModuleInit, OnApplicationB
11
11
  constructor(options: NecordModuleOptions, client: Client, explorerService: ExplorerService<TextCommandDiscovery>);
12
12
  onModuleInit(): void;
13
13
  onApplicationBootstrap(): Client<boolean>;
14
+ add(textCommand: TextCommandDiscovery): void;
15
+ remove(name: string): void;
14
16
  }
@@ -36,7 +36,7 @@ let TextCommandsService = class TextCommandsService {
36
36
  onModuleInit() {
37
37
  return this.explorerService
38
38
  .explore(necord_constants_1.TEXT_COMMAND_METADATA)
39
- .forEach(textCommand => this.textCommands.set(textCommand.getName(), textCommand));
39
+ .forEach(textCommand => this.add(textCommand));
40
40
  }
41
41
  onApplicationBootstrap() {
42
42
  return this.client.on('messageCreate', (message) => __awaiter(this, void 0, void 0, function* () {
@@ -56,6 +56,12 @@ let TextCommandsService = class TextCommandsService {
56
56
  return (_c = this.textCommands.get(cmd)) === null || _c === void 0 ? void 0 : _c.execute([message]);
57
57
  }));
58
58
  }
59
+ add(textCommand) {
60
+ this.textCommands.set(textCommand.getName(), textCommand);
61
+ }
62
+ remove(name) {
63
+ this.textCommands.delete(name);
64
+ }
59
65
  };
60
66
  TextCommandsService = __decorate([
61
67
  (0, common_1.Injectable)(),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "necord",
3
3
  "description": "A module for creating Discord bots using NestJS, based on Discord.js.",
4
- "version": "5.3.1",
4
+ "version": "5.4.1",
5
5
  "scripts": {
6
6
  "build": "rimraf -rf dist && tsc -p tsconfig.json",
7
7
  "prepublish:npm": "npm run build",
@@ -53,14 +53,14 @@
53
53
  "devDependencies": {
54
54
  "@commitlint/cli": "17.3.0",
55
55
  "@commitlint/config-angular": "17.3.0",
56
- "@favware/npm-deprecate": "1.0.5",
57
- "@nestjs/common": "9.2.0",
58
- "@nestjs/core": "9.2.0",
56
+ "@favware/npm-deprecate": "1.0.6",
57
+ "@nestjs/common": "9.2.1",
58
+ "@nestjs/core": "9.2.1",
59
59
  "@types/node": "18.11.9",
60
- "@typescript-eslint/eslint-plugin": "5.44.0",
61
- "@typescript-eslint/parser": "5.44.0",
60
+ "@typescript-eslint/eslint-plugin": "5.45.0",
61
+ "@typescript-eslint/parser": "5.45.0",
62
62
  "discord-api-types": "0.37.20",
63
- "discord.js": "14.6.0",
63
+ "discord.js": "14.7.0",
64
64
  "eslint": "8.28.0",
65
65
  "eslint-config-prettier": "8.5.0",
66
66
  "eslint-plugin-prettier": "4.2.1",