Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
220 changes: 110 additions & 110 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,16 @@
"expect": "^30.2.0",
"lefthook": "^2.0.4"
},
"imports": {
"#log": "./src/utils/logger.ts",
"#db": "./src/storage/db/db.ts",
"#*": "./src/*"
},
"trustedDependencies": [
"@biomejs/biome",
"lefthook"
],
"engines": {
"node": ">=24.10.0"
"node": ">=25.1.0"
}
}
44 changes: 22 additions & 22 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
import { GatewayIntentBits, Partials, Client } from "discord.js";
import * as sentry from "@sentry/node";

import { readConfig, databasePath, args } from "@/service/config.js";
import log from "@log";
import { readConfig, databasePath, args } from "#service/config.ts";
import log from "#log";

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

import * as kysely from "@/storage/db/db.js";
import * as kysely from "#storage/db/db.ts";

import type { ReactionHandler } from "@/handler/ReactionHandler.js";
import messageDeleteHandler from "@/handler/messageDeleteHandler.js";
import { woisVoteReactionHandler } from "@/commands/woisvote.js";
import * as voiceStateService from "@/service/voiceState.js";
import type { ReactionHandler } from "#handler/ReactionHandler.ts";
import messageDeleteHandler from "#handler/messageDeleteHandler.ts";
import { woisVoteReactionHandler } from "#commands/woisvote.ts";
import * as voiceStateService from "#service/voiceState.ts";

import roleAssignerHandler from "@/handler/reaction/roleAssignerHandler.js";
import pollReactionHandler from "@/handler/reaction/pollReactionHandler.js";
import logEmotesReactionHandler from "@/handler/reaction/logEmotesReactionHandler.js";
import quoteReactionHandler from "@/handler/reaction/quoteHandler.js";
import roleAssignerHandler from "#handler/reaction/roleAssignerHandler.ts";
import pollReactionHandler from "#handler/reaction/pollReactionHandler.ts";
import logEmotesReactionHandler from "#handler/reaction/logEmotesReactionHandler.ts";
import quoteReactionHandler from "#handler/reaction/quoteHandler.ts";

import {
handleInteractionEvent,
loadCommands,
messageCommandHandler,
registerAllApplicationCommandsAsGuildCommands,
} from "@/handler/commandHandler.js";
import * as guildMemberHandler from "@/handler/guildMemberHandler.js";
import deleteThreadMessagesHandler from "@/handler/messageCreate/deleteThreadMessagesHandler.js";
import { createBotContext, type BotContext } from "@/context.js";
import { ehreReactionHandler } from "@/commands/ehre.js";
import * as terminal from "@/utils/terminal.js";
import * as cronService from "@/service/cron.js";
import { handlePresenceUpdate } from "./handler/presenceHandler.js";
} from "#handler/commandHandler.ts";
import * as guildMemberHandler from "#handler/guildMemberHandler.ts";
import deleteThreadMessagesHandler from "#handler/messageCreate/deleteThreadMessagesHandler.ts";
import { createBotContext, type BotContext } from "#context.ts";
import { ehreReactionHandler } from "#commands/ehre.ts";
import * as terminal from "#utils/terminal.ts";
import * as cronService from "#service/cron.ts";
import { handlePresenceUpdate } from "./handler/presenceHandler.ts";

const env = process.env;

Expand Down Expand Up @@ -130,8 +130,8 @@ process.once("SIGTERM", signal => {
process.exit(1);
});
process.once("exit", code => {
client.destroy();
kysely.disconnectFromDb();
const _ = client.destroy();
const __ = kysely.disconnectFromDb();
log.warn(`Process exited with code: ${code}`);
});

Expand Down
6 changes: 3 additions & 3 deletions src/commands/aoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
} from "discord.js";
import type * as discord from "discord.js";

import type { BotContext } from "@/context.js";
import type { ApplicationCommand } from "@/commands/command.js";
import type { BotContext } from "#context.ts";
import type { ApplicationCommand } from "#commands/command.ts";

import log from "@log";
import log from "#log";

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

Expand Down
6 changes: 3 additions & 3 deletions src/commands/autoEhre.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ProcessableMessage } from "@/service/command.js";
import type { SpecialCommand } from "@/commands/command.js";
import type { ProcessableMessage } from "#service/command.ts";
import type { SpecialCommand } from "#commands/command.ts";

