necord 5.4.8 → 5.5.0-dev.1678451232.28d3cf7

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 (167) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +9 -2
  3. package/dist/commands/command.discovery.d.ts +8 -8
  4. package/dist/commands/command.discovery.js +13 -13
  5. package/dist/commands/commands.service.d.ts +15 -15
  6. package/dist/commands/commands.service.js +80 -80
  7. package/dist/commands/context-menus/context-menu.discovery.d.ts +11 -11
  8. package/dist/commands/context-menus/context-menu.discovery.js +19 -19
  9. package/dist/commands/context-menus/context-menus.service.d.ts +18 -18
  10. package/dist/commands/context-menus/context-menus.service.js +61 -61
  11. package/dist/commands/context-menus/decorators/context-menu.decorator.d.ts +2 -2
  12. package/dist/commands/context-menus/decorators/context-menu.decorator.js +8 -8
  13. package/dist/commands/context-menus/decorators/index.d.ts +4 -4
  14. package/dist/commands/context-menus/decorators/index.js +20 -20
  15. package/dist/commands/context-menus/decorators/message-command.decorator.d.ts +2 -2
  16. package/dist/commands/context-menus/decorators/message-command.decorator.js +7 -7
  17. package/dist/commands/context-menus/decorators/target.decorator.d.ts +7 -7
  18. package/dist/commands/context-menus/decorators/target.decorator.js +38 -38
  19. package/dist/commands/context-menus/decorators/user-command.decorator.d.ts +2 -2
  20. package/dist/commands/context-menus/decorators/user-command.decorator.js +7 -7
  21. package/dist/commands/context-menus/index.d.ts +3 -3
  22. package/dist/commands/context-menus/index.js +19 -19
  23. package/dist/commands/index.d.ts +4 -4
  24. package/dist/commands/index.js +20 -20
  25. package/dist/commands/slash-commands/autocomplete/autocomplete.interceptor.d.ts +7 -7
  26. package/dist/commands/slash-commands/autocomplete/autocomplete.interceptor.js +39 -39
  27. package/dist/commands/slash-commands/autocomplete/index.d.ts +1 -1
  28. package/dist/commands/slash-commands/autocomplete/index.js +17 -17
  29. package/dist/commands/slash-commands/decorators/index.d.ts +3 -3
  30. package/dist/commands/slash-commands/decorators/index.js +19 -19
  31. package/dist/commands/slash-commands/decorators/slash-command.decorator.d.ts +2 -2
  32. package/dist/commands/slash-commands/decorators/slash-command.decorator.js +9 -9
  33. package/dist/commands/slash-commands/decorators/subcommand-group.decorator.d.ts +2 -2
  34. package/dist/commands/slash-commands/decorators/subcommand-group.decorator.js +18 -18
  35. package/dist/commands/slash-commands/decorators/subcommand.decorator.d.ts +2 -2
  36. package/dist/commands/slash-commands/decorators/subcommand.decorator.js +9 -9
  37. package/dist/commands/slash-commands/index.d.ts +5 -5
  38. package/dist/commands/slash-commands/index.js +21 -21
  39. package/dist/commands/slash-commands/options/attachment-option.decorator.d.ts +7 -7
  40. package/dist/commands/slash-commands/options/attachment-option.decorator.js +6 -6
  41. package/dist/commands/slash-commands/options/boolean-option.decorator.d.ts +7 -7
  42. package/dist/commands/slash-commands/options/boolean-option.decorator.js +6 -6
  43. package/dist/commands/slash-commands/options/channel-option.decorator.d.ts +8 -8
  44. package/dist/commands/slash-commands/options/channel-option.decorator.js +6 -6
  45. package/dist/commands/slash-commands/options/index.d.ts +11 -11
  46. package/dist/commands/slash-commands/options/index.js +27 -27
  47. package/dist/commands/slash-commands/options/integer-option.decorator.d.ts +20 -20
  48. package/dist/commands/slash-commands/options/integer-option.decorator.js +6 -6
  49. package/dist/commands/slash-commands/options/member-option.decorator.d.ts +7 -7
  50. package/dist/commands/slash-commands/options/member-option.decorator.js +6 -6
  51. package/dist/commands/slash-commands/options/mentionable-option.decorator.d.ts +7 -7
  52. package/dist/commands/slash-commands/options/mentionable-option.decorator.js +6 -6
  53. package/dist/commands/slash-commands/options/number-option.decorator.d.ts +20 -20
  54. package/dist/commands/slash-commands/options/number-option.decorator.js +6 -6
  55. package/dist/commands/slash-commands/options/option.util.d.ts +5 -5
  56. package/dist/commands/slash-commands/options/option.util.js +21 -21
  57. package/dist/commands/slash-commands/options/options.decorator.d.ts +2 -2
  58. package/dist/commands/slash-commands/options/options.decorator.js +32 -32
  59. package/dist/commands/slash-commands/options/role-option.decorator.d.ts +7 -7
  60. package/dist/commands/slash-commands/options/role-option.decorator.js +6 -6
  61. package/dist/commands/slash-commands/options/string-option.decorator.d.ts +20 -20
  62. package/dist/commands/slash-commands/options/string-option.decorator.js +6 -6
  63. package/dist/commands/slash-commands/options/user-option.decorator.d.ts +7 -7
  64. package/dist/commands/slash-commands/options/user-option.decorator.js +6 -6
  65. package/dist/commands/slash-commands/slash-command.discovery.d.ts +20 -20
  66. package/dist/commands/slash-commands/slash-command.discovery.js +44 -44
  67. package/dist/commands/slash-commands/slash-commands.service.d.ts +20 -20
  68. package/dist/commands/slash-commands/slash-commands.service.js +89 -89
  69. package/dist/context/decorators/context.decorator.d.ts +2 -2
  70. package/dist/context/decorators/context.decorator.js +7 -7
  71. package/dist/context/decorators/discovery.decorator.d.ts +1 -1
  72. package/dist/context/decorators/discovery.decorator.js +6 -6
  73. package/dist/context/decorators/index.d.ts +2 -2
  74. package/dist/context/decorators/index.js +18 -18
  75. package/dist/context/decorators/params.util.d.ts +3 -3
  76. package/dist/context/decorators/params.util.js +12 -12
  77. package/dist/context/index.d.ts +7 -7
  78. package/dist/context/index.js +23 -23
  79. package/dist/context/necord-arguments-host.d.ts +13 -13
  80. package/dist/context/necord-arguments-host.js +22 -22
  81. package/dist/context/necord-base.discovery.d.ts +30 -30
  82. package/dist/context/necord-base.discovery.js +47 -47
  83. package/dist/context/necord-context.interface.d.ts +22 -22
  84. package/dist/context/necord-context.interface.js +2 -2
  85. package/dist/context/necord-execution-context.d.ts +6 -6
  86. package/dist/context/necord-execution-context.js +13 -13
  87. package/dist/context/necord-params.factory.d.ts +6 -6
  88. package/dist/context/necord-params.factory.js +19 -19
  89. package/dist/context/necord-paramtype.enum.d.ts +4 -4
  90. package/dist/context/necord-paramtype.enum.js +8 -8
  91. package/dist/index.d.ts +9 -9
  92. package/dist/index.js +25 -25
  93. package/dist/listeners/decorators/index.d.ts +3 -3
  94. package/dist/listeners/decorators/index.js +19 -19
  95. package/dist/listeners/decorators/listener.decorator.d.ts +2 -2
  96. package/dist/listeners/decorators/listener.decorator.js +8 -8
  97. package/dist/listeners/decorators/on.decorator.d.ts +2 -2
  98. package/dist/listeners/decorators/on.decorator.js +6 -6
  99. package/dist/listeners/decorators/once.decorator.d.ts +2 -2
  100. package/dist/listeners/decorators/once.decorator.js +6 -6
  101. package/dist/listeners/index.d.ts +3 -3
  102. package/dist/listeners/index.js +19 -19
  103. package/dist/listeners/listener.discovery.d.ts +11 -11
  104. package/dist/listeners/listener.discovery.js +19 -19
  105. package/dist/listeners/listener.interface.d.ts +90 -90
  106. package/dist/listeners/listener.interface.js +2 -2
  107. package/dist/listeners/listeners.service.d.ts +22 -22
  108. package/dist/listeners/listeners.service.js +237 -237
  109. package/dist/message-components/decorators/button.decorator.d.ts +1 -1
  110. package/dist/message-components/decorators/button.decorator.js +7 -7
  111. package/dist/message-components/decorators/component-param.decorator.d.ts +1 -1
  112. package/dist/message-components/decorators/component-param.decorator.js +17 -17
  113. package/dist/message-components/decorators/index.d.ts +6 -6
  114. package/dist/message-components/decorators/index.js +22 -22
  115. package/dist/message-components/decorators/message-component.decorator.d.ts +2 -2
  116. package/dist/message-components/decorators/message-component.decorator.js +8 -8
  117. package/dist/message-components/decorators/select-menu.decorator.d.ts +12 -12
  118. package/dist/message-components/decorators/select-menu.decorator.js +23 -23
  119. package/dist/message-components/decorators/selected.decorator.d.ts +10 -10
  120. package/dist/message-components/decorators/selected.decorator.js +40 -40
  121. package/dist/message-components/decorators/values.decorator.d.ts +7 -7
  122. package/dist/message-components/decorators/values.decorator.js +17 -17
  123. package/dist/message-components/index.d.ts +3 -3
  124. package/dist/message-components/index.js +19 -19
  125. package/dist/message-components/message-component.discovery.d.ts +14 -14
  126. package/dist/message-components/message-component.discovery.js +27 -27
  127. package/dist/message-components/message-components.service.d.ts +16 -16
  128. package/dist/message-components/message-components.service.js +61 -61
  129. package/dist/modals/decorators/fields.decorator.d.ts +1 -1
  130. package/dist/modals/decorators/fields.decorator.js +14 -14
  131. package/dist/modals/decorators/index.d.ts +3 -3
  132. package/dist/modals/decorators/index.js +19 -19
  133. package/dist/modals/decorators/modal-param.decorator.d.ts +1 -1
  134. package/dist/modals/decorators/modal-param.decorator.js +17 -17
  135. package/dist/modals/decorators/modal.decorator.d.ts +1 -1
  136. package/dist/modals/decorators/modal.decorator.js +8 -8
  137. package/dist/modals/index.d.ts +3 -3
  138. package/dist/modals/index.js +19 -19
  139. package/dist/modals/modal.discovery.d.ts +12 -12
  140. package/dist/modals/modal.discovery.js +24 -24
  141. package/dist/modals/modals.service.d.ts +15 -15
  142. package/dist/modals/modals.service.js +56 -56
  143. package/dist/necord-client.provider.d.ts +3 -3
  144. package/dist/necord-client.provider.js +10 -10
  145. package/dist/necord-explorer.service.d.ts +15 -15
  146. package/dist/necord-explorer.service.js +59 -59
  147. package/dist/necord-options.interface.d.ts +8 -7
  148. package/dist/necord-options.interface.js +2 -2
  149. package/dist/necord-rest.provider.d.ts +3 -0
  150. package/dist/necord-rest.provider.js +10 -0
  151. package/dist/necord.constants.d.ts +12 -12
  152. package/dist/necord.constants.js +19 -20
  153. package/dist/necord.module.d.ts +11 -11
  154. package/dist/necord.module.js +71 -68
  155. package/dist/text-commands/decorators/arguments.decorator.d.ts +2 -2
  156. package/dist/text-commands/decorators/arguments.decorator.js +14 -14
  157. package/dist/text-commands/decorators/index.d.ts +2 -2
  158. package/dist/text-commands/decorators/index.js +18 -18
  159. package/dist/text-commands/decorators/text-command.decorator.d.ts +2 -2
  160. package/dist/text-commands/decorators/text-command.decorator.js +8 -8
  161. package/dist/text-commands/index.d.ts +3 -3
  162. package/dist/text-commands/index.js +19 -19
  163. package/dist/text-commands/text-command.discovery.d.ts +11 -11
  164. package/dist/text-commands/text-command.discovery.js +19 -19
  165. package/dist/text-commands/text-commands.service.d.ts +17 -17
  166. package/dist/text-commands/text-commands.service.js +78 -78
  167. package/package.json +8 -8
