Skip to content

Commit bc6a642

Browse files
authored
Use native import path alises (#551)
* Use native import path alises We have to use # instead of @ because @ can appear in external packages. # is reserved for that * Allow ts imports * Use ts file extensions as per Node.js recommendation * Fix linter * Use different prefix due to nodejs/node#51949 * Use tsx again due to enums * Align config with package.json
1 parent 4c239bf commit bc6a642

File tree

145 files changed

+679
-674
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+679
-674
lines changed

package-lock.json

Lines changed: 110 additions & 110 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,16 @@
5858
"expect": "^30.2.0",
5959
"lefthook": "^2.0.4"
6060
},
61+
"imports": {
62+
"#log": "./src/utils/logger.ts",
63+
"#db": "./src/storage/db/db.ts",
64+
"#*": "./src/*"
65+
},
6166
"trustedDependencies": [
6267
"@biomejs/biome",
6368
"lefthook"
6469
],
6570
"engines": {
66-
"node": ">=24.10.0"
71+
"node": ">=25.1.0"
6772
}
6873
}

src/app.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
import { GatewayIntentBits, Partials, Client } from "discord.js";
22
import * as sentry from "@sentry/node";
33

4-
import { readConfig, databasePath, args } from "@/service/config.js";
5-
import log from "@log";
4+
import { readConfig, databasePath, args } from "#service/config.ts";
5+
import log from "#log";
66

77
import { Temporal } from "@js-temporal/polyfill";
8-
import "@/polyfills.js";
8+
import "#polyfills.ts";
99

10-
import * as kysely from "@/storage/db/db.js";
10+
import * as kysely from "#storage/db/db.ts";
1111

12-
import type { ReactionHandler } from "@/handler/ReactionHandler.js";
13-
import messageDeleteHandler from "@/handler/messageDeleteHandler.js";
14-
import { woisVoteReactionHandler } from "@/commands/woisvote.js";
15-
import * as voiceStateService from "@/service/voiceState.js";
12+
import type { ReactionHandler } from "#handler/ReactionHandler.ts";
13+
import messageDeleteHandler from "#handler/messageDeleteHandler.ts";
14+
import { woisVoteReactionHandler } from "#commands/woisvote.ts";
15+
import * as voiceStateService from "#service/voiceState.ts";
1616

17-
import roleAssignerHandler from "@/handler/reaction/roleAssignerHandler.js";
18-
import pollReactionHandler from "@/handler/reaction/pollReactionHandler.js";
19-
import logEmotesReactionHandler from "@/handler/reaction/logEmotesReactionHandler.js";
20-
import quoteReactionHandler from "@/handler/reaction/quoteHandler.js";
17+
import roleAssignerHandler from "#handler/reaction/roleAssignerHandler.ts";
18+
import pollReactionHandler from "#handler/reaction/pollReactionHandler.ts";
19+
import logEmotesReactionHandler from "#handler/reaction/logEmotesReactionHandler.ts";
20+
import quoteReactionHandler from "#handler/reaction/quoteHandler.ts";
2121

2222
import {
2323
handleInteractionEvent,
2424
loadCommands,
2525
messageCommandHandler,
2626
registerAllApplicationCommandsAsGuildCommands,
27-
} from "@/handler/commandHandler.js";
28-
import * as guildMemberHandler from "@/handler/guildMemberHandler.js";
29-
import deleteThreadMessagesHandler from "@/handler/messageCreate/deleteThreadMessagesHandler.js";
30-
import { createBotContext, type BotContext } from "@/context.js";
31-
import { ehreReactionHandler } from "@/commands/ehre.js";
32-
import * as terminal from "@/utils/terminal.js";
33-
import * as cronService from "@/service/cron.js";
34-
import { handlePresenceUpdate } from "./handler/presenceHandler.js";
27+
} from "#handler/commandHandler.ts";
28+
import * as guildMemberHandler from "#handler/guildMemberHandler.ts";
29+
import deleteThreadMessagesHandler from "#handler/messageCreate/deleteThreadMessagesHandler.ts";
30+
import { createBotContext, type BotContext } from "#context.ts";
31+
import { ehreReactionHandler } from "#commands/ehre.ts";
32+
import * as terminal from "#utils/terminal.ts";
33+
import * as cronService from "#service/cron.ts";
34+
import { handlePresenceUpdate } from "./handler/presenceHandler.ts";
3535

3636
const env = process.env;
3737

