Skip to content

Commit 1efb66c

Browse files
committed
refactor: update localization keys and simplify handler loading in templates
1 parent 7b2692a commit 1efb66c

File tree

8 files changed

+23
-23
lines changed

8 files changed

+23
-23
lines changed

packages/cli/templates/commands/i18n/message_command.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ export const {{name}}Command = createCommand({
44
build: {
55
message: {
66
name: "{{name}}",
7-
nameLocalizations: t => t("commands.{{name}}.name"),
7+
nameLocalizations: t => t("{{i18nName}}"),
88
},
99
},
1010
run: (ctx) => {
11-
return ctx.reply(ctx.t("commands.{{name}}.run"));
11+
return ctx.reply(ctx.t("default.run"));
1212
},
1313
});

packages/cli/templates/commands/i18n/slash_command.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ export const {{name}}Command = createCommand({
44
build: {
55
slash: {
66
name: "{{name}}",
7-
nameLocalizations: t => t("commands.{{name}}.name"),
7+
nameLocalizations: t => t("{{i18nName}}"),
88
description: "A slash command",
9-
descriptionLocalizations: t => t("commands.{{name}}.description"),
9+
descriptionLocalizations: t => t("{{i18nDescription}}"),
1010
},
1111
},
1212
run: (ctx) => {
13-
return ctx.reply(ctx.t("commands.{{name}}.run"));
13+
return ctx.reply(ctx.t("default.run"));
1414
},
1515
});

packages/cli/templates/commands/i18n/sub_command.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { createCommand } from "arcscord";
33
export const {{name}}Command = createCommand({
44
build: {
55
name: "{{name}}",
6-
nameLocalizations: t => t("commands.{{name}}.name"),
6+
nameLocalizations: t => t("{{i18nName}}"),
77
description: "A sub command",
8-
descriptionLocalizations: t => t("commands.{{name}}.description"),
8+
descriptionLocalizations: t => t("{{i18nDescription}}"),
99
},
1010
run: (ctx) => {
11-
return ctx.reply(ctx.t("commands.{{name}}.run"));
11+
return ctx.reply(ctx.t("default.run"));
1212
}
1313
});

packages/cli/templates/commands/i18n/sub_def_command.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { SlashWithSubsCommandDefinition } from "arcscord";
22

33
export const {{name}}CommandDef = {
44
name: "{{name}}",
5-
nameLocalizations: t => t("commands.{{name}}.name"),
5+
nameLocalizations: t => t("{{i18nName}}"),
66
description: "Command description",
7-
descriptionLocalizations: t => t("commands.{{name}}.description"),
7+
descriptionLocalizations: t => t("{{i18nDescription}}"),
88
} satisfies SlashWithSubsCommandDefinition;

packages/cli/templates/commands/i18n/user_command.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ export const {{name}}Command = createCommand({
44
build: {
55
user: {
66
name: "{{name}}",
7-
nameLocalizations: t => t("commands.{{name}}.name"),
7+
nameLocalizations: t => t("{{i18nName}}"),
88
},
99
},
1010
run: (ctx) => {
11-
return ctx.reply(ctx.t("commands.{{name}}.run"));
11+
return ctx.reply(ctx.t("default.run"));
1212
},
1313
});

packages/cli/templates/init/basic/src/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ const client = new ArcClient(process.env.TOKEN ?? "", {
77
intents: [],
88
});
99

10-
client.loadEvents(handlers.events);
11-
client.loadTasks(handlers.tasks);
12-
client.loadComponents(handlers.components);
13-
client.on("ready", async () => {
14-
void client.loadCommands(handlers.commands);
10+
client.loadHandlers(handlers);
11+
client.on("ready", () => {
12+
client.logger.info("Ready !");
1513
});
1614

1715
void client.login();
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"test": "test"
2+
"test": "test",
3+
"default": {
4+
"run": "pong"
5+
}
36
}

packages/cli/templates/init/i18n/src/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ const client = new ArcClient(process.env.TOKEN ?? "", {
2121
},
2222
});
2323

24-
client.loadEvents(handlers.events);
25-
client.loadTasks(handlers.tasks);
26-
client.loadComponents(handlers.components);
27-
client.on("ready", async () => {
28-
void client.loadCommands(handlers.commands);
24+
client.loadHandlers(handlers);
25+
26+
client.on("ready", () => {
27+
client.logger.info("Ready !");
2928
});
3029

3130
void client.login();

0 commit comments

Comments
 (0)