necord 6.13.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/command.discovery.d.ts +3 -3
- package/dist/commands/command.discovery.js +2 -6
- package/dist/commands/commands.module.d.ts +4 -4
- package/dist/commands/commands.module.js +23 -22
- package/dist/commands/commands.service.d.ts +8 -7
- package/dist/commands/commands.service.js +24 -18
- package/dist/commands/context-menus/context-menu.discovery.d.ts +3 -3
- package/dist/commands/context-menus/context-menu.discovery.js +2 -6
- package/dist/commands/context-menus/context-menus.module.d.ts +4 -4
- package/dist/commands/context-menus/context-menus.module.js +16 -19
- package/dist/commands/context-menus/context-menus.service.d.ts +2 -2
- package/dist/commands/context-menus/context-menus.service.js +8 -11
- package/dist/commands/context-menus/decorators/context-menu.decorator.d.ts +1 -1
- package/dist/commands/context-menus/decorators/context-menu.decorator.js +4 -7
- package/dist/commands/context-menus/decorators/index.d.ts +4 -4
- package/dist/commands/context-menus/decorators/index.js +4 -7
- package/dist/commands/context-menus/decorators/message-command.decorator.d.ts +2 -2
- package/dist/commands/context-menus/decorators/message-command.decorator.js +3 -7
- package/dist/commands/context-menus/decorators/target.decorator.js +8 -11
- package/dist/commands/context-menus/decorators/user-command.decorator.d.ts +2 -2
- package/dist/commands/context-menus/decorators/user-command.decorator.js +3 -7
- package/dist/commands/context-menus/index.d.ts +4 -4
- package/dist/commands/context-menus/index.js +4 -7
- package/dist/commands/index.d.ts +5 -5
- package/dist/commands/index.js +5 -8
- package/dist/commands/slash-commands/autocomplete/autocomplete.interceptor.d.ts +1 -1
- package/dist/commands/slash-commands/autocomplete/autocomplete.interceptor.js +9 -12
- package/dist/commands/slash-commands/autocomplete/index.d.ts +1 -1
- package/dist/commands/slash-commands/autocomplete/index.js +1 -4
- package/dist/commands/slash-commands/decorators/index.d.ts +3 -3
- package/dist/commands/slash-commands/decorators/index.js +3 -6
- package/dist/commands/slash-commands/decorators/slash-command.decorator.d.ts +2 -2
- package/dist/commands/slash-commands/decorators/slash-command.decorator.js +6 -9
- package/dist/commands/slash-commands/decorators/subcommand-group.decorator.d.ts +3 -3
- package/dist/commands/slash-commands/decorators/subcommand-group.decorator.js +13 -17
- package/dist/commands/slash-commands/decorators/subcommand.decorator.d.ts +2 -2
- package/dist/commands/slash-commands/decorators/subcommand.decorator.js +6 -9
- package/dist/commands/slash-commands/index.d.ts +6 -6
- package/dist/commands/slash-commands/index.js +6 -9
- package/dist/commands/slash-commands/options/attachment-option.decorator.js +3 -6
- package/dist/commands/slash-commands/options/boolean-option.decorator.js +3 -6
- package/dist/commands/slash-commands/options/channel-option.decorator.js +3 -6
- package/dist/commands/slash-commands/options/index.d.ts +12 -12
- package/dist/commands/slash-commands/options/index.js +12 -15
- package/dist/commands/slash-commands/options/integer-option.decorator.js +3 -6
- package/dist/commands/slash-commands/options/member-option.decorator.js +3 -6
- package/dist/commands/slash-commands/options/mentionable-option.decorator.js +3 -6
- package/dist/commands/slash-commands/options/number-option.decorator.js +3 -6
- package/dist/commands/slash-commands/options/option.util.d.ts +2 -2
- package/dist/commands/slash-commands/options/option.util.js +5 -10
- package/dist/commands/slash-commands/options/options.decorator.js +22 -14
- package/dist/commands/slash-commands/options/role-option.decorator.js +3 -6
- package/dist/commands/slash-commands/options/string-option.decorator.js +3 -6
- package/dist/commands/slash-commands/options/user-option.decorator.js +3 -6
- package/dist/commands/slash-commands/slash-command.discovery.d.ts +5 -34
- package/dist/commands/slash-commands/slash-command.discovery.js +7 -10
- package/dist/commands/slash-commands/slash-commands.module.d.ts +4 -4
- package/dist/commands/slash-commands/slash-commands.module.js +17 -20
- package/dist/commands/slash-commands/slash-commands.service.d.ts +3 -3
- package/dist/commands/slash-commands/slash-commands.service.js +16 -16
- package/dist/context/decorators/context.decorator.js +4 -7
- package/dist/context/decorators/discovery.decorator.js +3 -6
- package/dist/context/decorators/index.d.ts +2 -2
- package/dist/context/decorators/index.js +2 -5
- package/dist/context/decorators/params.util.d.ts +1 -1
- package/dist/context/decorators/params.util.js +8 -8
- package/dist/context/index.d.ts +7 -7
- package/dist/context/index.js +7 -10
- package/dist/context/necord-arguments-host.d.ts +3 -3
- package/dist/context/necord-arguments-host.js +2 -6
- package/dist/context/necord-base.discovery.d.ts +6 -6
- package/dist/context/necord-base.discovery.js +3 -7
- package/dist/context/necord-context.interface.d.ts +1 -1
- package/dist/context/necord-context.interface.js +1 -2
- package/dist/context/necord-execution-context.d.ts +1 -1
- package/dist/context/necord-execution-context.js +2 -6
- package/dist/context/necord-params.factory.d.ts +3 -3
- package/dist/context/necord-params.factory.js +4 -8
- package/dist/context/necord-paramtype.enum.js +2 -5
- package/dist/index.d.ts +12 -12
- package/dist/index.js +12 -15
- package/dist/listeners/decorators/custom-listener.decorator.js +3 -6
- package/dist/listeners/decorators/index.d.ts +4 -4
- package/dist/listeners/decorators/index.js +4 -7
- package/dist/listeners/decorators/listener.decorator.d.ts +1 -1
- package/dist/listeners/decorators/listener.decorator.js +4 -7
- package/dist/listeners/decorators/on.decorator.d.ts +2 -2
- package/dist/listeners/decorators/on.decorator.js +4 -8
- package/dist/listeners/decorators/once.decorator.d.ts +2 -2
- package/dist/listeners/decorators/once.decorator.js +4 -8
- package/dist/listeners/handlers/base.handler.d.ts +1 -1
- package/dist/listeners/handlers/base.handler.js +7 -11
- package/dist/listeners/handlers/channel-update.handler.d.ts +2 -2
- package/dist/listeners/handlers/channel-update.handler.js +14 -17
- package/dist/listeners/handlers/guild-audit-log-entry-create.handler.d.ts +2 -2
- package/dist/listeners/handlers/guild-audit-log-entry-create.handler.js +19 -22
- package/dist/listeners/handlers/guild-member-update.handler.d.ts +14 -6
- package/dist/listeners/handlers/guild-member-update.handler.js +46 -39
- package/dist/listeners/handlers/guild-update.handler.d.ts +8 -4
- package/dist/listeners/handlers/guild-update.handler.js +34 -37
- package/dist/listeners/handlers/index.d.ts +11 -11
- package/dist/listeners/handlers/index.js +11 -14
- package/dist/listeners/handlers/message-update.handler.d.ts +2 -2
- package/dist/listeners/handlers/message-update.handler.js +19 -22
- package/dist/listeners/handlers/presence-update.handler.d.ts +2 -2
- package/dist/listeners/handlers/presence-update.handler.js +15 -18
- package/dist/listeners/handlers/role-update.handler.d.ts +5 -5
- package/dist/listeners/handlers/role-update.handler.js +24 -27
- package/dist/listeners/handlers/thread-update.handler.d.ts +6 -6
- package/dist/listeners/handlers/thread-update.handler.js +34 -37
- package/dist/listeners/handlers/user-update.handler.d.ts +6 -6
- package/dist/listeners/handlers/user-update.handler.js +34 -37
- package/dist/listeners/handlers/voice-state-update.handler.d.ts +2 -2
- package/dist/listeners/handlers/voice-state-update.handler.js +47 -34
- package/dist/listeners/index.d.ts +6 -6
- package/dist/listeners/index.js +6 -9
- package/dist/listeners/listener.discovery.d.ts +2 -2
- package/dist/listeners/listener.discovery.js +2 -6
- package/dist/listeners/listener.interface.d.ts +1 -1
- package/dist/listeners/listener.interface.js +1 -2
- package/dist/listeners/listeners.module.d.ts +4 -4
- package/dist/listeners/listeners.module.js +28 -28
- package/dist/listeners/scopes/async-custom-listener.context.d.ts +1 -1
- package/dist/listeners/scopes/async-custom-listener.context.js +6 -10
- package/dist/listeners/scopes/index.d.ts +1 -1
- package/dist/listeners/scopes/index.js +1 -4
- package/dist/message-components/decorators/button.decorator.js +3 -7
- package/dist/message-components/decorators/component-param.decorator.js +4 -7
- package/dist/message-components/decorators/index.d.ts +5 -5
- package/dist/message-components/decorators/index.js +5 -8
- package/dist/message-components/decorators/message-component.decorator.d.ts +1 -1
- package/dist/message-components/decorators/message-component.decorator.js +4 -7
- package/dist/message-components/decorators/select-menu.decorator.js +7 -15
- package/dist/message-components/decorators/selected.decorator.js +17 -20
- package/dist/message-components/index.d.ts +4 -4
- package/dist/message-components/index.js +4 -7
- package/dist/message-components/message-component.discovery.d.ts +1 -1
- package/dist/message-components/message-component.discovery.js +4 -8
- package/dist/message-components/message-components.module.d.ts +4 -4
- package/dist/message-components/message-components.module.js +16 -19
- package/dist/message-components/message-components.service.d.ts +2 -2
- package/dist/message-components/message-components.service.js +8 -11
- package/dist/modals/decorators/fields.decorator.js +4 -7
- package/dist/modals/decorators/index.d.ts +3 -3
- package/dist/modals/decorators/index.js +3 -6
- package/dist/modals/decorators/modal-param.decorator.js +4 -7
- package/dist/modals/decorators/modal.decorator.d.ts +1 -1
- package/dist/modals/decorators/modal.decorator.js +4 -7
- package/dist/modals/index.d.ts +4 -4
- package/dist/modals/index.js +4 -7
- package/dist/modals/modal.discovery.d.ts +1 -1
- package/dist/modals/modal.discovery.js +4 -8
- package/dist/modals/modals.module.d.ts +4 -4
- package/dist/modals/modals.module.js +16 -19
- package/dist/modals/modals.service.d.ts +2 -2
- package/dist/modals/modals.service.js +8 -11
- package/dist/necord-context.creator.d.ts +1 -1
- package/dist/necord-context.creator.js +29 -24
- package/dist/necord-explorer.service.d.ts +2 -2
- package/dist/necord-explorer.service.js +28 -21
- package/dist/necord-options.interface.d.ts +4 -0
- package/dist/necord-options.interface.js +1 -2
- package/dist/necord.module-definition.d.ts +1 -1
- package/dist/necord.module-definition.js +3 -7
- package/dist/necord.module.d.ts +4 -4
- package/dist/necord.module.js +35 -38
- package/dist/providers/channels.provider.d.ts +1 -1
- package/dist/providers/channels.provider.js +4 -7
- package/dist/providers/client.provider.js +6 -9
- package/dist/providers/guilds.provider.d.ts +1 -1
- package/dist/providers/guilds.provider.js +4 -7
- package/dist/providers/index.d.ts +8 -8
- package/dist/providers/index.js +8 -11
- package/dist/providers/rest.provider.js +4 -7
- package/dist/providers/shard.provider.d.ts +2 -2
- package/dist/providers/shard.provider.js +4 -7
- package/dist/providers/users.provider.d.ts +1 -1
- package/dist/providers/users.provider.js +4 -7
- package/dist/providers/voice.provider.d.ts +1 -1
- package/dist/providers/voice.provider.js +4 -7
- package/dist/providers/ws.provider.d.ts +1 -1
- package/dist/providers/ws.provider.js +4 -7
- package/dist/scopes/async.context.d.ts +1 -1
- package/dist/scopes/async.context.js +10 -14
- package/dist/scopes/index.d.ts +1 -1
- package/dist/scopes/index.js +1 -4
- package/dist/text-commands/decorators/arguments.decorator.js +5 -8
- package/dist/text-commands/decorators/index.d.ts +2 -2
- package/dist/text-commands/decorators/index.js +2 -5
- package/dist/text-commands/decorators/text-command.decorator.d.ts +1 -1
- package/dist/text-commands/decorators/text-command.decorator.js +4 -7
- package/dist/text-commands/index.d.ts +4 -4
- package/dist/text-commands/index.js +4 -7
- package/dist/text-commands/text-command.discovery.d.ts +3 -1
- package/dist/text-commands/text-command.discovery.js +5 -6
- package/dist/text-commands/text-commands.module.d.ts +6 -6
- package/dist/text-commands/text-commands.module.js +29 -24
- package/dist/text-commands/text-commands.service.d.ts +2 -2
- package/dist/text-commands/text-commands.service.js +16 -12
- package/package.json +42 -33
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -1
- package/.prettierrc +0 -8
- package/.release-it.json +0 -74
- package/CHANGELOG.md +0 -461
- package/coverage/clover.xml +0 -1794
- package/coverage/coverage-final.json +0 -113
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -431
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov.info +0 -3295
- package/eslint.config.mjs +0 -53
- package/jest.config.json +0 -16
- package/tsconfig.json +0 -30
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseApplicationCommandData, Snowflake } from 'discord.js';
|
|
2
|
-
import { NecordBaseDiscovery } from '../context';
|
|
2
|
+
import { NecordBaseDiscovery } from '../context/index.js';
|
|
3
3
|
export interface BaseCommandMeta extends BaseApplicationCommandData {
|
|
4
4
|
guilds?: Snowflake[];
|
|
5
5
|
}
|
|
@@ -21,10 +21,10 @@ export declare abstract class CommandDiscovery<T extends BaseCommandMeta = BaseC
|
|
|
21
21
|
/**
|
|
22
22
|
* Checks if the command has a guild.
|
|
23
23
|
*/
|
|
24
|
-
hasGuild(guild: Snowflake): boolean;
|
|
24
|
+
hasGuild(guild: Snowflake): boolean | undefined;
|
|
25
25
|
isGlobal(): boolean;
|
|
26
26
|
/**
|
|
27
27
|
* Returns the guilds.
|
|
28
28
|
*/
|
|
29
|
-
getGuilds(): Snowflake[];
|
|
29
|
+
getGuilds(): Snowflake[] | undefined;
|
|
30
30
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommandDiscovery = void 0;
|
|
4
|
-
const context_1 = require("../context");
|
|
1
|
+
import { NecordBaseDiscovery } from '../context/index.js';
|
|
5
2
|
/**
|
|
6
3
|
* Represents a command discovery.
|
|
7
4
|
* @abstract
|
|
8
5
|
* @url https://necord.org/interactions/slash-commands
|
|
9
6
|
*/
|
|
10
|
-
class CommandDiscovery extends
|
|
7
|
+
export class CommandDiscovery extends NecordBaseDiscovery {
|
|
11
8
|
/**
|
|
12
9
|
* Returns the command name.
|
|
13
10
|
*/
|
|
@@ -37,4 +34,3 @@ class CommandDiscovery extends context_1.NecordBaseDiscovery {
|
|
|
37
34
|
return this.meta.guilds;
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
|
-
exports.CommandDiscovery = CommandDiscovery;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
|
|
2
|
-
import { CommandsService } from './commands.service';
|
|
3
2
|
import { Client } from 'discord.js';
|
|
4
|
-
import { NecordModuleOptions } from '../necord-options.interface';
|
|
5
|
-
|
|
3
|
+
import { NecordModuleOptions } from '../necord-options.interface.js';
|
|
4
|
+
import { CommandsService } from './commands.service.js';
|
|
5
|
+
export declare class CommandsModule implements OnApplicationBootstrap, OnModuleInit {
|
|
6
6
|
private readonly client;
|
|
7
7
|
private readonly options;
|
|
8
8
|
private readonly commandsService;
|
|
9
9
|
private readonly logger;
|
|
10
10
|
constructor(client: Client, options: NecordModuleOptions, commandsService: CommandsService);
|
|
11
|
-
onModuleInit(): Client<boolean
|
|
11
|
+
onModuleInit(): Client<boolean> | undefined;
|
|
12
12
|
onApplicationBootstrap(): void;
|
|
13
13
|
}
|
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var CommandsModule_1;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const discord_js_1 = require("discord.js");
|
|
11
|
-
const necord_module_definition_1 = require("../necord.module-definition");
|
|
2
|
+
import { __decorate, __metadata, __param } from "tslib";
|
|
3
|
+
import { Global, Inject, Logger, Module } from '@nestjs/common';
|
|
4
|
+
import { Client } from 'discord.js';
|
|
5
|
+
import { NECORD_MODULE_OPTIONS } from '../necord.module-definition.js';
|
|
6
|
+
import { SlashCommandsModule } from './slash-commands/index.js';
|
|
7
|
+
import { ContextMenusModule } from './context-menus/index.js';
|
|
8
|
+
import { CommandsService } from './commands.service.js';
|
|
12
9
|
let CommandsModule = CommandsModule_1 = class CommandsModule {
|
|
13
10
|
constructor(client, options, commandsService) {
|
|
14
11
|
this.client = client;
|
|
15
12
|
this.options = options;
|
|
16
13
|
this.commandsService = commandsService;
|
|
17
|
-
this.logger = new
|
|
14
|
+
this.logger = new Logger(CommandsModule_1.name);
|
|
18
15
|
}
|
|
19
16
|
onModuleInit() {
|
|
20
17
|
if (this.options.skipRegistration) {
|
|
21
18
|
return;
|
|
22
19
|
}
|
|
23
20
|
return this.client.once('clientReady', async () => {
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
const application = this.client.application;
|
|
22
|
+
if (!application) {
|
|
23
|
+
throw new Error('Discord client application is unavailable after clientReady.');
|
|
24
|
+
}
|
|
25
|
+
if (application.partial) {
|
|
26
|
+
await application.fetch();
|
|
26
27
|
}
|
|
27
28
|
return this.commandsService.registerAllCommands();
|
|
28
29
|
});
|
|
@@ -42,14 +43,14 @@ let CommandsModule = CommandsModule_1 = class CommandsModule {
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
exports: [context_menus_1.ContextMenusModule, slash_commands_1.SlashCommandsModule, commands_service_1.CommandsService]
|
|
46
|
+
CommandsModule = CommandsModule_1 = __decorate([
|
|
47
|
+
Global(),
|
|
48
|
+
Module({
|
|
49
|
+
imports: [ContextMenusModule, SlashCommandsModule],
|
|
50
|
+
providers: [CommandsService],
|
|
51
|
+
exports: [ContextMenusModule, SlashCommandsModule, CommandsService]
|
|
52
52
|
}),
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
__param(1, Inject(NECORD_MODULE_OPTIONS)),
|
|
54
|
+
__metadata("design:paramtypes", [Client, Object, CommandsService])
|
|
55
55
|
], CommandsModule);
|
|
56
|
+
export { CommandsModule };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Client, Collection } from 'discord.js';
|
|
2
|
-
import {
|
|
3
|
-
import { ContextMenusService } from './context-menus';
|
|
4
|
-
import {
|
|
2
|
+
import { SlashCommandsService } from './slash-commands/index.js';
|
|
3
|
+
import { ContextMenusService } from './context-menus/index.js';
|
|
4
|
+
import { CommandDiscovery } from './command.discovery.js';
|
|
5
5
|
/**
|
|
6
6
|
* Represents a service that manages commands.
|
|
7
7
|
* @url https://necord.org/interactions/slash-commands
|
|
@@ -19,7 +19,7 @@ export declare class CommandsService {
|
|
|
19
19
|
registerAllCommands(): Promise<void>;
|
|
20
20
|
registerGlobalCommands(): Promise<Collection<string, import("discord.js").ApplicationCommand<{
|
|
21
21
|
guild: import("discord.js").GuildResolvable;
|
|
22
|
-
}
|
|
22
|
+
}>> | undefined>;
|
|
23
23
|
/**
|
|
24
24
|
* Registers commands in a guild.
|
|
25
25
|
* @param guildId
|
|
@@ -28,9 +28,10 @@ export declare class CommandsService {
|
|
|
28
28
|
registerCommandsInGuild(guildId: string, commands: CommandDiscovery[]): Promise<Collection<string, import("discord.js").ApplicationCommand<{}>>>;
|
|
29
29
|
getCommands(): CommandDiscovery[];
|
|
30
30
|
getCommandsGroupedByGuilds(): Collection<string, CommandDiscovery[]>;
|
|
31
|
-
getCommandByName(name: string): CommandDiscovery;
|
|
31
|
+
getCommandByName(name: string): CommandDiscovery | undefined;
|
|
32
32
|
getGlobalCommands(): CommandDiscovery[];
|
|
33
|
-
getGlobalCommandByName(name: string): CommandDiscovery;
|
|
33
|
+
getGlobalCommandByName(name: string): CommandDiscovery | undefined;
|
|
34
34
|
getGuildCommands(guildId: string): CommandDiscovery[];
|
|
35
|
-
getGuildCommandByName(guildId: string, name: string): CommandDiscovery;
|
|
35
|
+
getGuildCommandByName(guildId: string, name: string): CommandDiscovery | undefined;
|
|
36
|
+
private getApplication;
|
|
36
37
|
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var CommandsService_1;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const context_menus_1 = require("./context-menus");
|
|
9
|
-
const slash_commands_1 = require("./slash-commands");
|
|
2
|
+
import { __decorate, __metadata } from "tslib";
|
|
3
|
+
import { Injectable, Logger } from '@nestjs/common';
|
|
4
|
+
import { Client, Collection } from 'discord.js';
|
|
5
|
+
import { SlashCommandsService } from './slash-commands/index.js';
|
|
6
|
+
import { ContextMenusService } from './context-menus/index.js';
|
|
10
7
|
/**
|
|
11
8
|
* Represents a service that manages commands.
|
|
12
9
|
* @url https://necord.org/interactions/slash-commands
|
|
@@ -16,7 +13,7 @@ let CommandsService = CommandsService_1 = class CommandsService {
|
|
|
16
13
|
this.client = client;
|
|
17
14
|
this.contextMenusService = contextMenusService;
|
|
18
15
|
this.slashCommandsService = slashCommandsService;
|
|
19
|
-
this.logger = new
|
|
16
|
+
this.logger = new Logger(CommandsService_1.name);
|
|
20
17
|
}
|
|
21
18
|
/**
|
|
22
19
|
* Registers all commands.
|
|
@@ -37,8 +34,9 @@ let CommandsService = CommandsService_1 = class CommandsService {
|
|
|
37
34
|
if (rawCommands.length === 0) {
|
|
38
35
|
return;
|
|
39
36
|
}
|
|
37
|
+
const application = this.getApplication();
|
|
40
38
|
this.logger.debug(`Registering ${rawCommands.length} global application commands...`);
|
|
41
|
-
return
|
|
39
|
+
return application.commands.set(rawCommands).catch(error => {
|
|
42
40
|
this.logger.error(`Failed to register application commands (global): ${error}`, error.stack);
|
|
43
41
|
throw error;
|
|
44
42
|
});
|
|
@@ -53,8 +51,9 @@ let CommandsService = CommandsService_1 = class CommandsService {
|
|
|
53
51
|
throw new TypeError('Guild ID is required to register guild commands.');
|
|
54
52
|
}
|
|
55
53
|
const rawCommands = commands.flatMap(command => command.toJSON());
|
|
54
|
+
const application = this.getApplication();
|
|
56
55
|
this.logger.debug(`Registering ${rawCommands.length} guild commands in ${guildId}`);
|
|
57
|
-
return
|
|
56
|
+
return application.commands.set(rawCommands, guildId).catch(error => {
|
|
58
57
|
this.logger.error(`Failed to register application commands (guild: ${guildId}): ${error}`, error.stack);
|
|
59
58
|
throw error;
|
|
60
59
|
});
|
|
@@ -66,7 +65,7 @@ let CommandsService = CommandsService_1 = class CommandsService {
|
|
|
66
65
|
].flat();
|
|
67
66
|
}
|
|
68
67
|
getCommandsGroupedByGuilds() {
|
|
69
|
-
const collection = new
|
|
68
|
+
const collection = new Collection();
|
|
70
69
|
const commands = this.getCommands();
|
|
71
70
|
for (const command of commands) {
|
|
72
71
|
const guilds = command.getGuilds();
|
|
@@ -95,11 +94,18 @@ let CommandsService = CommandsService_1 = class CommandsService {
|
|
|
95
94
|
getGuildCommandByName(guildId, name) {
|
|
96
95
|
return this.getGuildCommands(guildId).find(command => command.getName() === name);
|
|
97
96
|
}
|
|
97
|
+
getApplication() {
|
|
98
|
+
const application = this.client.application;
|
|
99
|
+
if (!application) {
|
|
100
|
+
throw new Error('Discord client application is unavailable while registering commands.');
|
|
101
|
+
}
|
|
102
|
+
return application;
|
|
103
|
+
}
|
|
98
104
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
slash_commands_1.SlashCommandsService])
|
|
105
|
+
CommandsService = CommandsService_1 = __decorate([
|
|
106
|
+
Injectable(),
|
|
107
|
+
__metadata("design:paramtypes", [Client,
|
|
108
|
+
ContextMenusService,
|
|
109
|
+
SlashCommandsService])
|
|
105
110
|
], CommandsService);
|
|
111
|
+
export { CommandsService };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ContextMenuCommandInteraction, MessageApplicationCommandData, Snowflake, UserApplicationCommandData } from 'discord.js';
|
|
2
|
-
import { CommandDiscovery } from '../command.discovery';
|
|
2
|
+
import { CommandDiscovery } from '../command.discovery.js';
|
|
3
3
|
/**
|
|
4
4
|
* The context menu metadata.
|
|
5
5
|
*/
|
|
6
|
-
export type ContextMenuMeta =
|
|
6
|
+
export type ContextMenuMeta = {
|
|
7
7
|
guilds?: Snowflake[];
|
|
8
|
-
};
|
|
8
|
+
} & (MessageApplicationCommandData | UserApplicationCommandData);
|
|
9
9
|
/**
|
|
10
10
|
* The context menu discovery.
|
|
11
11
|
* @see CommandDiscovery
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ContextMenuDiscovery = void 0;
|
|
4
|
-
const command_discovery_1 = require("../command.discovery");
|
|
1
|
+
import { CommandDiscovery } from '../command.discovery.js';
|
|
5
2
|
/**
|
|
6
3
|
* The context menu discovery.
|
|
7
4
|
* @see CommandDiscovery
|
|
8
5
|
* @see ContextMenuMeta
|
|
9
6
|
*/
|
|
10
|
-
class ContextMenuDiscovery extends
|
|
7
|
+
export class ContextMenuDiscovery extends CommandDiscovery {
|
|
11
8
|
/**
|
|
12
9
|
* Gets the discovery type.
|
|
13
10
|
*/
|
|
@@ -34,4 +31,3 @@ class ContextMenuDiscovery extends command_discovery_1.CommandDiscovery {
|
|
|
34
31
|
return this.meta;
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
|
-
exports.ContextMenuDiscovery = ContextMenuDiscovery;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { OnApplicationBootstrap, OnModuleInit } from '@nestjs/common';
|
|
2
|
-
import { ContextMenusService } from './context-menus.service';
|
|
3
|
-
import { NecordExplorerService } from '../../necord-explorer.service';
|
|
4
|
-
import { ContextMenuDiscovery } from './context-menu.discovery';
|
|
5
2
|
import { Client } from 'discord.js';
|
|
6
|
-
|
|
3
|
+
import { NecordExplorerService } from '../../necord-explorer.service.js';
|
|
4
|
+
import { ContextMenuDiscovery } from './context-menu.discovery.js';
|
|
5
|
+
import { ContextMenusService } from './context-menus.service.js';
|
|
6
|
+
export declare class ContextMenusModule implements OnApplicationBootstrap, OnModuleInit {
|
|
7
7
|
private readonly client;
|
|
8
8
|
private readonly explorerService;
|
|
9
9
|
private readonly contextMenusService;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const necord_explorer_service_1 = require("../../necord-explorer.service");
|
|
8
|
-
const discord_js_1 = require("discord.js");
|
|
9
|
-
const decorators_1 = require("./decorators");
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { Global, Module } from '@nestjs/common';
|
|
3
|
+
import { Client } from 'discord.js';
|
|
4
|
+
import { NecordExplorerService } from '../../necord-explorer.service.js';
|
|
5
|
+
import { ContextMenusService } from './context-menus.service.js';
|
|
6
|
+
import { ContextMenu } from './decorators/index.js';
|
|
10
7
|
let ContextMenusModule = class ContextMenusModule {
|
|
11
8
|
constructor(client, explorerService, contextMenusService) {
|
|
12
9
|
this.client = client;
|
|
@@ -15,7 +12,7 @@ let ContextMenusModule = class ContextMenusModule {
|
|
|
15
12
|
}
|
|
16
13
|
onModuleInit() {
|
|
17
14
|
return this.explorerService
|
|
18
|
-
.explore(
|
|
15
|
+
.explore(ContextMenu.KEY)
|
|
19
16
|
.forEach(contextMenu => this.contextMenusService.add(contextMenu));
|
|
20
17
|
}
|
|
21
18
|
onApplicationBootstrap() {
|
|
@@ -28,14 +25,14 @@ let ContextMenusModule = class ContextMenusModule {
|
|
|
28
25
|
});
|
|
29
26
|
}
|
|
30
27
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
exports: [context_menus_service_1.ContextMenusService]
|
|
28
|
+
ContextMenusModule = __decorate([
|
|
29
|
+
Global(),
|
|
30
|
+
Module({
|
|
31
|
+
providers: [ContextMenusService],
|
|
32
|
+
exports: [ContextMenusService]
|
|
37
33
|
}),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
__metadata("design:paramtypes", [Client,
|
|
35
|
+
NecordExplorerService,
|
|
36
|
+
ContextMenusService])
|
|
41
37
|
], ContextMenusModule);
|
|
38
|
+
export { ContextMenusModule };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Collection } from 'discord.js';
|
|
2
|
-
import { ContextMenuDiscovery, ContextMenuMeta } from './context-menu.discovery';
|
|
2
|
+
import { ContextMenuDiscovery, ContextMenuMeta } from './context-menu.discovery.js';
|
|
3
3
|
/**
|
|
4
4
|
* Service that manages context menus.
|
|
5
5
|
* @see ContextMenuDiscovery
|
|
@@ -12,7 +12,7 @@ export declare class ContextMenusService {
|
|
|
12
12
|
private readonly logger;
|
|
13
13
|
readonly cache: Collection<string, ContextMenuDiscovery>;
|
|
14
14
|
add(contextMenu: ContextMenuDiscovery): void;
|
|
15
|
-
get(type: ContextMenuMeta['type'], name: ContextMenuMeta['name']): ContextMenuDiscovery;
|
|
15
|
+
get(type: ContextMenuMeta['type'], name: ContextMenuMeta['name']): ContextMenuDiscovery | undefined;
|
|
16
16
|
remove(type: ContextMenuMeta['type'], name: ContextMenuMeta['name']): boolean;
|
|
17
17
|
private getId;
|
|
18
18
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var ContextMenusService_1;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const discord_js_1 = require("discord.js");
|
|
7
|
-
const common_1 = require("@nestjs/common");
|
|
2
|
+
import { __decorate } from "tslib";
|
|
3
|
+
import { Injectable, Logger } from '@nestjs/common';
|
|
4
|
+
import { Collection } from 'discord.js';
|
|
8
5
|
/**
|
|
9
6
|
* Service that manages context menus.
|
|
10
7
|
* @see ContextMenuDiscovery
|
|
@@ -15,8 +12,8 @@ const common_1 = require("@nestjs/common");
|
|
|
15
12
|
*/
|
|
16
13
|
let ContextMenusService = ContextMenusService_1 = class ContextMenusService {
|
|
17
14
|
constructor() {
|
|
18
|
-
this.logger = new
|
|
19
|
-
this.cache = new
|
|
15
|
+
this.logger = new Logger(ContextMenusService_1.name);
|
|
16
|
+
this.cache = new Collection();
|
|
20
17
|
}
|
|
21
18
|
add(contextMenu) {
|
|
22
19
|
const id = this.getId(contextMenu.getType(), contextMenu.getName());
|
|
@@ -35,7 +32,7 @@ let ContextMenusService = ContextMenusService_1 = class ContextMenusService {
|
|
|
35
32
|
return type.toString().concat(':', name);
|
|
36
33
|
}
|
|
37
34
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
(0, common_1.Injectable)()
|
|
35
|
+
ContextMenusService = ContextMenusService_1 = __decorate([
|
|
36
|
+
Injectable()
|
|
41
37
|
], ContextMenusService);
|
|
38
|
+
export { ContextMenusService };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContextMenuDiscovery, ContextMenuMeta } from '../context-menu.discovery';
|
|
1
|
+
import { ContextMenuDiscovery, ContextMenuMeta } from '../context-menu.discovery.js';
|
|
2
2
|
/**
|
|
3
3
|
* Decorator that marks a method as a context menu.
|
|
4
4
|
* @param options The context menu options.
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ContextMenu = void 0;
|
|
4
|
-
const context_menu_discovery_1 = require("../context-menu.discovery");
|
|
5
|
-
const core_1 = require("@nestjs/core");
|
|
1
|
+
import { Reflector } from '@nestjs/core';
|
|
2
|
+
import { ContextMenuDiscovery } from '../context-menu.discovery.js';
|
|
6
3
|
/**
|
|
7
4
|
* Decorator that marks a method as a context menu.
|
|
8
5
|
* @param options The context menu options.
|
|
@@ -13,6 +10,6 @@ const core_1 = require("@nestjs/core");
|
|
|
13
10
|
* @see UserCommand
|
|
14
11
|
* @url https://necord.org/interactions/context-menus
|
|
15
12
|
*/
|
|
16
|
-
|
|
17
|
-
transform: options => new
|
|
13
|
+
export const ContextMenu = Reflector.createDecorator({
|
|
14
|
+
transform: options => new ContextMenuDiscovery(options)
|
|
18
15
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './context-menu.decorator';
|
|
2
|
-
export * from './message-command.decorator';
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
1
|
+
export * from './context-menu.decorator.js';
|
|
2
|
+
export * from './message-command.decorator.js';
|
|
3
|
+
export * from './target.decorator.js';
|
|
4
|
+
export * from './user-command.decorator.js';
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
tslib_1.__exportStar(require("./message-command.decorator"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./user-command.decorator"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./target.decorator"), exports);
|
|
1
|
+
export * from './context-menu.decorator.js';
|
|
2
|
+
export * from './message-command.decorator.js';
|
|
3
|
+
export * from './target.decorator.js';
|
|
4
|
+
export * from './user-command.decorator.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContextMenuMeta } from '../context-menu.discovery';
|
|
1
|
+
import { ContextMenuMeta } from '../context-menu.discovery.js';
|
|
2
2
|
/**
|
|
3
3
|
* Decorator that marks a method as a message context menu.
|
|
4
4
|
* @param options The context menu options.
|
|
@@ -15,4 +15,4 @@ import { ContextMenuMeta } from '../context-menu.discovery';
|
|
|
15
15
|
* }
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
-
export declare const MessageCommand: (options: Omit<ContextMenuMeta,
|
|
18
|
+
export declare const MessageCommand: (options: Omit<ContextMenuMeta, 'type'>) => import("@nestjs/common").CustomDecorator;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.MessageCommand = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const context_menu_decorator_1 = require("./context-menu.decorator");
|
|
1
|
+
import { ApplicationCommandType } from 'discord.js';
|
|
2
|
+
import { ContextMenu } from './context-menu.decorator.js';
|
|
6
3
|
/**
|
|
7
4
|
* Decorator that marks a method as a message context menu.
|
|
8
5
|
* @param options The context menu options.
|
|
@@ -19,5 +16,4 @@ const context_menu_decorator_1 = require("./context-menu.decorator");
|
|
|
19
16
|
* }
|
|
20
17
|
* ```
|
|
21
18
|
*/
|
|
22
|
-
const MessageCommand = (options) =>
|
|
23
|
-
exports.MessageCommand = MessageCommand;
|
|
19
|
+
export const MessageCommand = (options) => ContextMenu({ type: ApplicationCommandType.Message, ...options });
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.TargetMember = exports.TargetUser = exports.TargetMessage = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const context_1 = require("../../../context");
|
|
1
|
+
import { createParamDecorator } from '@nestjs/common';
|
|
2
|
+
import { NecordExecutionContext } from '../../../context/index.js';
|
|
6
3
|
/**
|
|
7
4
|
* Decorator that injects the target message of a message context menu command.
|
|
8
5
|
* @see TargetUser
|
|
@@ -17,8 +14,8 @@ const context_1 = require("../../../context");
|
|
|
17
14
|
* }
|
|
18
15
|
* ```
|
|
19
16
|
*/
|
|
20
|
-
|
|
21
|
-
const necordContext =
|
|
17
|
+
export const TargetMessage = createParamDecorator((_, context) => {
|
|
18
|
+
const necordContext = NecordExecutionContext.create(context);
|
|
22
19
|
const [interaction] = necordContext.getContext();
|
|
23
20
|
if (!interaction.isMessageContextMenuCommand())
|
|
24
21
|
return null;
|
|
@@ -38,8 +35,8 @@ exports.TargetMessage = (0, common_1.createParamDecorator)((_, context) => {
|
|
|
38
35
|
* }
|
|
39
36
|
* ```
|
|
40
37
|
*/
|
|
41
|
-
|
|
42
|
-
const necordContext =
|
|
38
|
+
export const TargetUser = createParamDecorator((_, context) => {
|
|
39
|
+
const necordContext = NecordExecutionContext.create(context);
|
|
43
40
|
const [interaction] = necordContext.getContext();
|
|
44
41
|
if (!interaction.isUserContextMenuCommand())
|
|
45
42
|
return null;
|
|
@@ -59,8 +56,8 @@ exports.TargetUser = (0, common_1.createParamDecorator)((_, context) => {
|
|
|
59
56
|
* }
|
|
60
57
|
* ```
|
|
61
58
|
*/
|
|
62
|
-
|
|
63
|
-
const necordContext =
|
|
59
|
+
export const TargetMember = createParamDecorator((_, context) => {
|
|
60
|
+
const necordContext = NecordExecutionContext.create(context);
|
|
64
61
|
const [interaction] = necordContext.getContext();
|
|
65
62
|
if (!interaction.isUserContextMenuCommand())
|
|
66
63
|
return null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContextMenuMeta } from '../context-menu.discovery';
|
|
1
|
+
import { ContextMenuMeta } from '../context-menu.discovery.js';
|
|
2
2
|
/**
|
|
3
3
|
* Decorator that marks a method as a user context menu.
|
|
4
4
|
* @param options The context menu options.
|
|
@@ -16,4 +16,4 @@ import { ContextMenuMeta } from '../context-menu.discovery';
|
|
|
16
16
|
* }
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
export declare const UserCommand: (options: Omit<ContextMenuMeta,
|
|
19
|
+
export declare const UserCommand: (options: Omit<ContextMenuMeta, 'type'>) => import("@nestjs/common").CustomDecorator;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.UserCommand = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const context_menu_decorator_1 = require("./context-menu.decorator");
|
|
1
|
+
import { ApplicationCommandType } from 'discord.js';
|
|
2
|
+
import { ContextMenu } from './context-menu.decorator.js';
|
|
6
3
|
/**
|
|
7
4
|
* Decorator that marks a method as a user context menu.
|
|
8
5
|
* @param options The context menu options.
|
|
@@ -20,5 +17,4 @@ const context_menu_decorator_1 = require("./context-menu.decorator");
|
|
|
20
17
|
* }
|
|
21
18
|
* ```
|
|
22
19
|
*/
|
|
23
|
-
const UserCommand = (options) =>
|
|
24
|
-
exports.UserCommand = UserCommand;
|
|
20
|
+
export const UserCommand = (options) => ContextMenu({ type: ApplicationCommandType.User, ...options });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './context-
|
|
3
|
-
export * from './context-menus.
|
|
4
|
-
export * from './
|
|
1
|
+
export * from './context-menu.discovery.js';
|
|
2
|
+
export * from './context-menus.module.js';
|
|
3
|
+
export * from './context-menus.service.js';
|
|
4
|
+
export * from './decorators/index.js';
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
tslib_1.__exportStar(require("./context-menu.discovery"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./context-menus.module"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./context-menus.service"), exports);
|
|
1
|
+
export * from './context-menu.discovery.js';
|
|
2
|
+
export * from './context-menus.module.js';
|
|
3
|
+
export * from './context-menus.service.js';
|
|
4
|
+
export * from './decorators/index.js';
|
package/dist/commands/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './commands.
|
|
1
|
+
export * from './command.discovery.js';
|
|
2
|
+
export * from './commands.module.js';
|
|
3
|
+
export * from './commands.service.js';
|
|
4
|
+
export * from './context-menus/index.js';
|
|
5
|
+
export * from './slash-commands/index.js';
|
package/dist/commands/index.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
tslib_1.__exportStar(require("./command.discovery"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./commands.module"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./commands.service"), exports);
|
|
1
|
+
export * from './command.discovery.js';
|
|
2
|
+
export * from './commands.module.js';
|
|
3
|
+
export * from './commands.service.js';
|
|
4
|
+
export * from './context-menus/index.js';
|
|
5
|
+
export * from './slash-commands/index.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
2
|
import { AutocompleteInteraction } from 'discord.js';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
4
|
/**
|
|
5
5
|
* The autocomplete interceptor.
|
|
6
6
|
* @see AutocompleteContext
|