import * as ehreService from "@/service/ehre.js";
import * as ehreService from "#service/ehre.ts";

export default class AutoEhreCommand implements SpecialCommand {
name = "AutoEhre";
Expand Down
10 changes: 5 additions & 5 deletions src/commands/banlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import {
time,
} from "discord.js";

import type { ApplicationCommand } from "@/commands/command.js";
import type { BotContext } from "@/context.js";
import type { Ban } from "@/storage/db/model.js";
import type { ApplicationCommand } from "#commands/command.ts";
import type { BotContext } from "#context.ts";
import type { Ban } from "#storage/db/model.ts";

import * as banService from "@/service/ban.js";
import log from "@log";
import * as banService from "#service/ban.ts";
import log from "#log";

export default class BanListCommand implements ApplicationCommand {
name = "banlist";
Expand Down
6 changes: 3 additions & 3 deletions src/commands/bonk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import * as fs from "node:fs/promises";
import { createCanvas, loadImage } from "@napi-rs/canvas";
import type { GuildMember } from "discord.js";

import type { MessageCommand } from "@/commands/command.js";
import type { ProcessableMessage } from "@/service/command.js";
import log from "@log";
import type { MessageCommand } from "#commands/command.ts";
import type { ProcessableMessage } from "#service/command.ts";
import log from "#log";

const createBonkMeme = async (author: GuildMember): Promise<Buffer> => {
const bonk = await fs.readFile("assets/bonk.png");
Expand Down
12 changes: 6 additions & 6 deletions src/commands/boobs.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { time, TimestampStyles, type User } from "discord.js";

import type { ProcessableMessage } from "@/service/command.js";
import type { MessageCommand } from "@/commands/command.js";
import type { Boob } from "@/storage/db/model.js";
import * as boob from "@/storage/boob.js";
import log from "@log";
import { randomEntry } from "@/service/random.js";
import type { ProcessableMessage } from "#service/command.ts";
import type { MessageCommand } from "#commands/command.ts";
import type { Boob } from "#storage/db/model.ts";
import * as boob from "#storage/boob.ts";
import log from "#log";
import { randomEntry } from "#service/random.ts";

interface Booba {
description: string;
Expand Down
6 changes: 3 additions & 3 deletions src/commands/clap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {
SlashCommandStringOption,
} from "discord.js";

import type { BotContext } from "@/context.js";
import type { ProcessableMessage } from "@/service/command.js";
import type { ApplicationCommand, MessageCommand } from "@/commands/command.js";
import type { BotContext } from "#context.ts";
import type { ProcessableMessage } from "#service/command.ts";
import type { ApplicationCommand, MessageCommand } from "#commands/command.ts";

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

Expand Down
4 changes: 2 additions & 2 deletions src/commands/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import type {
SlashCommandBuilder,
} from "discord.js";

import type { ProcessableMessage } from "@/service/command.js";
import type { BotContext } from "@/context.js";
import type { ProcessableMessage } from "#service/command.ts";
import type { BotContext } from "#context.ts";

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

Expand Down
10 changes: 5 additions & 5 deletions src/commands/dadJoke.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { cleanContent } from "discord.js";

import type { ProcessableMessage } from "@/service/command.js";
import type { SpecialCommand } from "@/commands/command.js";
import type { BotContext } from "@/context.js";
import { substringAfter } from "@/utils/stringUtils.js";
import { randomEntry } from "@/service/random.js";
import type { ProcessableMessage } from "#service/command.ts";
import type { SpecialCommand } from "#commands/command.ts";
import type { BotContext } from "#context.ts";
import { substringAfter } from "#utils/stringUtils.ts";
import { randomEntry } from "#service/random.ts";

type Lang = "german" | "austrian";

Expand Down
8 changes: 4 additions & 4 deletions src/commands/deoida.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { BotContext } from "@/context.js";
import type { ProcessableMessage } from "@/service/command.js";
import type { MessageCommand } from "@/commands/command.js";
import * as austrianTranslation from "@/storage/austrianTranslation.js";
import type { BotContext } from "#context.ts";
import type { ProcessableMessage } from "#service/command.ts";
import type { MessageCommand } from "#commands/command.ts";
import * as austrianTranslation from "#storage/austrianTranslation.ts";

async function deOidaLine(line: string): Promise<string> {
// We cannot just split all words using \s*. That could tear apart words or translations like "fescher bub"
Expand Down
6 changes: 3 additions & 3 deletions src/commands/doener.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { BotContext } from "@/context.js";
import type { ProcessableMessage } from "@/service/command.js";
import type { MessageCommand } from "@/commands/command.js";
import type { BotContext } from "#context.ts";
import type { ProcessableMessage } from "#service/command.ts";
import type { MessageCommand } from "#commands/command.ts";

const prices = {
kebab: 5.5,
Expand Down
10 changes: 5 additions & 5 deletions src/commands/download-video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {
MessageFlags,
} from "discord.js";

import type { BotContext } from "@/context.js";
import type { ApplicationCommand } from "@/commands/command.js";
import * as ytDlService from "@/service/ytDl.js";
import assertNever from "@/utils/assertNever.js";
import TempDir from "@/utils/TempDir.js";
import type { BotContext } from "#context.ts";
import type { ApplicationCommand } from "#commands/command.ts";
import * as ytDlService from "#service/ytDl.ts";
import assertNever from "#utils/assertNever.ts";
import TempDir from "#utils/TempDir.ts";

export default class DownloadVideoCommand implements ApplicationCommand {
name = "Download Video"; // Must be upper case, because this name will be matched against the application command name
Expand Down
10 changes: 5 additions & 5 deletions src/commands/ehre.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import {
userMention,
} from "discord.js";

import type { ApplicationCommand } from "@/commands/command.js";
import type { BotContext } from "@/context.js";
import type { EhrePoints } from "@/storage/db/model.js";
import type { ReactionHandler } from "@/handler/ReactionHandler.js";
import type { ApplicationCommand } from "#commands/command.ts";
import type { BotContext } from "#context.ts";
import type { EhrePoints } from "#storage/db/model.ts";
import type { ReactionHandler } from "#handler/ReactionHandler.ts";

import * as ehreService from "@/service/ehre.js";
import * as ehreService from "#service/ehre.ts";

function createUserPointString(e: EhrePoints) {
return `${userMention(e.userId)}: ${ehreService.formatPoints(e.points)}`;
Expand Down
10 changes: 5 additions & 5 deletions src/commands/emote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import {
type AutocompleteInteraction,
} from "discord.js";

import type { ApplicationCommand, AutocompleteCommand } from "@/commands/command.js";
import type { BotContext } from "@/context.js";
import type { Emote } from "@/storage/db/model.js";
import * as emoteLoggingService from "@/service/emoteLogging.js";
import { formatDateTime } from "@/utils/dateUtils.js";
import type { ApplicationCommand, AutocompleteCommand } from "#commands/command.ts";
import type { BotContext } from "#context.ts";
import type { Emote } from "#storage/db/model.ts";
import * as emoteLoggingService from "#service/emoteLogging.ts";
import { formatDateTime } from "#utils/dateUtils.ts";

function buildSingleEmoteResponse(
emote: Emote,
Expand Down
10 changes: 5 additions & 5 deletions src/commands/emoteLogger.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { ProcessableMessage } from "@/service/command.js";
import type { SpecialCommand } from "@/commands/command.js";
import type { BotContext } from "@/context.js";
import type { ProcessableMessage } from "#service/command.ts";
import type { SpecialCommand } from "#commands/command.ts";
import type { BotContext } from "#context.ts";

import * as emoteService from "@/service/emote.js";
import * as emoteLoggingService from "@/service/emoteLogging.js";
import * as emoteService from "#service/emote.ts";
import * as emoteLoggingService from "#service/emoteLogging.ts";

export default class EmoteLoggerCommand implements SpecialCommand {
name = "EmoteLogger";
Expand Down
6 changes: 3 additions & 3 deletions src/commands/emoteSender.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Message } from "discord.js";

import type { BotContext } from "@/context.js";
import type { SpecialCommand } from "@/commands/command.js";
import log from "@log";
import type { BotContext } from "#context.ts";
import type { SpecialCommand } from "#commands/command.ts";
import log from "#log";

export default class EmoteSenderCommand implements SpecialCommand {
name = "EmoteSender";
Expand Down
18 changes: 9 additions & 9 deletions src/commands/erinnerung.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import {
import * as chrono from "chrono-node";
import * as sentry from "@sentry/node";

import type { MessageCommand, ApplicationCommand } from "@/commands/command.js";
import type { BotContext } from "@/context.js";
import type { Reminder } from "@/storage/db/model.js";
import type { ProcessableMessage } from "@/service/command.js";
import log from "@log";
import * as reminderService from "@/storage/reminders.js";
import * as dateUtils from "@/utils/dateUtils.js";

import { ensureChatInputCommand } from "@/utils/interactionUtils.js";
import type { MessageCommand, ApplicationCommand } from "#commands/command.ts";
import type { BotContext } from "#context.ts";
import type { Reminder } from "#storage/db/model.ts";
import type { ProcessableMessage } from "#service/command.ts";
import log from "#log";
import * as reminderService from "#storage/reminders.ts";
import * as dateUtils from "#utils/dateUtils.ts";

import { ensureChatInputCommand } from "#utils/interactionUtils.ts";

const validateDate = (date: Date): true | string => {
if (!dateUtils.isValidDate(date)) {
Expand Down
6 changes: 3 additions & 3 deletions src/commands/erleuchtung.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { SlashCommandBuilder } from "discord.js";
import type { CommandInteraction, CacheType } from "discord.js";

import type { ApplicationCommand, MessageCommand } from "@/commands/command.js";
import type { ProcessableMessage } from "@/service/command.js";
import type { ApplicationCommand, MessageCommand } from "#commands/command.ts";
import type { ProcessableMessage } from "#service/command.ts";

import * as erleuchtungService from "@/service/erleuchtung.js";
import * as erleuchtungService from "#service/erleuchtung.ts";

export default class ErleuchtungCommand implements MessageCommand, ApplicationCommand {
name = "erleuchtung";
Expand Down
6 changes: 3 additions & 3 deletions src/commands/error.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { MessageCommand } from "./command.js";
import type { ProcessableMessage } from "@/service/command.js";
import type { BotContext } from "@/context.js";
import type { MessageCommand } from "./command.ts";
import type { ProcessableMessage } from "#service/command.ts";
import type { BotContext } from "#context.ts";

export default class ErrorCommand implements MessageCommand {
name = "feler";
Expand Down
20 changes: 10 additions & 10 deletions src/commands/extend.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { ActionRowBuilder, ComponentType, type Message, StringSelectMenuBuilder } from "discord.js";

import type { MessageCommand } from "@/commands/command.js";
import type { BotContext } from "@/context.js";
import type { ProcessableMessage } from "@/service/command.js";
import type { Poll } from "@/storage/db/model.js";

import * as pollEmbedService from "@/service/pollEmbed.js";
import { parseLegacyMessageParts } from "@/service/command.js";
import * as pollService from "@/service/poll.js";
import { defer } from "@/utils/interactionUtils.js";
import { truncateToLength } from "@/utils/stringUtils.js";
import type { MessageCommand } from "#commands/command.ts";
import type { BotContext } from "#context.ts";
import type { ProcessableMessage } from "#service/command.ts";
import type { Poll } from "#storage/db/model.ts";

import * as pollEmbedService from "#service/pollEmbed.ts";
import { parseLegacyMessageParts } from "#service/command.ts";
import * as pollService from "#service/poll.ts";
import { defer } from "#utils/interactionUtils.ts";
import { truncateToLength } from "#utils/stringUtils.ts";

export default class ExtendCommand implements MessageCommand {
name = "extend";
Expand Down
8 changes: 4 additions & 4 deletions src/commands/faulenzerping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import {
userMention,
} from "discord.js";

import type { BotContext } from "@/context.js";
import type { ApplicationCommand } from "@/commands/command.js";
import { chunkArray } from "@/utils/arrayUtils.js";
import * as time from "@/utils/time.js";
import type { BotContext } from "#context.ts";
import type { ApplicationCommand } from "#commands/command.ts";
import { chunkArray } from "#utils/arrayUtils.ts";
import * as time from "#utils/time.ts";

export default class FaulenzerPingCommand implements ApplicationCommand {
name = "Faulenzerping"; // Must be upper case, because this name will be matched against the application command name
Expand Down
Loading