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
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"*.ts": "$(capture).test.ts,$(capture).d.ts"
},
"oxc.typeAware": true,
"js/ts.experimental.useTsgo": false,
"js/ts.tsdk.path": "node_modules/typescript/lib",
"js/ts.experimental.useTsgo": true,

"cSpell.language": "de,en",
"editor.formatOnSaveMode": "modificationsIfAvailable",
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ FROM node:alpine
RUN echo "RELEASE_IDENTIFIER=${RELEASE_IDENTIFIER:-debug}" >> /app/.env && \
echo "BUILD_NUMBER=${BUILD_NUMBER:-0}" >> /app/.env

ENTRYPOINT ["node", "--env-file", "/app/.env", "src/app.ts"]
ENTRYPOINT ["node", "--env-file", "/app/.env", "--require", "./src/polyfills.ts", "src/app.ts"]
17 changes: 1 addition & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@
"lefthook": "^2.1.3",
"oxfmt": "^0.36.0",
"oxlint": "^1.51.0",
"oxlint-tsgolint": "^0.16.0",
"typescript": "^6.0.1-rc"
"oxlint-tsgolint": "^0.16.0"
},
"engines": {
"node": ">=25.6.1"
Expand Down
13 changes: 0 additions & 13 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import * as sentry from "@sentry/node";
import { readConfig, databasePath, args } from "#/service/config.ts";
import log from "#log";

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

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

import type { ReactionHandler } from "#/handler/ReactionHandler.ts";
Expand Down Expand Up @@ -58,16 +55,6 @@ log.info(`Bot starting up...${release ? ` (release: ${release})` : ""}`);

const config = await readConfig();

// This polyfill requires that Temporal is already available in the runtime
// We cannot add it in the polyfills.ts because that file is also used as --require argument for ts-node
// TODO: Remove this once temporal is available in Node.js, see: https://github.com/nodejs/node/issues/57127
if (typeof Date.prototype.toTemporalInstant !== "function") {
// biome-ignore lint/suspicious/noExplicitAny: hack
(Date.prototype as any).toTemporalInstant = function () {
return Temporal.Instant.fromEpochMilliseconds(this.getTime());
};
}

if (config.sentry?.dsn) {
sentry.init({
dsn: config.sentry.dsn,
Expand Down
1 change: 0 additions & 1 deletion src/commands/lauscher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import type { ApplicationCommand } from "#/commands/command.ts";
import type { BotContext } from "#/context.ts";
import assertNever from "#/utils/assertNever.ts";
import { getPlaybackStats, setUserRegistration, type TrackStat } from "#/service/lauscher.ts";
import { Temporal } from "@js-temporal/polyfill";
import { truncateToLength } from "#/utils/stringUtils.ts";
import { chunkArray } from "#/utils/arrayUtils.ts";
import { Vec2 } from "#/utils/math.ts";
Expand Down
1 change: 0 additions & 1 deletion src/commands/vote.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { parseArgs, type ParseArgsConfig } from "node:util";

import { cleanContent } from "discord.js";
import { Temporal } from "@js-temporal/polyfill";

import type { MessageCommand } from "#/commands/command.ts";
import type { BotContext } from "#/context.ts";
Expand Down
2 changes: 0 additions & 2 deletions src/commands/woisvote.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { Temporal } from "@js-temporal/polyfill"; // TODO: Remove once Node.js ships temporal

import {
type CommandInteraction,
type Message,
Expand Down
1 change: 0 additions & 1 deletion src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import type {
} from "discord.js";
import { ChannelType } from "discord.js";
import { SpotifyApi } from "@spotify/web-api-ts-sdk";
import { Temporal } from "@js-temporal/polyfill";

import type { UserMapEntry } from "#/commands/aoc.ts";
import { readConfig } from "#/service/config.ts";
Expand Down
1 change: 0 additions & 1 deletion src/handler/reaction/quoteHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
type GuildTextBasedChannel,
hyperlink,
} from "discord.js";
import { Temporal } from "@js-temporal/polyfill";

import type { BotContext, QuoteConfig } from "#/context.ts";
import type { ReactionHandler } from "../ReactionHandler.ts";
Expand Down
13 changes: 9 additions & 4 deletions src/polyfills.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Temporal } from "@js-temporal/polyfill";
import { Temporal as PolyfillTemporal } from "@js-temporal/polyfill";

declare global {
// type polyfill for Math.sumPrecise (currently in stage 2):
Expand All @@ -13,10 +13,15 @@ declare global {
getOrInsert(key: K, defaultValue: V): V;
getOrInsertComputed<TK extends K>(key: TK, callbackFunction: (key: TK) => V): V;
}
}

interface Date {
toTemporalInstant(): Temporal.Instant;
}
globalThis.Temporal = PolyfillTemporal as typeof Temporal;

// TODO: Remove this once temporal is available in Node.js, see: https://github.com/nodejs/node/issues/57127
if (typeof Date.prototype.toTemporalInstant !== "function") {
Date.prototype.toTemporalInstant = function () {
return Temporal.Instant.fromEpochMilliseconds(this.getTime());
};
}

if (typeof Math.sumPrecise !== "function") {
Expand Down
1 change: 0 additions & 1 deletion src/service/ban.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { time, type GuildMember, type User, TimestampStyles } from "discord.js";
import * as sentry from "@sentry/node";
import { Temporal } from "@js-temporal/polyfill";

import type { BotContext } from "#/context.ts";
import * as ban from "#/storage/ban.ts";
Expand Down
1 change: 0 additions & 1 deletion src/service/fadingMessage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { TextChannel } from "discord.js";
import * as sentry from "@sentry/node";
import { Temporal } from "@js-temporal/polyfill";

import type { BotContext } from "#/context.ts";

Expand Down
1 change: 0 additions & 1 deletion src/service/lauscher.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { Temporal } from "@js-temporal/polyfill";
import type { Activity, User } from "discord.js";

import type { BotContext } from "#/context.ts";
Expand Down
1 change: 0 additions & 1 deletion src/service/loot.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { User, Snowflake, Message } from "discord.js";
import { Temporal } from "@js-temporal/polyfill";

import type { LootId, LootInsertable, LootOrigin } from "#/storage/db/model.ts";
import type { LootAttributeKindId, LootKindId } from "./lootData.ts";
Expand Down
1 change: 0 additions & 1 deletion src/service/lootDrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
type MessageComponentInteraction,
type BaseMessageOptions,
} from "discord.js";
import { Temporal } from "@js-temporal/polyfill";
import * as sentry from "@sentry/node";

import type { BotContext } from "#/context.ts";
Expand Down
1 change: 0 additions & 1 deletion src/service/poll.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { GuildMember, Message, MessageReaction, TextBasedChannel, User } from "discord.js";
import { Temporal } from "@js-temporal/polyfill";

import * as legacyDelayedPoll from "#/service/delayedPollLegacy.ts";
import type { Poll, PollId } from "#/storage/db/model.ts";
Expand Down
1 change: 0 additions & 1 deletion src/service/pollEmbed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
TimestampStyles,
type User,
} from "discord.js";
import { Temporal } from "@js-temporal/polyfill";

export const LETTERS = [
":regional_indicator_a:",
Expand Down
1 change: 0 additions & 1 deletion src/service/roll.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { cleanContent, type APIEmbed, type TextChannel, type User } from "discord.js";
import { Temporal } from "@js-temporal/polyfill";

export async function rollInChannel(
author: User,
Expand Down
1 change: 0 additions & 1 deletion src/service/voiceState.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { VoiceState } from "discord.js";
import { Temporal } from "@js-temporal/polyfill";

import type { BotContext } from "#/context.ts";
import log from "#log";
Expand Down
1 change: 0 additions & 1 deletion src/storage/ban.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { GuildMember, Snowflake, User } from "discord.js";
import type { Temporal } from "@js-temporal/polyfill";

import type { Ban } from "./db/model.ts";
import db from "#db";
Expand Down
1 change: 0 additions & 1 deletion src/storage/db/date-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type {
RootOperationNode,
UnknownRow,
} from "kysely";
import { Temporal } from "@js-temporal/polyfill";

import log from "#log";

Expand Down
1 change: 0 additions & 1 deletion src/storage/emote.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { sql } from "kysely";
import { Temporal } from "@js-temporal/polyfill";
import type { Message, Snowflake } from "discord.js";

import type { Emote } from "./db/model.ts";
Expand Down
1 change: 0 additions & 1 deletion src/storage/fadingMessage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Message } from "discord.js";
import { Temporal } from "@js-temporal/polyfill";

import type { FadingMessage } from "./db/model.ts";
import db from "#db";
Expand Down
1 change: 0 additions & 1 deletion src/storage/lauscher.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Temporal } from "@js-temporal/polyfill"; // TODO: Remove once Node.js ships temporal
import type { User } from "discord.js";

import type { LauscherRegistration, LauscherSpotifyLogEntry } from "#/storage/db/model.ts";
Expand Down
1 change: 0 additions & 1 deletion src/storage/loot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type {
User,
} from "discord.js";
import { type ExpressionBuilder, sql } from "kysely";
import type { Temporal } from "@js-temporal/polyfill";

import type { BotContext } from "#/context.ts";
import type {
Expand Down
1 change: 0 additions & 1 deletion src/storage/poll.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Snowflake } from "discord.js";
import type { Temporal } from "@js-temporal/polyfill";

import db from "#db";
import type { Poll, PollAnswer, PollId, PollOption, PollOptionId } from "./db/model.ts";
Expand Down
1 change: 0 additions & 1 deletion src/storage/reminders.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Snowflake, User } from "discord.js";
import { Temporal } from "@js-temporal/polyfill";

import type { Reminder } from "./db/model.ts";

Expand Down
1 change: 0 additions & 1 deletion src/storage/woisAction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Message, PartialMessage, Snowflake, User } from "discord.js";
import type { Temporal } from "@js-temporal/polyfill";

import type { WoisAction } from "./db/model.ts";
import db from "#db";
Expand Down
2 changes: 0 additions & 2 deletions src/utils/dateUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { Temporal } from "@js-temporal/polyfill"; // TODO: Remove once Node.js ships temporal

const timeFormatter = new Intl.DateTimeFormat("de-DE", {
hour: "2-digit",
minute: "2-digit",
Expand Down