@globalart/nestcord 1.5.1 → 1.5.2
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/commands/context-menus/context-menus.module.js +2 -1
- package/dist/core/commands/context-menus/decorators/target.decorator.js +8 -4
- package/dist/core/commands/slash-commands/autocomplete/autocomplete.interceptor.js +2 -1
- package/dist/core/commands/slash-commands/options/options.decorator.js +2 -1
- package/dist/core/commands/slash-commands/slash-commands.module.js +2 -1
- package/dist/core/message-components/decorators/component-param.decorator.js +4 -2
- package/dist/core/message-components/message-components.module.js +2 -1
- package/dist/core/modals/decorators/modal-param.decorator.js +4 -2
- package/dist/core/modals/modals.module.js +2 -1
- package/dist/core/nestcord-explorer.service.js +2 -1
- package/dist/core/nestcord-options.interface.d.ts +1 -1
- package/dist/core/nestcord.module.d.ts +1 -1
- package/dist/core/nestcord.module.js +1 -1
- package/dist/core/text-commands/decorators/arguments.decorator.js +2 -1
- package/dist/core/text-commands/text-commands.module.js +6 -3
- package/dist/localization/interceptors/localization.interceptor.js +2 -1
- package/dist/localization/nestcord-localization.module-definition.js +5 -1
- package/dist/localization/nestcord-localization.service.js +4 -1
- package/dist/stat-reporter/nestcord-stat-reporter.service.js +2 -2
- package/package.json +1 -1
|
@@ -29,8 +29,9 @@ let ContextMenusModule = class ContextMenusModule {
|
|
|
29
29
|
onApplicationBootstrap() {
|
|
30
30
|
return this.client.on('interactionCreate', (interaction) => {
|
|
31
31
|
var _a;
|
|
32
|
-
if (!interaction.isContextMenuCommand())
|
|
32
|
+
if (!interaction.isContextMenuCommand()) {
|
|
33
33
|
return;
|
|
34
|
+
}
|
|
34
35
|
return (_a = this.contextMenusService.get(interaction.commandType, interaction.commandName)) === null || _a === void 0 ? void 0 : _a.execute(interaction);
|
|
35
36
|
});
|
|
36
37
|
}
|
|
@@ -9,8 +9,9 @@ const context_1 = require("../../../context");
|
|
|
9
9
|
exports.Target = (0, common_1.createParamDecorator)((_, context) => {
|
|
10
10
|
const nestcordContext = context_1.NestCordExecutionContext.create(context);
|
|
11
11
|
const [interaction] = nestcordContext.getContext();
|
|
12
|
-
if (!interaction.isContextMenuCommand())
|
|
12
|
+
if (!interaction.isContextMenuCommand()) {
|
|
13
13
|
return null;
|
|
14
|
+
}
|
|
14
15
|
return interaction.isMessageContextMenuCommand()
|
|
15
16
|
? interaction.options.getMessage('message')
|
|
16
17
|
: interaction.options.getUser('user');
|
|
@@ -32,8 +33,9 @@ exports.Target = (0, common_1.createParamDecorator)((_, context) => {
|
|
|
32
33
|
exports.TargetMessage = (0, common_1.createParamDecorator)((_, context) => {
|
|
33
34
|
const nestcordContext = context_1.NestCordExecutionContext.create(context);
|
|
34
35
|
const [interaction] = nestcordContext.getContext();
|
|
35
|
-
if (!interaction.isMessageContextMenuCommand())
|
|
36
|
+
if (!interaction.isMessageContextMenuCommand()) {
|
|
36
37
|
return null;
|
|
38
|
+
}
|
|
37
39
|
return interaction.targetMessage;
|
|
38
40
|
});
|
|
39
41
|
/**
|
|
@@ -53,8 +55,9 @@ exports.TargetMessage = (0, common_1.createParamDecorator)((_, context) => {
|
|
|
53
55
|
exports.TargetUser = (0, common_1.createParamDecorator)((_, context) => {
|
|
54
56
|
const nestcordContext = context_1.NestCordExecutionContext.create(context);
|
|
55
57
|
const [interaction] = nestcordContext.getContext();
|
|
56
|
-
if (!interaction.isUserContextMenuCommand())
|
|
58
|
+
if (!interaction.isUserContextMenuCommand()) {
|
|
57
59
|
return null;
|
|
60
|
+
}
|
|
58
61
|
return interaction.targetUser;
|
|
59
62
|
});
|
|
60
63
|
/**
|
|
@@ -74,7 +77,8 @@ exports.TargetUser = (0, common_1.createParamDecorator)((_, context) => {
|
|
|
74
77
|
exports.TargetMember = (0, common_1.createParamDecorator)((_, context) => {
|
|
75
78
|
const nestcordContext = context_1.NestCordExecutionContext.create(context);
|
|
76
79
|
const [interaction] = nestcordContext.getContext();
|
|
77
|
-
if (!interaction.isUserContextMenuCommand())
|
|
80
|
+
if (!interaction.isUserContextMenuCommand()) {
|
|
78
81
|
return null;
|
|
82
|
+
}
|
|
79
83
|
return interaction.targetMember;
|
|
80
84
|
});
|
|
@@ -30,8 +30,9 @@ let AutocompleteInterceptor = class AutocompleteInterceptor {
|
|
|
30
30
|
const nestcordContext = context_1.NestCordExecutionContext.create(context);
|
|
31
31
|
const [interaction] = nestcordContext.getContext();
|
|
32
32
|
const discovery = nestcordContext.getDiscovery();
|
|
33
|
-
if (!interaction.isAutocomplete() || !discovery.isSlashCommand())
|
|
33
|
+
if (!interaction.isAutocomplete() || !discovery.isSlashCommand()) {
|
|
34
34
|
return next.handle();
|
|
35
|
+
}
|
|
35
36
|
return (0, rxjs_1.of)(this.transformOptions(interaction));
|
|
36
37
|
});
|
|
37
38
|
}
|
|
@@ -13,8 +13,9 @@ exports.Options = (0, common_1.createParamDecorator)((_, context) => {
|
|
|
13
13
|
const nestcordContext = context_1.NestCordExecutionContext.create(context);
|
|
14
14
|
const [interaction] = nestcordContext.getContext();
|
|
15
15
|
const discovery = nestcordContext.getDiscovery();
|
|
16
|
-
if (!discovery.isSlashCommand())
|
|
16
|
+
if (!discovery.isSlashCommand()) {
|
|
17
17
|
return null;
|
|
18
|
+
}
|
|
18
19
|
return Object.entries(discovery.getRawOptions()).reduce((acc, [parameter, option]) => {
|
|
19
20
|
acc[parameter] = interaction.options[option.resolver].call(interaction.options, option.name, !!option.required);
|
|
20
21
|
return acc;
|
|
@@ -30,8 +30,9 @@ let SlashCommandsModule = class SlashCommandsModule {
|
|
|
30
30
|
onApplicationBootstrap() {
|
|
31
31
|
return this.client.on('interactionCreate', (i) => {
|
|
32
32
|
var _a;
|
|
33
|
-
if (!i.isChatInputCommand() && !i.isAutocomplete())
|
|
33
|
+
if (!i.isChatInputCommand() && !i.isAutocomplete()) {
|
|
34
34
|
return;
|
|
35
|
+
}
|
|
35
36
|
return (_a = this.slashCommandsService.get(i.commandName)) === null || _a === void 0 ? void 0 : _a.execute(i);
|
|
36
37
|
});
|
|
37
38
|
}
|
|
@@ -12,10 +12,12 @@ exports.ComponentParam = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
|
12
12
|
const nestcordContext = context_1.NestCordExecutionContext.create(ctx);
|
|
13
13
|
const [interaction] = nestcordContext.getContext();
|
|
14
14
|
const discovery = nestcordContext.getDiscovery();
|
|
15
|
-
if (!discovery.isMessageComponent() || !interaction.isMessageComponent())
|
|
15
|
+
if (!discovery.isMessageComponent() || !interaction.isMessageComponent()) {
|
|
16
16
|
return null;
|
|
17
|
+
}
|
|
17
18
|
const match = discovery.matcher([interaction.componentType, interaction.customId].join('_'));
|
|
18
|
-
if (!match)
|
|
19
|
+
if (!match) {
|
|
19
20
|
return null;
|
|
21
|
+
}
|
|
20
22
|
return data ? match.params[data] : match.params;
|
|
21
23
|
});
|
|
@@ -29,8 +29,9 @@ let MessageComponentsModule = class MessageComponentsModule {
|
|
|
29
29
|
onApplicationBootstrap() {
|
|
30
30
|
return this.client.on('interactionCreate', (interaction) => {
|
|
31
31
|
var _a;
|
|
32
|
-
if (!interaction.isMessageComponent())
|
|
32
|
+
if (!interaction.isMessageComponent()) {
|
|
33
33
|
return;
|
|
34
|
+
}
|
|
34
35
|
return (_a = this.messageComponentsService.get(interaction.componentType, interaction.customId)) === null || _a === void 0 ? void 0 : _a.execute(interaction);
|
|
35
36
|
});
|
|
36
37
|
}
|
|
@@ -11,10 +11,12 @@ exports.ModalParam = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
|
11
11
|
const nestcordContext = context_1.NestCordExecutionContext.create(ctx);
|
|
12
12
|
const [interaction] = nestcordContext.getContext();
|
|
13
13
|
const discovery = nestcordContext.getDiscovery();
|
|
14
|
-
if (!discovery.isModal() || !interaction.isModalSubmit())
|
|
14
|
+
if (!discovery.isModal() || !interaction.isModalSubmit()) {
|
|
15
15
|
return null;
|
|
16
|
+
}
|
|
16
17
|
const match = discovery.matcher(interaction.customId);
|
|
17
|
-
if (!match)
|
|
18
|
+
if (!match) {
|
|
18
19
|
return null;
|
|
20
|
+
}
|
|
19
21
|
return data ? match.params[data] : match.params;
|
|
20
22
|
});
|
|
@@ -27,8 +27,9 @@ let ModalsModule = class ModalsModule {
|
|
|
27
27
|
onApplicationBootstrap() {
|
|
28
28
|
return this.client.on('interactionCreate', (interaction) => {
|
|
29
29
|
var _a;
|
|
30
|
-
if (!interaction.isModalSubmit())
|
|
30
|
+
if (!interaction.isModalSubmit()) {
|
|
31
31
|
return;
|
|
32
|
+
}
|
|
32
33
|
return (_a = this.modalsService.get(interaction.customId)) === null || _a === void 0 ? void 0 : _a.execute(interaction);
|
|
33
34
|
});
|
|
34
35
|
}
|
|
@@ -43,8 +43,9 @@ let ExplorerService = class ExplorerService extends core_1.Reflector {
|
|
|
43
43
|
const prototype = Object.getPrototypeOf(instance);
|
|
44
44
|
return this.metadataScanner.getAllMethodNames(prototype).map((methodName) => {
|
|
45
45
|
const item = this.get(metadataKey, instance[methodName]);
|
|
46
|
-
if (!item)
|
|
46
|
+
if (!item) {
|
|
47
47
|
return;
|
|
48
|
+
}
|
|
48
49
|
item.setDiscoveryMeta({ class: instance.constructor, handler: instance[methodName] });
|
|
49
50
|
item.setContextCallback(this.createContextCallback(instance, prototype, methodName));
|
|
50
51
|
return item;
|
|
@@ -10,7 +10,7 @@ export interface NestCordModuleOptions extends DiscordClientOptions {
|
|
|
10
10
|
/**
|
|
11
11
|
* If you are using TextCommand, you can specify the prefix here. It can be a string for a static prefix, or a function which returns a string based off the message being sent. If using a function, it can be asynchronous.
|
|
12
12
|
*/
|
|
13
|
-
prefix?: string |
|
|
13
|
+
prefix?: string | ((...args: unknown[]) => string);
|
|
14
14
|
/**
|
|
15
15
|
* As discord caches application commands for up to an hour, it is recommended to specify a development guild when doing development.
|
|
16
16
|
*
|
|
@@ -7,5 +7,5 @@ export declare class NestCordModule extends ConfigurableModuleClass implements O
|
|
|
7
7
|
private readonly options;
|
|
8
8
|
constructor(client: Client, options: NestCordModuleOptions);
|
|
9
9
|
onApplicationBootstrap(): Promise<string>;
|
|
10
|
-
onApplicationShutdown(
|
|
10
|
+
onApplicationShutdown(): Promise<void>;
|
|
11
11
|
}
|
|
@@ -34,7 +34,7 @@ let NestCordModule = class NestCordModule extends nestcord_module_definition_1.C
|
|
|
34
34
|
onApplicationBootstrap() {
|
|
35
35
|
return this.client.login(this.options.token);
|
|
36
36
|
}
|
|
37
|
-
onApplicationShutdown(
|
|
37
|
+
onApplicationShutdown() {
|
|
38
38
|
return this.client.destroy();
|
|
39
39
|
}
|
|
40
40
|
};
|
|
@@ -11,8 +11,9 @@ exports.Arguments = (0, common_1.createParamDecorator)((_, context) => {
|
|
|
11
11
|
const nestcordContext = context_1.NestCordExecutionContext.create(context);
|
|
12
12
|
const [message] = nestcordContext.getContext();
|
|
13
13
|
const discovery = nestcordContext.getDiscovery();
|
|
14
|
-
if (!discovery.isTextCommand())
|
|
14
|
+
if (!discovery.isTextCommand()) {
|
|
15
15
|
return null;
|
|
16
|
+
}
|
|
16
17
|
return message.content.split(/ +/g).slice(1);
|
|
17
18
|
});
|
|
18
19
|
exports.Args = exports.Arguments;
|
|
@@ -43,16 +43,19 @@ let TextCommandsModule = class TextCommandsModule {
|
|
|
43
43
|
onApplicationBootstrap() {
|
|
44
44
|
return this.client.on('messageCreate', (message) => __awaiter(this, void 0, void 0, function* () {
|
|
45
45
|
var _a, _b;
|
|
46
|
-
if (!message || !((_a = message.content) === null || _a === void 0 ? void 0 : _a.length) || message.webhookId || message.author.bot)
|
|
46
|
+
if (!message || !((_a = message.content) === null || _a === void 0 ? void 0 : _a.length) || message.webhookId || message.author.bot) {
|
|
47
47
|
return;
|
|
48
|
+
}
|
|
48
49
|
const content = message.content.toLowerCase();
|
|
49
50
|
const prefix = typeof this.options.prefix !== 'function' ? this.options.prefix || '!' : yield this.options.prefix(message);
|
|
50
|
-
if (!prefix || !content.startsWith(prefix))
|
|
51
|
+
if (!prefix || !content.startsWith(prefix)) {
|
|
51
52
|
return;
|
|
53
|
+
}
|
|
52
54
|
const args = content.substring(prefix.length).split(/ +/g);
|
|
53
55
|
const cmd = args.shift();
|
|
54
|
-
if (!cmd)
|
|
56
|
+
if (!cmd) {
|
|
55
57
|
return;
|
|
58
|
+
}
|
|
56
59
|
return (_b = this.textCommandsService.get(cmd)) === null || _b === void 0 ? void 0 : _b.execute([message]);
|
|
57
60
|
}));
|
|
58
61
|
}
|
|
@@ -45,8 +45,9 @@ let LocalizationInterceptor = LocalizationInterceptor_1 = class LocalizationInte
|
|
|
45
45
|
}
|
|
46
46
|
intercept(context, next) {
|
|
47
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
if (context.getType() !== 'nestcord')
|
|
48
|
+
if (context.getType() !== 'nestcord') {
|
|
49
49
|
return next.handle();
|
|
50
|
+
}
|
|
50
51
|
const nestcordContext = core_1.NestCordExecutionContext.create(context);
|
|
51
52
|
const discovery = nestcordContext.getDiscovery();
|
|
52
53
|
if (!discovery.isSlashCommand() && !discovery.isContextMenu() && !discovery.isMessageComponent()) {
|
|
@@ -20,7 +20,11 @@ _a = new common_1.ConfigurableModuleBuilder()
|
|
|
20
20
|
};
|
|
21
21
|
const resolversProviders = {
|
|
22
22
|
provide: providers_1.LOCALIZATION_RESOLVERS,
|
|
23
|
-
|
|
23
|
+
useFactory: (options) => {
|
|
24
|
+
const resolvers = (options === null || options === void 0 ? void 0 : options.resolvers) || extras.resolvers;
|
|
25
|
+
return Array.isArray(resolvers) ? resolvers : [resolvers];
|
|
26
|
+
},
|
|
27
|
+
inject: [exports.MODULE_OPTIONS_TOKEN],
|
|
24
28
|
};
|
|
25
29
|
return Object.assign(Object.assign({}, definition), { providers: [adapterProvider, ...definition.providers, resolversProviders], exports: [...(definition.exports || []), adapterProvider] });
|
|
26
30
|
})
|
|
@@ -36,12 +36,14 @@ let NestCordLocalizationService = class NestCordLocalizationService {
|
|
|
36
36
|
return [rootCommand, ...subcommandGroups, ...subcommands];
|
|
37
37
|
});
|
|
38
38
|
for (const command of commands) {
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
40
|
const commandMetadata = command['meta'];
|
|
40
41
|
commandMetadata.nameLocalizations = this.getLocalizationMap(commandMetadata.nameLocalizations);
|
|
41
42
|
commandMetadata.descriptionLocalizations = this.getLocalizationMap(commandMetadata.descriptionLocalizations);
|
|
42
43
|
if (command.isSlashCommand() && command.getSubcommands().size === 0) {
|
|
43
44
|
const rawOptions = command.getRawOptions();
|
|
44
45
|
for (const key in rawOptions) {
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
47
|
const optionMetadata = rawOptions[key];
|
|
46
48
|
optionMetadata.name_localizations = this.getLocalizationMap(optionMetadata.name_localizations);
|
|
47
49
|
optionMetadata.description_localizations = this.getLocalizationMap(optionMetadata.description_localizations);
|
|
@@ -53,8 +55,9 @@ let NestCordLocalizationService = class NestCordLocalizationService {
|
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
57
|
getLocalizationMap(map) {
|
|
56
|
-
if (!map)
|
|
58
|
+
if (!map) {
|
|
57
59
|
return;
|
|
60
|
+
}
|
|
58
61
|
return Object.entries(map).reduce((acc, [locale, value]) => {
|
|
59
62
|
acc[locale] = this.localizationAdapter.getTranslation(value, locale);
|
|
60
63
|
return acc;
|
|
@@ -66,8 +66,8 @@ let NestCordStatReporterService = NestCordStatReporterService_1 = class NestCord
|
|
|
66
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
67
|
var _a;
|
|
68
68
|
try {
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
yield this.client.application.fetch();
|
|
70
|
+
const [serverCount, shardCount] = yield Promise.all([
|
|
71
71
|
this.calculateServerCount(),
|
|
72
72
|
Promise.resolve(((_a = this.shard) === null || _a === void 0 ? void 0 : _a.count) || 1),
|
|
73
73
|
]);
|
package/package.json
CHANGED