@@ -130,8 +130,8 @@ process.once("SIGTERM", signal => {
130130
process.exit(1);
131131
});
132132
process.once("exit", code => {
133-
client.destroy();
134-
kysely.disconnectFromDb();
133+
const _ = client.destroy();
134+
const __ = kysely.disconnectFromDb();
135135
log.warn(`Process exited with code: ${code}`);
136136
});
137137

src/commands/aoc.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import {
77
} from "discord.js";
88
import type * as discord from "discord.js";
99

10-
import type { BotContext } from "@/context.js";
11-
import type { ApplicationCommand } from "@/commands/command.js";
10+
import type { BotContext } from "#context.ts";
11+
import type { ApplicationCommand } from "#commands/command.ts";
1212

13-
import log from "@log";
13+
import log from "#log";
1414

1515
type CompletionInfo = Record<1 | 2, { get_start_ts: number }>;
1616

src/commands/autoEhre.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { ProcessableMessage } from "@/service/command.js";
2-
import type { SpecialCommand } from "@/commands/command.js";
1+
import type { ProcessableMessage } from "#service/command.ts";
2+
import type { SpecialCommand } from "#commands/command.ts";
33

4-
import * as ehreService from "@/service/ehre.js";
4+
import * as ehreService from "#service/ehre.ts";
55

66
export default class AutoEhreCommand implements SpecialCommand {
77
name = "AutoEhre";

src/commands/banlist.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import {
66
time,
77
} from "discord.js";
88

9-
import type { ApplicationCommand } from "@/commands/command.js";
10-
import type { BotContext } from "@/context.js";
11-
import type { Ban } from "@/storage/db/model.js";
9+
import type { ApplicationCommand } from "#commands/command.ts";
10+
import type { BotContext } from "#context.ts";
11+
import type { Ban } from "#storage/db/model.ts";
1212

13-
import * as banService from "@/service/ban.js";
14-
import log from "@log";
13+
import * as banService from "#service/ban.ts";
14+
import log from "#log";
1515

1616
export default class BanListCommand implements ApplicationCommand {
1717
name = "banlist";

src/commands/bonk.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import * as fs from "node:fs/promises";
33
import { createCanvas, loadImage } from "@napi-rs/canvas";
44
import type { GuildMember } from "discord.js";
55

6-
import type { MessageCommand } from "@/commands/command.js";
7-
import type { ProcessableMessage } from "@/service/command.js";
8-
import log from "@log";
6+
import type { MessageCommand } from "#commands/command.ts";
7+
import type { ProcessableMessage } from "#service/command.ts";
8+
import log from "#log";
99

1010
const createBonkMeme = async (author: GuildMember): Promise<Buffer> => {
1111
const bonk = await fs.readFile("assets/bonk.png");

src/commands/boobs.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { time, TimestampStyles, type User } from "discord.js";
22

3-
import type { ProcessableMessage } from "@/service/command.js";
4-
import type { MessageCommand } from "@/commands/command.js";
5-
import type { Boob } from "@/storage/db/model.js";
6-
import * as boob from "@/storage/boob.js";
7-
import log from "@log";
8-
import { randomEntry } from "@/service/random.js";
3+
import type { ProcessableMessage } from "#service/command.ts";
4+
import type { MessageCommand } from "#commands/command.ts";
5+
import type { Boob } from "#storage/db/model.ts";
6+
import * as boob from "#storage/boob.ts";
7+
import log from "#log";
8+
import { randomEntry } from "#service/random.ts";
99

1010
interface Booba {
1111
description: string;

src/commands/clap.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import {
88
SlashCommandStringOption,
99
} from "discord.js";
1010

11-
import type { BotContext } from "@/context.js";
12-
import type { ProcessableMessage } from "@/service/command.js";
13-
import type { ApplicationCommand, MessageCommand } from "@/commands/command.js";
11+
import type { BotContext } from "#context.ts";
12+
import type { ProcessableMessage } from "#service/command.ts";
13+
import type { ApplicationCommand, MessageCommand } from "#commands/command.ts";
1414

1515
const clapify = (str: string): string => `${str.split(/\s+/).join(" :clap: ")} :clap:`;
1616

src/commands/command.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import type {
66
SlashCommandBuilder,
77
} from "discord.js";
88

9-
import type { ProcessableMessage } from "@/service/command.js";
10-
import type { BotContext } from "@/context.js";
9+
import type { ProcessableMessage } from "#service/command.ts";
10+
import type { BotContext } from "#context.ts";
1111

1212
export type Command = ApplicationCommand | AutocompleteCommand | MessageCommand | SpecialCommand;
1313

0 commit comments

Comments
 (0)