@globalart/nestcord 1.7.1 → 1.7.3
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/README.md +0 -1
- package/dist/core/src/commands/context-menus/context-menu.discovery.d.ts +1 -1
- package/dist/core/src/commands/slash-commands/autocomplete/autocomplete.interceptor.d.ts +1 -1
- package/dist/core/src/commands/slash-commands/options/attachment-option.decorator.d.ts +2 -7
- package/dist/core/src/commands/slash-commands/options/boolean-option.decorator.d.ts +2 -7
- package/dist/core/src/commands/slash-commands/options/channel-option.decorator.d.ts +2 -8
- package/dist/core/src/commands/slash-commands/options/integer-option.decorator.d.ts +2 -21
- package/dist/core/src/commands/slash-commands/options/member-option.decorator.d.ts +2 -7
- package/dist/core/src/commands/slash-commands/options/mentionable-option.decorator.d.ts +2 -7
- package/dist/core/src/commands/slash-commands/options/number-option.decorator.d.ts +2 -21
- package/dist/core/src/commands/slash-commands/options/option.util.d.ts +2 -2
- package/dist/core/src/commands/slash-commands/options/option.util.js +1 -2
- package/dist/core/src/commands/slash-commands/options/role-option.decorator.d.ts +2 -7
- package/dist/core/src/commands/slash-commands/options/string-option.decorator.d.ts +2 -21
- package/dist/core/src/commands/slash-commands/options/user-option.decorator.d.ts +2 -7
- package/dist/core/src/commands/slash-commands/slash-command.discovery.d.ts +16 -6
- package/dist/core/src/context/nestcord-base.discovery.d.ts +5 -5
- package/dist/core/src/context/nestcord-base.discovery.js +0 -1
- package/dist/core/src/message-components/message-component.discovery.d.ts +1 -1
- package/dist/core/src/modals/modal.discovery.d.ts +1 -1
- package/dist/localization/src/adapters/default-localization.adapter.d.ts +2 -1
- package/dist/localization/src/interceptors/localization.interceptor.d.ts +1 -1
- package/dist/localization/src/nestcord-localization.service.d.ts +2 -1
- package/dist/localization/src/nestcord-localization.service.js +13 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
13
13
|
<a href='https://img.shields.io/npm/v/@globalart/nestcord'><img src="https://img.shields.io/npm/v/@globalart/nestcord" alt="NPM Version" /></a>
|
|
14
|
-
<a href='https://img.shields.io/npm/l/@globalart/nestcord'><img src="https://img.shields.io/npm/l/@globalart/nestcord" alt="NPM License" /></a>
|
|
15
14
|
<a href='https://img.shields.io/npm/dm/@globalart/nestcord'><img src="https://img.shields.io/npm/dm/@globalart/nestcord" alt="NPM Downloads" /></a>
|
|
16
15
|
</p>
|
|
17
16
|
|
|
@@ -24,7 +24,7 @@ export declare class ContextMenuDiscovery extends CommandDiscovery<ContextMenuMe
|
|
|
24
24
|
* Executes the context menu discovery.
|
|
25
25
|
* @param interaction The interaction to execute.
|
|
26
26
|
*/
|
|
27
|
-
execute(interaction: ContextMenuCommandInteraction):
|
|
27
|
+
execute(interaction: ContextMenuCommandInteraction): unknown;
|
|
28
28
|
/**
|
|
29
29
|
* Converts the context menu discovery to JSON.
|
|
30
30
|
*/
|
|
@@ -8,5 +8,5 @@ import { AutocompleteInteraction } from 'discord.js';
|
|
|
8
8
|
*/
|
|
9
9
|
export declare abstract class AutocompleteInterceptor implements NestInterceptor {
|
|
10
10
|
abstract transformOptions(interaction: AutocompleteInteraction): void | Promise<void>;
|
|
11
|
-
intercept(context: ExecutionContext, next: CallHandler): Promise<Observable<
|
|
11
|
+
intercept(context: ExecutionContext, next: CallHandler): Promise<Observable<void | Promise<void>>>;
|
|
12
12
|
}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
+
import { APIApplicationCommandAttachmentOption } from 'discord.js';
|
|
1
2
|
/**
|
|
2
3
|
* Param decorator that marks a method as an attachment option.
|
|
3
4
|
* @param options The attachment options.
|
|
4
5
|
* @returns The decorated method.
|
|
5
6
|
*/
|
|
6
|
-
export declare const AttachmentOption: (data:
|
|
7
|
-
name: string;
|
|
8
|
-
name_localizations?: import("discord.js").LocalizationMap | null;
|
|
9
|
-
description: string;
|
|
10
|
-
description_localizations?: import("discord.js").LocalizationMap | null;
|
|
11
|
-
required?: boolean;
|
|
12
|
-
}) => PropertyDecorator;
|
|
7
|
+
export declare const AttachmentOption: (data: Omit<APIApplicationCommandAttachmentOption, "type">) => PropertyDecorator;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
+
import { APIApplicationCommandBooleanOption } from 'discord.js';
|
|
1
2
|
/**
|
|
2
3
|
* Param decorator that marks a method as a boolean option.
|
|
3
4
|
* @param options The boolean options.
|
|
4
5
|
* @returns The decorated method.
|
|
5
6
|
*/
|
|
6
|
-
export declare const BooleanOption: (data:
|
|
7
|
-
name: string;
|
|
8
|
-
name_localizations?: import("discord.js").LocalizationMap | null;
|
|
9
|
-
description: string;
|
|
10
|
-
description_localizations?: import("discord.js").LocalizationMap | null;
|
|
11
|
-
required?: boolean;
|
|
12
|
-
}) => PropertyDecorator;
|
|
7
|
+
export declare const BooleanOption: (data: Omit<APIApplicationCommandBooleanOption, "type">) => PropertyDecorator;
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
+
import { APIApplicationCommandChannelOption } from 'discord.js';
|
|
1
2
|
/**
|
|
2
3
|
* Param decorator that marks a method as a channel option.
|
|
3
4
|
* @param options The channel options.
|
|
4
5
|
* @returns The decorated method.
|
|
5
6
|
*/
|
|
6
|
-
export declare const ChannelOption: (data:
|
|
7
|
-
name: string;
|
|
8
|
-
name_localizations?: import("discord.js").LocalizationMap | null;
|
|
9
|
-
description: string;
|
|
10
|
-
description_localizations?: import("discord.js").LocalizationMap | null;
|
|
11
|
-
required?: boolean;
|
|
12
|
-
channel_types?: Exclude<import("discord.js").ChannelType, import("discord.js").ChannelType.DM | import("discord.js").ChannelType.GroupDM>[];
|
|
13
|
-
}) => PropertyDecorator;
|
|
7
|
+
export declare const ChannelOption: (data: Omit<APIApplicationCommandChannelOption, "type">) => PropertyDecorator;
|
|
@@ -1,26 +1,7 @@
|
|
|
1
|
+
import { APIApplicationCommandIntegerOption } from 'discord.js';
|
|
1
2
|
/**
|
|
2
3
|
* Param decorator that marks a method as an integer option.
|
|
3
4
|
* @param options The integer options.
|
|
4
5
|
* @returns The decorated method.
|
|
5
6
|
*/
|
|
6
|
-
export declare const IntegerOption: (data:
|
|
7
|
-
name: string;
|
|
8
|
-
name_localizations?: import("discord.js").LocalizationMap | null;
|
|
9
|
-
description: string;
|
|
10
|
-
description_localizations?: import("discord.js").LocalizationMap | null;
|
|
11
|
-
required?: boolean;
|
|
12
|
-
choices?: [];
|
|
13
|
-
min_value?: number;
|
|
14
|
-
max_value?: number;
|
|
15
|
-
autocomplete: true;
|
|
16
|
-
} | {
|
|
17
|
-
name: string;
|
|
18
|
-
name_localizations?: import("discord.js").LocalizationMap | null;
|
|
19
|
-
description: string;
|
|
20
|
-
description_localizations?: import("discord.js").LocalizationMap | null;
|
|
21
|
-
required?: boolean;
|
|
22
|
-
choices?: import("discord.js").APIApplicationCommandOptionChoice<number>[];
|
|
23
|
-
min_value?: number;
|
|
24
|
-
max_value?: number;
|
|
25
|
-
autocomplete?: false;
|
|
26
|
-
}) => PropertyDecorator;
|
|
7
|
+
export declare const IntegerOption: (data: Omit<APIApplicationCommandIntegerOption, "type">) => PropertyDecorator;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
+
import { APIApplicationCommandUserOption } from 'discord.js';
|
|
1
2
|
/**
|
|
2
3
|
* Param decorator that marks a method as a member option.
|
|
3
4
|
* @param options The member options.
|
|
4
5
|
* @returns The decorated method.
|
|
5
6
|
*/
|
|
6
|
-
export declare const MemberOption: (data:
|
|
7
|
-
name: string;
|
|
8
|
-
name_localizations?: import("discord.js").LocalizationMap | null;
|
|
9
|
-
description: string;
|
|
10
|
-
description_localizations?: import("discord.js").LocalizationMap | null;
|
|
11
|
-
required?: boolean;
|
|
12
|
-
}) => PropertyDecorator;
|
|
7
|
+
export declare const MemberOption: (data: Omit<APIApplicationCommandUserOption, "type">) => PropertyDecorator;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
+
import { APIApplicationCommandMentionableOption } from 'discord.js';
|
|
1
2
|
/**
|
|
2
3
|
* Param decorator that marks a method as a mentionable option.
|
|
3
4
|
* @param options The mentionable options.
|
|
4
5
|
* @returns The decorated method.
|
|
5
6
|
*/
|
|
6
|
-
export declare const MentionableOption: (data:
|
|
7
|
-
name: string;
|
|
8
|
-
name_localizations?: import("discord.js").LocalizationMap | null;
|
|
9
|
-
description: string;
|
|
10
|
-
description_localizations?: import("discord.js").LocalizationMap | null;
|
|
11
|
-
required?: boolean;
|
|
12
|
-
}) => PropertyDecorator;
|
|
7
|
+
export declare const MentionableOption: (data: Omit<APIApplicationCommandMentionableOption, "type">) => PropertyDecorator;
|
|
@@ -1,26 +1,7 @@
|
|
|
1
|
+
import { APIApplicationCommandNumberOption } from 'discord.js';
|
|
1
2
|
/**
|
|
2
3
|
* Param decorator that marks a method as a number option.
|
|
3
4
|
* @param options The number options.
|
|
4
5
|
* @returns The decorated method.
|
|
5
6
|
*/
|
|
6
|
-
export declare const NumberOption: (data:
|
|
7
|
-
name: string;
|
|
8
|
-
name_localizations?: import("discord.js").LocalizationMap | null;
|
|
9
|
-
description: string;
|
|
10
|
-
description_localizations?: import("discord.js").LocalizationMap | null;
|
|
11
|
-
required?: boolean;
|
|
12
|
-
choices?: [];
|
|
13
|
-
min_value?: number;
|
|
14
|
-
max_value?: number;
|
|
15
|
-
autocomplete: true;
|
|
16
|
-
} | {
|
|
17
|
-
name: string;
|
|
18
|
-
name_localizations?: import("discord.js").LocalizationMap | null;
|
|
19
|
-
description: string;
|
|
20
|
-
description_localizations?: import("discord.js").LocalizationMap | null;
|
|
21
|
-
required?: boolean;
|
|
22
|
-
choices?: import("discord.js").APIApplicationCommandOptionChoice<number>[];
|
|
23
|
-
min_value?: number;
|
|
24
|
-
max_value?: number;
|
|
25
|
-
autocomplete?: false;
|
|
26
|
-
}) => PropertyDecorator;
|
|
7
|
+
export declare const NumberOption: (data: Omit<APIApplicationCommandNumberOption, "type">) => PropertyDecorator;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { APIApplicationCommandOptionBase } from 'discord-api-types/payloads/v10/_interactions/_applicationCommands/_chatInput/base';
|
|
2
2
|
import { ApplicationCommandOptionType } from 'discord.js';
|
|
3
3
|
import { OptionMeta } from '../slash-command.discovery';
|
|
4
|
-
import
|
|
4
|
+
import 'reflect-metadata';
|
|
5
5
|
export declare const OPTIONS_METADATA = "necstord:options_meta";
|
|
6
|
-
export declare function createOptionDecorator<T extends APIApplicationCommandOptionBase<
|
|
6
|
+
export declare function createOptionDecorator<T extends APIApplicationCommandOptionBase<ApplicationCommandOptionType>>(type: ApplicationCommandOptionType, resolver: OptionMeta['resolver']): (data: Omit<T, "type">) => PropertyDecorator;
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OPTIONS_METADATA = void 0;
|
|
4
4
|
exports.createOptionDecorator = createOptionDecorator;
|
|
5
|
+
require("reflect-metadata");
|
|
5
6
|
exports.OPTIONS_METADATA = 'necstord:options_meta';
|
|
6
7
|
function createOptionDecorator(type, resolver) {
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
8
|
-
// @ts-ignore
|
|
9
8
|
return (data) => {
|
|
10
9
|
return (target, propertyKey) => {
|
|
11
10
|
let metadata = Reflect.getOwnMetadata(exports.OPTIONS_METADATA, target);
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
+
import { APIApplicationCommandRoleOption } from 'discord.js';
|
|
1
2
|
/**
|
|
2
3
|
* Param decorator that marks a method as a role option.
|
|
3
4
|
* @param options The role options.
|
|
4
5
|
* @returns The decorated method.
|
|
5
6
|
*/
|
|
6
|
-
export declare const RoleOption: (data:
|
|
7
|
-
name: string;
|
|
8
|
-
name_localizations?: import("discord.js").LocalizationMap | null;
|
|
9
|
-
description: string;
|
|
10
|
-
description_localizations?: import("discord.js").LocalizationMap | null;
|
|
11
|
-
required?: boolean;
|
|
12
|
-
}) => PropertyDecorator;
|
|
7
|
+
export declare const RoleOption: (data: Omit<APIApplicationCommandRoleOption, "type">) => PropertyDecorator;
|
|
@@ -1,26 +1,7 @@
|
|
|
1
|
+
import { APIApplicationCommandStringOption } from 'discord.js';
|
|
1
2
|
/**
|
|
2
3
|
* Param decorator that marks a method as a string option.
|
|
3
4
|
* @param options The string options.
|
|
4
5
|
* @returns The decorated method.
|
|
5
6
|
*/
|
|
6
|
-
export declare const StringOption: (data:
|
|
7
|
-
name: string;
|
|
8
|
-
name_localizations?: import("discord.js").LocalizationMap | null;
|
|
9
|
-
description: string;
|
|
10
|
-
description_localizations?: import("discord.js").LocalizationMap | null;
|
|
11
|
-
required?: boolean;
|
|
12
|
-
choices?: [];
|
|
13
|
-
autocomplete: true;
|
|
14
|
-
min_length?: number;
|
|
15
|
-
max_length?: number;
|
|
16
|
-
} | {
|
|
17
|
-
name: string;
|
|
18
|
-
name_localizations?: import("discord.js").LocalizationMap | null;
|
|
19
|
-
description: string;
|
|
20
|
-
description_localizations?: import("discord.js").LocalizationMap | null;
|
|
21
|
-
required?: boolean;
|
|
22
|
-
choices?: import("discord.js").APIApplicationCommandOptionChoice<string>[];
|
|
23
|
-
autocomplete?: false;
|
|
24
|
-
min_length?: number;
|
|
25
|
-
max_length?: number;
|
|
26
|
-
}) => PropertyDecorator;
|
|
7
|
+
export declare const StringOption: (data: Omit<APIApplicationCommandStringOption, "type">) => PropertyDecorator;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
+
import { APIApplicationCommandUserOption } from 'discord.js';
|
|
1
2
|
/**
|
|
2
3
|
* Param decorator that marks a method as a user option.
|
|
3
4
|
* @param options The user options.
|
|
4
5
|
* @returns The decorated method.
|
|
5
6
|
*/
|
|
6
|
-
export declare const UserOption: (data:
|
|
7
|
-
name: string;
|
|
8
|
-
name_localizations?: import("discord.js").LocalizationMap | null;
|
|
9
|
-
description: string;
|
|
10
|
-
description_localizations?: import("discord.js").LocalizationMap | null;
|
|
11
|
-
required?: boolean;
|
|
12
|
-
}) => PropertyDecorator;
|
|
7
|
+
export declare const UserOption: (data: Omit<APIApplicationCommandUserOption, "type">) => PropertyDecorator;
|
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
import { ApplicationCommandOptionType, ApplicationCommandType, AutocompleteInteraction, ChatInputApplicationCommandData, ChatInputCommandInteraction, Collection, CommandInteractionOptionResolver, Snowflake } from 'discord.js';
|
|
1
|
+
import { ApplicationCommand, ApplicationCommandOptionType, ApplicationCommandSubCommandData, ApplicationCommandSubGroupData, ApplicationCommandType, AutocompleteInteraction, ChatInputApplicationCommandData, ChatInputCommandInteraction, Collection, CommandInteractionOptionResolver, Snowflake } from 'discord.js';
|
|
2
2
|
import { APIApplicationCommandOptionBase } from 'discord-api-types/payloads/v10/_interactions/_applicationCommands/_chatInput/base';
|
|
3
|
-
import { CommandDiscovery } from '../command.discovery';
|
|
4
|
-
|
|
5
|
-
type?: ApplicationCommandType.ChatInput | ApplicationCommandOptionType.SubcommandGroup | ApplicationCommandOptionType.Subcommand;
|
|
3
|
+
import { BaseCommandMeta, CommandDiscovery } from '../command.discovery';
|
|
4
|
+
interface BaseSlashCommandMeta {
|
|
6
5
|
category?: string;
|
|
7
6
|
guilds?: Snowflake[];
|
|
8
|
-
discordResponse?:
|
|
7
|
+
discordResponse?: ApplicationCommand;
|
|
9
8
|
}
|
|
10
|
-
export interface
|
|
9
|
+
export interface ChatInputSlashCommandMeta extends BaseSlashCommandMeta, ChatInputApplicationCommandData {
|
|
10
|
+
type: ApplicationCommandType.ChatInput;
|
|
11
|
+
}
|
|
12
|
+
export interface SubcommandSlashCommandMeta extends BaseSlashCommandMeta, ApplicationCommandSubCommandData {
|
|
13
|
+
type: ApplicationCommandOptionType.Subcommand;
|
|
14
|
+
}
|
|
15
|
+
export interface SubcommandGroupSlashCommandMeta extends BaseCommandMeta, ApplicationCommandSubGroupData {
|
|
16
|
+
type: ApplicationCommandOptionType.SubcommandGroup;
|
|
17
|
+
}
|
|
18
|
+
export type SlashCommandMeta = ChatInputSlashCommandMeta | SubcommandSlashCommandMeta | SubcommandGroupSlashCommandMeta;
|
|
19
|
+
export interface OptionMeta extends APIApplicationCommandOptionBase<ApplicationCommandOptionType> {
|
|
11
20
|
resolver?: keyof CommandInteractionOptionResolver;
|
|
12
21
|
}
|
|
13
22
|
/**
|
|
@@ -61,3 +70,4 @@ export declare class SlashCommandDiscovery extends CommandDiscovery<SlashCommand
|
|
|
61
70
|
*/
|
|
62
71
|
toJSON(): any;
|
|
63
72
|
}
|
|
73
|
+
export {};
|
|
@@ -5,20 +5,20 @@ import { ListenerDiscovery } from '../listeners';
|
|
|
5
5
|
import { TextCommandDiscovery } from '../text-commands';
|
|
6
6
|
import { ModalDiscovery } from '../modals';
|
|
7
7
|
interface DiscoveredItem {
|
|
8
|
-
class:
|
|
8
|
+
class: new (...args: unknown[]) => unknown;
|
|
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
|
-
protected contextCallback:
|
|
15
|
+
protected contextCallback: (context: unknown, discovery: this) => unknown;
|
|
16
16
|
constructor(meta: T);
|
|
17
|
-
getClass():
|
|
17
|
+
getClass(): new (...args: unknown[]) => unknown;
|
|
18
18
|
getHandler(): (...args: unknown[]) => void;
|
|
19
19
|
setDiscoveryMeta(meta: DiscoveredItem): void;
|
|
20
|
-
setContextCallback(fn:
|
|
21
|
-
execute(context?: unknown):
|
|
20
|
+
setContextCallback(fn: (context: unknown, discovery: this) => unknown): void;
|
|
21
|
+
execute(context?: unknown): unknown;
|
|
22
22
|
isContextMenu(): this is ContextMenuDiscovery;
|
|
23
23
|
isSlashCommand(): this is SlashCommandDiscovery;
|
|
24
24
|
isMessageComponent(): this is MessageComponentDiscovery;
|
|
@@ -11,7 +11,7 @@ export declare class MessageComponentDiscovery extends NestCordBaseDiscovery<Mes
|
|
|
11
11
|
readonly matcher: import("path-to-regexp").MatchFunction<Partial<Record<string, string | string[]>>>;
|
|
12
12
|
getType(): MessageComponentType;
|
|
13
13
|
getCustomId(): string;
|
|
14
|
-
execute(interaction: MessageComponentInteraction):
|
|
14
|
+
execute(interaction: MessageComponentInteraction): unknown;
|
|
15
15
|
isMessageComponent(): this is MessageComponentDiscovery;
|
|
16
16
|
toJSON(): MessageComponentMeta;
|
|
17
17
|
}
|
|
@@ -9,7 +9,7 @@ export interface ModalMeta {
|
|
|
9
9
|
export declare class ModalDiscovery extends NestCordBaseDiscovery<ModalMeta> {
|
|
10
10
|
readonly matcher: import("path-to-regexp").MatchFunction<Partial<Record<string, string | string[]>>>;
|
|
11
11
|
getCustomId(): string;
|
|
12
|
-
execute(interaction: ModalSubmitInteraction):
|
|
12
|
+
execute(interaction: ModalSubmitInteraction): unknown;
|
|
13
13
|
isModal(): this is ModalDiscovery;
|
|
14
14
|
toJSON(): Record<string, any>;
|
|
15
15
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseLocalizationAdapter } from './base-localization.adapter';
|
|
2
|
+
import { Locale } from 'discord.js';
|
|
2
3
|
interface DefaultLocalizationAdapterOptions {
|
|
3
4
|
fallbackLocale?: string;
|
|
4
5
|
locales?: Record<string, Record<string, string>>;
|
|
@@ -6,7 +7,7 @@ interface DefaultLocalizationAdapterOptions {
|
|
|
6
7
|
export declare class DefaultLocalizationAdapter extends BaseLocalizationAdapter<DefaultLocalizationAdapterOptions> {
|
|
7
8
|
getTranslation(key: string, locale: string, placeholders?: unknown): string;
|
|
8
9
|
translate(key: string, placeholders?: unknown): string;
|
|
9
|
-
updateLocales(locales: Record<
|
|
10
|
+
updateLocales(locales: Record<Locale, Record<string, string>>): void;
|
|
10
11
|
private getTranslations;
|
|
11
12
|
private getFallbackTranslation;
|
|
12
13
|
}
|
|
@@ -12,7 +12,7 @@ export declare class LocalizationInterceptor implements NestInterceptor, OnModul
|
|
|
12
12
|
static getCurrentTranslationFn(): TranslationFn;
|
|
13
13
|
constructor(localizationAdapter: BaseLocalizationAdapter, resolvers: (LocaleResolver | Type<LocaleResolver>)[], moduleRef: ModuleRef);
|
|
14
14
|
onModuleInit(): Promise<void>;
|
|
15
|
-
intercept(context: ExecutionContext, next: CallHandler<
|
|
15
|
+
intercept(context: ExecutionContext, next: CallHandler<unknown>): Promise<Observable<unknown>>;
|
|
16
16
|
private getLocale;
|
|
17
17
|
private getResolver;
|
|
18
18
|
private getTranslationFn;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { OnModuleInit } from '@nestjs/common';
|
|
2
2
|
import { CommandsService } from '../../core';
|
|
3
3
|
import { DefaultLocalizationAdapter } from './adapters';
|
|
4
|
+
import { Locale } from 'discord.js';
|
|
4
5
|
export declare class NestCordLocalizationService implements OnModuleInit {
|
|
5
6
|
private readonly localizationAdapter;
|
|
6
7
|
private readonly commandsService;
|
|
7
8
|
constructor(localizationAdapter: DefaultLocalizationAdapter, commandsService: CommandsService);
|
|
8
9
|
onModuleInit(): void;
|
|
9
|
-
updateLocales(locales:
|
|
10
|
+
updateLocales(locales: Record<Locale, Record<string, string>>): Promise<void>;
|
|
10
11
|
private updateCommandsLocalization;
|
|
11
12
|
private getLocalizationMap;
|
|
12
13
|
}
|
|
@@ -55,14 +55,22 @@ let NestCordLocalizationService = class NestCordLocalizationService {
|
|
|
55
55
|
});
|
|
56
56
|
for (const command of commands) {
|
|
57
57
|
const commandMetadata = command['meta'];
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
if (commandMetadata.nameLocalizations) {
|
|
59
|
+
commandMetadata.nameLocalizations = this.getLocalizationMap(commandMetadata.nameLocalizations);
|
|
60
|
+
}
|
|
61
|
+
if (commandMetadata.descriptionLocalizations) {
|
|
62
|
+
commandMetadata.descriptionLocalizations = this.getLocalizationMap(commandMetadata.descriptionLocalizations);
|
|
63
|
+
}
|
|
60
64
|
if (command.isSlashCommand() && command.getSubcommands().size === 0) {
|
|
61
65
|
const rawOptions = command.getRawOptions();
|
|
62
66
|
for (const key in rawOptions) {
|
|
63
67
|
const optionMetadata = rawOptions[key];
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
if (optionMetadata.name_localizations) {
|
|
69
|
+
optionMetadata.name_localizations = this.getLocalizationMap(optionMetadata.name_localizations);
|
|
70
|
+
}
|
|
71
|
+
if (optionMetadata.description_localizations) {
|
|
72
|
+
optionMetadata.description_localizations = this.getLocalizationMap(optionMetadata.description_localizations);
|
|
73
|
+
}
|
|
66
74
|
if (optionMetadata.choices) {
|
|
67
75
|
optionMetadata.choices = optionMetadata.choices.map((choice) => (Object.assign(Object.assign({}, choice), { name_localizations: this.getLocalizationMap(choice.name_localizations) })));
|
|
68
76
|
}
|
|
@@ -72,7 +80,7 @@ let NestCordLocalizationService = class NestCordLocalizationService {
|
|
|
72
80
|
}
|
|
73
81
|
getLocalizationMap(map) {
|
|
74
82
|
if (!map) {
|
|
75
|
-
return;
|
|
83
|
+
return undefined;
|
|
76
84
|
}
|
|
77
85
|
return Object.entries(map).reduce((acc, [locale, value]) => {
|
|
78
86
|
acc[locale] = this.localizationAdapter.getTranslation(value, locale);
|
package/package.json
CHANGED