package/CHANGELOG.md CHANGED
@@ -1,6 +1,30 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ # [5.5.0](https://github.com/necordjs/necord/compare/v5.4.8...v5.5.0) - (2023-03-09)
5
+
6
+ ## Bug Fixes
7
+
8
+ - Remove extras ([318e5dd](https://github.com/necordjs/necord/commit/318e5ddd43059b01dc078bd68523df637bad8300))
9
+
10
+ ## Features
11
+
12
+ - Add rest provider ([85a9c33](https://github.com/necordjs/necord/commit/85a9c33a78d2b76f791d26346073746515674722))
13
+
14
+ ## Styling
15
+
16
+ - Lint ([56a59f8](https://github.com/necordjs/necord/commit/56a59f8cb140d3df891d1cb56bc942de6ef4d8fc))
17
+
18
+ # [5.4.8](https://github.com/necordjs/necord/compare/v5.4.7...v5.4.8) - (2023-02-28)
19
+
20
+ ## Features
21
+
22
+ - Add configurable module class ([8af0f0d](https://github.com/necordjs/necord/commit/8af0f0d5a70c17b3eee78d7cf8860208c26c5d79))
23
+
24
+ ## Styling
25
+
26
+ - Remove imports ([b115aa0](https://github.com/necordjs/necord/commit/b115aa040eaf87fbdaf41681153f601072e4d5c9))
27
+
4
28
  # [5.4.7](https://github.com/necordjs/necord/compare/v5.4.6...v5.4.7) - (2023-02-28)
5
29
 
6
30
  ## Bug Fixes
package/README.md CHANGED
@@ -8,6 +8,14 @@
8
8
  </div>
9
9
 
10
10
 
11
+ <br/>
12
+
13
+ <p align="center">
14
+ <a href='https://img.shields.io/npm/v/necord'><img src="https://img.shields.io/npm/v/necord" alt="NPM Version" /></a>
15
+ <a href='https://img.shields.io/npm/l/necord'><img src="https://img.shields.io/npm/l/necord" alt="NPM License" /></a>
16
+ <a href='https://img.shields.io/npm/dm/necord'><img src="https://img.shields.io/npm/dm/necord" alt="NPM Downloads" /></a>
17
+ <a href='https://img.shields.io/github/last-commit/necordjs/necord'><img src="https://img.shields.io/github/last-commit/SocketSomeone/necord" alt="Last commit" /></a>
18
+ </p>
11
19
 
12
20
 
13
21
  ## About
@@ -43,13 +51,12 @@ Once the installation process is complete, we can import the `NecordModule` into
43
51
  ```typescript
44
52
  import { NecordModule } from 'necord';
45
53
  import { Module } from '@nestjs/common';
46
- import { Intents } from 'discord.js';
47
54
 
48
55
  @Module({
49
56
  imports: [
50
57
  NecordModule.forRoot({
51
58
  token: 'DISCORD_BOT_TOKEN',
52
- intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.DIRECT_MESSAGES]
59
+ intents: ['Guilds', 'GuildMessages', 'DirectMessages']
53
60
  })
54
61
  ],
55
62
  providers: []
@@ -1,8 +1,8 @@
1
- import { BaseApplicationCommandData, Snowflake } from 'discord.js';
2
- import { NecordBaseDiscovery } from '../context';
3
- export declare abstract class CommandDiscovery<T extends BaseApplicationCommandData & {
4
- guilds?: Snowflake[];
5
- } = BaseApplicationCommandData> extends NecordBaseDiscovery<T> {
6
- getName(): string;
7
- getGuilds(): Snowflake[];
8
- }
1
+ import { BaseApplicationCommandData, Snowflake } from 'discord.js';
2
+ import { NecordBaseDiscovery } from '../context';
3
+ export declare abstract class CommandDiscovery<T extends BaseApplicationCommandData & {
4
+ guilds?: Snowflake[];
5
+ } = BaseApplicationCommandData> extends NecordBaseDiscovery<T> {
6
+ getName(): string;
7
+ getGuilds(): Snowflake[];
8
+ }
@@ -1,13 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommandDiscovery = void 0;
4
- const context_1 = require("../context");
5
- class CommandDiscovery extends context_1.NecordBaseDiscovery {
6
- getName() {
7
- return this.meta.name;
8
- }
9
- getGuilds() {
10
- return this.meta.guilds;
11
- }
12
- }
13
- exports.CommandDiscovery = CommandDiscovery;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommandDiscovery = void 0;
4
+ const context_1 = require("../context");
5
+ class CommandDiscovery extends context_1.NecordBaseDiscovery {
6
+ getName() {
7
+ return this.meta.name;
8
+ }
9
+ getGuilds() {
10
+ return this.meta.guilds;
11
+ }
12
+ }
13
+ exports.CommandDiscovery = CommandDiscovery;
@@ -1,15 +1,15 @@
1
- import { OnModuleInit } from '@nestjs/common';
2
- import { Client } from 'discord.js';
3
- import { NecordModuleOptions } from '../necord-options.interface';
4
- import { ContextMenusService } from './context-menus';
5
- import { SlashCommandsService } from './slash-commands';
6
- export declare class CommandsService implements OnModuleInit {
7
- private readonly client;
8
- private readonly options;
9
- private readonly contextMenusService;
10
- private readonly slashCommandsService;
11
- private readonly logger;
12
- constructor(client: Client, options: NecordModuleOptions, contextMenusService: ContextMenusService, slashCommandsService: SlashCommandsService);
13
- onModuleInit(): Client<boolean>;
14
- register(client: Client): Promise<void>;
15
- }
1
+ import { OnModuleInit } from '@nestjs/common';
2
+ import { Client } from 'discord.js';
3
+ import { NecordModuleOptions } from '../necord-options.interface';
4
+ import { ContextMenusService } from './context-menus';
5
+ import { SlashCommandsService } from './slash-commands';
6
+ export declare class CommandsService implements OnModuleInit {
7
+ private readonly client;
8
+ private readonly options;
9
+ private readonly contextMenusService;
10
+ private readonly slashCommandsService;
11
+ private readonly logger;
12
+ constructor(client: Client, options: NecordModuleOptions, contextMenusService: ContextMenusService, slashCommandsService: SlashCommandsService);
13
+ onModuleInit(): Client<boolean>;
14
+ register(client: Client): Promise<void>;
15
+ }
@@ -1,80 +1,80 @@
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
- var CommandsService_1;
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.CommandsService = void 0;
26
- const common_1 = require("@nestjs/common");
27
- const necord_constants_1 = require("../necord.constants");
28
- const discord_js_1 = require("discord.js");
29
- const context_menus_1 = require("./context-menus");
30
- const slash_commands_1 = require("./slash-commands");
31
- let CommandsService = CommandsService_1 = class CommandsService {
32
- constructor(client, options, contextMenusService, slashCommandsService) {
33
- this.client = client;
34
- this.options = options;
35
- this.contextMenusService = contextMenusService;
36
- this.slashCommandsService = slashCommandsService;
37
- this.logger = new common_1.Logger(CommandsService_1.name);
38
- }
39
- onModuleInit() {
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* () {
48
- if (client.application.partial) {
49
- yield client.application.fetch();
50
- }
51
- const clientCommands = client.application.commands;
52
- const commands = [
53
- ...this.contextMenusService.getCommands(),
54
- ...this.slashCommandsService.getCommands()
55
- ];
56
- const commandsByGuildMap = new Map([[undefined, []]]);
57
- for (const command of commands) {
58
- const guilds = Array.isArray(this.options.development)
59
- ? this.options.development
60
- : (_a = command.getGuilds()) !== null && _a !== void 0 ? _a : [undefined];
61
- for (const guildId of guilds) {
62
- const visitedCommands = (_b = commandsByGuildMap.get(guildId)) !== null && _b !== void 0 ? _b : [];
63
- commandsByGuildMap.set(guildId, visitedCommands.concat(command));
64
- }
65
- }
66
- this.logger.log(`Started refreshing application commands.`);
67
- for (const [guild, commands] of commandsByGuildMap) {
68
- yield clientCommands.set(commands.flatMap(command => command.toJSON()), guild);
69
- }
70
- this.logger.log(`Successfully reloaded application commands.`);
71
- });
72
- }
73
- };
74
- CommandsService = CommandsService_1 = __decorate([
75
- (0, common_1.Injectable)(),
76
- __param(1, (0, common_1.Inject)(necord_constants_1.NECORD_MODULE_OPTIONS)),
77
- __metadata("design:paramtypes", [discord_js_1.Client, Object, context_menus_1.ContextMenusService,
78
- slash_commands_1.SlashCommandsService])
79
- ], CommandsService);
80
- exports.CommandsService = CommandsService;
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
+ var CommandsService_1;
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.CommandsService = void 0;
26
+ const common_1 = require("@nestjs/common");
27
+ const necord_constants_1 = require("../necord.constants");
28
+ const discord_js_1 = require("discord.js");
29
+ const context_menus_1 = require("./context-menus");
30
+ const slash_commands_1 = require("./slash-commands");
31
+ let CommandsService = CommandsService_1 = class CommandsService {
32
+ constructor(client, options, contextMenusService, slashCommandsService) {
33
+ this.client = client;
34
+ this.options = options;
35
+ this.contextMenusService = contextMenusService;
36
+ this.slashCommandsService = slashCommandsService;
37
+ this.logger = new common_1.Logger(CommandsService_1.name);
38
+ }
39
+ onModuleInit() {
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* () {
48
+ if (client.application.partial) {
49
+ yield client.application.fetch();
50
+ }
51
+ const clientCommands = client.application.commands;
52
+ const commands = [
53
+ ...this.contextMenusService.getCommands(),
54
+ ...this.slashCommandsService.getCommands()
55
+ ];
56
+ const commandsByGuildMap = new Map([[undefined, []]]);
57
+ for (const command of commands) {
58
+ const guilds = Array.isArray(this.options.development)
59
+ ? this.options.development
60
+ : (_a = command.getGuilds()) !== null && _a !== void 0 ? _a : [undefined];
61
+ for (const guildId of guilds) {
62
+ const visitedCommands = (_b = commandsByGuildMap.get(guildId)) !== null && _b !== void 0 ? _b : [];
63
+ commandsByGuildMap.set(guildId, visitedCommands.concat(command));
64
+ }
65
+ }
66
+ this.logger.log(`Started refreshing application commands.`);
67
+ for (const [guild, commands] of commandsByGuildMap) {
68
+ yield clientCommands.set(commands.flatMap(command => command.toJSON()), guild);
69
+ }
70
+ this.logger.log(`Successfully reloaded application commands.`);
71
+ });
72
+ }
73
+ };
74
+ CommandsService = CommandsService_1 = __decorate([
75
+ (0, common_1.Injectable)(),
76
+ __param(1, (0, common_1.Inject)(necord_constants_1.NECORD_MODULE_OPTIONS)),
77
+ __metadata("design:paramtypes", [discord_js_1.Client, Object, context_menus_1.ContextMenusService,
78
+ slash_commands_1.SlashCommandsService])
79
+ ], CommandsService);
80
+ exports.CommandsService = CommandsService;
@@ -1,11 +1,11 @@
1
- import { ContextMenuCommandInteraction, MessageApplicationCommandData, Snowflake, UserApplicationCommandData } from 'discord.js';
2
- import { CommandDiscovery } from '../command.discovery';
3
- export type ContextMenuMeta = (MessageApplicationCommandData | UserApplicationCommandData) & {
4
- guilds?: Snowflake[];
5
- };
6
- export declare class ContextMenuDiscovery extends CommandDiscovery<ContextMenuMeta> {
7
- getType(): import("discord.js").ApplicationCommandType.User | import("discord.js").ApplicationCommandType.Message;
8
- isContextMenu(): this is ContextMenuDiscovery;
9
- execute(interaction: ContextMenuCommandInteraction): any;
10
- toJSON(): ContextMenuMeta;
11
- }
1
+ import { ContextMenuCommandInteraction, MessageApplicationCommandData, Snowflake, UserApplicationCommandData } from 'discord.js';
2
+ import { CommandDiscovery } from '../command.discovery';
3
+ export type ContextMenuMeta = (MessageApplicationCommandData | UserApplicationCommandData) & {
4
+ guilds?: Snowflake[];
5
+ };
6
+ export declare class ContextMenuDiscovery extends CommandDiscovery<ContextMenuMeta> {
7
+ getType(): import("discord.js").ApplicationCommandType.User | import("discord.js").ApplicationCommandType.Message;
8
+ isContextMenu(): this is ContextMenuDiscovery;
9
+ execute(interaction: ContextMenuCommandInteraction): any;
10
+ toJSON(): ContextMenuMeta;
11
+ }
@@ -1,19 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ContextMenuDiscovery = void 0;
4
- const command_discovery_1 = require("../command.discovery");
5
- class ContextMenuDiscovery extends command_discovery_1.CommandDiscovery {
6
- getType() {
7
- return this.meta.type;
8
- }
9
- isContextMenu() {
10
- return true;
11
- }
12
- execute(interaction) {
13
- return super.execute([interaction]);
14
- }
15
- toJSON() {
16
- return this.meta;
17
- }
18
- }
19
- exports.ContextMenuDiscovery = ContextMenuDiscovery;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContextMenuDiscovery = void 0;
4
+ const command_discovery_1 = require("../command.discovery");
5
+ class ContextMenuDiscovery extends command_discovery_1.CommandDiscovery {
6
+ getType() {
7
+ return this.meta.type;
8
+ }
9
+ isContextMenu() {
10
+ return true;
11
+ }
12
+ execute(interaction) {
13
+ return super.execute([interaction]);
14
+ }
15
+ toJSON() {
16
+ return this.meta;
17
+ }
18
+ }
19
+ exports.ContextMenuDiscovery = ContextMenuDiscovery;
@@ -1,18 +1,18 @@
1
- import { Client } from 'discord.js';
2
- import { OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
3
- import { ContextMenuDiscovery, ContextMenuMeta } from './context-menu.discovery';
4
- import { ExplorerService } from '../../necord-explorer.service';
5
- import { CommandDiscovery } from '../command.discovery';
6
- export declare class ContextMenusService implements OnModuleInit, OnApplicationBootstrap {
7
- private readonly client;
8
- private readonly explorerService;
9
- private readonly logger;
10
- private readonly contextMenus;
11
- constructor(client: Client, explorerService: ExplorerService<ContextMenuDiscovery>);
12
- onModuleInit(): void;
13
- onApplicationBootstrap(): Client<boolean>;
14
- getCommands(): CommandDiscovery[];
15
- add(contextMenu: ContextMenuDiscovery): void;
16
- remove(type: ContextMenuMeta['type'], name: ContextMenuMeta['name']): boolean;
17
- private getId;
18
- }
1
+ import { Client } from 'discord.js';
2
+ import { OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
3
+ import { ContextMenuDiscovery, ContextMenuMeta } from './context-menu.discovery';
4
+ import { ExplorerService } from '../../necord-explorer.service';
5
+ import { CommandDiscovery } from '../command.discovery';
6
+ export declare class ContextMenusService implements OnModuleInit, OnApplicationBootstrap {
7
+ private readonly client;
8
+ private readonly explorerService;
9
+ private readonly logger;
10
+ private readonly contextMenus;
11
+ constructor(client: Client, explorerService: ExplorerService<ContextMenuDiscovery>);
12
+ onModuleInit(): void;
13
+ onApplicationBootstrap(): Client<boolean>;
14
+ getCommands(): CommandDiscovery[];
15
+ add(contextMenu: ContextMenuDiscovery): void;
16
+ remove(type: ContextMenuMeta['type'], name: ContextMenuMeta['name']): boolean;
17
+ private getId;
18
+ }
@@ -1,61 +1,61 @@
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 ContextMenusService_1;
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.ContextMenusService = void 0;
14
- const discord_js_1 = require("discord.js");
15
- const common_1 = require("@nestjs/common");
16
- const necord_constants_1 = require("../../necord.constants");
17
- const necord_explorer_service_1 = require("../../necord-explorer.service");
18
- let ContextMenusService = ContextMenusService_1 = class ContextMenusService {
19
- constructor(client, explorerService) {
20
- this.client = client;
21
- this.explorerService = explorerService;
22
- this.logger = new common_1.Logger(ContextMenusService_1.name);
23
- this.contextMenus = new Map();
24
- }
25
- onModuleInit() {
26
- return this.explorerService
27
- .explore(necord_constants_1.CONTEXT_MENU_METADATA)
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.contextMenus
36
- .get(this.getId(interaction.commandType, interaction.commandName))) === null || _a === void 0 ? void 0 : _a.execute(interaction);
37
- });
38
- }
39
- getCommands() {
40
- return [...this.contextMenus.values()];
41
- }
42
- add(contextMenu) {
43
- const id = this.getId(contextMenu.getType(), contextMenu.getName());
44
- if (this.contextMenus.has(id)) {
45
- this.logger.warn(`ContextMenu with id : ${id} is already exists`);
46
- }
47
- this.contextMenus.set(id, contextMenu);
48
- }
49
- remove(type, name) {
50
- return this.contextMenus.delete(this.getId(type, name));
51
- }
52
- getId(type, name) {
53
- return type.toString().concat(':', name);
54
- }
55
- };
56
- ContextMenusService = ContextMenusService_1 = __decorate([
57
- (0, common_1.Injectable)(),
58
- __metadata("design:paramtypes", [discord_js_1.Client,
59
- necord_explorer_service_1.ExplorerService])
60
- ], ContextMenusService);
61
- exports.ContextMenusService = ContextMenusService;
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 ContextMenusService_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.ContextMenusService = void 0;
14
+ const discord_js_1 = require("discord.js");
15
+ const common_1 = require("@nestjs/common");
16
+ const necord_constants_1 = require("../../necord.constants");
17
+ const necord_explorer_service_1 = require("../../necord-explorer.service");
18
+ let ContextMenusService = ContextMenusService_1 = class ContextMenusService {
19
+ constructor(client, explorerService) {
20
+ this.client = client;
21
+ this.explorerService = explorerService;
22
+ this.logger = new common_1.Logger(ContextMenusService_1.name);
23
+ this.contextMenus = new Map();
24
+ }
25
+ onModuleInit() {
26
+ return this.explorerService
27
+ .explore(necord_constants_1.CONTEXT_MENU_METADATA)
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.contextMenus
36
+ .get(this.getId(interaction.commandType, interaction.commandName))) === null || _a === void 0 ? void 0 : _a.execute(interaction);
37
+ });
38
+ }
39
+ getCommands() {
40
+ return [...this.contextMenus.values()];
41
+ }
42
+ add(contextMenu) {
43
+ const id = this.getId(contextMenu.getType(), contextMenu.getName());
44
+ if (this.contextMenus.has(id)) {
45
+ this.logger.warn(`ContextMenu with id : ${id} is already exists`);
46
+ }
47
+ this.contextMenus.set(id, contextMenu);
48
+ }
49
+ remove(type, name) {
50
+ return this.contextMenus.delete(this.getId(type, name));
51
+ }
52
+ getId(type, name) {
53
+ return type.toString().concat(':', name);
54
+ }
55
+ };
56
+ ContextMenusService = ContextMenusService_1 = __decorate([
57
+ (0, common_1.Injectable)(),
58
+ __metadata("design:paramtypes", [discord_js_1.Client,
59
+ necord_explorer_service_1.ExplorerService])
60
+ ], ContextMenusService);
61
+ exports.ContextMenusService = ContextMenusService;
@@ -1,2 +1,2 @@
1
- import { ContextMenuMeta } from '../context-menu.discovery';
2
- export declare const ContextMenu: (options: ContextMenuMeta) => import("@nestjs/common").CustomDecorator<string>;
1
+ import { ContextMenuMeta } from '../context-menu.discovery';
2
+ export declare const ContextMenu: (options: ContextMenuMeta) => import("@nestjs/common").CustomDecorator<string>;
@@ -1,8 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ContextMenu = void 0;
4
- const context_menu_discovery_1 = require("../context-menu.discovery");
5
- const common_1 = require("@nestjs/common");
6
- const necord_constants_1 = require("../../../necord.constants");
7
- const ContextMenu = (options) => (0, common_1.SetMetadata)(necord_constants_1.CONTEXT_MENU_METADATA, new context_menu_discovery_1.ContextMenuDiscovery(options));
8
- exports.ContextMenu = ContextMenu;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContextMenu = void 0;
4
+ const context_menu_discovery_1 = require("../context-menu.discovery");
5
+ const common_1 = require("@nestjs/common");
6
+ const necord_constants_1 = require("../../../necord.constants");
7
+ const ContextMenu = (options) => (0, common_1.SetMetadata)(necord_constants_1.CONTEXT_MENU_METADATA, new context_menu_discovery_1.ContextMenuDiscovery(options));
8
+ exports.ContextMenu = ContextMenu;
@@ -1,4 +1,4 @@
1
- export * from './context-menu.decorator';
2
- export * from './message-command.decorator';
3
- export * from './user-command.decorator';
4
- export * from './target.decorator';
1
+ export * from './context-menu.decorator';
2
+ export * from './message-command.decorator';
3
+ export * from './user-command.decorator';
4
+ export * from './target.decorator';
@@ -1,20 +1,20 @@
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-menu.decorator"), exports);
18
- __exportStar(require("./message-command.decorator"), exports);
19
- __exportStar(require("./user-command.decorator"), exports);
20
- __exportStar(require("./target.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-menu.decorator"), exports);
18
+ __exportStar(require("./message-command.decorator"), exports);
19
+ __exportStar(require("./user-command.decorator"), exports);
20
+ __exportStar(require("./target.decorator"), exports);
@@ -1,2 +1,2 @@
1
- import { ContextMenuMeta } from '../context-menu.discovery';
2
- export declare const MessageCommand: (options: Omit<ContextMenuMeta, 'type'>) => import("@nestjs/common").CustomDecorator<string>;
1
+ import { ContextMenuMeta } from '../context-menu.discovery';
2
+ export declare const MessageCommand: (options: Omit<ContextMenuMeta, 'type'>) => import("@nestjs/common").CustomDecorator<string>;
@@ -1,7 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessageCommand = void 0;
4
- const discord_js_1 = require("discord.js");
5
- const context_menu_decorator_1 = require("./context-menu.decorator");
6
- const MessageCommand = (options) => (0, context_menu_decorator_1.ContextMenu)(Object.assign({ type: discord_js_1.ApplicationCommandType.Message }, options));
7
- exports.MessageCommand = MessageCommand;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessageCommand = void 0;
4
+ const discord_js_1 = require("discord.js");
5
+ const context_menu_decorator_1 = require("./context-menu.decorator");
6
+ const MessageCommand = (options) => (0, context_menu_decorator_1.ContextMenu)(Object.assign({ type: discord_js_1.ApplicationCommandType.Message }, options));
7
+ exports.MessageCommand = MessageCommand;