@globalart/nestcord 1.5.8 → 1.5.10
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/core/src/commands/command.discovery.d.ts +10 -1
- package/dist/core/src/commands/command.discovery.js +13 -0
- package/dist/core/src/commands/commands.module.js +6 -3
- package/dist/core/src/commands/commands.service.d.ts +1 -0
- package/dist/core/src/commands/commands.service.js +16 -0
- package/dist/core/src/commands/slash-commands/slash-command.discovery.d.ts +1 -0
- package/dist/core/src/commands/slash-commands/slash-commands.service.d.ts +1 -0
- package/dist/core/src/commands/slash-commands/slash-commands.service.js +3 -0
- package/dist/core/src/context/nestcord-base.discovery.d.ts +1 -1
- package/dist/pagination/src/builders/index.d.ts +3 -1
- package/dist/pagination/src/builders/index.js +17 -0
- package/dist/pagination/src/index.d.ts +1 -0
- package/dist/pagination/src/index.js +1 -0
- package/package.json +1 -1
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import { BaseApplicationCommandData, Snowflake } from 'discord.js';
|
|
1
|
+
import { ApplicationCommand, BaseApplicationCommandData, Snowflake } from 'discord.js';
|
|
2
2
|
import { NestCordBaseDiscovery } from '../context';
|
|
3
3
|
export interface BaseCommandMeta extends BaseApplicationCommandData {
|
|
4
4
|
guilds?: Snowflake[];
|
|
5
5
|
category?: string;
|
|
6
|
+
discordResponse?: ApplicationCommand;
|
|
6
7
|
}
|
|
7
8
|
/**
|
|
8
9
|
* Represents a command discovery.
|
|
9
10
|
* @abstract
|
|
10
11
|
*/
|
|
11
12
|
export declare abstract class CommandDiscovery<T extends BaseCommandMeta = BaseCommandMeta> extends NestCordBaseDiscovery<T> {
|
|
13
|
+
/**
|
|
14
|
+
* Return the command ID
|
|
15
|
+
*/
|
|
16
|
+
getId(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Return the discord response of command
|
|
19
|
+
*/
|
|
20
|
+
getDiscordResponse(): ApplicationCommand<{}>;
|
|
12
21
|
/**
|
|
13
22
|
* Returns the command name.
|
|
14
23
|
*/
|
|
@@ -7,6 +7,19 @@ const context_1 = require("../context");
|
|
|
7
7
|
* @abstract
|
|
8
8
|
*/
|
|
9
9
|
class CommandDiscovery extends context_1.NestCordBaseDiscovery {
|
|
10
|
+
/**
|
|
11
|
+
* Return the command ID
|
|
12
|
+
*/
|
|
13
|
+
getId() {
|
|
14
|
+
var _a;
|
|
15
|
+
return (_a = this.meta.discordResponse) === null || _a === void 0 ? void 0 : _a.id;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Return the discord response of command
|
|
19
|
+
*/
|
|
20
|
+
getDiscordResponse() {
|
|
21
|
+
return this.meta.discordResponse;
|
|
22
|
+
}
|
|
10
23
|
/**
|
|
11
24
|
* Returns the command name.
|
|
12
25
|
*/
|
|
@@ -38,14 +38,17 @@ let CommandsModule = class CommandsModule {
|
|
|
38
38
|
}
|
|
39
39
|
onModuleInit() {
|
|
40
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
if (this.options.skipRegistration) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
41
|
this.client.once('ready', () => __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
yield this.client.application.commands.fetch();
|
|
43
|
+
this.commandsService.getAllCommandsAndSetAdditionalMeta();
|
|
44
|
+
if (this.options.skipRegistration) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
45
47
|
if (this.client.application.partial) {
|
|
46
48
|
yield this.client.application.fetch();
|
|
47
49
|
}
|
|
48
50
|
yield this.commandsService.registerAllCommands();
|
|
51
|
+
this.commandsService.getAllCommandsAndSetAdditionalMeta();
|
|
49
52
|
}));
|
|
50
53
|
});
|
|
51
54
|
}
|
|
@@ -30,4 +30,5 @@ export declare class CommandsService {
|
|
|
30
30
|
getGlobalCommandByName(name: string): CommandDiscovery;
|
|
31
31
|
getGuildCommands(guildId: string): CommandDiscovery[];
|
|
32
32
|
getGuildCommandByName(guildId: string, name: string): CommandDiscovery;
|
|
33
|
+
getAllCommandsAndSetAdditionalMeta(): void;
|
|
33
34
|
}
|
|
@@ -110,6 +110,22 @@ let CommandsService = CommandsService_1 = class CommandsService {
|
|
|
110
110
|
getGuildCommandByName(guildId, name) {
|
|
111
111
|
return this.getGuildCommands(guildId).find((command) => command.getName() === name);
|
|
112
112
|
}
|
|
113
|
+
getAllCommandsAndSetAdditionalMeta() {
|
|
114
|
+
const commands = this.getCommandsMap();
|
|
115
|
+
const commandsCache = this.client.application.commands.cache;
|
|
116
|
+
const matchingCommands = Array.from(commandsCache.values()).filter((command) => commands.has(command.name));
|
|
117
|
+
for (const command of matchingCommands) {
|
|
118
|
+
const commandByName = commands.get(command.name);
|
|
119
|
+
if (commandByName.meta) {
|
|
120
|
+
commandByName.meta.discordResponse = command;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
// @ts-ignore
|
|
124
|
+
commandByName.meta = { discordResponse: command };
|
|
125
|
+
}
|
|
126
|
+
this.slashCommandsService.update(commandByName);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
113
129
|
};
|
|
114
130
|
exports.CommandsService = CommandsService;
|
|
115
131
|
exports.CommandsService = CommandsService = CommandsService_1 = __decorate([
|
|
@@ -5,6 +5,7 @@ export interface SlashCommandMeta extends ChatInputApplicationCommandData {
|
|
|
5
5
|
type?: ApplicationCommandType.ChatInput | ApplicationCommandOptionType.SubcommandGroup | ApplicationCommandOptionType.Subcommand;
|
|
6
6
|
category?: string;
|
|
7
7
|
guilds?: Snowflake[];
|
|
8
|
+
discordResponse?: any;
|
|
8
9
|
}
|
|
9
10
|
export interface OptionMeta extends APIApplicationCommandOptionBase<any> {
|
|
10
11
|
resolver?: keyof CommandInteractionOptionResolver;
|
|
@@ -10,6 +10,7 @@ export declare class SlashCommandsService {
|
|
|
10
10
|
readonly cache: Collection<string, SlashCommandDiscovery>;
|
|
11
11
|
constructor(reflector: Reflector);
|
|
12
12
|
add(command: SlashCommandDiscovery): void;
|
|
13
|
+
update(command: SlashCommandDiscovery): void;
|
|
13
14
|
get(commandName: string): SlashCommandDiscovery;
|
|
14
15
|
remove(commandName: string): boolean;
|
|
15
16
|
addSubCommand(subCommand: SlashCommandDiscovery): void;
|
|
@@ -30,6 +30,9 @@ let SlashCommandsService = SlashCommandsService_1 = class SlashCommandsService {
|
|
|
30
30
|
}
|
|
31
31
|
this.cache.set(command.getName(), command);
|
|
32
32
|
}
|
|
33
|
+
update(command) {
|
|
34
|
+
this.cache.set(command.getName(), command);
|
|
35
|
+
}
|
|
33
36
|
get(commandName) {
|
|
34
37
|
return this.cache.get(commandName);
|
|
35
38
|
}
|
|
@@ -9,7 +9,7 @@ interface DiscoveredItem {
|
|
|
9
9
|
handler?: (...args: unknown[]) => void;
|
|
10
10
|
}
|
|
11
11
|
export declare abstract class NestCordBaseDiscovery<T = unknown> {
|
|
12
|
-
|
|
12
|
+
meta: T;
|
|
13
13
|
protected readonly reflector: Reflector;
|
|
14
14
|
protected discovery: DiscoveredItem;
|
|
15
15
|
protected contextCallback: Function;
|
|
@@ -1,2 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./buttons-padgination.builder"), exports);
|
|
18
|
+
__exportStar(require("./select-menu-pagination.builder"), exports);
|
|
19
|
+
__exportStar(require("./page.builder"), exports);
|
|
@@ -17,5 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./enums"), exports);
|
|
18
18
|
__exportStar(require("./exceptions"), exports);
|
|
19
19
|
__exportStar(require("./interfaces"), exports);
|
|
20
|
+
__exportStar(require("./builders"), exports);
|
|
20
21
|
__exportStar(require("./nestcord-pagination.module"), exports);
|
|
21
22
|
__exportStar(require("./nestcord-pagination.service"), exports);
|
package/package.json
CHANGED