diff --git a/biome.json b/biome.json index 20c629a..0e7f4d1 100644 --- a/biome.json +++ b/biome.json @@ -1,7 +1,13 @@ { "$schema": "https://biomejs.dev/schemas/1.4.1/schema.json", "files": { - "ignore": ["node_modules/", "build/", "./packages/site/functions/"] + "ignore": [ + "node_modules/", + "build/", + "./packages/site/functions/", + "./packages/site/bot/migrations/", + ".wrangler/" + ] }, "organizeImports": { "enabled": true diff --git a/packages/api/src/games.ts b/packages/api/src/games.ts index b1f8264..59e6151 100644 --- a/packages/api/src/games.ts +++ b/packages/api/src/games.ts @@ -1,4 +1,9 @@ -import { type RESTGetAPIEvents, type RESTGetAPIEvent, APIRouteBases, Routes } from "khl-api-types"; +import { + APIRouteBases, + type RESTGetAPIEvent, + type RESTGetAPIEvents, + Routes, +} from "khl-api-types"; import { KhlClientMethodOptions, requestJson } from "./rest"; export const getGames = async ( diff --git a/packages/api/src/players.ts b/packages/api/src/players.ts index add14aa..3271436 100644 --- a/packages/api/src/players.ts +++ b/packages/api/src/players.ts @@ -1,10 +1,10 @@ import { - Routes, - type RESTGetAPIPlayers, - type RESTGetAPIPlayersLight, APILightPlayer, APIPlayer, APIRouteBases, + type RESTGetAPIPlayers, + type RESTGetAPIPlayersLight, + Routes, } from "khl-api-types"; import { KhlApiError, KhlClientMethodOptions, requestJson } from "./rest"; diff --git a/packages/api/src/teams.ts b/packages/api/src/teams.ts index d76439b..d317ff6 100644 --- a/packages/api/src/teams.ts +++ b/packages/api/src/teams.ts @@ -1,4 +1,9 @@ -import { APIRouteBases, Routes, type RESTGetAPITeam, type RESTGetAPITeams } from "khl-api-types"; +import { + APIRouteBases, + type RESTGetAPITeam, + type RESTGetAPITeams, + Routes, +} from "khl-api-types"; import { KhlClientMethodOptions, requestJson } from "./rest"; // I didn't want to hardcode the teams like this but it tends to make a lot of diff --git a/packages/bot/migrations/meta/0000_snapshot.json b/packages/bot/migrations/meta/0000_snapshot.json index d87f2b5..3e862b3 100644 --- a/packages/bot/migrations/meta/0000_snapshot.json +++ b/packages/bot/migrations/meta/0000_snapshot.json @@ -54,10 +54,7 @@ "indexes": { "notifications_league_channelId_unique": { "name": "notifications_league_channelId_unique", - "columns": [ - "league", - "channelId" - ], + "columns": ["league", "channelId"], "isUnique": true } }, @@ -72,4 +69,4 @@ "tables": {}, "columns": {} } -} \ No newline at end of file +} diff --git a/packages/bot/migrations/meta/0001_snapshot.json b/packages/bot/migrations/meta/0001_snapshot.json index af09050..e960313 100644 --- a/packages/bot/migrations/meta/0001_snapshot.json +++ b/packages/bot/migrations/meta/0001_snapshot.json @@ -64,10 +64,7 @@ "indexes": { "games_league_nativeId_unique": { "name": "games_league_nativeId_unique", - "columns": [ - "league", - "nativeId" - ], + "columns": ["league", "nativeId"], "isUnique": true } }, @@ -127,10 +124,7 @@ "indexes": { "notifications_league_channelId_unique": { "name": "notifications_league_channelId_unique", - "columns": [ - "league", - "channelId" - ], + "columns": ["league", "channelId"], "isUnique": true } }, @@ -145,4 +139,4 @@ "tables": {}, "columns": {} } -} \ No newline at end of file +} diff --git a/packages/bot/migrations/meta/0002_snapshot.json b/packages/bot/migrations/meta/0002_snapshot.json index 1f46ef5..0536991 100644 --- a/packages/bot/migrations/meta/0002_snapshot.json +++ b/packages/bot/migrations/meta/0002_snapshot.json @@ -71,10 +71,7 @@ "indexes": { "games_league_nativeId_unique": { "name": "games_league_nativeId_unique", - "columns": [ - "league", - "nativeId" - ], + "columns": ["league", "nativeId"], "isUnique": true } }, @@ -134,10 +131,7 @@ "indexes": { "notifications_league_channelId_unique": { "name": "notifications_league_channelId_unique", - "columns": [ - "league", - "channelId" - ], + "columns": ["league", "channelId"], "isUnique": true } }, @@ -152,4 +146,4 @@ "tables": {}, "columns": {} } -} \ No newline at end of file +} diff --git a/packages/bot/migrations/meta/0003_snapshot.json b/packages/bot/migrations/meta/0003_snapshot.json index a0e82ea..64a7604 100644 --- a/packages/bot/migrations/meta/0003_snapshot.json +++ b/packages/bot/migrations/meta/0003_snapshot.json @@ -86,10 +86,7 @@ "indexes": { "games_league_nativeId_unique": { "name": "games_league_nativeId_unique", - "columns": [ - "league", - "nativeId" - ], + "columns": ["league", "nativeId"], "isUnique": true } }, @@ -149,10 +146,7 @@ "indexes": { "notifications_league_channelId_unique": { "name": "notifications_league_channelId_unique", - "columns": [ - "league", - "channelId" - ], + "columns": ["league", "channelId"], "isUnique": true } }, @@ -167,4 +161,4 @@ "tables": {}, "columns": {} } -} \ No newline at end of file +} diff --git a/packages/bot/migrations/meta/0004_snapshot.json b/packages/bot/migrations/meta/0004_snapshot.json index 7c7f517..4b44d13 100644 --- a/packages/bot/migrations/meta/0004_snapshot.json +++ b/packages/bot/migrations/meta/0004_snapshot.json @@ -94,10 +94,7 @@ "indexes": { "games_league_nativeId_unique": { "name": "games_league_nativeId_unique", - "columns": [ - "league", - "nativeId" - ], + "columns": ["league", "nativeId"], "isUnique": true } }, @@ -157,10 +154,7 @@ "indexes": { "notifications_league_channelId_unique": { "name": "notifications_league_channelId_unique", - "columns": [ - "league", - "channelId" - ], + "columns": ["league", "channelId"], "isUnique": true } }, @@ -175,4 +169,4 @@ "tables": {}, "columns": {} } -} \ No newline at end of file +} diff --git a/packages/bot/migrations/meta/_journal.json b/packages/bot/migrations/meta/_journal.json index 29fb246..93a8bae 100644 --- a/packages/bot/migrations/meta/_journal.json +++ b/packages/bot/migrations/meta/_journal.json @@ -38,4 +38,4 @@ "breakpoints": true } ] -} \ No newline at end of file +} diff --git a/packages/bot/src/commands.ts b/packages/bot/src/commands.ts index 31135e7..846bccc 100644 --- a/packages/bot/src/commands.ts +++ b/packages/bot/src/commands.ts @@ -11,22 +11,22 @@ import { ChannelType, RESTPostAPIApplicationCommandsJSONBody, } from "discord-api-types/v10"; -import { InteractionContext } from "./interactions"; +import { PermissionFlags, PermissionsBitField } from "discord-bitflag"; +import { aboutCallback } from "./commands/about"; import { khlCalendarCallback, pwhlGamedayCallback, pwhlScheduleCallback, } from "./commands/calendar"; -import { aboutCallback } from "./commands/about"; -import { teamAutocomplete } from "./commands/teamAutocomplete"; +import { notificationsCallback } from "./commands/notifications"; import { khlPlayerCallback, pwhlPlayerCallback, pwhlWhoisCallback, } from "./commands/player"; +import { teamAutocomplete } from "./commands/teamAutocomplete"; +import { InteractionContext } from "./interactions"; import { allSeasons, allTeams } from "./pwhl/team"; -import { notificationsCallback } from "./commands/notifications"; -import { PermissionFlags, PermissionsBitField } from "discord-bitflag"; export type AppCommandCallbackT = ( ctx: InteractionContext, diff --git a/packages/bot/src/commands/about.ts b/packages/bot/src/commands/about.ts index a9655d2..da13d25 100644 --- a/packages/bot/src/commands/about.ts +++ b/packages/bot/src/commands/about.ts @@ -1,14 +1,13 @@ import { ButtonBuilder, EmbedBuilder } from "@discordjs/builders"; -import { ChatInputAppCommandCallback } from "../commands"; -import { transformLocalizations } from "../util/l10n"; import { ButtonStyle } from "discord-api-types/v10"; +import { ChatInputAppCommandCallback } from "../commands"; import { colors } from "../util/colors"; +import { transformLocalizations } from "../util/l10n"; const s = transformLocalizations({ en: { about: "About", - description: - "This bot covers various aspects of the PWHL and KHL.", + description: "This bot covers various aspects of the PWHL and KHL.", site: "Website", // site: "Site (+ Mac/iOS app!)", }, diff --git a/packages/bot/src/commands/calendar.ts b/packages/bot/src/commands/calendar.ts index 5a50905..9ad6ef6 100644 --- a/packages/bot/src/commands/calendar.ts +++ b/packages/bot/src/commands/calendar.ts @@ -1,3 +1,10 @@ +import { + ActionRowBuilder, + ButtonBuilder, + EmbedBuilder, + time, +} from "@discordjs/builders"; +import * as api from "api"; import { APIGuildScheduledEvent, ButtonStyle, @@ -8,23 +15,16 @@ import { RESTPostAPIGuildScheduledEventResult, Routes, } from "discord-api-types/v10"; +import { PermissionFlags } from "discord-bitflag"; +import { type APIEvent, State } from "khl-api-types"; import { ChatInputAppCommandCallback } from "../commands"; -import { getKhlLocale, transformLocalizations, uni } from "../util/l10n"; -import * as api from "api"; -import { State, type APIEvent } from "khl-api-types"; -import { - ActionRowBuilder, - ButtonBuilder, - EmbedBuilder, - time, -} from "@discordjs/builders"; -import { khlTeamEmoji, pwhlTeamEmoji } from "../util/emojis"; +import { ButtonCallback, MinimumKVComponentState } from "../components"; import { getPwhlClient } from "../pwhl/client"; import { allSeasons, allTeams } from "../pwhl/team"; -import { storeComponents } from "../util/components"; -import { ButtonCallback, MinimumKVComponentState } from "../components"; -import { PermissionFlags } from "discord-bitflag"; import { colors } from "../util/colors"; +import { storeComponents } from "../util/components"; +import { khlTeamEmoji, pwhlTeamEmoji } from "../util/emojis"; +import { getKhlLocale, transformLocalizations, uni } from "../util/l10n"; export const DATE_REGEX = /^(\d{4})-(\d{1,2})-(\d{1,2})$/; diff --git a/packages/bot/src/commands/notifications.ts b/packages/bot/src/commands/notifications.ts index fb040e9..2daf258 100644 --- a/packages/bot/src/commands/notifications.ts +++ b/packages/bot/src/commands/notifications.ts @@ -1,6 +1,3 @@ -import { ChatInputAppCommandCallback } from "../commands"; -import * as api from "api"; -import { allTeams } from "../pwhl/team"; import { ActionRowBuilder, ButtonBuilder, @@ -8,19 +5,22 @@ import { StringSelectMenuBuilder, StringSelectMenuOptionBuilder, } from "@discordjs/builders"; -import { storeComponents } from "../util/components"; +import * as api from "api"; import { ButtonStyle, ChannelType, MessageFlags } from "discord-api-types/v10"; -import { transformLocalizations, uni } from "../util/l10n"; -import { colors } from "../util/colors"; -import { InteractionContext } from "../interactions"; +import { and, eq } from "drizzle-orm"; +import { ChatInputAppCommandCallback } from "../commands"; import { ButtonCallback, MinimumKVComponentState, SelectMenuCallback, } from "../components"; -import { League, makeSnowflake, notifications } from "../db/schema"; import { getDb } from "../db"; -import { and, eq } from "drizzle-orm"; +import { League, makeSnowflake, notifications } from "../db/schema"; +import { InteractionContext } from "../interactions"; +import { allTeams } from "../pwhl/team"; +import { colors } from "../util/colors"; +import { storeComponents } from "../util/components"; +import { transformLocalizations, uni } from "../util/l10n"; export interface NotificationSendConfig { preview?: boolean; diff --git a/packages/bot/src/commands/player.ts b/packages/bot/src/commands/player.ts index 7a4f051..9120085 100644 --- a/packages/bot/src/commands/player.ts +++ b/packages/bot/src/commands/player.ts @@ -1,12 +1,3 @@ -import { ChatInputAppCommandCallback } from "../commands"; -import type { APILightPlayer } from "khl-api-types"; -import * as api from "api"; -import { - getHtLocale, - getKhlLocale, - transformLocalizations, -} from "../util/l10n"; -import { APIInteraction, MessageFlags } from "discord-api-types/v10"; import { ActionRowBuilder, EmbedBuilder, @@ -14,15 +5,24 @@ import { StringSelectMenuBuilder, StringSelectMenuOptionBuilder, } from "@discordjs/builders"; -import { InteractionContext } from "../interactions"; -import { countryCodeEmoji, khlTeamEmoji, pwhlTeamEmoji } from "../util/emojis"; +import * as api from "api"; +import { APIInteraction, MessageFlags } from "discord-api-types/v10"; +import { RosterPlayer } from "hockeytech"; +import type { APILightPlayer } from "khl-api-types"; +import { getBorderCharacters, table } from "table"; +import { ChatInputAppCommandCallback } from "../commands"; import { SelectMenuCallback } from "../components"; -import { storeComponents } from "../util/components"; +import { InteractionContext } from "../interactions"; import { getPwhlClient } from "../pwhl/client"; import { allSeasons, allTeams, pwhlTeamLogoUrl } from "../pwhl/team"; -import { RosterPlayer } from "hockeytech"; import { colors } from "../util/colors"; -import { getBorderCharacters, table } from "table"; +import { storeComponents } from "../util/components"; +import { countryCodeEmoji, khlTeamEmoji, pwhlTeamEmoji } from "../util/emojis"; +import { + getHtLocale, + getKhlLocale, + transformLocalizations, +} from "../util/l10n"; type KhlPartialPlayer = Pick & { team: { name: string } | null; diff --git a/packages/bot/src/commands/teamAutocomplete.ts b/packages/bot/src/commands/teamAutocomplete.ts index da73fe1..3f44f67 100644 --- a/packages/bot/src/commands/teamAutocomplete.ts +++ b/packages/bot/src/commands/teamAutocomplete.ts @@ -1,5 +1,5 @@ -import { AppCommandAutocompleteCallback } from "../commands"; import * as api from "api"; +import { AppCommandAutocompleteCallback } from "../commands"; import { getKhlLocale } from "../util/l10n"; export const teamAutocomplete: AppCommandAutocompleteCallback = async (ctx) => { diff --git a/packages/bot/src/components.ts b/packages/bot/src/components.ts index e8ec7d6..1d7ec0f 100644 --- a/packages/bot/src/components.ts +++ b/packages/bot/src/components.ts @@ -5,14 +5,14 @@ import { APIMessageComponentSelectMenuInteraction, APIModalSubmitInteraction, } from "discord-api-types/v10"; -import { InteractionContext } from "./interactions"; -import { playerSearchSelectCallback } from "./commands/player"; import { addScheduleEventsCallback } from "./commands/calendar"; import { selectNotificationFeaturesCallback, selectNotificationTeamCallback, toggleNotificationActiveButtonCallback, } from "./commands/notifications"; +import { playerSearchSelectCallback } from "./commands/player"; +import { InteractionContext } from "./interactions"; export interface MinimumKVComponentState { /** The total number of seconds that the component/modal should be stored. */ diff --git a/packages/bot/src/cron.ts b/packages/bot/src/cron.ts index 6604648..dfa2de9 100644 --- a/packages/bot/src/cron.ts +++ b/packages/bot/src/cron.ts @@ -1,5 +1,19 @@ +import { EmbedBuilder, time } from "@discordjs/builders"; +import { REST } from "@discordjs/rest"; +import { APIMessage, ChannelType, Routes } from "discord-api-types/v10"; import { and, eq, or } from "drizzle-orm"; +import { + GameStatus, + GameSummary, + Goal, + Penalty, + Period, + Periods, + PlayerInfo, + ScorebarMatch, +} from "hockeytech"; import { Env } from "."; +import { NotificationSendConfig } from "./commands/notifications"; import { getDb } from "./db"; import { HypeMinute, @@ -10,25 +24,11 @@ import { notifications, } from "./db/schema"; import { getPwhlClient } from "./pwhl/client"; -import { NotificationSendConfig } from "./commands/notifications"; -import { - GameStatus, - GameSummary, - Goal, - Penalty, - Period, - Periods, - PlayerInfo, - ScorebarMatch, -} from "hockeytech"; -import { REST } from "@discordjs/rest"; -import { APIMessage, ChannelType, Routes } from "discord-api-types/v10"; -import { EmbedBuilder, time } from "@discordjs/builders"; +import { htPlayerImageUrl } from "./pwhl/player"; +import { pwhlTeamLogoUrl } from "./pwhl/team"; import { PwhlTeamId, colors } from "./util/colors"; import { pwhlTeamEmoji } from "./util/emojis"; -import { pwhlTeamLogoUrl } from "./pwhl/team"; import { toHMS } from "./util/time"; -import { htPlayerImageUrl } from "./pwhl/player"; const logErrors = async (promise: Promise) => { try { diff --git a/packages/bot/src/index.ts b/packages/bot/src/index.ts index 703b3d5..a1f0d18 100644 --- a/packages/bot/src/index.ts +++ b/packages/bot/src/index.ts @@ -1,18 +1,17 @@ -import { Router } from "itty-router"; -import { PlatformAlgorithm, isValidRequest } from "discord-verify"; -import { AppCommandCallbackT, appCommands, respond } from "./commands"; +import { REST } from "@discordjs/rest"; import { - InteractionType, - InteractionResponseType, - APIInteraction, APIApplicationCommandInteractionDataOption, + APIInteraction, + APIMessageComponentInteraction, ApplicationCommandOptionType, ApplicationCommandType, - APIMessageComponentInteraction, + InteractionResponseType, + InteractionType, } from "discord-api-types/v10"; -import { REST } from "@discordjs/rest"; -import { InteractionContext } from "./interactions"; -import { getErrorMessage, isDiscordError } from "./util/errors.js"; +import { PermissionFlags, PermissionsBitField } from "discord-bitflag"; +import { PlatformAlgorithm, isValidRequest } from "discord-verify"; +import { Router } from "itty-router"; +import { AppCommandCallbackT, appCommands, respond } from "./commands"; import { ComponentCallbackT, ComponentRoutingId, @@ -21,8 +20,9 @@ import { componentStore, modalStore, } from "./components"; -import { PermissionFlags, PermissionsBitField } from "discord-bitflag"; import { checkPosts } from "./cron"; +import { InteractionContext } from "./interactions"; +import { getErrorMessage, isDiscordError } from "./util/errors.js"; export interface Env { DB: D1Database; diff --git a/packages/bot/src/interactions.ts b/packages/bot/src/interactions.ts index 382d978..70330cd 100644 --- a/packages/bot/src/interactions.ts +++ b/packages/bot/src/interactions.ts @@ -1,4 +1,4 @@ -import { getDate, Snowflake } from "discord-snowflake"; +import { REST } from "@discordjs/rest"; import { APIApplicationCommandInteractionDataBooleanOption, APIApplicationCommandInteractionDataIntegerOption, @@ -38,9 +38,9 @@ import { Routes, } from "discord-api-types/v10"; import { PermissionFlags, PermissionsBitField } from "discord-bitflag"; +import { Snowflake, getDate } from "discord-snowflake"; import { MinimumKVComponentState } from "./components.js"; import { Env } from "./index.js"; -import { REST } from "@discordjs/rest"; export type APIPartialResolvedChannelBase = APIPartialChannel & { permissions: string; diff --git a/packages/bot/src/pwhl/client.ts b/packages/bot/src/pwhl/client.ts index ebfcd35..b9c1200 100644 --- a/packages/bot/src/pwhl/client.ts +++ b/packages/bot/src/pwhl/client.ts @@ -4,5 +4,7 @@ import HockeyTech from "hockeytech"; export type HockeyTechLeague = "pwhl"; export const getPwhlClient = (locale?: "en" | "fr") => { - return new HockeyTech("694cfeed58c932ee", "pwhl", locale, undefined, { adapter: fetchAdapter }); + return new HockeyTech("694cfeed58c932ee", "pwhl", locale, undefined, { + adapter: fetchAdapter, + }); }; diff --git a/packages/bot/src/pwhl/player.ts b/packages/bot/src/pwhl/player.ts index e2722b9..01a2553 100644 --- a/packages/bot/src/pwhl/player.ts +++ b/packages/bot/src/pwhl/player.ts @@ -1,4 +1,6 @@ import { HockeyTechLeague } from "./client"; -export const htPlayerImageUrl = (league: HockeyTechLeague, playerId: string | number) => - `https://assets.leaguestat.com/${league}/120x160/${playerId}.jpg`; +export const htPlayerImageUrl = ( + league: HockeyTechLeague, + playerId: string | number, +) => `https://assets.leaguestat.com/${league}/120x160/${playerId}.jpg`; diff --git a/packages/bot/src/register.ts b/packages/bot/src/register.ts index 72ccff6..539d1d8 100644 --- a/packages/bot/src/register.ts +++ b/packages/bot/src/register.ts @@ -1,5 +1,5 @@ -import { appCommands } from "./commands"; import dotenv from "dotenv"; +import { appCommands } from "./commands"; /** * This file is meant to be run from the command line, and is not used by the @@ -9,7 +9,7 @@ import dotenv from "dotenv"; const config = dotenv.config({ path: ".dev.vars" }); if (!config.parsed) { - throw Error("Invalid .dev.vars") + throw Error("Invalid .dev.vars"); } const token = config.parsed.DISCORD_TOKEN; diff --git a/packages/site/app/components/Header.tsx b/packages/site/app/components/Header.tsx index cf2ec7b..1d7b9d8 100644 --- a/packages/site/app/components/Header.tsx +++ b/packages/site/app/components/Header.tsx @@ -1,6 +1,6 @@ -import { League } from "~/types/league"; import { Link } from "@remix-run/react"; import { twMerge } from "tailwind-merge"; +import { League } from "~/types/league"; const LeagueLink: React.FC<{ league: League; name: string }> = ({ league, @@ -13,7 +13,12 @@ const LeagueLink: React.FC<{ league: League; name: string }> = ({ className="w-8 sm:w-6 my-auto mr-1" alt={`${name} Logo`} /> -

+

{name}

diff --git a/packages/site/app/root.tsx b/packages/site/app/root.tsx index da7a2a1..c8b2884 100644 --- a/packages/site/app/root.tsx +++ b/packages/site/app/root.tsx @@ -1,6 +1,5 @@ import type { LinksFunction } from "@remix-run/cloudflare"; import { cssBundleHref } from "@remix-run/css-bundle"; -import tailwind from "../styles/app.css"; import { Links, LiveReload, @@ -9,12 +8,17 @@ import { Scripts, ScrollRestoration, } from "@remix-run/react"; +import tailwind from "../styles/app.css"; export const links: LinksFunction = () => [ ...(cssBundleHref ? [{ rel: "stylesheet", href: cssBundleHref }] : []), { rel: "stylesheet", href: tailwind }, { rel: "preconnect", href: "https://fonts.googleapis.com" }, - { rel: "preconnect", href: "https://fonts.gstatic.com", crossOrigin: "anonymous" }, + { + rel: "preconnect", + href: "https://fonts.gstatic.com", + crossOrigin: "anonymous", + }, { href: "https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap", rel: "stylesheet", diff --git a/packages/site/app/routes/scores.tsx b/packages/site/app/routes/scores.tsx index 6cce8c8..b6788e9 100644 --- a/packages/site/app/routes/scores.tsx +++ b/packages/site/app/routes/scores.tsx @@ -3,9 +3,7 @@ import { Link, useSearchParams } from "@remix-run/react"; import { Header } from "~/components/Header"; export const meta: MetaFunction = () => { - return [ - { title: "Scores - Puckway" }, - ]; + return [{ title: "Scores - Puckway" }]; }; export default function Scores() {