necord 6.6.1 → 6.7.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 +18 -0
- package/dist/commands/command.discovery.js +18 -0
- package/dist/commands/commands.service.d.ts +12 -0
- package/dist/commands/commands.service.js +12 -0
- package/dist/commands/context-menus/context-menu.discovery.d.ts +21 -0
- package/dist/commands/context-menus/context-menu.discovery.js +18 -0
- package/dist/commands/context-menus/context-menus.service.d.ts +8 -0
- package/dist/commands/context-menus/context-menus.service.js +8 -0
- package/dist/commands/context-menus/decorators/context-menu.decorator.d.ts +10 -0
- package/dist/commands/context-menus/decorators/context-menu.decorator.js +10 -0
- package/dist/commands/context-menus/decorators/message-command.decorator.d.ts +16 -0
- package/dist/commands/context-menus/decorators/message-command.decorator.js +16 -0
- package/dist/commands/context-menus/decorators/target.decorator.d.ts +42 -0
- package/dist/commands/context-menus/decorators/target.decorator.js +42 -0
- package/dist/commands/context-menus/decorators/user-command.decorator.d.ts +17 -0
- package/dist/commands/context-menus/decorators/user-command.decorator.js +17 -0
- package/dist/commands/slash-commands/autocomplete/autocomplete.interceptor.d.ts +6 -0
- package/dist/commands/slash-commands/autocomplete/autocomplete.interceptor.js +6 -0
- package/dist/commands/slash-commands/decorators/slash-command.decorator.d.ts +9 -0
- package/dist/commands/slash-commands/decorators/slash-command.decorator.js +9 -0
- package/dist/commands/slash-commands/decorators/subcommand-group.decorator.d.ts +15 -0
- package/dist/commands/slash-commands/decorators/subcommand-group.decorator.js +15 -0
- package/dist/commands/slash-commands/decorators/subcommand.decorator.d.ts +7 -0
- package/dist/commands/slash-commands/decorators/subcommand.decorator.js +7 -0
- package/dist/commands/slash-commands/options/attachment-option.decorator.d.ts +6 -0
- package/dist/commands/slash-commands/options/attachment-option.decorator.js +6 -0
- package/dist/commands/slash-commands/options/boolean-option.decorator.d.ts +6 -0
- package/dist/commands/slash-commands/options/boolean-option.decorator.js +6 -0
- package/dist/commands/slash-commands/options/channel-option.decorator.d.ts +6 -0
- package/dist/commands/slash-commands/options/channel-option.decorator.js +6 -0
- package/dist/commands/slash-commands/options/integer-option.decorator.d.ts +6 -0
- package/dist/commands/slash-commands/options/integer-option.decorator.js +6 -0
- package/dist/commands/slash-commands/options/member-option.decorator.d.ts +6 -0
- package/dist/commands/slash-commands/options/member-option.decorator.js +6 -0
- package/dist/commands/slash-commands/options/mentionable-option.decorator.d.ts +6 -0
- package/dist/commands/slash-commands/options/mentionable-option.decorator.js +6 -0
- package/dist/commands/slash-commands/options/number-option.decorator.d.ts +6 -0
- package/dist/commands/slash-commands/options/number-option.decorator.js +6 -0
- package/dist/commands/slash-commands/options/options.decorator.d.ts +6 -0
- package/dist/commands/slash-commands/options/options.decorator.js +6 -0
- package/dist/commands/slash-commands/options/role-option.decorator.d.ts +6 -0
- package/dist/commands/slash-commands/options/role-option.decorator.js +6 -0
- package/dist/commands/slash-commands/options/string-option.decorator.d.ts +6 -0
- package/dist/commands/slash-commands/options/string-option.decorator.js +6 -0
- package/dist/commands/slash-commands/options/user-option.decorator.d.ts +6 -0
- package/dist/commands/slash-commands/options/user-option.decorator.js +6 -0
- package/dist/commands/slash-commands/slash-command.discovery.d.ts +39 -0
- package/dist/commands/slash-commands/slash-command.discovery.js +39 -0
- package/dist/commands/slash-commands/slash-commands.service.d.ts +4 -0
- package/dist/commands/slash-commands/slash-commands.service.js +4 -0
- package/dist/context/decorators/context.decorator.d.ts +6 -0
- package/dist/context/decorators/context.decorator.js +6 -0
- package/dist/context/decorators/discovery.decorator.d.ts +5 -0
- package/dist/context/decorators/discovery.decorator.js +5 -0
- package/dist/listeners/decorators/custom-listener.decorator.d.ts +10 -0
- package/dist/listeners/decorators/custom-listener.decorator.js +10 -0
- package/dist/listeners/decorators/listener.decorator.d.ts +6 -0
- package/dist/listeners/decorators/listener.decorator.js +6 -0
- package/dist/listeners/decorators/on.decorator.d.ts +6 -0
- package/dist/listeners/decorators/on.decorator.js +6 -0
- package/dist/listeners/decorators/once.decorator.d.ts +6 -0
- package/dist/listeners/decorators/once.decorator.js +6 -0
- package/dist/listeners/listener.discovery.d.ts +3 -0
- package/dist/listeners/listener.discovery.js +3 -0
- package/dist/message-components/decorators/button.decorator.d.ts +5 -0
- package/dist/message-components/decorators/button.decorator.js +5 -0
- package/dist/message-components/decorators/component-param.decorator.d.ts +7 -0
- package/dist/message-components/decorators/component-param.decorator.js +7 -0
- package/dist/message-components/decorators/message-component.decorator.d.ts +6 -0
- package/dist/message-components/decorators/message-component.decorator.js +6 -0
- package/dist/message-components/decorators/select-menu.decorator.d.ts +33 -0
- package/dist/message-components/decorators/select-menu.decorator.js +33 -0
- package/dist/message-components/message-component.discovery.d.ts +3 -0
- package/dist/message-components/message-component.discovery.js +3 -0
- package/dist/message-components/message-components.service.d.ts +3 -0
- package/dist/message-components/message-components.service.js +3 -0
- package/dist/modals/decorators/fields.decorator.d.ts +6 -0
- package/dist/modals/decorators/fields.decorator.js +6 -0
- package/dist/modals/decorators/modal-param.decorator.d.ts +6 -0
- package/dist/modals/decorators/modal-param.decorator.js +6 -0
- package/dist/modals/decorators/modal.decorator.d.ts +5 -0
- package/dist/modals/decorators/modal.decorator.js +5 -0
- package/dist/modals/modal.discovery.d.ts +3 -0
- package/dist/modals/modal.discovery.js +3 -0
- package/dist/modals/modals.service.d.ts +3 -0
- package/dist/modals/modals.service.js +3 -0
- package/dist/necord-explorer.service.d.ts +4 -0
- package/dist/necord-explorer.service.js +4 -0
- package/dist/necord-options.interface.d.ts +21 -2
- package/dist/text-commands/decorators/arguments.decorator.d.ts +6 -0
- package/dist/text-commands/decorators/arguments.decorator.js +6 -0
- package/dist/text-commands/decorators/text-command.decorator.d.ts +5 -0
- package/dist/text-commands/decorators/text-command.decorator.js +5 -0
- package/dist/text-commands/text-command.discovery.d.ts +3 -0
- package/dist/text-commands/text-command.discovery.js +3 -0
- package/dist/text-commands/text-commands.service.d.ts +3 -0
- package/dist/text-commands/text-commands.service.js +3 -0
- package/package.json +12 -12
|
@@ -3,9 +3,27 @@ import { NecordBaseDiscovery } from '../context';
|
|
|
3
3
|
export interface BaseCommandMeta extends BaseApplicationCommandData {
|
|
4
4
|
guilds?: Snowflake[];
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Represents a command discovery.
|
|
8
|
+
* @abstract
|
|
9
|
+
* @url https://necord.org/interactions/slash-commands
|
|
10
|
+
*/
|
|
6
11
|
export declare abstract class CommandDiscovery<T extends BaseCommandMeta = BaseCommandMeta> extends NecordBaseDiscovery<T> {
|
|
12
|
+
/**
|
|
13
|
+
* Returns the command name.
|
|
14
|
+
*/
|
|
7
15
|
getName(): string;
|
|
16
|
+
/**
|
|
17
|
+
* Sets the command guilds for register.
|
|
18
|
+
* @param guilds
|
|
19
|
+
*/
|
|
8
20
|
setGuilds(guilds: Snowflake[]): void;
|
|
21
|
+
/**
|
|
22
|
+
* Checks if the command has a guild.
|
|
23
|
+
*/
|
|
9
24
|
hasGuild(guild: Snowflake): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the guilds.
|
|
27
|
+
*/
|
|
10
28
|
getGuilds(): Snowflake[];
|
|
11
29
|
}
|
|
@@ -2,17 +2,35 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommandDiscovery = void 0;
|
|
4
4
|
const context_1 = require("../context");
|
|
5
|
+
/**
|
|
6
|
+
* Represents a command discovery.
|
|
7
|
+
* @abstract
|
|
8
|
+
* @url https://necord.org/interactions/slash-commands
|
|
9
|
+
*/
|
|
5
10
|
class CommandDiscovery extends context_1.NecordBaseDiscovery {
|
|
11
|
+
/**
|
|
12
|
+
* Returns the command name.
|
|
13
|
+
*/
|
|
6
14
|
getName() {
|
|
7
15
|
return this.meta.name;
|
|
8
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Sets the command guilds for register.
|
|
19
|
+
* @param guilds
|
|
20
|
+
*/
|
|
9
21
|
setGuilds(guilds) {
|
|
10
22
|
this.meta.guilds = guilds;
|
|
11
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Checks if the command has a guild.
|
|
26
|
+
*/
|
|
12
27
|
hasGuild(guild) {
|
|
13
28
|
var _a;
|
|
14
29
|
return (_a = this.meta.guilds) === null || _a === void 0 ? void 0 : _a.includes(guild);
|
|
15
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns the guilds.
|
|
33
|
+
*/
|
|
16
34
|
getGuilds() {
|
|
17
35
|
return this.meta.guilds;
|
|
18
36
|
}
|
|
@@ -2,13 +2,25 @@ import { Client, Collection } from 'discord.js';
|
|
|
2
2
|
import { CommandDiscovery } from './command.discovery';
|
|
3
3
|
import { ContextMenusService } from './context-menus';
|
|
4
4
|
import { SlashCommandsService } from './slash-commands';
|
|
5
|
+
/**
|
|
6
|
+
* Represents a service that manages commands.
|
|
7
|
+
* @url https://necord.org/interactions/slash-commands
|
|
8
|
+
*/
|
|
5
9
|
export declare class CommandsService {
|
|
6
10
|
private readonly client;
|
|
7
11
|
private readonly contextMenusService;
|
|
8
12
|
private readonly slashCommandsService;
|
|
9
13
|
private readonly logger;
|
|
10
14
|
constructor(client: Client, contextMenusService: ContextMenusService, slashCommandsService: SlashCommandsService);
|
|
15
|
+
/**
|
|
16
|
+
* Registers all commands.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
11
19
|
registerAllCommands(): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Registers commands in a guild.
|
|
22
|
+
* @param guildId
|
|
23
|
+
*/
|
|
12
24
|
registerInGuild(guildId: string): Promise<void | Collection<string, import("discord.js").ApplicationCommand<{}>>>;
|
|
13
25
|
getCommands(): CommandDiscovery[];
|
|
14
26
|
getCommandsByGuilds(): Collection<string, CommandDiscovery[]>;
|
|
@@ -24,6 +24,10 @@ const common_1 = require("@nestjs/common");
|
|
|
24
24
|
const discord_js_1 = require("discord.js");
|
|
25
25
|
const context_menus_1 = require("./context-menus");
|
|
26
26
|
const slash_commands_1 = require("./slash-commands");
|
|
27
|
+
/**
|
|
28
|
+
* Represents a service that manages commands.
|
|
29
|
+
* @url https://necord.org/interactions/slash-commands
|
|
30
|
+
*/
|
|
27
31
|
let CommandsService = CommandsService_1 = class CommandsService {
|
|
28
32
|
constructor(client, contextMenusService, slashCommandsService) {
|
|
29
33
|
this.client = client;
|
|
@@ -31,6 +35,10 @@ let CommandsService = CommandsService_1 = class CommandsService {
|
|
|
31
35
|
this.slashCommandsService = slashCommandsService;
|
|
32
36
|
this.logger = new common_1.Logger(CommandsService_1.name);
|
|
33
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Registers all commands.
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
34
42
|
registerAllCommands() {
|
|
35
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
44
|
const guilds = new Set(this.getCommandsByGuilds().keys());
|
|
@@ -41,6 +49,10 @@ let CommandsService = CommandsService_1 = class CommandsService {
|
|
|
41
49
|
this.logger.log(`Successfully reloaded application commands.`);
|
|
42
50
|
});
|
|
43
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Registers commands in a guild.
|
|
54
|
+
* @param guildId
|
|
55
|
+
*/
|
|
44
56
|
registerInGuild(guildId) {
|
|
45
57
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
58
|
const commands = this.getGuildCommands(guildId);
|
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
import { ContextMenuCommandInteraction, MessageApplicationCommandData, Snowflake, UserApplicationCommandData } from 'discord.js';
|
|
2
2
|
import { CommandDiscovery } from '../command.discovery';
|
|
3
|
+
/**
|
|
4
|
+
* The context menu metadata.
|
|
5
|
+
*/
|
|
3
6
|
export type ContextMenuMeta = (MessageApplicationCommandData | UserApplicationCommandData) & {
|
|
4
7
|
guilds?: Snowflake[];
|
|
5
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* The context menu discovery.
|
|
11
|
+
* @see CommandDiscovery
|
|
12
|
+
* @see ContextMenuMeta
|
|
13
|
+
*/
|
|
6
14
|
export declare class ContextMenuDiscovery extends CommandDiscovery<ContextMenuMeta> {
|
|
15
|
+
/**
|
|
16
|
+
* Gets the discovery type.
|
|
17
|
+
*/
|
|
7
18
|
getType(): import("discord.js").ApplicationCommandType.User | import("discord.js").ApplicationCommandType.Message;
|
|
19
|
+
/**
|
|
20
|
+
* Type guard for the context menu discovery.
|
|
21
|
+
*/
|
|
8
22
|
isContextMenu(): this is ContextMenuDiscovery;
|
|
23
|
+
/**
|
|
24
|
+
* Executes the context menu discovery.
|
|
25
|
+
* @param interaction The interaction to execute.
|
|
26
|
+
*/
|
|
9
27
|
execute(interaction: ContextMenuCommandInteraction): any;
|
|
28
|
+
/**
|
|
29
|
+
* Converts the context menu discovery to JSON.
|
|
30
|
+
*/
|
|
10
31
|
toJSON(): ContextMenuMeta;
|
|
11
32
|
}
|
|
@@ -2,16 +2,34 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ContextMenuDiscovery = void 0;
|
|
4
4
|
const command_discovery_1 = require("../command.discovery");
|
|
5
|
+
/**
|
|
6
|
+
* The context menu discovery.
|
|
7
|
+
* @see CommandDiscovery
|
|
8
|
+
* @see ContextMenuMeta
|
|
9
|
+
*/
|
|
5
10
|
class ContextMenuDiscovery extends command_discovery_1.CommandDiscovery {
|
|
11
|
+
/**
|
|
12
|
+
* Gets the discovery type.
|
|
13
|
+
*/
|
|
6
14
|
getType() {
|
|
7
15
|
return this.meta.type;
|
|
8
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Type guard for the context menu discovery.
|
|
19
|
+
*/
|
|
9
20
|
isContextMenu() {
|
|
10
21
|
return true;
|
|
11
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Executes the context menu discovery.
|
|
25
|
+
* @param interaction The interaction to execute.
|
|
26
|
+
*/
|
|
12
27
|
execute(interaction) {
|
|
13
28
|
return super.execute([interaction]);
|
|
14
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Converts the context menu discovery to JSON.
|
|
32
|
+
*/
|
|
15
33
|
toJSON() {
|
|
16
34
|
return this.meta;
|
|
17
35
|
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { Collection } from 'discord.js';
|
|
2
2
|
import { ContextMenuDiscovery, ContextMenuMeta } from './context-menu.discovery';
|
|
3
|
+
/**
|
|
4
|
+
* Service that manages context menus.
|
|
5
|
+
* @see ContextMenuDiscovery
|
|
6
|
+
* @see ContextMenuMeta
|
|
7
|
+
* @see ContextMenu
|
|
8
|
+
* @see MessageCommand
|
|
9
|
+
* @see UserCommand
|
|
10
|
+
*/
|
|
3
11
|
export declare class ContextMenusService {
|
|
4
12
|
private readonly logger;
|
|
5
13
|
readonly cache: Collection<string, ContextMenuDiscovery>;
|
|
@@ -10,6 +10,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.ContextMenusService = void 0;
|
|
11
11
|
const discord_js_1 = require("discord.js");
|
|
12
12
|
const common_1 = require("@nestjs/common");
|
|
13
|
+
/**
|
|
14
|
+
* Service that manages context menus.
|
|
15
|
+
* @see ContextMenuDiscovery
|
|
16
|
+
* @see ContextMenuMeta
|
|
17
|
+
* @see ContextMenu
|
|
18
|
+
* @see MessageCommand
|
|
19
|
+
* @see UserCommand
|
|
20
|
+
*/
|
|
13
21
|
let ContextMenusService = ContextMenusService_1 = class ContextMenusService {
|
|
14
22
|
constructor() {
|
|
15
23
|
this.logger = new common_1.Logger(ContextMenusService_1.name);
|
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
import { ContextMenuDiscovery, ContextMenuMeta } from '../context-menu.discovery';
|
|
2
|
+
/**
|
|
3
|
+
* Decorator that marks a method as a context menu.
|
|
4
|
+
* @param options The context menu options.
|
|
5
|
+
* @returns The decorated method.
|
|
6
|
+
* @see ContextMenuDiscovery
|
|
7
|
+
* @see ContextMenuMeta
|
|
8
|
+
* @see MessageCommand
|
|
9
|
+
* @see UserCommand
|
|
10
|
+
* @url https://necord.org/interactions/context-menus
|
|
11
|
+
*/
|
|
2
12
|
export declare const ContextMenu: import("@nestjs/core").ReflectableDecorator<ContextMenuMeta, ContextMenuDiscovery>;
|
|
@@ -3,6 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ContextMenu = void 0;
|
|
4
4
|
const context_menu_discovery_1 = require("../context-menu.discovery");
|
|
5
5
|
const core_1 = require("@nestjs/core");
|
|
6
|
+
/**
|
|
7
|
+
* Decorator that marks a method as a context menu.
|
|
8
|
+
* @param options The context menu options.
|
|
9
|
+
* @returns The decorated method.
|
|
10
|
+
* @see ContextMenuDiscovery
|
|
11
|
+
* @see ContextMenuMeta
|
|
12
|
+
* @see MessageCommand
|
|
13
|
+
* @see UserCommand
|
|
14
|
+
* @url https://necord.org/interactions/context-menus
|
|
15
|
+
*/
|
|
6
16
|
exports.ContextMenu = core_1.Reflector.createDecorator({
|
|
7
17
|
transform: options => new context_menu_discovery_1.ContextMenuDiscovery(options)
|
|
8
18
|
});
|
|
@@ -1,2 +1,18 @@
|
|
|
1
1
|
import { ContextMenuMeta } from '../context-menu.discovery';
|
|
2
|
+
/**
|
|
3
|
+
* Decorator that marks a method as a message context menu.
|
|
4
|
+
* @param options The context menu options.
|
|
5
|
+
* @returns The decorated method.
|
|
6
|
+
* @see ContextMenu
|
|
7
|
+
* @see ContextMenuMeta
|
|
8
|
+
* @see TargetMessage
|
|
9
|
+
* @url https://necord.org/interactions/context-menus#message-commands
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* @MessageCommand({ name: 'quote', type: 'MESSAGE' })
|
|
13
|
+
* public async quote(@TargetMessage() message: Message) {
|
|
14
|
+
* message.reply('Quoting...');
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
2
18
|
export declare const MessageCommand: (options: Omit<ContextMenuMeta, 'type'>) => import("@nestjs/common").CustomDecorator;
|
|
@@ -3,5 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MessageCommand = void 0;
|
|
4
4
|
const discord_js_1 = require("discord.js");
|
|
5
5
|
const context_menu_decorator_1 = require("./context-menu.decorator");
|
|
6
|
+
/**
|
|
7
|
+
* Decorator that marks a method as a message context menu.
|
|
8
|
+
* @param options The context menu options.
|
|
9
|
+
* @returns The decorated method.
|
|
10
|
+
* @see ContextMenu
|
|
11
|
+
* @see ContextMenuMeta
|
|
12
|
+
* @see TargetMessage
|
|
13
|
+
* @url https://necord.org/interactions/context-menus#message-commands
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* @MessageCommand({ name: 'quote', type: 'MESSAGE' })
|
|
17
|
+
* public async quote(@TargetMessage() message: Message) {
|
|
18
|
+
* message.reply('Quoting...');
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
6
22
|
const MessageCommand = (options) => (0, context_menu_decorator_1.ContextMenu)(Object.assign({ type: discord_js_1.ApplicationCommandType.Message }, options));
|
|
7
23
|
exports.MessageCommand = MessageCommand;
|
|
@@ -2,6 +2,48 @@
|
|
|
2
2
|
* @deprecated Use `@TargetMessage`, `@TargetUser` or `@TargetMember` instead
|
|
3
3
|
*/
|
|
4
4
|
export declare const Target: (...dataOrPipes: any[]) => ParameterDecorator;
|
|
5
|
+
/**
|
|
6
|
+
* Decorator that injects the target message of a message context menu command.
|
|
7
|
+
* @see TargetUser
|
|
8
|
+
* @see TargetMember
|
|
9
|
+
* @see MessageCommand
|
|
10
|
+
* @returns The target message.
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* @MessageCommand({ name: 'quote', type: 'MESSAGE' })
|
|
14
|
+
* public async quote(@TargetMessage() message: Message) {
|
|
15
|
+
* message.reply('Quoting...');
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
5
19
|
export declare const TargetMessage: (...dataOrPipes: any[]) => ParameterDecorator;
|
|
20
|
+
/**
|
|
21
|
+
* Decorator that injects the target user of a user context menu command.
|
|
22
|
+
* @see TargetMessage
|
|
23
|
+
* @see TargetMember
|
|
24
|
+
* @see UserCommand
|
|
25
|
+
* @returns The target user.
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* @UserCommand({ name: 'kick', type: 'USER' })
|
|
29
|
+
* public async avatar(@TargetUser() user: User) {
|
|
30
|
+
* user.avatarURL();
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
6
34
|
export declare const TargetUser: (...dataOrPipes: any[]) => ParameterDecorator;
|
|
35
|
+
/**
|
|
36
|
+
* Decorator that injects the target member of a user context menu command.
|
|
37
|
+
* @see TargetMessage
|
|
38
|
+
* @see TargetUser
|
|
39
|
+
* @see UserCommand
|
|
40
|
+
* @returns The target member.
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* @UserCommand({ name: 'ban', type: 'USER' })
|
|
44
|
+
* public async ban(@TargetMember() member: GuildMember) {
|
|
45
|
+
* member.ban();
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
7
49
|
export declare const TargetMember: (...dataOrPipes: any[]) => ParameterDecorator;
|
|
@@ -15,6 +15,20 @@ exports.Target = (0, common_1.createParamDecorator)((_, context) => {
|
|
|
15
15
|
? interaction.options.getMessage('message')
|
|
16
16
|
: interaction.options.getUser('user');
|
|
17
17
|
});
|
|
18
|
+
/**
|
|
19
|
+
* Decorator that injects the target message of a message context menu command.
|
|
20
|
+
* @see TargetUser
|
|
21
|
+
* @see TargetMember
|
|
22
|
+
* @see MessageCommand
|
|
23
|
+
* @returns The target message.
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* @MessageCommand({ name: 'quote', type: 'MESSAGE' })
|
|
27
|
+
* public async quote(@TargetMessage() message: Message) {
|
|
28
|
+
* message.reply('Quoting...');
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
18
32
|
exports.TargetMessage = (0, common_1.createParamDecorator)((_, context) => {
|
|
19
33
|
const necordContext = context_1.NecordExecutionContext.create(context);
|
|
20
34
|
const [interaction] = necordContext.getContext();
|
|
@@ -22,6 +36,20 @@ exports.TargetMessage = (0, common_1.createParamDecorator)((_, context) => {
|
|
|
22
36
|
return null;
|
|
23
37
|
return interaction.targetMessage;
|
|
24
38
|
});
|
|
39
|
+
/**
|
|
40
|
+
* Decorator that injects the target user of a user context menu command.
|
|
41
|
+
* @see TargetMessage
|
|
42
|
+
* @see TargetMember
|
|
43
|
+
* @see UserCommand
|
|
44
|
+
* @returns The target user.
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* @UserCommand({ name: 'kick', type: 'USER' })
|
|
48
|
+
* public async avatar(@TargetUser() user: User) {
|
|
49
|
+
* user.avatarURL();
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
25
53
|
exports.TargetUser = (0, common_1.createParamDecorator)((_, context) => {
|
|
26
54
|
const necordContext = context_1.NecordExecutionContext.create(context);
|
|
27
55
|
const [interaction] = necordContext.getContext();
|
|
@@ -29,6 +57,20 @@ exports.TargetUser = (0, common_1.createParamDecorator)((_, context) => {
|
|
|
29
57
|
return null;
|
|
30
58
|
return interaction.targetUser;
|
|
31
59
|
});
|
|
60
|
+
/**
|
|
61
|
+
* Decorator that injects the target member of a user context menu command.
|
|
62
|
+
* @see TargetMessage
|
|
63
|
+
* @see TargetUser
|
|
64
|
+
* @see UserCommand
|
|
65
|
+
* @returns The target member.
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* @UserCommand({ name: 'ban', type: 'USER' })
|
|
69
|
+
* public async ban(@TargetMember() member: GuildMember) {
|
|
70
|
+
* member.ban();
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
32
74
|
exports.TargetMember = (0, common_1.createParamDecorator)((_, context) => {
|
|
33
75
|
const necordContext = context_1.NecordExecutionContext.create(context);
|
|
34
76
|
const [interaction] = necordContext.getContext();
|
|
@@ -1,2 +1,19 @@
|
|
|
1
1
|
import { ContextMenuMeta } from '../context-menu.discovery';
|
|
2
|
+
/**
|
|
3
|
+
* Decorator that marks a method as a user context menu.
|
|
4
|
+
* @param options The context menu options.
|
|
5
|
+
* @returns The decorated method.
|
|
6
|
+
* @see ContextMenu
|
|
7
|
+
* @see ContextMenuMeta
|
|
8
|
+
* @see TargetUser
|
|
9
|
+
* @see TargetMessage
|
|
10
|
+
* @url https://necord.org/interactions/context-menus#user-commands
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* @UserCommand({ name: 'ping' })
|
|
14
|
+
* public async ping(@TargetUser() user: User) {
|
|
15
|
+
* user.send('Pong!');
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
2
19
|
export declare const UserCommand: (options: Omit<ContextMenuMeta, 'type'>) => import("@nestjs/common").CustomDecorator;
|
|
@@ -3,5 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.UserCommand = void 0;
|
|
4
4
|
const discord_js_1 = require("discord.js");
|
|
5
5
|
const context_menu_decorator_1 = require("./context-menu.decorator");
|
|
6
|
+
/**
|
|
7
|
+
* Decorator that marks a method as a user context menu.
|
|
8
|
+
* @param options The context menu options.
|
|
9
|
+
* @returns The decorated method.
|
|
10
|
+
* @see ContextMenu
|
|
11
|
+
* @see ContextMenuMeta
|
|
12
|
+
* @see TargetUser
|
|
13
|
+
* @see TargetMessage
|
|
14
|
+
* @url https://necord.org/interactions/context-menus#user-commands
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* @UserCommand({ name: 'ping' })
|
|
18
|
+
* public async ping(@TargetUser() user: User) {
|
|
19
|
+
* user.send('Pong!');
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
6
23
|
const UserCommand = (options) => (0, context_menu_decorator_1.ContextMenu)(Object.assign({ type: discord_js_1.ApplicationCommandType.User }, options));
|
|
7
24
|
exports.UserCommand = UserCommand;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { AutocompleteInteraction } from 'discord.js';
|
|
4
|
+
/**
|
|
5
|
+
* The autocomplete interceptor.
|
|
6
|
+
* @see AutocompleteContext
|
|
7
|
+
* @see AutocompleteInteraction
|
|
8
|
+
* @url https://necord.org/interactions/slash-commands#autocomplete
|
|
9
|
+
*/
|
|
4
10
|
export declare abstract class AutocompleteInterceptor implements NestInterceptor {
|
|
5
11
|
abstract transformOptions(interaction: AutocompleteInteraction): void | Promise<void>;
|
|
6
12
|
intercept(context: ExecutionContext, next: CallHandler): Promise<Observable<any>>;
|
|
@@ -19,6 +19,12 @@ exports.AutocompleteInterceptor = void 0;
|
|
|
19
19
|
const common_1 = require("@nestjs/common");
|
|
20
20
|
const rxjs_1 = require("rxjs");
|
|
21
21
|
const context_1 = require("../../../context");
|
|
22
|
+
/**
|
|
23
|
+
* The autocomplete interceptor.
|
|
24
|
+
* @see AutocompleteContext
|
|
25
|
+
* @see AutocompleteInteraction
|
|
26
|
+
* @url https://necord.org/interactions/slash-commands#autocomplete
|
|
27
|
+
*/
|
|
22
28
|
let AutocompleteInterceptor = class AutocompleteInterceptor {
|
|
23
29
|
intercept(context, next) {
|
|
24
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import { SlashCommandDiscovery, SlashCommandMeta } from '../slash-command.discovery';
|
|
2
|
+
/**
|
|
3
|
+
* Decorator that marks a method as a slash command.
|
|
4
|
+
* @param options The slash command options.
|
|
5
|
+
* @returns The decorated method.
|
|
6
|
+
* @see SlashCommandDiscovery
|
|
7
|
+
* @see SlashCommandMeta
|
|
8
|
+
* @url https://necord.org/interactions/slash-commands
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
2
11
|
export declare const SlashCommand: import("@nestjs/core").ReflectableDecorator<Omit<SlashCommandMeta, "type" | "options">, SlashCommandDiscovery>;
|
|
@@ -4,6 +4,15 @@ exports.SlashCommand = void 0;
|
|
|
4
4
|
const slash_command_discovery_1 = require("../slash-command.discovery");
|
|
5
5
|
const discord_js_1 = require("discord.js");
|
|
6
6
|
const core_1 = require("@nestjs/core");
|
|
7
|
+
/**
|
|
8
|
+
* Decorator that marks a method as a slash command.
|
|
9
|
+
* @param options The slash command options.
|
|
10
|
+
* @returns The decorated method.
|
|
11
|
+
* @see SlashCommandDiscovery
|
|
12
|
+
* @see SlashCommandMeta
|
|
13
|
+
* @url https://necord.org/interactions/slash-commands
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
7
16
|
exports.SlashCommand = core_1.Reflector.createDecorator({
|
|
8
17
|
transform: options => new slash_command_discovery_1.SlashCommandDiscovery(Object.assign({ type: discord_js_1.ApplicationCommandType.ChatInput }, options))
|
|
9
18
|
});
|
|
@@ -1,3 +1,18 @@
|
|
|
1
1
|
import { SlashCommandDiscovery, SlashCommandMeta } from '../slash-command.discovery';
|
|
2
|
+
/**
|
|
3
|
+
* Decorator that marks a method as a subcommand.
|
|
4
|
+
* @param options The subcommand options.
|
|
5
|
+
* @returns The decorated method.
|
|
6
|
+
* @see SlashCommandDiscovery
|
|
7
|
+
* @url https://necord.org/interactions/slash-commands#groups
|
|
8
|
+
*/
|
|
2
9
|
export declare const SubcommandGroup: import("@nestjs/core").ReflectableDecorator<Omit<SlashCommandMeta, "type" | "defaultMemberPermissions" | "guilds" | "options">, SlashCommandDiscovery>;
|
|
10
|
+
/**
|
|
11
|
+
* Factory that creates a decorator that marks a class as a slash command group.
|
|
12
|
+
* @param rootOptions
|
|
13
|
+
* @returns The decorator.
|
|
14
|
+
* @see SlashCommand
|
|
15
|
+
* @see SubcommandGroup
|
|
16
|
+
* @url https://necord.org/interactions/slash-commands#groups
|
|
17
|
+
*/
|
|
3
18
|
export declare const createCommandGroupDecorator: (rootOptions: Omit<SlashCommandMeta, 'type'>) => (subOptions?: Omit<SlashCommandMeta, 'type'>) => ClassDecorator;
|
|
@@ -7,9 +7,24 @@ const slash_command_discovery_1 = require("../slash-command.discovery");
|
|
|
7
7
|
const slash_command_decorator_1 = require("./slash-command.decorator");
|
|
8
8
|
const rxjs_1 = require("rxjs");
|
|
9
9
|
const core_1 = require("@nestjs/core");
|
|
10
|
+
/**
|
|
11
|
+
* Decorator that marks a method as a subcommand.
|
|
12
|
+
* @param options The subcommand options.
|
|
13
|
+
* @returns The decorated method.
|
|
14
|
+
* @see SlashCommandDiscovery
|
|
15
|
+
* @url https://necord.org/interactions/slash-commands#groups
|
|
16
|
+
*/
|
|
10
17
|
exports.SubcommandGroup = core_1.Reflector.createDecorator({
|
|
11
18
|
transform: options => new slash_command_discovery_1.SlashCommandDiscovery(Object.assign({ type: discord_js_1.ApplicationCommandOptionType.SubcommandGroup }, options))
|
|
12
19
|
});
|
|
20
|
+
/**
|
|
21
|
+
* Factory that creates a decorator that marks a class as a slash command group.
|
|
22
|
+
* @param rootOptions
|
|
23
|
+
* @returns The decorator.
|
|
24
|
+
* @see SlashCommand
|
|
25
|
+
* @see SubcommandGroup
|
|
26
|
+
* @url https://necord.org/interactions/slash-commands#groups
|
|
27
|
+
*/
|
|
13
28
|
const createCommandGroupDecorator = (rootOptions) => {
|
|
14
29
|
const rootCommand = (0, slash_command_decorator_1.SlashCommand)(rootOptions);
|
|
15
30
|
return (subOptions) => {
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import { SlashCommandDiscovery, SlashCommandMeta } from '../slash-command.discovery';
|
|
2
|
+
/**
|
|
3
|
+
* Decorator that marks a method as a subcommand.
|
|
4
|
+
* @param options The subcommand options.
|
|
5
|
+
* @returns The decorated method.
|
|
6
|
+
* @see SlashCommandDiscovery
|
|
7
|
+
* @url https://necord.org/interactions/slash-commands#groups
|
|
8
|
+
*/
|
|
2
9
|
export declare const Subcommand: import("@nestjs/core").ReflectableDecorator<Omit<SlashCommandMeta, "type" | "defaultMemberPermissions" | "guilds" | "options">, SlashCommandDiscovery>;
|
|
@@ -4,6 +4,13 @@ exports.Subcommand = void 0;
|
|
|
4
4
|
const slash_command_discovery_1 = require("../slash-command.discovery");
|
|
5
5
|
const discord_js_1 = require("discord.js");
|
|
6
6
|
const core_1 = require("@nestjs/core");
|
|
7
|
+
/**
|
|
8
|
+
* Decorator that marks a method as a subcommand.
|
|
9
|
+
* @param options The subcommand options.
|
|
10
|
+
* @returns The decorated method.
|
|
11
|
+
* @see SlashCommandDiscovery
|
|
12
|
+
* @url https://necord.org/interactions/slash-commands#groups
|
|
13
|
+
*/
|
|
7
14
|
exports.Subcommand = core_1.Reflector.createDecorator({
|
|
8
15
|
transform: options => new slash_command_discovery_1.SlashCommandDiscovery(Object.assign({ type: discord_js_1.ApplicationCommandOptionType.Subcommand }, options))
|
|
9
16
|
});
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Param decorator that marks a method as an attachment option.
|
|
3
|
+
* @param options The attachment options.
|
|
4
|
+
* @returns The decorated method.
|
|
5
|
+
* @url https://necord.org/interactions/slash-commands#options
|
|
6
|
+
*/
|
|
1
7
|
export declare const AttachmentOption: (data: {
|
|
2
8
|
name: string;
|
|
3
9
|
description: string;
|
|
@@ -3,4 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AttachmentOption = void 0;
|
|
4
4
|
const discord_js_1 = require("discord.js");
|
|
5
5
|
const option_util_1 = require("./option.util");
|
|
6
|
+
/**
|
|
7
|
+
* Param decorator that marks a method as an attachment option.
|
|
8
|
+
* @param options The attachment options.
|
|
9
|
+
* @returns The decorated method.
|
|
10
|
+
* @url https://necord.org/interactions/slash-commands#options
|
|
11
|
+
*/
|
|
6
12
|
exports.AttachmentOption = (0, option_util_1.createOptionDecorator)(discord_js_1.ApplicationCommandOptionType.Attachment, 'getAttachment');
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Param decorator that marks a method as a boolean option.
|
|
3
|
+
* @param options The boolean options.
|
|
4
|
+
* @returns The decorated method.
|
|
5
|
+
* @url https://necord.org/interactions/slash-commands#options
|
|
6
|
+
*/
|
|
1
7
|
export declare const BooleanOption: (data: {
|
|
2
8
|
name: string;
|
|
3
9
|
description: string;
|
|
@@ -3,4 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BooleanOption = void 0;
|
|
4
4
|
const discord_js_1 = require("discord.js");
|
|
5
5
|
const option_util_1 = require("./option.util");
|
|
6
|
+
/**
|
|
7
|
+
* Param decorator that marks a method as a boolean option.
|
|
8
|
+
* @param options The boolean options.
|
|
9
|
+
* @returns The decorated method.
|
|
10
|
+
* @url https://necord.org/interactions/slash-commands#options
|
|
11
|
+
*/
|
|
6
12
|
exports.BooleanOption = (0, option_util_1.createOptionDecorator)(discord_js_1.ApplicationCommandOptionType.Boolean, 'getBoolean');
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Param decorator that marks a method as a channel option.
|
|
3
|
+
* @param options The channel options.
|
|
4
|
+
* @returns The decorated method.
|
|
5
|
+
* @url https://necord.org/interactions/slash-commands#options
|
|
6
|
+
*/
|
|
1
7
|
export declare const ChannelOption: (data: {
|
|
2
8
|
name: string;
|
|
3
9
|
description: string;
|
|
@@ -3,4 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ChannelOption = void 0;
|
|
4
4
|
const discord_js_1 = require("discord.js");
|
|
5
5
|
const option_util_1 = require("./option.util");
|
|
6
|
+
/**
|
|
7
|
+
* Param decorator that marks a method as a channel option.
|
|
8
|
+
* @param options The channel options.
|
|
9
|
+
* @returns The decorated method.
|
|
10
|
+
* @url https://necord.org/interactions/slash-commands#options
|
|
11
|
+
*/
|
|
6
12
|
exports.ChannelOption = (0, option_util_1.createOptionDecorator)(discord_js_1.ApplicationCommandOptionType.Channel, 'getChannel');
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Param decorator that marks a method as an integer option.
|
|
3
|
+
* @param options The integer options.
|
|
4
|
+
* @returns The decorated method.
|
|
5
|
+
* @url https://necord.org/interactions/slash-commands#options
|
|
6
|
+
*/
|
|
1
7
|
export declare const IntegerOption: (data: {
|
|
2
8
|
name: string;
|
|
3
9
|
description: string;
|