@arox/framework 0.1.2-beta.1 → 0.1.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/dist/constants/exports.d.ts +1 -0
- package/dist/constants/lang.d.ts +2 -0
- package/dist/events/interaction.d.ts +4 -1
- package/dist/events/message.d.ts +4 -1
- package/dist/events/ready.d.ts +4 -1
- package/dist/index.cjs +3 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -1194
- package/dist/structures/builder/Builder.d.ts +60 -9
- package/dist/structures/builder/Command.d.ts +23 -11
- package/dist/structures/builder/Context.d.ts +33 -18
- package/dist/structures/builder/Event.d.ts +7 -6
- package/dist/structures/builder/index.d.ts +4 -4
- package/dist/structures/core/Client.d.ts +29 -6
- package/dist/structures/core/index.d.ts +1 -1
- package/dist/structures/index.d.ts +3 -2
- package/dist/structures/parser/MessageCommandParser.d.ts +25 -0
- package/dist/structures/parser/index.d.ts +1 -0
- package/dist/utils/applicationCommandLocalization.d.ts +3 -0
- package/dist/utils/builderAutoSet.d.ts +7 -0
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/logger/ILogger.d.ts +2 -44
- package/dist/utils/logger/Logger.d.ts +18 -54
- package/dist/utils/util.d.ts +8 -3
- package/package.json +1 -1
- package/types/client.d.ts +43 -13
- package/types/logger.d.ts +66 -0
- package/dist/context.d.ts +0 -4
|
@@ -1,19 +1,70 @@
|
|
|
1
|
-
import { SlashCommandBuilder, RESTPostAPIChatInputApplicationCommandsJSONBody } from "discord.js";
|
|
2
|
-
import { Client } from "../core";
|
|
1
|
+
import { SlashCommandAttachmentOption, SlashCommandBooleanOption, SlashCommandBuilder, SlashCommandChannelOption, SlashCommandIntegerOption, SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandRoleOption, SlashCommandStringOption, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandUserOption, type RESTPostAPIChatInputApplicationCommandsJSONBody } from "discord.js";
|
|
2
|
+
import { Client } from "../core/index.js";
|
|
3
3
|
export interface ApplicationJSONBody extends RESTPostAPIChatInputApplicationCommandsJSONBody {
|
|
4
4
|
prefix_support: boolean;
|
|
5
5
|
slash_support: boolean;
|
|
6
|
-
|
|
6
|
+
}
|
|
7
|
+
export declare class AutoSlashCommandStringOption extends SlashCommandStringOption {
|
|
8
|
+
autoSet(key: string): this;
|
|
9
|
+
}
|
|
10
|
+
export declare class AutoSlashCommandIntegerOption extends SlashCommandIntegerOption {
|
|
11
|
+
autoSet(key: string): this;
|
|
12
|
+
}
|
|
13
|
+
export declare class AutoSlashCommandNumberOption extends SlashCommandNumberOption {
|
|
14
|
+
autoSet(key: string): this;
|
|
15
|
+
}
|
|
16
|
+
export declare class AutoSlashCommandBooleanOption extends SlashCommandBooleanOption {
|
|
17
|
+
autoSet(key: string): this;
|
|
18
|
+
}
|
|
19
|
+
export declare class AutoSlashCommandUserOption extends SlashCommandUserOption {
|
|
20
|
+
autoSet(key: string): this;
|
|
21
|
+
}
|
|
22
|
+
export declare class AutoSlashCommandChannelOption extends SlashCommandChannelOption {
|
|
23
|
+
autoSet(key: string): this;
|
|
24
|
+
}
|
|
25
|
+
export declare class AutoSlashCommandRoleOption extends SlashCommandRoleOption {
|
|
26
|
+
autoSet(key: string): this;
|
|
27
|
+
}
|
|
28
|
+
export declare class AutoSlashCommandMentionableOption extends SlashCommandMentionableOption {
|
|
29
|
+
autoSet(key: string): this;
|
|
30
|
+
}
|
|
31
|
+
export declare class AutoSlashCommandAttachmentOption extends SlashCommandAttachmentOption {
|
|
32
|
+
autoSet(key: string): this;
|
|
33
|
+
}
|
|
34
|
+
export declare class AutoSlashCommandSubcommandBuilder extends SlashCommandSubcommandBuilder {
|
|
35
|
+
autoSet(key: string): this;
|
|
36
|
+
addStringOption(input: SlashCommandStringOption | ((builder: SlashCommandStringOption) => SlashCommandStringOption)): SlashCommandSubcommandBuilder;
|
|
37
|
+
addIntegerOption(input: SlashCommandIntegerOption | ((builder: SlashCommandIntegerOption) => SlashCommandIntegerOption)): SlashCommandSubcommandBuilder;
|
|
38
|
+
addNumberOption(input: SlashCommandNumberOption | ((builder: SlashCommandNumberOption) => SlashCommandNumberOption)): SlashCommandSubcommandBuilder;
|
|
39
|
+
addBooleanOption(input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)): SlashCommandSubcommandBuilder;
|
|
40
|
+
addUserOption(input: SlashCommandUserOption | ((builder: SlashCommandUserOption) => SlashCommandUserOption)): SlashCommandSubcommandBuilder;
|
|
41
|
+
addChannelOption(input: SlashCommandChannelOption | ((builder: SlashCommandChannelOption) => SlashCommandChannelOption)): SlashCommandSubcommandBuilder;
|
|
42
|
+
addRoleOption(input: SlashCommandRoleOption | ((builder: SlashCommandRoleOption) => SlashCommandRoleOption)): SlashCommandSubcommandBuilder;
|
|
43
|
+
addMentionableOption(input: SlashCommandMentionableOption | ((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption)): SlashCommandSubcommandBuilder;
|
|
44
|
+
addAttachmentOption(input: SlashCommandAttachmentOption | ((builder: SlashCommandAttachmentOption) => SlashCommandAttachmentOption)): SlashCommandSubcommandBuilder;
|
|
45
|
+
}
|
|
46
|
+
export declare class AutoSlashCommandSubcommandGroupBuilder extends SlashCommandSubcommandGroupBuilder {
|
|
47
|
+
autoSet(key: string): this;
|
|
48
|
+
addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): this;
|
|
7
49
|
}
|
|
8
50
|
export declare class ApplicationCommandBuilder extends SlashCommandBuilder {
|
|
9
|
-
constructor();
|
|
10
51
|
protected prefix_support: boolean;
|
|
11
52
|
protected slash_support: boolean;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
53
|
+
setPrefixSupport(value?: boolean): this;
|
|
54
|
+
setSlashSupport(value?: boolean): this;
|
|
55
|
+
autoSet(key: string): this;
|
|
56
|
+
addStringOption(input: SlashCommandStringOption | ((builder: SlashCommandStringOption) => SlashCommandStringOption)): import("discord.js").SlashCommandOptionsOnlyBuilder;
|
|
57
|
+
addIntegerOption(input: SlashCommandIntegerOption | ((builder: SlashCommandIntegerOption) => SlashCommandIntegerOption)): import("discord.js").SlashCommandOptionsOnlyBuilder;
|
|
58
|
+
addNumberOption(input: SlashCommandNumberOption | ((builder: SlashCommandNumberOption) => SlashCommandNumberOption)): import("discord.js").SlashCommandOptionsOnlyBuilder;
|
|
59
|
+
addBooleanOption(input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)): import("discord.js").SlashCommandOptionsOnlyBuilder;
|
|
60
|
+
addUserOption(input: SlashCommandUserOption | ((builder: SlashCommandUserOption) => SlashCommandUserOption)): import("discord.js").SlashCommandOptionsOnlyBuilder;
|
|
61
|
+
addChannelOption(input: SlashCommandChannelOption | ((builder: SlashCommandChannelOption) => SlashCommandChannelOption)): import("discord.js").SlashCommandOptionsOnlyBuilder;
|
|
62
|
+
addRoleOption(input: SlashCommandRoleOption | ((builder: SlashCommandRoleOption) => SlashCommandRoleOption)): import("discord.js").SlashCommandOptionsOnlyBuilder;
|
|
63
|
+
addMentionableOption(input: SlashCommandMentionableOption | ((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption)): import("discord.js").SlashCommandOptionsOnlyBuilder;
|
|
64
|
+
addAttachmentOption(input: SlashCommandAttachmentOption | ((builder: SlashCommandAttachmentOption) => SlashCommandAttachmentOption)): import("discord.js").SlashCommandOptionsOnlyBuilder;
|
|
65
|
+
addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): import("discord.js").SlashCommandSubcommandsOnlyBuilder;
|
|
66
|
+
addSubcommandGroup(input: SlashCommandSubcommandGroupBuilder | ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder)): import("discord.js").SlashCommandSubcommandsOnlyBuilder;
|
|
17
67
|
toJSON(): ApplicationJSONBody;
|
|
18
68
|
toClientJSON(_client: Client): ReturnType<ApplicationCommandBuilder["toJSON"]>;
|
|
69
|
+
private assertNoMixedTopLevelOptionTypes;
|
|
19
70
|
}
|
|
@@ -1,21 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { MaybePromise } from "#types/extra.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
type MessageContext =
|
|
7
|
-
type InteractionContext =
|
|
1
|
+
import { Client } from "../index.js";
|
|
2
|
+
import { Logger } from "../../utils/index.js";
|
|
3
|
+
import type { MaybePromise } from "#types/extra.js";
|
|
4
|
+
import { ApplicationCommandBuilder } from "../builder/Builder.js";
|
|
5
|
+
import type { InteractionContextJSON, MessageContextJSON } from "../builder/Context.js";
|
|
6
|
+
type MessageContext = MessageContextJSON;
|
|
7
|
+
type InteractionContext = InteractionContextJSON;
|
|
8
|
+
type CommandContext = MessageContext | InteractionContext;
|
|
8
9
|
export declare class CommandBuilder {
|
|
9
10
|
#private;
|
|
10
11
|
readonly data: ApplicationCommandBuilder;
|
|
11
|
-
readonly client: Client;
|
|
12
|
-
readonly logger: Logger;
|
|
13
12
|
_onMessage?: (ctx: MessageContext) => MaybePromise<void>;
|
|
14
13
|
_onInteraction?: (ctx: InteractionContext) => MaybePromise<void>;
|
|
15
|
-
|
|
16
|
-
get
|
|
14
|
+
protected createContextHandler<T extends CommandContext>(primary: ((ctx: T) => MaybePromise<void>) | undefined, fallback: ((ctx: CommandContext) => MaybePromise<void>) | undefined): ((ctx: T) => MaybePromise<void>) | undefined;
|
|
15
|
+
get client(): Client;
|
|
16
|
+
get logger(): Logger;
|
|
17
|
+
get supportsSlash(): boolean;
|
|
18
|
+
get supportsPrefix(): boolean;
|
|
17
19
|
constructor(data: ApplicationCommandBuilder);
|
|
20
|
+
attach(client: Client): this;
|
|
18
21
|
onMessage(func: (ctx: MessageContext) => MaybePromise<void>): this;
|
|
19
22
|
onInteraction(func: (ctx: InteractionContext) => MaybePromise<void>): this;
|
|
20
23
|
}
|
|
24
|
+
export interface CommandOptions {
|
|
25
|
+
data: ApplicationCommandBuilder;
|
|
26
|
+
execute?: (ctx: CommandContext) => MaybePromise<void>;
|
|
27
|
+
onMessage?: (ctx: MessageContext) => MaybePromise<void>;
|
|
28
|
+
onInteraction?: (ctx: InteractionContext) => MaybePromise<void>;
|
|
29
|
+
}
|
|
30
|
+
export declare class Command extends CommandBuilder {
|
|
31
|
+
constructor(options: CommandOptions);
|
|
32
|
+
}
|
|
21
33
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ChatInputCommandInteraction, Locale, Message, User } from "discord.js";
|
|
2
|
+
import type { TOptions } from "i18next";
|
|
3
|
+
import type { Client } from "../index.js";
|
|
4
4
|
type ContextPayload<T extends ChatInputCommandInteraction | Message> = T extends ChatInputCommandInteraction ? {
|
|
5
5
|
interaction: T;
|
|
6
6
|
args?: string[];
|
|
@@ -8,7 +8,30 @@ type ContextPayload<T extends ChatInputCommandInteraction | Message> = T extends
|
|
|
8
8
|
message: T;
|
|
9
9
|
args?: string[];
|
|
10
10
|
};
|
|
11
|
+
type TranslateFn = (key: string, options?: TOptions & {
|
|
12
|
+
defaultValue?: string;
|
|
13
|
+
}) => string;
|
|
14
|
+
type DefaultLocalizationFn = (key: string, fallback?: string) => string;
|
|
15
|
+
type LocalizationAliasesFn = (key: string, fallback?: string | string[]) => string[];
|
|
16
|
+
export interface InteractionContextJSON {
|
|
17
|
+
kind: "interaction";
|
|
18
|
+
interaction: ChatInputCommandInteraction;
|
|
19
|
+
author: User | null;
|
|
20
|
+
t: TranslateFn;
|
|
21
|
+
getDefaultLocalization: DefaultLocalizationFn;
|
|
22
|
+
getLocalizationAliases: LocalizationAliasesFn;
|
|
23
|
+
}
|
|
24
|
+
export interface MessageContextJSON {
|
|
25
|
+
kind: "message";
|
|
26
|
+
message: Message;
|
|
27
|
+
args: string[];
|
|
28
|
+
author: User | null;
|
|
29
|
+
t: TranslateFn;
|
|
30
|
+
getDefaultLocalization: DefaultLocalizationFn;
|
|
31
|
+
getLocalizationAliases: LocalizationAliasesFn;
|
|
32
|
+
}
|
|
11
33
|
export declare class Context<T extends ChatInputCommandInteraction | Message> {
|
|
34
|
+
#private;
|
|
12
35
|
readonly client: Client;
|
|
13
36
|
readonly args: string[];
|
|
14
37
|
readonly data: T;
|
|
@@ -17,23 +40,15 @@ export declare class Context<T extends ChatInputCommandInteraction | Message> {
|
|
|
17
40
|
isInteraction(): this is Context<ChatInputCommandInteraction>;
|
|
18
41
|
isMessage(): this is Context<Message>;
|
|
19
42
|
get author(): User | null;
|
|
43
|
+
private resolveIdentityToken;
|
|
44
|
+
private resolveContextToken;
|
|
45
|
+
private resolveTemplateToken;
|
|
20
46
|
t(key: string, options?: TOptions & {
|
|
21
47
|
defaultValue?: string;
|
|
22
48
|
}): string;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
t: any;
|
|
28
|
-
message?: undefined;
|
|
29
|
-
args?: undefined;
|
|
30
|
-
} | {
|
|
31
|
-
kind: "message";
|
|
32
|
-
message: Message;
|
|
33
|
-
args: string[];
|
|
34
|
-
author: User | null;
|
|
35
|
-
t: any;
|
|
36
|
-
interaction?: undefined;
|
|
37
|
-
};
|
|
49
|
+
getDefaultLocalization(key: string, fallback?: string): string;
|
|
50
|
+
getLocalizationAliases(key: string, fallback?: string | string[]): string[];
|
|
51
|
+
toJSON(this: Context<ChatInputCommandInteraction>): InteractionContextJSON;
|
|
52
|
+
toJSON(this: Context<Message>): MessageContextJSON;
|
|
38
53
|
}
|
|
39
54
|
export {};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { ClientEvents } from "discord.js";
|
|
2
|
-
import { MaybePromise } from "#types/extra.js";
|
|
3
|
-
import { Client } from "../index";
|
|
4
|
-
import { Logger } from "../../utils/index";
|
|
1
|
+
import type { ClientEvents } from "discord.js";
|
|
2
|
+
import type { MaybePromise } from "#types/extra.js";
|
|
3
|
+
import { Client } from "../index.js";
|
|
4
|
+
import { Logger } from "../../utils/index.js";
|
|
5
5
|
type EventArgs<K extends keyof ClientEvents> = ClientEvents[K];
|
|
6
6
|
type EventHandler<K extends keyof ClientEvents> = (context: EventBuilder<K>, ...args: EventArgs<K>) => MaybePromise<void>;
|
|
7
7
|
export declare class EventBuilder<K extends keyof ClientEvents> {
|
|
8
8
|
#private;
|
|
9
9
|
readonly name: K;
|
|
10
10
|
readonly once: boolean;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
get client(): Client;
|
|
12
|
+
get logger(): Logger;
|
|
13
13
|
constructor(name: K, once?: boolean, _handler?: EventHandler<K>);
|
|
14
|
+
attach(client: Client): this;
|
|
14
15
|
onExecute(func: EventHandler<K>): this;
|
|
15
16
|
}
|
|
16
17
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./Command";
|
|
2
|
-
export * from "./Context";
|
|
3
|
-
export * from "./Event";
|
|
4
|
-
export * from "./Builder";
|
|
1
|
+
export * from "./Command.js";
|
|
2
|
+
export * from "./Context.js";
|
|
3
|
+
export * from "./Event.js";
|
|
4
|
+
export * from "./Builder.js";
|
|
@@ -1,19 +1,42 @@
|
|
|
1
1
|
import { Client as DiscordClient, Collection, IntentsBitField } from "discord.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import type { i18n } from "i18next";
|
|
3
|
+
import type { FrameworkOptions, ModuleExport, PrefixFn, TemplateContext, TemplateParserFn } from "#types/client.js";
|
|
4
|
+
import { Logger } from "../../utils/index.js";
|
|
5
|
+
import { CommandBuilder } from "../index.js";
|
|
6
6
|
export declare class Client<Ready extends boolean = boolean> extends DiscordClient<Ready> {
|
|
7
7
|
#private;
|
|
8
8
|
readonly logger: Logger;
|
|
9
9
|
commands: Collection<string, CommandBuilder>;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
private slashCommandLookup;
|
|
11
|
+
private prefixCommandLookup;
|
|
12
|
+
private readonly templateParsers;
|
|
13
|
+
readonly prefix: PrefixFn;
|
|
12
14
|
i18n: i18n | undefined;
|
|
15
|
+
readonly i18next: {
|
|
16
|
+
readonly instance: i18n | undefined;
|
|
17
|
+
readonly parser: {
|
|
18
|
+
addParser: (parser: TemplateParserFn) => void;
|
|
19
|
+
removeParser: (parser: TemplateParserFn) => boolean;
|
|
20
|
+
clearParsers: () => void;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
13
23
|
options: Omit<FrameworkOptions, "intents"> & {
|
|
14
24
|
intents: IntentsBitField;
|
|
15
25
|
};
|
|
16
26
|
constructor(opts: FrameworkOptions);
|
|
17
27
|
login(token?: string): Promise<string>;
|
|
28
|
+
registerExport(exported: ModuleExport, source: string, factoryDepth?: number): Promise<void>;
|
|
29
|
+
private normalizeCommandName;
|
|
30
|
+
invalidateCommandLookupCache(): void;
|
|
31
|
+
addTemplateParser(parser: TemplateParserFn): void;
|
|
32
|
+
removeTemplateParser(parser: TemplateParserFn): boolean;
|
|
33
|
+
clearTemplateParsers(): void;
|
|
34
|
+
parseTemplateToken(key: string, context: TemplateContext): string | undefined;
|
|
35
|
+
private buildCommandLookup;
|
|
36
|
+
private getSlashCommandLookup;
|
|
37
|
+
private getPrefixCommandLookup;
|
|
38
|
+
getSlashCommandsPayload(): import("../index.js").ApplicationJSONBody[];
|
|
39
|
+
resolveInteractionCommand(commandName: string): CommandBuilder | undefined;
|
|
40
|
+
resolveMessageCommand(commandName: string): CommandBuilder | undefined;
|
|
18
41
|
registerCommands(): Promise<void>;
|
|
19
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./Client";
|
|
1
|
+
export * from "./Client.js";
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export * from "./core";
|
|
2
|
-
export * from "./builder";
|
|
1
|
+
export * from "./core/index.js";
|
|
2
|
+
export * from "./builder/index.js";
|
|
3
|
+
export * from "./parser/index.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { MessageContextJSON } from "../builder/Context.js";
|
|
2
|
+
interface IntegerOptionConfig {
|
|
3
|
+
key: string;
|
|
4
|
+
fallbackAliases?: string[];
|
|
5
|
+
defaultValue?: number;
|
|
6
|
+
startIndex?: number;
|
|
7
|
+
useFuzzy?: boolean;
|
|
8
|
+
maxDistance?: number;
|
|
9
|
+
}
|
|
10
|
+
interface MatchOptions {
|
|
11
|
+
useFuzzy?: boolean;
|
|
12
|
+
maxDistance?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare class MessageCommandParser {
|
|
15
|
+
private readonly ctx;
|
|
16
|
+
readonly args: string[];
|
|
17
|
+
readonly normalizedArgs: string[];
|
|
18
|
+
constructor(ctx: MessageContextJSON);
|
|
19
|
+
static normalizeToken(value: string): string;
|
|
20
|
+
getAliases(key: string, fallbackAliases?: string[]): string[];
|
|
21
|
+
private findClosestAlias;
|
|
22
|
+
matchesArg(index: number, key: string, fallbackAliases?: string[], options?: MatchOptions): boolean;
|
|
23
|
+
parseIntegerOption(config: IntegerOptionConfig): number;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./MessageCommandParser.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type AutoSetTarget = {
|
|
2
|
+
setName(name: string): unknown;
|
|
3
|
+
setDescription(description: string): unknown;
|
|
4
|
+
};
|
|
5
|
+
export declare const applyAutoSet: <T extends AutoSetTarget>(target: T, key: string) => T;
|
|
6
|
+
export declare const asCustomBuilder: <T extends object>(builder: object, ctor: new () => T) => T;
|
|
7
|
+
export {};
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./util";
|
|
2
|
-
export * from "./Files";
|
|
3
|
-
export * from "./logger/Logger";
|
|
1
|
+
export * from "./util.js";
|
|
2
|
+
export * from "./Files.js";
|
|
3
|
+
export * from "./logger/Logger.js";
|
|
@@ -27,50 +27,8 @@ export declare enum LogLevel {
|
|
|
27
27
|
*/
|
|
28
28
|
Fatal = 60,
|
|
29
29
|
/**
|
|
30
|
-
* An
|
|
30
|
+
* An uncategorized level.
|
|
31
31
|
*/
|
|
32
32
|
None = 100
|
|
33
33
|
}
|
|
34
|
-
export
|
|
35
|
-
/**
|
|
36
|
-
* Checks whether a level is supported.
|
|
37
|
-
* @param level The level to check.
|
|
38
|
-
*/
|
|
39
|
-
has(level: LogLevel): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Alias of {@link ILogger.write} with {@link LogLevel.Trace} as level.
|
|
42
|
-
* @param values The values to log.
|
|
43
|
-
*/
|
|
44
|
-
trace(...values: readonly unknown[]): void;
|
|
45
|
-
/**
|
|
46
|
-
* Alias of {@link ILogger.write} with {@link LogLevel.Debug} as level.
|
|
47
|
-
* @param values The values to log.
|
|
48
|
-
*/
|
|
49
|
-
debug(...values: readonly unknown[]): void;
|
|
50
|
-
/**
|
|
51
|
-
* Alias of {@link ILogger.write} with {@link LogLevel.Info} as level.
|
|
52
|
-
* @param values The values to log.
|
|
53
|
-
*/
|
|
54
|
-
info(...values: readonly unknown[]): void;
|
|
55
|
-
/**
|
|
56
|
-
* Alias of {@link ILogger.write} with {@link LogLevel.Warn} as level.
|
|
57
|
-
* @param values The values to log.
|
|
58
|
-
*/
|
|
59
|
-
warn(...values: readonly unknown[]): void;
|
|
60
|
-
/**
|
|
61
|
-
* Alias of {@link ILogger.write} with {@link LogLevel.Error} as level.
|
|
62
|
-
* @param values The values to log.
|
|
63
|
-
*/
|
|
64
|
-
error(...values: readonly unknown[]): void;
|
|
65
|
-
/**
|
|
66
|
-
* Alias of {@link ILogger.write} with {@link LogLevel.Fatal} as level.
|
|
67
|
-
* @param values The values to log.
|
|
68
|
-
*/
|
|
69
|
-
fatal(...values: readonly unknown[]): void;
|
|
70
|
-
/**
|
|
71
|
-
* Writes the log message given a level and the value(s).
|
|
72
|
-
* @param level The log level.
|
|
73
|
-
* @param values The values to log.
|
|
74
|
-
*/
|
|
75
|
-
write(level: LogLevel, ...values: readonly unknown[]): void;
|
|
76
|
-
}
|
|
34
|
+
export type { ILogger } from "#types/logger.js";
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Console } from "console";
|
|
2
2
|
import type { Color } from "colorette";
|
|
3
3
|
import { Timestamp } from "@sapphire/timestamp";
|
|
4
|
-
import type { ILogger } from "./ILogger";
|
|
5
|
-
import { LogLevel } from "./ILogger";
|
|
6
|
-
import {
|
|
7
|
-
|
|
4
|
+
import type { ILogger } from "./ILogger.js";
|
|
5
|
+
import { LogLevel } from "./ILogger.js";
|
|
6
|
+
import type { LoggerLevelOptions, LoggerOptions, LoggerStyleResolvable, LoggerValues, LoggerTimestampFormatter, LoggerTimestampOptions } from "#types/logger.js";
|
|
7
|
+
import type { LoggerModule } from "i18next";
|
|
8
|
+
export { LogLevel } from "./ILogger.js";
|
|
9
|
+
export type { LoggerFormatOptions, LoggerLevelOptions, LoggerOptions, LoggerStyleOptions, LoggerStyleResolvable, LoggerValues, LoggerTimestampFormatter, LoggerTimestampOptions, } from "#types/logger.js";
|
|
8
10
|
export declare class Logger implements ILogger {
|
|
9
11
|
level: LogLevel;
|
|
10
12
|
readonly formats: Map<LogLevel, LoggerLevel>;
|
|
@@ -20,15 +22,15 @@ export declare class Logger implements ILogger {
|
|
|
20
22
|
static get stylize(): boolean;
|
|
21
23
|
setLevel(level: LogLevel): void;
|
|
22
24
|
has(level: LogLevel): boolean;
|
|
23
|
-
trace(...values:
|
|
24
|
-
debug(...values:
|
|
25
|
-
info(...values:
|
|
26
|
-
log(...values:
|
|
27
|
-
warn(...values:
|
|
28
|
-
error(...values:
|
|
29
|
-
fatal(...values:
|
|
30
|
-
write(level: LogLevel, ...values:
|
|
31
|
-
protected preprocess(values:
|
|
25
|
+
trace(...values: LoggerValues): void;
|
|
26
|
+
debug(...values: LoggerValues): void;
|
|
27
|
+
info(...values: LoggerValues): void;
|
|
28
|
+
log(...values: LoggerValues): void;
|
|
29
|
+
warn(...values: LoggerValues): void;
|
|
30
|
+
error(...values: LoggerValues): void;
|
|
31
|
+
fatal(...values: LoggerValues): void;
|
|
32
|
+
write(level: LogLevel, ...values: LoggerValues): void;
|
|
33
|
+
protected preprocess(values: LoggerValues): string;
|
|
32
34
|
private createFormatMap;
|
|
33
35
|
private createDefaultLevel;
|
|
34
36
|
private getLevelKey;
|
|
@@ -57,44 +59,6 @@ export declare class LoggerLevel {
|
|
|
57
59
|
}
|
|
58
60
|
declare const _default: Logger;
|
|
59
61
|
export default _default;
|
|
60
|
-
export interface LoggerOptions {
|
|
61
|
-
stdout?: NodeJS.WritableStream;
|
|
62
|
-
stderr?: NodeJS.WritableStream;
|
|
63
|
-
defaultFormat?: LoggerLevelOptions;
|
|
64
|
-
format?: LoggerFormatOptions;
|
|
65
|
-
level?: LogLevel;
|
|
66
|
-
join?: string;
|
|
67
|
-
depth?: number;
|
|
68
|
-
}
|
|
69
|
-
export interface LoggerFormatOptions {
|
|
70
|
-
trace?: LoggerLevelOptions;
|
|
71
|
-
debug?: LoggerLevelOptions;
|
|
72
|
-
info?: LoggerLevelOptions;
|
|
73
|
-
warn?: LoggerLevelOptions;
|
|
74
|
-
error?: LoggerLevelOptions;
|
|
75
|
-
fatal?: LoggerLevelOptions;
|
|
76
|
-
none?: LoggerLevelOptions;
|
|
77
|
-
}
|
|
78
|
-
export interface LoggerLevelOptions {
|
|
79
|
-
timestamp?: LoggerTimestampOptions | null;
|
|
80
|
-
infix?: string;
|
|
81
|
-
message?: LoggerStyleResolvable | null;
|
|
82
|
-
}
|
|
83
|
-
export interface LoggerTimestampOptions {
|
|
84
|
-
pattern?: string;
|
|
85
|
-
utc?: boolean;
|
|
86
|
-
color?: LoggerStyleResolvable | null;
|
|
87
|
-
formatter?: LoggerTimestampFormatter;
|
|
88
|
-
}
|
|
89
|
-
export interface LoggerTimestampFormatter {
|
|
90
|
-
(timestamp: string): string;
|
|
91
|
-
}
|
|
92
|
-
export interface LoggerStyleOptions {
|
|
93
|
-
effects?: LoggerStyleEffect[];
|
|
94
|
-
text?: LoggerStyleText;
|
|
95
|
-
background?: LoggerStyleBackground;
|
|
96
|
-
}
|
|
97
|
-
export type LoggerStyleResolvable = Color | LoggerStyleOptions;
|
|
98
62
|
export declare enum LoggerStyleEffect {
|
|
99
63
|
Reset = "reset",
|
|
100
64
|
Bold = "bold",
|
|
@@ -146,7 +110,7 @@ export declare class I18nLoggerAdapter implements LoggerModule {
|
|
|
146
110
|
private readonly logger;
|
|
147
111
|
readonly type = "logger";
|
|
148
112
|
constructor(logger: Logger);
|
|
149
|
-
log(...args:
|
|
150
|
-
warn(...args:
|
|
151
|
-
error(...args:
|
|
113
|
+
log(...args: Parameters<LoggerModule["log"]>): void;
|
|
114
|
+
warn(...args: Parameters<LoggerModule["warn"]>): void;
|
|
115
|
+
error(...args: Parameters<LoggerModule["error"]>): void;
|
|
152
116
|
}
|
package/dist/utils/util.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ChatInputCommandInteraction, InteractionResponse, Locale, Message } from "discord.js";
|
|
2
|
+
import type { Context } from "../structures/index.js";
|
|
3
|
+
export declare const allowedLocales: readonly ["id", "en-US", "en-GB", "bg", "zh-CN", "zh-TW", "hr", "cs", "da", "nl", "fi", "fr", "de", "el", "hi", "hu", "it", "ja", "ko", "lt", "no", "pl", "pt-BR", "ro", "ru", "es-ES", "es-419", "sv-SE", "th", "tr", "uk", "vi"];
|
|
4
|
+
export declare function sanitizeDiscordText(value: unknown): string;
|
|
5
|
+
export declare function parseThings<TContext>(value: string, ctx: TContext, resolver: (name: string, ctx: TContext) => string | undefined): string;
|
|
6
|
+
export declare function collectTemplateTokens(value: string): Set<string>;
|
|
3
7
|
export declare function deleteMessageAfterSent(message: Message | InteractionResponse, time?: number): Promise<void>;
|
|
4
|
-
export declare function
|
|
8
|
+
export declare function toAllowedLocale(locale: string | null | undefined): `${Locale}` | undefined;
|
|
9
|
+
export declare function getDefaultLang(ctx: Context<ChatInputCommandInteraction | Message>): `${Locale}`;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@arox/framework","version":"0.1.
|
|
1
|
+
{"name":"@arox/framework","version":"0.1.3","description":"","keywords":["arox","discord.js","framework"],"homepage":"https://github.com/AroxBot/framework#readme","bugs":{"url":"https://github.com/AroxBot/framework/issues"},"license":"Apache-2.0","author":"vrdons","contributors":["fhyrox"],"repository":{"type":"git","url":"git+https://github.com/AroxBot/framework.git"},"type":"module","main":"dist/index.cjs","module":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"},"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"default":"./dist/index.js"}},"dependencies":{"@sapphire/timestamp":"^1.0.5","colorette":"^2.0.20","fast-glob":"^3.3.3","fastest-levenshtein":"^1.0.16","i18next":"^25.8.0"},"peerDependencies":{"discord.js":">=14.25.1"}}
|
package/types/client.d.ts
CHANGED
|
@@ -1,22 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
ChatInputCommandInteraction,
|
|
3
|
+
ClientOptions,
|
|
4
|
+
Locale,
|
|
5
|
+
Message,
|
|
6
|
+
} from "discord.js";
|
|
7
|
+
import type { LoggerOptions } from "./logger.js";
|
|
3
8
|
import { i18n } from "i18next";
|
|
9
|
+
import type { Context } from "../src/structures/builder/Context.js";
|
|
10
|
+
import type { CommandBuilder } from "../src/structures/builder/Command.js";
|
|
11
|
+
import type { EventBuilder } from "../src/structures/builder/Event.js";
|
|
12
|
+
import type { Client } from "../src/structures/core/Client.js";
|
|
4
13
|
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
| string;
|
|
14
|
+
export type PrefixFn = (ctx: Context<Message>) => string | false;
|
|
15
|
+
export type TemplateContext = Context<ChatInputCommandInteraction | Message>;
|
|
16
|
+
export type GetDefaultLangFn = (
|
|
17
|
+
ctx: TemplateContext
|
|
18
|
+
) => `${Locale}` | undefined;
|
|
19
|
+
export type TemplateParserFn = (
|
|
20
|
+
key: string,
|
|
21
|
+
context: TemplateContext
|
|
22
|
+
) => string | undefined | null;
|
|
15
23
|
|
|
16
24
|
export interface FrameworkOptions extends ClientOptions {
|
|
17
25
|
logger?: LoggerOptions;
|
|
18
|
-
prefix?:
|
|
26
|
+
prefix?: PrefixFn;
|
|
27
|
+
getDefaultLang?: GetDefaultLangFn;
|
|
19
28
|
autoRegisterCommands?: boolean;
|
|
20
29
|
includePaths: string[];
|
|
21
30
|
i18n?: i18n;
|
|
22
31
|
}
|
|
32
|
+
|
|
33
|
+
export type AttachableExport = {
|
|
34
|
+
attach: (client: Client) => void | Promise<void>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type ModuleExport =
|
|
38
|
+
| CommandBuilder
|
|
39
|
+
| EventBuilder<keyof import("discord.js").ClientEvents>
|
|
40
|
+
| AttachableExport
|
|
41
|
+
| ModuleExportFactory
|
|
42
|
+
| readonly ModuleExport[]
|
|
43
|
+
| null
|
|
44
|
+
| undefined;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Factory function that produces module exports.
|
|
48
|
+
* The implementation must handle nested factories with appropriate depth limiting.
|
|
49
|
+
*/
|
|
50
|
+
export type ModuleExportFactory = (
|
|
51
|
+
client: Client
|
|
52
|
+
) => ModuleExport | Promise<ModuleExport>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Color } from "colorette";
|
|
2
|
+
import type { Console } from "node:console";
|
|
3
|
+
import type { LogLevel } from "../src/utils/logger/ILogger.js";
|
|
4
|
+
import type {
|
|
5
|
+
LoggerStyleBackground,
|
|
6
|
+
LoggerStyleEffect,
|
|
7
|
+
LoggerStyleText,
|
|
8
|
+
} from "../src/utils/logger/Logger.js";
|
|
9
|
+
|
|
10
|
+
export interface ILogger {
|
|
11
|
+
has(level: LogLevel): boolean;
|
|
12
|
+
trace(...values: LoggerValues): void;
|
|
13
|
+
debug(...values: LoggerValues): void;
|
|
14
|
+
info(...values: LoggerValues): void;
|
|
15
|
+
warn(...values: LoggerValues): void;
|
|
16
|
+
error(...values: LoggerValues): void;
|
|
17
|
+
fatal(...values: LoggerValues): void;
|
|
18
|
+
write(level: LogLevel, ...values: LoggerValues): void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface LoggerOptions {
|
|
22
|
+
stdout?: NodeJS.WritableStream;
|
|
23
|
+
stderr?: NodeJS.WritableStream;
|
|
24
|
+
defaultFormat?: LoggerLevelOptions;
|
|
25
|
+
format?: LoggerFormatOptions;
|
|
26
|
+
level?: LogLevel;
|
|
27
|
+
join?: string;
|
|
28
|
+
depth?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface LoggerFormatOptions {
|
|
32
|
+
trace?: LoggerLevelOptions;
|
|
33
|
+
debug?: LoggerLevelOptions;
|
|
34
|
+
info?: LoggerLevelOptions;
|
|
35
|
+
warn?: LoggerLevelOptions;
|
|
36
|
+
error?: LoggerLevelOptions;
|
|
37
|
+
fatal?: LoggerLevelOptions;
|
|
38
|
+
none?: LoggerLevelOptions;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface LoggerLevelOptions {
|
|
42
|
+
timestamp?: LoggerTimestampOptions | null;
|
|
43
|
+
infix?: string;
|
|
44
|
+
message?: LoggerStyleResolvable | null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface LoggerTimestampOptions {
|
|
48
|
+
pattern?: string;
|
|
49
|
+
utc?: boolean;
|
|
50
|
+
color?: LoggerStyleResolvable | null;
|
|
51
|
+
formatter?: LoggerTimestampFormatter;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface LoggerTimestampFormatter {
|
|
55
|
+
(timestamp: string): string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface LoggerStyleOptions {
|
|
59
|
+
effects?: LoggerStyleEffect[];
|
|
60
|
+
text?: LoggerStyleText;
|
|
61
|
+
background?: LoggerStyleBackground;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type LoggerValues = Parameters<Console["log"]>;
|
|
65
|
+
|
|
66
|
+
export type LoggerStyleResolvable = Color | LoggerStyleOptions;
|