necord 6.14.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 +3 -3
- 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 +1 -1
- package/dist/commands/context-menus/context-menu.discovery.js +2 -6
- package/dist/commands/context-menus/context-menus.module.d.ts +3 -3
- 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.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 +3 -32
- package/dist/commands/slash-commands/slash-command.discovery.js +7 -10
- package/dist/commands/slash-commands/slash-commands.module.d.ts +3 -3
- package/dist/commands/slash-commands/slash-commands.module.js +17 -20
- package/dist/commands/slash-commands/slash-commands.service.d.ts +2 -2
- 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 +2 -2
- package/dist/listeners/listeners.module.js +28 -28
- 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 +3 -3
- 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 +3 -3
- 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.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 +3 -3
- package/dist/necord.module.js +35 -38
- package/dist/providers/channels.provider.js +4 -7
- package/dist/providers/client.provider.js +6 -9
- 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 +1 -1
- package/dist/providers/shard.provider.js +4 -7
- package/dist/providers/users.provider.js +4 -7
- package/dist/providers/voice.provider.js +4 -7
- 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 +1 -1
- package/dist/text-commands/text-command.discovery.js +2 -6
- package/dist/text-commands/text-commands.module.d.ts +4 -4
- package/dist/text-commands/text-commands.module.js +19 -22
- package/dist/text-commands/text-commands.service.d.ts +2 -2
- package/dist/text-commands/text-commands.service.js +8 -11
- package/package.json +41 -32
- 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 -478
- package/coverage/clover.xml +0 -1805
- 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 -3316
- package/eslint.config.mjs +0 -94
- package/jest.config.json +0 -16
- package/tsconfig.json +0 -27
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
const rxjs_1 = require("rxjs");
|
|
7
|
-
const context_1 = require("../../../context");
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { Injectable } from '@nestjs/common';
|
|
3
|
+
import { of } from 'rxjs';
|
|
4
|
+
import { NecordExecutionContext } from '../../../context/index.js';
|
|
8
5
|
/**
|
|
9
6
|
* The autocomplete interceptor.
|
|
10
7
|
* @see AutocompleteContext
|
|
@@ -13,15 +10,15 @@ const context_1 = require("../../../context");
|
|
|
13
10
|
*/
|
|
14
11
|
let AutocompleteInterceptor = class AutocompleteInterceptor {
|
|
15
12
|
async intercept(context, next) {
|
|
16
|
-
const necordContext =
|
|
13
|
+
const necordContext = NecordExecutionContext.create(context);
|
|
17
14
|
const [interaction] = necordContext.getContext();
|
|
18
15
|
const discovery = necordContext.getDiscovery();
|
|
19
16
|
if (!interaction.isAutocomplete() || !discovery.isSlashCommand())
|
|
20
17
|
return next.handle();
|
|
21
|
-
return
|
|
18
|
+
return of(this.transformOptions(interaction));
|
|
22
19
|
}
|
|
23
20
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
(0, common_1.Injectable)()
|
|
21
|
+
AutocompleteInterceptor = __decorate([
|
|
22
|
+
Injectable()
|
|
27
23
|
], AutocompleteInterceptor);
|
|
24
|
+
export { AutocompleteInterceptor };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './autocomplete.interceptor';
|
|
1
|
+
export * from './autocomplete.interceptor.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './slash-command.decorator';
|
|
2
|
-
export * from './subcommand-group.decorator';
|
|
3
|
-
export * from './subcommand.decorator';
|
|
1
|
+
export * from './slash-command.decorator.js';
|
|
2
|
+
export * from './subcommand-group.decorator.js';
|
|
3
|
+
export * from './subcommand.decorator.js';
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
tslib_1.__exportStar(require("./slash-command.decorator"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./subcommand-group.decorator"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./subcommand.decorator"), exports);
|
|
1
|
+
export * from './slash-command.decorator.js';
|
|
2
|
+
export * from './subcommand-group.decorator.js';
|
|
3
|
+
export * from './subcommand.decorator.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RootCommandMeta, SlashCommandDiscovery } from '../slash-command.discovery';
|
|
1
|
+
import { RootCommandMeta, SlashCommandDiscovery } from '../slash-command.discovery.js';
|
|
2
2
|
/**
|
|
3
3
|
* Decorator that marks a method as a slash command.
|
|
4
4
|
* @param options The slash command options.
|
|
@@ -8,4 +8,4 @@ import { RootCommandMeta, SlashCommandDiscovery } from '../slash-command.discove
|
|
|
8
8
|
* @url https://necord.org/interactions/slash-commands
|
|
9
9
|
*
|
|
10
10
|
*/
|
|
11
|
-
export declare const SlashCommand: import("@nestjs/core").ReflectableDecorator<Omit<RootCommandMeta, "
|
|
11
|
+
export declare const SlashCommand: import("@nestjs/core").ReflectableDecorator<Omit<RootCommandMeta, "options" | "type">, SlashCommandDiscovery>;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const core_1 = require("@nestjs/core");
|
|
6
|
-
const slash_command_discovery_1 = require("../slash-command.discovery");
|
|
1
|
+
import { ApplicationCommandType } from 'discord.js';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
import { SlashCommandDiscovery } from '../slash-command.discovery.js';
|
|
7
4
|
/**
|
|
8
5
|
* Decorator that marks a method as a slash command.
|
|
9
6
|
* @param options The slash command options.
|
|
@@ -13,9 +10,9 @@ const slash_command_discovery_1 = require("../slash-command.discovery");
|
|
|
13
10
|
* @url https://necord.org/interactions/slash-commands
|
|
14
11
|
*
|
|
15
12
|
*/
|
|
16
|
-
|
|
17
|
-
transform: options => new
|
|
18
|
-
type:
|
|
13
|
+
export const SlashCommand = Reflector.createDecorator({
|
|
14
|
+
transform: options => new SlashCommandDiscovery({
|
|
15
|
+
type: ApplicationCommandType.ChatInput,
|
|
19
16
|
...options
|
|
20
17
|
})
|
|
21
18
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RootCommandMeta, SlashCommandDiscovery, SubcommandGroupMeta } from '../slash-command.discovery';
|
|
1
|
+
import { RootCommandMeta, SlashCommandDiscovery, SubcommandGroupMeta } from '../slash-command.discovery.js';
|
|
2
2
|
/**
|
|
3
3
|
* Decorator that marks a method as a subcommand.
|
|
4
4
|
* @param options The subcommand options.
|
|
@@ -6,7 +6,7 @@ import { RootCommandMeta, SlashCommandDiscovery, SubcommandGroupMeta } from '../
|
|
|
6
6
|
* @see SlashCommandDiscovery
|
|
7
7
|
* @url https://necord.org/interactions/slash-commands#groups
|
|
8
8
|
*/
|
|
9
|
-
export declare const SubcommandGroup: import("@nestjs/core").ReflectableDecorator<Omit<import("discord.js").ApplicationCommandSubGroupData, "
|
|
9
|
+
export declare const SubcommandGroup: import("@nestjs/core").ReflectableDecorator<Omit<import("discord.js").ApplicationCommandSubGroupData, "options" | "type">, SlashCommandDiscovery>;
|
|
10
10
|
/**
|
|
11
11
|
* Factory that creates a decorator that marks a class as a slash command group.
|
|
12
12
|
* @param rootOptions
|
|
@@ -15,4 +15,4 @@ export declare const SubcommandGroup: import("@nestjs/core").ReflectableDecorato
|
|
|
15
15
|
* @see SubcommandGroup
|
|
16
16
|
* @url https://necord.org/interactions/slash-commands#groups
|
|
17
17
|
*/
|
|
18
|
-
export declare const createCommandGroupDecorator: (rootOptions: Omit<RootCommandMeta,
|
|
18
|
+
export declare const createCommandGroupDecorator: (rootOptions: Omit<RootCommandMeta, 'type'>) => (subOptions?: Omit<SubcommandGroupMeta, 'type' | 'options'>) => ClassDecorator;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const rxjs_1 = require("rxjs");
|
|
8
|
-
const slash_command_discovery_1 = require("../slash-command.discovery");
|
|
9
|
-
const slash_command_decorator_1 = require("./slash-command.decorator");
|
|
1
|
+
import { ApplicationCommandOptionType } from 'discord.js';
|
|
2
|
+
import { applyDecorators } from '@nestjs/common';
|
|
3
|
+
import { Reflector } from '@nestjs/core';
|
|
4
|
+
import { noop } from 'rxjs';
|
|
5
|
+
import { SlashCommandDiscovery } from '../slash-command.discovery.js';
|
|
6
|
+
import { SlashCommand } from './slash-command.decorator.js';
|
|
10
7
|
/**
|
|
11
8
|
* Decorator that marks a method as a subcommand.
|
|
12
9
|
* @param options The subcommand options.
|
|
@@ -14,9 +11,9 @@ const slash_command_decorator_1 = require("./slash-command.decorator");
|
|
|
14
11
|
* @see SlashCommandDiscovery
|
|
15
12
|
* @url https://necord.org/interactions/slash-commands#groups
|
|
16
13
|
*/
|
|
17
|
-
|
|
18
|
-
transform: options => new
|
|
19
|
-
type:
|
|
14
|
+
export const SubcommandGroup = Reflector.createDecorator({
|
|
15
|
+
transform: options => new SlashCommandDiscovery({
|
|
16
|
+
type: ApplicationCommandOptionType.SubcommandGroup,
|
|
20
17
|
options: [],
|
|
21
18
|
...options
|
|
22
19
|
})
|
|
@@ -29,11 +26,10 @@ exports.SubcommandGroup = core_1.Reflector.createDecorator({
|
|
|
29
26
|
* @see SubcommandGroup
|
|
30
27
|
* @url https://necord.org/interactions/slash-commands#groups
|
|
31
28
|
*/
|
|
32
|
-
const createCommandGroupDecorator = (rootOptions) => {
|
|
33
|
-
const rootCommand =
|
|
29
|
+
export const createCommandGroupDecorator = (rootOptions) => {
|
|
30
|
+
const rootCommand = SlashCommand(rootOptions);
|
|
34
31
|
return (subOptions) => {
|
|
35
|
-
const subCommandGroup = subOptions ?
|
|
36
|
-
return
|
|
32
|
+
const subCommandGroup = subOptions ? SubcommandGroup(subOptions) : noop;
|
|
33
|
+
return applyDecorators(rootCommand, subCommandGroup);
|
|
37
34
|
};
|
|
38
35
|
};
|
|
39
|
-
exports.createCommandGroupDecorator = createCommandGroupDecorator;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SlashCommandDiscovery } from '../slash-command.discovery';
|
|
1
|
+
import { SlashCommandDiscovery } from '../slash-command.discovery.js';
|
|
2
2
|
/**
|
|
3
3
|
* Decorator that marks a method as a subcommand.
|
|
4
4
|
* @param options The subcommand options.
|
|
@@ -6,4 +6,4 @@ import { SlashCommandDiscovery } from '../slash-command.discovery';
|
|
|
6
6
|
* @see SlashCommandDiscovery
|
|
7
7
|
* @url https://necord.org/interactions/slash-commands#groups
|
|
8
8
|
*/
|
|
9
|
-
export declare const Subcommand: import("@nestjs/core").ReflectableDecorator<Omit<import("discord.js").ApplicationCommandSubCommandData, "
|
|
9
|
+
export declare const Subcommand: import("@nestjs/core").ReflectableDecorator<Omit<import("discord.js").ApplicationCommandSubCommandData, "autocomplete" | "options" | "type">, SlashCommandDiscovery>;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const core_1 = require("@nestjs/core");
|
|
6
|
-
const slash_command_discovery_1 = require("../slash-command.discovery");
|
|
1
|
+
import { ApplicationCommandOptionType } from 'discord.js';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
import { SlashCommandDiscovery } from '../slash-command.discovery.js';
|
|
7
4
|
/**
|
|
8
5
|
* Decorator that marks a method as a subcommand.
|
|
9
6
|
* @param options The subcommand options.
|
|
@@ -11,9 +8,9 @@ const slash_command_discovery_1 = require("../slash-command.discovery");
|
|
|
11
8
|
* @see SlashCommandDiscovery
|
|
12
9
|
* @url https://necord.org/interactions/slash-commands#groups
|
|
13
10
|
*/
|
|
14
|
-
|
|
15
|
-
transform: options => new
|
|
16
|
-
type:
|
|
11
|
+
export const Subcommand = Reflector.createDecorator({
|
|
12
|
+
transform: options => new SlashCommandDiscovery({
|
|
13
|
+
type: ApplicationCommandOptionType.Subcommand,
|
|
17
14
|
...options
|
|
18
15
|
})
|
|
19
16
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './autocomplete';
|
|
2
|
-
export * from './decorators';
|
|
3
|
-
export * from './options';
|
|
4
|
-
export * from './slash-command.discovery';
|
|
5
|
-
export * from './slash-commands.module';
|
|
6
|
-
export * from './slash-commands.service';
|
|
1
|
+
export * from './autocomplete/index.js';
|
|
2
|
+
export * from './decorators/index.js';
|
|
3
|
+
export * from './options/index.js';
|
|
4
|
+
export * from './slash-command.discovery.js';
|
|
5
|
+
export * from './slash-commands.module.js';
|
|
6
|
+
export * from './slash-commands.service.js';
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
tslib_1.__exportStar(require("./slash-command.discovery"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./slash-commands.module"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./slash-commands.service"), exports);
|
|
1
|
+
export * from './autocomplete/index.js';
|
|
2
|
+
export * from './decorators/index.js';
|
|
3
|
+
export * from './options/index.js';
|
|
4
|
+
export * from './slash-command.discovery.js';
|
|
5
|
+
export * from './slash-commands.module.js';
|
|
6
|
+
export * from './slash-commands.service.js';
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.AttachmentOption = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const option_util_1 = require("./option.util");
|
|
1
|
+
import { ApplicationCommandOptionType } from 'discord.js';
|
|
2
|
+
import { createOptionDecorator } from './option.util.js';
|
|
6
3
|
/**
|
|
7
4
|
* Param decorator that marks a method as an attachment option.
|
|
8
5
|
* @param options The attachment options.
|
|
9
6
|
* @returns The decorated method.
|
|
10
7
|
* @url https://necord.org/interactions/slash-commands#options
|
|
11
8
|
*/
|
|
12
|
-
|
|
9
|
+
export const AttachmentOption = createOptionDecorator(ApplicationCommandOptionType.Attachment, 'getAttachment');
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.BooleanOption = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const option_util_1 = require("./option.util");
|
|
1
|
+
import { ApplicationCommandOptionType } from 'discord.js';
|
|
2
|
+
import { createOptionDecorator } from './option.util.js';
|
|
6
3
|
/**
|
|
7
4
|
* Param decorator that marks a method as a boolean option.
|
|
8
5
|
* @param options The boolean options.
|
|
9
6
|
* @returns The decorated method.
|
|
10
7
|
* @url https://necord.org/interactions/slash-commands#options
|
|
11
8
|
*/
|
|
12
|
-
|
|
9
|
+
export const BooleanOption = createOptionDecorator(ApplicationCommandOptionType.Boolean, 'getBoolean');
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ChannelOption = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const option_util_1 = require("./option.util");
|
|
1
|
+
import { ApplicationCommandOptionType } from 'discord.js';
|
|
2
|
+
import { createOptionDecorator } from './option.util.js';
|
|
6
3
|
/**
|
|
7
4
|
* Param decorator that marks a method as a channel option.
|
|
8
5
|
* @param options The channel options.
|
|
9
6
|
* @returns The decorated method.
|
|
10
7
|
* @url https://necord.org/interactions/slash-commands#options
|
|
11
8
|
*/
|
|
12
|
-
|
|
9
|
+
export const ChannelOption = createOptionDecorator(ApplicationCommandOptionType.Channel, 'getChannel');
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export * from './attachment-option.decorator';
|
|
2
|
-
export * from './boolean-option.decorator';
|
|
3
|
-
export * from './channel-option.decorator';
|
|
4
|
-
export * from './integer-option.decorator';
|
|
5
|
-
export * from './member-option.decorator';
|
|
6
|
-
export * from './mentionable-option.decorator';
|
|
7
|
-
export * from './number-option.decorator';
|
|
8
|
-
export * from './option.util';
|
|
9
|
-
export * from './options.decorator';
|
|
10
|
-
export * from './role-option.decorator';
|
|
11
|
-
export * from './string-option.decorator';
|
|
12
|
-
export * from './user-option.decorator';
|
|
1
|
+
export * from './attachment-option.decorator.js';
|
|
2
|
+
export * from './boolean-option.decorator.js';
|
|
3
|
+
export * from './channel-option.decorator.js';
|
|
4
|
+
export * from './integer-option.decorator.js';
|
|
5
|
+
export * from './member-option.decorator.js';
|
|
6
|
+
export * from './mentionable-option.decorator.js';
|
|
7
|
+
export * from './number-option.decorator.js';
|
|
8
|
+
export * from './option.util.js';
|
|
9
|
+
export * from './options.decorator.js';
|
|
10
|
+
export * from './role-option.decorator.js';
|
|
11
|
+
export * from './string-option.decorator.js';
|
|
12
|
+
export * from './user-option.decorator.js';
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
tslib_1.__exportStar(require("./role-option.decorator"), exports);
|
|
14
|
-
tslib_1.__exportStar(require("./string-option.decorator"), exports);
|
|
15
|
-
tslib_1.__exportStar(require("./user-option.decorator"), exports);
|
|
1
|
+
export * from './attachment-option.decorator.js';
|
|
2
|
+
export * from './boolean-option.decorator.js';
|
|
3
|
+
export * from './channel-option.decorator.js';
|
|
4
|
+
export * from './integer-option.decorator.js';
|
|
5
|
+
export * from './member-option.decorator.js';
|
|
6
|
+
export * from './mentionable-option.decorator.js';
|
|
7
|
+
export * from './number-option.decorator.js';
|
|
8
|
+
export * from './option.util.js';
|
|
9
|
+
export * from './options.decorator.js';
|
|
10
|
+
export * from './role-option.decorator.js';
|
|
11
|
+
export * from './string-option.decorator.js';
|
|
12
|
+
export * from './user-option.decorator.js';
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.IntegerOption = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const option_util_1 = require("./option.util");
|
|
1
|
+
import { ApplicationCommandOptionType } from 'discord.js';
|
|
2
|
+
import { createOptionDecorator } from './option.util.js';
|
|
6
3
|
/**
|
|
7
4
|
* Param decorator that marks a method as an integer option.
|
|
8
5
|
* @param options The integer options.
|
|
9
6
|
* @returns The decorated method.
|
|
10
7
|
* @url https://necord.org/interactions/slash-commands#options
|
|
11
8
|
*/
|
|
12
|
-
|
|
9
|
+
export const IntegerOption = createOptionDecorator(ApplicationCommandOptionType.Integer, 'getInteger');
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.MemberOption = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const option_util_1 = require("./option.util");
|
|
1
|
+
import { ApplicationCommandOptionType } from 'discord.js';
|
|
2
|
+
import { createOptionDecorator } from './option.util.js';
|
|
6
3
|
/**
|
|
7
4
|
* Param decorator that marks a method as a member option.
|
|
8
5
|
* @param options The member options.
|
|
9
6
|
* @returns The decorated method.
|
|
10
7
|
* @url https://necord.org/interactions/slash-commands#options
|
|
11
8
|
*/
|
|
12
|
-
|
|
9
|
+
export const MemberOption = createOptionDecorator(ApplicationCommandOptionType.User, 'getMember');
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.MentionableOption = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const option_util_1 = require("./option.util");
|
|
1
|
+
import { ApplicationCommandOptionType } from 'discord.js';
|
|
2
|
+
import { createOptionDecorator } from './option.util.js';
|
|
6
3
|
/**
|
|
7
4
|
* Param decorator that marks a method as a mentionable option.
|
|
8
5
|
* @param options The mentionable options.
|
|
9
6
|
* @returns The decorated method.
|
|
10
7
|
* @url https://necord.org/interactions/slash-commands#options
|
|
11
8
|
*/
|
|
12
|
-
|
|
9
|
+
export const MentionableOption = createOptionDecorator(ApplicationCommandOptionType.Mentionable, 'getMentionable');
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.NumberOption = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const option_util_1 = require("./option.util");
|
|
1
|
+
import { ApplicationCommandOptionType } from 'discord.js';
|
|
2
|
+
import { createOptionDecorator } from './option.util.js';
|
|
6
3
|
/**
|
|
7
4
|
* Param decorator that marks a method as a number option.
|
|
8
5
|
* @param options The number options.
|
|
9
6
|
* @returns The decorated method.
|
|
10
7
|
* @url https://necord.org/interactions/slash-commands#options
|
|
11
8
|
*/
|
|
12
|
-
|
|
9
|
+
export const NumberOption = createOptionDecorator(ApplicationCommandOptionType.Number, 'getNumber');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIApplicationCommandOptionBase } from 'discord-api-types/v10';
|
|
2
2
|
import { ApplicationCommandOptionType } from 'discord.js';
|
|
3
|
-
import { OptionMeta } from '../slash-command.discovery';
|
|
3
|
+
import { OptionMeta } from '../slash-command.discovery.js';
|
|
4
4
|
export declare const OPTIONS_METADATA = "necord:options_meta";
|
|
5
|
-
export declare function createOptionDecorator<T extends APIApplicationCommandOptionBase<any>>(type: ApplicationCommandOptionType, resolver: OptionMeta['resolver']): (data: Omit<T,
|
|
5
|
+
export declare function createOptionDecorator<T extends APIApplicationCommandOptionBase<any>>(type: ApplicationCommandOptionType, resolver: OptionMeta['resolver']): (data: Omit<T, 'type'>) => PropertyDecorator;
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.OPTIONS_METADATA = void 0;
|
|
4
|
-
exports.createOptionDecorator = createOptionDecorator;
|
|
5
|
-
exports.OPTIONS_METADATA = 'necord:options_meta';
|
|
6
|
-
function createOptionDecorator(type, resolver) {
|
|
1
|
+
export const OPTIONS_METADATA = 'necord:options_meta';
|
|
2
|
+
export function createOptionDecorator(type, resolver) {
|
|
7
3
|
return (data) => {
|
|
8
4
|
return (target, propertyKey) => {
|
|
9
|
-
let metadata = Reflect.getOwnMetadata(
|
|
10
|
-
if (!metadata)
|
|
5
|
+
let metadata = Reflect.getOwnMetadata(OPTIONS_METADATA, target);
|
|
6
|
+
if (!metadata)
|
|
11
7
|
metadata = {};
|
|
12
|
-
}
|
|
13
8
|
metadata[String(propertyKey)] = {
|
|
14
9
|
...data,
|
|
15
10
|
type,
|
|
16
11
|
resolver
|
|
17
12
|
};
|
|
18
|
-
Reflect.defineMetadata(
|
|
13
|
+
Reflect.defineMetadata(OPTIONS_METADATA, metadata, target);
|
|
19
14
|
};
|
|
20
15
|
};
|
|
21
16
|
}
|
|
@@ -1,36 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const context_1 = require("../../../context");
|
|
6
|
-
const option_util_1 = require("./option.util");
|
|
1
|
+
import { createParamDecorator } from '@nestjs/common';
|
|
2
|
+
import { NecordExecutionContext } from '../../../context/index.js';
|
|
3
|
+
import { OPTIONS_METADATA } from './option.util.js';
|
|
7
4
|
/**
|
|
8
5
|
* Options decorator that mark arguments as options.
|
|
9
6
|
* This decorator is used to retrieve the options from a slash command.
|
|
10
7
|
* @returns The decorated argument.
|
|
11
8
|
* @url https://necord.org/interactions/slash-commands#options
|
|
12
9
|
*/
|
|
13
|
-
|
|
14
|
-
const necordContext =
|
|
10
|
+
export const Options = createParamDecorator((_, context) => {
|
|
11
|
+
const necordContext = NecordExecutionContext.create(context);
|
|
15
12
|
const [interaction] = necordContext.getContext();
|
|
16
13
|
const discovery = necordContext.getDiscovery();
|
|
17
|
-
if (!discovery.isSlashCommand())
|
|
14
|
+
if (!interaction || !discovery.isSlashCommand())
|
|
18
15
|
return null;
|
|
19
16
|
return Object.entries(discovery.getRawOptions()).reduce((acc, [parameter, option]) => {
|
|
20
|
-
|
|
17
|
+
const resolver = option.resolver;
|
|
18
|
+
if (!resolver) {
|
|
19
|
+
return acc;
|
|
20
|
+
}
|
|
21
|
+
acc[parameter] = interaction.options[resolver].call(interaction.options, option.name, !!option.required);
|
|
21
22
|
return acc;
|
|
22
23
|
}, {});
|
|
23
24
|
}, [
|
|
24
25
|
(target, propertyKey, parameterIndex) => {
|
|
26
|
+
if (propertyKey === undefined) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
25
29
|
const paramTypes = Reflect.getMetadata('design:paramtypes', target, propertyKey);
|
|
26
|
-
|
|
30
|
+
const paramType = paramTypes?.[parameterIndex];
|
|
31
|
+
if (!paramType) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let { prototype } = paramType;
|
|
27
35
|
const options = {};
|
|
28
36
|
do {
|
|
29
|
-
const metadata = Reflect.getOwnMetadata(
|
|
37
|
+
const metadata = Reflect.getOwnMetadata(OPTIONS_METADATA, prototype);
|
|
30
38
|
Object.assign(options, metadata);
|
|
31
39
|
} while ((prototype = Reflect.getPrototypeOf(prototype)) &&
|
|
32
40
|
prototype !== Object.prototype);
|
|
33
|
-
Reflect.defineMetadata(
|
|
41
|
+
Reflect.defineMetadata(OPTIONS_METADATA, options, target[propertyKey]);
|
|
34
42
|
}
|
|
35
43
|
]);
|
|
36
|
-
|
|
44
|
+
export const Opts = Options;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.RoleOption = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const option_util_1 = require("./option.util");
|
|
1
|
+
import { ApplicationCommandOptionType } from 'discord.js';
|
|
2
|
+
import { createOptionDecorator } from './option.util.js';
|
|
6
3
|
/**
|
|
7
4
|
* Param decorator that marks a method as a role option.
|
|
8
5
|
* @param options The role options.
|
|
9
6
|
* @returns The decorated method.
|
|
10
7
|
* @url https://necord.org/interactions/slash-commands#options
|
|
11
8
|
*/
|
|
12
|
-
|
|
9
|
+
export const RoleOption = createOptionDecorator(ApplicationCommandOptionType.Role, 'getRole');
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.StringOption = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const option_util_1 = require("./option.util");
|
|
1
|
+
import { ApplicationCommandOptionType } from 'discord.js';
|
|
2
|
+
import { createOptionDecorator } from './option.util.js';
|
|
6
3
|
/**
|
|
7
4
|
* Param decorator that marks a method as a string option.
|
|
8
5
|
* @param options The string options.
|
|
9
6
|
* @returns The decorated method.
|
|
10
7
|
* @url https://necord.org/interactions/slash-commands#options
|
|
11
8
|
*/
|
|
12
|
-
|
|
9
|
+
export const StringOption = createOptionDecorator(ApplicationCommandOptionType.String, 'getString');
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.UserOption = void 0;
|
|
4
|
-
const discord_js_1 = require("discord.js");
|
|
5
|
-
const option_util_1 = require("./option.util");
|
|
1
|
+
import { ApplicationCommandOptionType } from 'discord.js';
|
|
2
|
+
import { createOptionDecorator } from './option.util.js';
|
|
6
3
|
/**
|
|
7
4
|
* Param decorator that marks a method as a user option.
|
|
8
5
|
* @param options The user options.
|
|
9
6
|
* @returns The decorated method.
|
|
10
7
|
* @url https://necord.org/interactions/slash-commands#options
|
|
11
8
|
*/
|
|
12
|
-
|
|
9
|
+
export const UserOption = createOptionDecorator(ApplicationCommandOptionType.User, 'getUser');
|