necord 6.1.8 → 6.2.0-dev.1698195236.c6e73c2

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 (50) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/dist/commands/commands.module.d.ts +16 -0
  3. package/dist/commands/commands.module.js +73 -0
  4. package/dist/commands/commands.service.d.ts +3 -7
  5. package/dist/commands/commands.service.js +25 -37
  6. package/dist/commands/context-menus/context-menus.module.d.ts +13 -0
  7. package/dist/commands/context-menus/context-menus.module.js +49 -0
  8. package/dist/commands/context-menus/context-menus.service.d.ts +1 -7
  9. package/dist/commands/context-menus/context-menus.service.js +2 -24
  10. package/dist/commands/context-menus/index.d.ts +1 -0
  11. package/dist/commands/context-menus/index.js +1 -0
  12. package/dist/commands/index.d.ts +1 -0
  13. package/dist/commands/index.js +1 -0
  14. package/dist/commands/slash-commands/autocomplete/autocomplete.interceptor.d.ts +1 -1
  15. package/dist/commands/slash-commands/decorators/subcommand-group.decorator.d.ts +1 -1
  16. package/dist/commands/slash-commands/decorators/subcommand.decorator.d.ts +1 -1
  17. package/dist/commands/slash-commands/index.d.ts +1 -0
  18. package/dist/commands/slash-commands/index.js +1 -0
  19. package/dist/commands/slash-commands/slash-commands.module.d.ts +13 -0
  20. package/dist/commands/slash-commands/slash-commands.module.js +51 -0
  21. package/dist/commands/slash-commands/slash-commands.service.d.ts +3 -8
  22. package/dist/commands/slash-commands/slash-commands.service.js +3 -22
  23. package/dist/context/necord-context.interface.d.ts +1 -1
  24. package/dist/listeners/index.d.ts +1 -0
  25. package/dist/listeners/index.js +1 -0
  26. package/dist/listeners/listener.interface.d.ts +2 -2
  27. package/dist/listeners/listeners.module.d.ts +11 -0
  28. package/dist/listeners/listeners.module.js +41 -0
  29. package/dist/listeners/listeners.service.d.ts +1 -5
  30. package/dist/listeners/listeners.service.js +2 -11
  31. package/dist/message-components/index.d.ts +1 -0
  32. package/dist/message-components/index.js +1 -0
  33. package/dist/message-components/message-components.module.d.ts +13 -0
  34. package/dist/message-components/message-components.module.js +49 -0
  35. package/dist/message-components/message-components.service.d.ts +1 -7
  36. package/dist/message-components/message-components.service.js +2 -24
  37. package/dist/modals/index.d.ts +1 -0
  38. package/dist/modals/index.js +1 -0
  39. package/dist/modals/modals.module.d.ts +13 -0
  40. package/dist/modals/modals.module.js +48 -0
  41. package/dist/modals/modals.service.d.ts +1 -7
  42. package/dist/modals/modals.service.js +2 -22
  43. package/dist/necord.module.js +14 -19
  44. package/dist/text-commands/index.d.ts +1 -0
  45. package/dist/text-commands/index.js +1 -0
  46. package/dist/text-commands/text-commands.module.d.ts +15 -0
  47. package/dist/text-commands/text-commands.module.js +73 -0
  48. package/dist/text-commands/text-commands.service.d.ts +1 -9
  49. package/dist/text-commands/text-commands.service.js +2 -49
  50. package/package.json +10 -10
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
+ # [6.2.0](https://github.com/necordjs/necord/compare/v6.1.8...v6.2.0) - (2023-10-23)
5
+
6
+ ## Refactor
7
+
8
+ - Use modules for listeners and explorer ([4759617](https://github.com/necordjs/necord/commit/475961792dc4fd4b957720aebc935b5a7dad01c1))
9
+
10
+ # [6.1.8](https://github.com/necordjs/necord/compare/v6.1.7...v6.1.8) - (2023-10-09)
11
+
12
+ ## Bug Fixes
13
+
14
+ - Remove type of member permissions from subcommand and groups ([df4683e](https://github.com/necordjs/necord/commit/df4683ef1dc70747e754d711283d2fcd17b05a29))
15
+
4
16
  # [6.1.5](https://github.com/necordjs/necord/compare/v6.1.4...v6.1.5) - (2023-09-26)
5
17
 
6
18
  ## Bug Fixes
@@ -73,7 +85,7 @@ All notable changes to this project will be documented in this file.
73
85
  ## Styling
74
86
 
75
87
  - Remove unused imports ([ab1c420](https://github.com/necordjs/necord/commit/ab1c420bb4b165bcf47c013dff0a050d145a626a))
76
- - Use curly brackets for switch-case" ([81ebbb0](https://github.com/necordjs/necord/commit/81ebbb0ff7ab6a28d32ff4eef78169d47352a608))
88
+ - Use curly brackets for switch-case ([81ebbb0](https://github.com/necordjs/necord/commit/81ebbb0ff7ab6a28d32ff4eef78169d47352a608))
77
89
 
78
90
  # [5.8.4](https://github.com/necordjs/necord/compare/v5.8.3...v5.8.4) - (2023-05-10)
79
91
 
@@ -0,0 +1,16 @@
1
+ import { OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
2
+ import { ContextMenusService } from './context-menus';
3
+ import { SlashCommandsService } from './slash-commands';
4
+ import { CommandsService } from './commands.service';
5
+ import { Client } from 'discord.js';
6
+ import { NecordModuleOptions } from '../necord-options.interface';
7
+ export declare class CommandsModule implements OnModuleInit, OnApplicationBootstrap {
8
+ private readonly client;
9
+ private readonly options;
10
+ private readonly commandsService;
11
+ private readonly contextMenusService;
12
+ private readonly slashCommandsService;
13
+ constructor(client: Client, options: NecordModuleOptions, commandsService: CommandsService, contextMenusService: ContextMenusService, slashCommandsService: SlashCommandsService);
14
+ onModuleInit(): Client<boolean>;
15
+ onApplicationBootstrap(): void;
16
+ }
@@ -0,0 +1,73 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.CommandsModule = void 0;
25
+ const common_1 = require("@nestjs/common");
26
+ const context_menus_1 = require("./context-menus");
27
+ const slash_commands_1 = require("./slash-commands");
28
+ const commands_service_1 = require("./commands.service");
29
+ const discord_js_1 = require("discord.js");
30
+ const necord_module_definition_1 = require("../necord.module-definition");
31
+ let CommandsModule = class CommandsModule {
32
+ constructor(client, options, commandsService, contextMenusService, slashCommandsService) {
33
+ this.client = client;
34
+ this.options = options;
35
+ this.commandsService = commandsService;
36
+ this.contextMenusService = contextMenusService;
37
+ this.slashCommandsService = slashCommandsService;
38
+ }
39
+ onModuleInit() {
40
+ if (this.options.skipRegistration) {
41
+ return;
42
+ }
43
+ return this.client.once('ready', () => __awaiter(this, void 0, void 0, function* () { return this.commandsService.register(); }));
44
+ }
45
+ onApplicationBootstrap() {
46
+ var _a;
47
+ const commands = [
48
+ ...this.contextMenusService.cache.values(),
49
+ ...this.slashCommandsService.cache.values()
50
+ ];
51
+ for (const command of commands) {
52
+ if (Array.isArray(this.options.development)) {
53
+ command.setGuilds(this.options.development);
54
+ }
55
+ else {
56
+ command.setGuilds((_a = command.getGuilds()) !== null && _a !== void 0 ? _a : [undefined]);
57
+ }
58
+ }
59
+ }
60
+ };
61
+ exports.CommandsModule = CommandsModule;
62
+ exports.CommandsModule = CommandsModule = __decorate([
63
+ (0, common_1.Global)(),
64
+ (0, common_1.Module)({
65
+ imports: [context_menus_1.ContextMenusModule, slash_commands_1.SlashCommandsModule],
66
+ providers: [commands_service_1.CommandsService],
67
+ exports: [context_menus_1.ContextMenusModule, slash_commands_1.SlashCommandsModule, commands_service_1.CommandsService]
68
+ }),
69
+ __param(1, (0, common_1.Inject)(necord_module_definition_1.NECORD_MODULE_OPTIONS)),
70
+ __metadata("design:paramtypes", [discord_js_1.Client, Object, commands_service_1.CommandsService,
71
+ context_menus_1.ContextMenusService,
72
+ slash_commands_1.SlashCommandsService])
73
+ ], CommandsModule);
@@ -1,21 +1,17 @@
1
1
  import { Client, Collection } from 'discord.js';
2
- import { NecordModuleOptions } from '../necord-options.interface';
3
- import { ContextMenusService } from './context-menus';
4
2
  import { CommandDiscovery } from './command.discovery';
3
+ import { ContextMenusService } from './context-menus';
5
4
  import { SlashCommandsService } from './slash-commands';
6
5
  export declare class CommandsService {
7
6
  private readonly client;
8
- private readonly options;
9
7
  private readonly contextMenusService;
10
8
  private readonly slashCommandsService;
11
9
  private readonly logger;
12
- readonly cache: Collection<string, CommandDiscovery<import("./command.discovery").BaseCommandMeta>[]>;
13
- constructor(client: Client, options: NecordModuleOptions, contextMenusService: ContextMenusService, slashCommandsService: SlashCommandsService);
14
- private onModuleInit;
15
- private onApplicationBootstrap;
10
+ constructor(client: Client, contextMenusService: ContextMenusService, slashCommandsService: SlashCommandsService);
16
11
  register(): Promise<void>;
17
12
  registerInGuild(guildId: string): Promise<Collection<string, import("discord.js").ApplicationCommand<{}>>>;
18
13
  getCommands(): CommandDiscovery[];
14
+ getCommandsByGuilds(): Collection<string, CommandDiscovery[]>;
19
15
  getCommandByName(name: string): CommandDiscovery;
20
16
  getGlobalCommands(): CommandDiscovery[];
21
17
  getGlobalCommandByName(name: string): CommandDiscovery;
@@ -8,9 +8,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
11
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
12
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
13
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -24,40 +21,15 @@ var CommandsService_1;
24
21
  Object.defineProperty(exports, "__esModule", { value: true });
25
22
  exports.CommandsService = void 0;
26
23
  const common_1 = require("@nestjs/common");
27
- const necord_module_definition_1 = require("../necord.module-definition");
28
24
  const discord_js_1 = require("discord.js");
29
25
  const context_menus_1 = require("./context-menus");
30
26
  const slash_commands_1 = require("./slash-commands");
31
27
  let CommandsService = CommandsService_1 = class CommandsService {
32
- constructor(client, options, contextMenusService, slashCommandsService) {
28
+ constructor(client, contextMenusService, slashCommandsService) {
33
29
  this.client = client;
34
- this.options = options;
35
30
  this.contextMenusService = contextMenusService;
36
31
  this.slashCommandsService = slashCommandsService;
37
32
  this.logger = new common_1.Logger(CommandsService_1.name);
38
- this.cache = new discord_js_1.Collection([[undefined, []]]);
39
- }
40
- onModuleInit() {
41
- if (this.options.skipRegistration) {
42
- return;
43
- }
44
- return this.client.once('ready', () => __awaiter(this, void 0, void 0, function* () { return this.register(); }));
45
- }
46
- onApplicationBootstrap() {
47
- var _a, _b;
48
- const commands = [
49
- ...this.contextMenusService.cache.values(),
50
- ...this.slashCommandsService.cache.values()
51
- ];
52
- for (const command of commands) {
53
- const guilds = Array.isArray(this.options.development)
54
- ? this.options.development
55
- : (_a = command.getGuilds()) !== null && _a !== void 0 ? _a : [undefined];
56
- for (const guildId of guilds) {
57
- const visitedCommands = (_b = this.cache.get(guildId)) !== null && _b !== void 0 ? _b : [];
58
- this.cache.set(guildId, visitedCommands.concat(command));
59
- }
60
- }
61
33
  }
62
34
  register() {
63
35
  return __awaiter(this, void 0, void 0, function* () {
@@ -65,12 +37,13 @@ let CommandsService = CommandsService_1 = class CommandsService {
65
37
  yield this.client.application.fetch();
66
38
  }
67
39
  this.logger.log(`Started refreshing application commands.`);
68
- for (const guild of this.cache.keys()) {
69
- if (this.getGuildCommands(guild).length === 0) {
40
+ for (const [guild, commands] of this.getCommandsByGuilds().entries()) {
41
+ if (commands.length === 0) {
70
42
  this.logger.log(`Skipping ${guild ? `guild ${guild}` : 'global'} as it has no commands.`);
71
43
  continue;
72
44
  }
73
- yield this.registerInGuild(guild).catch(error => {
45
+ const rawCommands = commands.flatMap(command => command.toJSON());
46
+ yield this.client.application.commands.set(rawCommands, guild).catch(error => {
74
47
  this.logger.error(`Failed to register application commands (${guild ? `in guild ${guild}` : 'global'}): ${error}`, error.stack);
75
48
  });
76
49
  }
@@ -83,21 +56,36 @@ let CommandsService = CommandsService_1 = class CommandsService {
83
56
  });
84
57
  }
85
58
  getCommands() {
86
- return [...this.cache.values()].flat();
59
+ return [
60
+ ...this.contextMenusService.cache.values(),
61
+ ...this.slashCommandsService.cache.values()
62
+ ].flat();
63
+ }
64
+ getCommandsByGuilds() {
65
+ var _a;
66
+ const collection = new discord_js_1.Collection();
67
+ const commands = this.getCommands();
68
+ for (const command of commands) {
69
+ for (const guildId of command.getGuilds()) {
70
+ const visitedCommands = (_a = collection.get(guildId)) !== null && _a !== void 0 ? _a : [];
71
+ collection.set(guildId, visitedCommands.concat(command));
72
+ }
73
+ }
74
+ return collection;
87
75
  }
88
76
  getCommandByName(name) {
89
77
  return this.getCommands().find(command => command.getName() === name);
90
78
  }
91
79
  getGlobalCommands() {
92
80
  var _a;
93
- return (_a = this.cache.get(undefined)) !== null && _a !== void 0 ? _a : [];
81
+ return (_a = this.getCommandsByGuilds().get(undefined)) !== null && _a !== void 0 ? _a : [];
94
82
  }
95
83
  getGlobalCommandByName(name) {
96
84
  return this.getGlobalCommands().find(command => command.getName() === name);
97
85
  }
98
86
  getGuildCommands(guildId) {
99
87
  var _a;
100
- return (_a = this.cache.get(guildId)) !== null && _a !== void 0 ? _a : [];
88
+ return (_a = this.getCommandsByGuilds().get(guildId)) !== null && _a !== void 0 ? _a : [];
101
89
  }
102
90
  getGuildCommandByName(guildId, name) {
103
91
  return this.getGuildCommands(guildId).find(command => command.getName() === name);
@@ -106,7 +94,7 @@ let CommandsService = CommandsService_1 = class CommandsService {
106
94
  exports.CommandsService = CommandsService;
107
95
  exports.CommandsService = CommandsService = CommandsService_1 = __decorate([
108
96
  (0, common_1.Injectable)(),
109
- __param(1, (0, common_1.Inject)(necord_module_definition_1.NECORD_MODULE_OPTIONS)),
110
- __metadata("design:paramtypes", [discord_js_1.Client, Object, context_menus_1.ContextMenusService,
97
+ __metadata("design:paramtypes", [discord_js_1.Client,
98
+ context_menus_1.ContextMenusService,
111
99
  slash_commands_1.SlashCommandsService])
112
100
  ], CommandsService);
@@ -0,0 +1,13 @@
1
+ import { OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
2
+ import { ContextMenusService } from './context-menus.service';
3
+ import { ExplorerService } from '../../necord-explorer.service';
4
+ import { ContextMenuDiscovery } from './context-menu.discovery';
5
+ import { Client } from 'discord.js';
6
+ export declare class ContextMenusModule implements OnModuleInit, OnApplicationBootstrap {
7
+ private readonly client;
8
+ private readonly explorerService;
9
+ private readonly contextMenusService;
10
+ constructor(client: Client, explorerService: ExplorerService<ContextMenuDiscovery>, contextMenusService: ContextMenusService);
11
+ onModuleInit(): void;
12
+ onApplicationBootstrap(): Client<boolean>;
13
+ }
@@ -0,0 +1,49 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ContextMenusModule = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const context_menus_service_1 = require("./context-menus.service");
15
+ const necord_explorer_service_1 = require("../../necord-explorer.service");
16
+ const discord_js_1 = require("discord.js");
17
+ const decorators_1 = require("./decorators");
18
+ let ContextMenusModule = class ContextMenusModule {
19
+ constructor(client, explorerService, contextMenusService) {
20
+ this.client = client;
21
+ this.explorerService = explorerService;
22
+ this.contextMenusService = contextMenusService;
23
+ }
24
+ onModuleInit() {
25
+ return this.explorerService
26
+ .explore(decorators_1.ContextMenu.KEY)
27
+ .forEach(contextMenu => this.contextMenusService.add(contextMenu));
28
+ }
29
+ onApplicationBootstrap() {
30
+ return this.client.on('interactionCreate', interaction => {
31
+ var _a;
32
+ if (!interaction.isContextMenuCommand())
33
+ return;
34
+ return (_a = this.contextMenusService
35
+ .get(interaction.commandType, interaction.commandName)) === null || _a === void 0 ? void 0 : _a.execute(interaction);
36
+ });
37
+ }
38
+ };
39
+ exports.ContextMenusModule = ContextMenusModule;
40
+ exports.ContextMenusModule = ContextMenusModule = __decorate([
41
+ (0, common_1.Global)(),
42
+ (0, common_1.Module)({
43
+ providers: [context_menus_service_1.ContextMenusService],
44
+ exports: [context_menus_service_1.ContextMenusService]
45
+ }),
46
+ __metadata("design:paramtypes", [discord_js_1.Client,
47
+ necord_explorer_service_1.ExplorerService,
48
+ context_menus_service_1.ContextMenusService])
49
+ ], ContextMenusModule);
@@ -1,14 +1,8 @@
1
- import { Client, Collection } from 'discord.js';
1
+ import { Collection } from 'discord.js';
2
2
  import { ContextMenuDiscovery, ContextMenuMeta } from './context-menu.discovery';
3
- import { ExplorerService } from '../../necord-explorer.service';
4
3
  export declare class ContextMenusService {
5
- private readonly client;
6
- private readonly explorerService;
7
4
  private readonly logger;
8
5
  readonly cache: Collection<string, ContextMenuDiscovery>;
9
- constructor(client: Client, explorerService: ExplorerService<ContextMenuDiscovery>);
10
- private onModuleInit;
11
- private onApplicationBootstrap;
12
6
  add(contextMenu: ContextMenuDiscovery): void;
13
7
  get(type: ContextMenuMeta['type'], name: ContextMenuMeta['name']): ContextMenuDiscovery;
14
8
  remove(type: ContextMenuMeta['type'], name: ContextMenuMeta['name']): boolean;
@@ -5,36 +5,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
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
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
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
8
  var ContextMenusService_1;
12
9
  Object.defineProperty(exports, "__esModule", { value: true });
13
10
  exports.ContextMenusService = void 0;
14
11
  const discord_js_1 = require("discord.js");
15
12
  const common_1 = require("@nestjs/common");
16
- const necord_explorer_service_1 = require("../../necord-explorer.service");
17
- const decorators_1 = require("./decorators");
18
13
  let ContextMenusService = ContextMenusService_1 = class ContextMenusService {
19
- constructor(client, explorerService) {
20
- this.client = client;
21
- this.explorerService = explorerService;
14
+ constructor() {
22
15
  this.logger = new common_1.Logger(ContextMenusService_1.name);
23
16
  this.cache = new discord_js_1.Collection();
24
17
  }
25
- onModuleInit() {
26
- return this.explorerService
27
- .explore(decorators_1.ContextMenu.KEY)
28
- .forEach(contextMenu => this.add(contextMenu));
29
- }
30
- onApplicationBootstrap() {
31
- return this.client.on('interactionCreate', interaction => {
32
- var _a;
33
- if (!interaction.isContextMenuCommand())
34
- return;
35
- return (_a = this.get(interaction.commandType, interaction.commandName)) === null || _a === void 0 ? void 0 : _a.execute(interaction);
36
- });
37
- }
38
18
  add(contextMenu) {
39
19
  const id = this.getId(contextMenu.getType(), contextMenu.getName());
40
20
  if (this.cache.has(id)) {
@@ -54,7 +34,5 @@ let ContextMenusService = ContextMenusService_1 = class ContextMenusService {
54
34
  };
55
35
  exports.ContextMenusService = ContextMenusService;
56
36
  exports.ContextMenusService = ContextMenusService = ContextMenusService_1 = __decorate([
57
- (0, common_1.Injectable)(),
58
- __metadata("design:paramtypes", [discord_js_1.Client,
59
- necord_explorer_service_1.ExplorerService])
37
+ (0, common_1.Injectable)()
60
38
  ], ContextMenusService);
@@ -1,3 +1,4 @@
1
1
  export * from './decorators';
2
2
  export * from './context-menu.discovery';
3
+ export * from './context-menus.module';
3
4
  export * from './context-menus.service';
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./decorators"), exports);
18
18
  __exportStar(require("./context-menu.discovery"), exports);
19
+ __exportStar(require("./context-menus.module"), exports);
19
20
  __exportStar(require("./context-menus.service"), exports);
@@ -1,4 +1,5 @@
1
1
  export * from './context-menus';
2
2
  export * from './slash-commands';
3
3
  export * from './command.discovery';
4
+ export * from './commands.module';
4
5
  export * from './commands.service';
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./context-menus"), exports);
18
18
  __exportStar(require("./slash-commands"), exports);
19
19
  __exportStar(require("./command.discovery"), exports);
20
+ __exportStar(require("./commands.module"), exports);
20
21
  __exportStar(require("./commands.service"), exports);
@@ -3,5 +3,5 @@ import { Observable } from 'rxjs';
3
3
  import { AutocompleteInteraction } from 'discord.js';
4
4
  export declare abstract class AutocompleteInterceptor implements NestInterceptor {
5
5
  abstract transformOptions(interaction: AutocompleteInteraction): void | Promise<void>;
6
- intercept(context: ExecutionContext, next: CallHandler<any>): Promise<Observable<any>>;
6
+ intercept(context: ExecutionContext, next: CallHandler): Promise<Observable<any>>;
7
7
  }
@@ -1,3 +1,3 @@
1
1
  import { SlashCommandDiscovery, SlashCommandMeta } from '../slash-command.discovery';
2
- export declare const SubcommandGroup: import("@nestjs/core").ReflectableDecorator<Omit<SlashCommandMeta, "type" | "guilds" | "options" | "defaultMemberPermissions">, SlashCommandDiscovery>;
2
+ export declare const SubcommandGroup: import("@nestjs/core").ReflectableDecorator<Omit<SlashCommandMeta, "type" | "options" | "guilds" | "defaultMemberPermissions">, SlashCommandDiscovery>;
3
3
  export declare const createCommandGroupDecorator: (rootOptions: Omit<SlashCommandMeta, 'type'>) => (subOptions?: Omit<SlashCommandMeta, 'type'>) => ClassDecorator;
@@ -1,2 +1,2 @@
1
1
  import { SlashCommandDiscovery, SlashCommandMeta } from '../slash-command.discovery';
2
- export declare const Subcommand: import("@nestjs/core").ReflectableDecorator<Omit<SlashCommandMeta, "type" | "guilds" | "options" | "defaultMemberPermissions">, SlashCommandDiscovery>;
2
+ export declare const Subcommand: import("@nestjs/core").ReflectableDecorator<Omit<SlashCommandMeta, "type" | "options" | "guilds" | "defaultMemberPermissions">, SlashCommandDiscovery>;
@@ -2,4 +2,5 @@ export * from './autocomplete';
2
2
  export * from './decorators';
3
3
  export * from './options';
4
4
  export * from './slash-command.discovery';
5
+ export * from './slash-commands.module';
5
6
  export * from './slash-commands.service';
@@ -18,4 +18,5 @@ __exportStar(require("./autocomplete"), exports);
18
18
  __exportStar(require("./decorators"), exports);
19
19
  __exportStar(require("./options"), exports);
20
20
  __exportStar(require("./slash-command.discovery"), exports);
21
+ __exportStar(require("./slash-commands.module"), exports);
21
22
  __exportStar(require("./slash-commands.service"), exports);
@@ -0,0 +1,13 @@
1
+ import { OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
2
+ import { SlashCommandsService } from './slash-commands.service';
3
+ import { Client } from 'discord.js';
4
+ import { ExplorerService } from '../../necord-explorer.service';
5
+ import { SlashCommandDiscovery } from './slash-command.discovery';
6
+ export declare class SlashCommandsModule implements OnModuleInit, OnApplicationBootstrap {
7
+ private readonly client;
8
+ private readonly explorerService;
9
+ private readonly slashCommandsService;
10
+ constructor(client: Client, explorerService: ExplorerService<SlashCommandDiscovery>, slashCommandsService: SlashCommandsService);
11
+ onModuleInit(): void;
12
+ onApplicationBootstrap(): Client<boolean>;
13
+ }
@@ -0,0 +1,51 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SlashCommandsModule = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const slash_commands_service_1 = require("./slash-commands.service");
15
+ const discord_js_1 = require("discord.js");
16
+ const necord_explorer_service_1 = require("../../necord-explorer.service");
17
+ const decorators_1 = require("./decorators");
18
+ let SlashCommandsModule = class SlashCommandsModule {
19
+ constructor(client, explorerService, slashCommandsService) {
20
+ this.client = client;
21
+ this.explorerService = explorerService;
22
+ this.slashCommandsService = slashCommandsService;
23
+ }
24
+ onModuleInit() {
25
+ this.explorerService
26
+ .explore(decorators_1.SlashCommand.KEY)
27
+ .forEach(command => this.slashCommandsService.add(command));
28
+ return this.explorerService
29
+ .explore(decorators_1.Subcommand.KEY)
30
+ .forEach(subcommand => this.slashCommandsService.addSubCommand(subcommand));
31
+ }
32
+ onApplicationBootstrap() {
33
+ return this.client.on('interactionCreate', i => {
34
+ var _a;
35
+ if (!i.isChatInputCommand() && !i.isAutocomplete())
36
+ return;
37
+ return (_a = this.slashCommandsService.get(i.commandName)) === null || _a === void 0 ? void 0 : _a.execute(i);
38
+ });
39
+ }
40
+ };
41
+ exports.SlashCommandsModule = SlashCommandsModule;
42
+ exports.SlashCommandsModule = SlashCommandsModule = __decorate([
43
+ (0, common_1.Global)(),
44
+ (0, common_1.Module)({
45
+ providers: [slash_commands_service_1.SlashCommandsService],
46
+ exports: [slash_commands_service_1.SlashCommandsService]
47
+ }),
48
+ __metadata("design:paramtypes", [discord_js_1.Client,
49
+ necord_explorer_service_1.ExplorerService,
50
+ slash_commands_service_1.SlashCommandsService])
51
+ ], SlashCommandsModule);
@@ -1,18 +1,13 @@
1
1
  import { SlashCommandDiscovery } from './slash-command.discovery';
2
- import { Client, Collection } from 'discord.js';
3
- import { ExplorerService } from '../../necord-explorer.service';
2
+ import { Collection } from 'discord.js';
4
3
  import { Reflector } from '@nestjs/core';
5
4
  export declare class SlashCommandsService {
6
- private readonly client;
7
- private readonly explorerService;
8
5
  private readonly reflector;
9
6
  private readonly logger;
10
7
  readonly cache: Collection<string, SlashCommandDiscovery>;
11
- constructor(client: Client, explorerService: ExplorerService<SlashCommandDiscovery>, reflector: Reflector);
12
- private onModuleInit;
13
- private onApplicationBootstrap;
8
+ constructor(reflector: Reflector);
14
9
  add(command: SlashCommandDiscovery): void;
15
10
  get(commandName: string): SlashCommandDiscovery;
16
11
  remove(commandName: string): boolean;
17
- private addSubCommand;
12
+ addSubCommand(subCommand: SlashCommandDiscovery): void;
18
13
  }
@@ -13,31 +13,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.SlashCommandsService = void 0;
14
14
  const common_1 = require("@nestjs/common");
15
15
  const discord_js_1 = require("discord.js");
16
- const necord_explorer_service_1 = require("../../necord-explorer.service");
17
16
  const core_1 = require("@nestjs/core");
18
17
  const decorators_1 = require("./decorators");
19
18
  let SlashCommandsService = SlashCommandsService_1 = class SlashCommandsService {
20
- constructor(client, explorerService, reflector) {
21
- this.client = client;
22
- this.explorerService = explorerService;
19
+ constructor(reflector) {
23
20
  this.reflector = reflector;
24
21
  this.logger = new common_1.Logger(SlashCommandsService_1.name);
25
22
  this.cache = new discord_js_1.Collection();
26
23
  }
27
- onModuleInit() {
28
- this.explorerService.explore(decorators_1.SlashCommand.KEY).forEach(command => this.add(command));
29
- return this.explorerService
30
- .explore(decorators_1.Subcommand.KEY)
31
- .forEach(subcommand => this.addSubCommand(subcommand));
32
- }
33
- onApplicationBootstrap() {
34
- return this.client.on('interactionCreate', i => {
35
- var _a;
36
- if (!i.isChatInputCommand() && !i.isAutocomplete())
37
- return;
38
- return (_a = this.get(i.commandName)) === null || _a === void 0 ? void 0 : _a.execute(i);
39
- });
40
- }
41
24
  add(command) {
42
25
  if (this.cache.has(command.getName())) {
43
26
  this.logger.warn(`Slash Command : ${command.getName()} already exists`);
@@ -65,8 +48,6 @@ let SlashCommandsService = SlashCommandsService_1 = class SlashCommandsService {
65
48
  };
66
49
  exports.SlashCommandsService = SlashCommandsService;
67
50
  exports.SlashCommandsService = SlashCommandsService = SlashCommandsService_1 = __decorate([
68
- (0, common_1.Injectable)(),
69
- __metadata("design:paramtypes", [discord_js_1.Client,
70
- necord_explorer_service_1.ExplorerService,
71
- core_1.Reflector])
51
+ (0, common_1.Injectable)({ scope: common_1.Scope.DEFAULT, durable: true }),
52
+ __metadata("design:paramtypes", [core_1.Reflector])
72
53
  ], SlashCommandsService);
@@ -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/listener.interface';
2
+ import { NecordEvents } from '../listeners';
3
3
  export type AutocompleteContext = [AutocompleteInteraction];
4
4
  export type SlashCommandContext = [ChatInputCommandInteraction];
5
5
  export type TextCommandContext = [Message];
@@ -1,4 +1,5 @@
1
1
  export * from './decorators';
2
2
  export * from './listener.discovery';
3
3
  export * from './listener.interface';
4
+ export * from './listeners.module';
4
5
  export * from './listeners.service';
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./decorators"), exports);
18
18
  __exportStar(require("./listener.discovery"), exports);
19
19
  __exportStar(require("./listener.interface"), exports);
20
+ __exportStar(require("./listeners.module"), exports);
20
21
  __exportStar(require("./listeners.service"), exports);
@@ -36,9 +36,9 @@ export interface NecordEvents extends ClientEvents {
36
36
  guildPartnerRemove: [guild: Guild];
37
37
  guildVerificationAdd: [guild: Guild];
38
38
  guildVerificationRemove: [guild: Guild];
39
- messagePinned: [Message<boolean> | PartialMessage];
39
+ messagePinned: [Message | PartialMessage];
40
40
  messageContentEdited: [
41
- message: Message<boolean> | PartialMessage,
41
+ message: Message | PartialMessage,
42
42
  oldContent: string,
43
43
  newContent: string
44
44
  ];
@@ -0,0 +1,11 @@
1
+ import { OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
2
+ import { Client } from 'discord.js';
3
+ import { ExplorerService } from '../necord-explorer.service';
4
+ import { ListenerDiscovery } from './listener.discovery';
5
+ export declare class ListenersModule implements OnModuleInit, OnApplicationBootstrap {
6
+ private readonly client;
7
+ private readonly explorerService;
8
+ constructor(client: Client, explorerService: ExplorerService<ListenerDiscovery>);
9
+ onModuleInit(): void;
10
+ onApplicationBootstrap(): any;
11
+ }