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
6 changes: 3 additions & 3 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22

- run: npm ci

Expand All @@ -40,7 +40,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22

- run: npm ci

Expand All @@ -57,7 +57,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22

- run: npm ci

Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v22.12.0
14 changes: 7 additions & 7 deletions app/commands/convene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import type {
} from "discord.js";
import { ApplicationCommandType } from "discord-api-types/v10";

import { reacord } from "~/discord/client.server";
import { quoteAndEscape } from "~/helpers/discord";
import { ReportReasons, reportUser } from "~/helpers/modLog";
import { resolutions } from "~/helpers/modResponse";
import { reacord } from "#~/discord/client.server";
import { quoteAndEscape } from "#~/helpers/discord";
import { ReportReasons, reportUser } from "#~/helpers/modLog";
import { resolutions } from "#~/helpers/modResponse";

import { fetchSettings, SETTINGS } from "~/models/guilds.server";
import { applyRestriction, ban, kick, timeout } from "~/models/discord.server";
import { ModResponse } from "~/commands/reacord/ModResponse";
import { fetchSettings, SETTINGS } from "#~/models/guilds.server";
import { applyRestriction, ban, kick, timeout } from "#~/models/discord.server";
import { ModResponse } from "#~/commands/reacord/ModResponse";

export const command = new ContextMenuCommandBuilder()
.setName("Convene mods")
Expand Down
4 changes: 2 additions & 2 deletions app/commands/reacord/ModResponse.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { ComponentEventUser } from "reacord";
import { Button } from "reacord";

import type { Resolution } from "~/helpers/modResponse";
import type { Resolution } from "#~/helpers/modResponse";
import {
humanReadableResolutions,
resolutions,
useVotes,
} from "~/helpers/modResponse";
} from "#~/helpers/modResponse";

const VOTES_TO_APPROVE = 3;

Expand Down
2 changes: 1 addition & 1 deletion app/commands/report.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { MessageContextMenuCommandInteraction } from "discord.js";
import { PermissionFlagsBits, ContextMenuCommandBuilder } from "discord.js";
import { ApplicationCommandType } from "discord-api-types/v10";
import { ReportReasons, reportUser } from "~/helpers/modLog";
import { ReportReasons, reportUser } from "#~/helpers/modLog";

export const command = new ContextMenuCommandBuilder()
.setName("Report")
Expand Down
2 changes: 1 addition & 1 deletion app/commands/setup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ChatInputCommandInteraction } from "discord.js";
import { PermissionFlagsBits, SlashCommandBuilder } from "discord.js";

import { SETTINGS, setSettings, registerGuild } from "~/models/guilds.server";
import { SETTINGS, setSettings, registerGuild } from "#~/models/guilds.server";

export const command = new SlashCommandBuilder()
.setName("setup")
Expand Down
8 changes: 4 additions & 4 deletions app/commands/setupTickets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ import {
import { REST } from "@discordjs/rest";
import { Routes, TextInputStyle } from "discord-api-types/v10";

import { discordToken } from "~/helpers/env.server";
import { SETTINGS, fetchSettings } from "~/models/guilds.server";
import { discordToken } from "#~/helpers/env.server";
import { SETTINGS, fetchSettings } from "#~/models/guilds.server";
import { format } from "date-fns";
import type {
AnyCommand,
MessageComponentCommand,
ModalCommand,
SlashCommand,
} from "~/helpers/discord";
import { quoteMessageContent } from "~/helpers/discord";
} from "#~/helpers/discord";
import { quoteMessageContent } from "#~/helpers/discord";

const rest = new REST({ version: "10" }).setToken(discordToken);

Expand Down
4 changes: 2 additions & 2 deletions app/commands/track.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { MessageContextMenuCommandInteraction } from "discord.js";
import { PermissionFlagsBits, ContextMenuCommandBuilder } from "discord.js";
import { ApplicationCommandType } from "discord-api-types/v10";
import { Button } from "reacord";
import { reacord } from "~/discord/client.server";
import { reacord } from "#~/discord/client.server";

import { ReportReasons, reportUser } from "~/helpers/modLog";
import { ReportReasons, reportUser } from "#~/helpers/modLog";

export const command = new ContextMenuCommandBuilder()
.setName("Track")
Expand Down
2 changes: 1 addition & 1 deletion app/discord/activityTracker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Events, ChannelType } from "discord.js";
import type { Client, Message, PartialMessage, TextChannel } from "discord.js";
import db from "~/db.server";
import db from "#~/db.server";

export async function startActivityTracking(client: Client) {
const channelCache = new Map<string, TextChannel>();
Expand Down
2 changes: 1 addition & 1 deletion app/discord/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { REST } from "discord.js";
import { discordToken } from "~/helpers/env.server";
import { discordToken } from "#~/helpers/env.server";

export const rest = new REST({ version: "10" }).setToken(discordToken);
2 changes: 1 addition & 1 deletion app/discord/automod.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isSpam } from "./automod";

vi.mock("~/helpers/env.server");
vi.mock("#~/helpers/env.server");

test("isSpam has a reasonable threshold", () => {
expect(isSpam("Hello @everyone")).toBe(true);
Expand Down
4 changes: 2 additions & 2 deletions app/discord/automod.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Client } from "discord.js";

import { isStaff } from "~/helpers/discord";
import { reportUser, ReportReasons } from "~/helpers/modLog";
import { isStaff } from "#~/helpers/discord";
import { reportUser, ReportReasons } from "#~/helpers/modLog";
import { client } from "./client.server";

const AUTO_SPAM_THRESHOLD = 3;
Expand Down
2 changes: 1 addition & 1 deletion app/discord/client.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GatewayIntentBits, Client, Partials, ActivityType } from "discord.js";
import { ReacordDiscordJs } from "reacord";
import { discordToken } from "~/helpers/env.server";
import { discordToken } from "#~/helpers/env.server";

export const client = new Client({
intents: [
Expand Down
10 changes: 5 additions & 5 deletions app/discord/deployCommands.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import type {
} from "discord.js";
import { InteractionType, Routes } from "discord.js";

import { rest } from "~/discord/api";
import type { AnyCommand } from "~/helpers/discord";
import { rest } from "#~/discord/api";
import type { AnyCommand } from "#~/helpers/discord";
import {
isMessageComponentCommand,
isMessageContextCommand,
isModalCommand,
isSlashCommand,
isUserContextCommand,
} from "~/helpers/discord";
import { applicationId, isProd } from "~/helpers/env.server";
import { calculateChangedCommands } from "~/helpers/discordCommands";
} from "#~/helpers/discord";
import { applicationId, isProd } from "#~/helpers/env.server";
import { calculateChangedCommands } from "#~/helpers/discordCommands";

/**
* deployCommands notifies Discord of the latest commands to use and registers
Expand Down
12 changes: 6 additions & 6 deletions app/discord/gateway.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Sentry from "~/helpers/sentry.server";
import Sentry from "#~/helpers/sentry.server";

import { client, login } from "~/discord/client.server";
import { deployCommands } from "~/discord/deployCommands.server";
import { client, login } from "#~/discord/client.server";
import { deployCommands } from "#~/discord/deployCommands.server";

import automod from "~/discord/automod";
import onboardGuild from "~/discord/onboardGuild";
import { startActivityTracking } from "~/discord/activityTracker";
import automod from "#~/discord/automod";
import onboardGuild from "#~/discord/onboardGuild";
import { startActivityTracking } from "#~/discord/activityTracker";

export default function init() {
login();
Expand Down
4 changes: 2 additions & 2 deletions app/discord/onboardGuild.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Client, TextChannel } from "discord.js";
import { ChannelType } from "discord.js";
import { retry } from "~/helpers/misc";
import { retry } from "#~/helpers/misc";

import { fetchGuild } from "~/models/guilds.server";
import { fetchGuild } from "#~/models/guilds.server";

export default async (bot: Client) => {
// This is called any time the bot comes online, when a server becomes
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/__mocks__/env.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const isProd = () => false;

export const databaseUrl = "DATABASE_URL";
export const databaseUrl = undefined;
export const sessionSecret = "SESSION_SECRET";

export const applicationKey = "DISCORD_PUBLIC_KEY";
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/discordCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
} from "discord.js";
import { ApplicationCommandType } from "discord.js";

import { difference } from "~/helpers/sets";
import { difference } from "#~/helpers/sets";

export const compareCommands = (
localCommand: ContextMenuCommandBuilder | SlashCommandBuilder,
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/modLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import { MessageType, ChannelType } from "discord.js";
import { format, formatDistanceToNowStrict } from "date-fns";
import TTLCache from "@isaacs/ttlcache";

import { fetchSettings, SETTINGS } from "~/models/guilds.server";
import { fetchSettings, SETTINGS } from "#~/models/guilds.server";
import {
constructDiscordLink,
describeAttachments,
describeReactions,
quoteAndEscape,
quoteAndEscapePoll,
} from "~/helpers/discord";
import { simplifyString, truncateMessage } from "~/helpers/string";
} from "#~/helpers/discord";
import { simplifyString, truncateMessage } from "#~/helpers/string";

export const enum ReportReasons {
anonReport = "anonReport",
Expand Down
4 changes: 2 additions & 2 deletions app/models/activity.server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DB } from "~/db.server";
import db from "~/db.server";
import type { DB } from "#~/db.server";
import db from "#~/db.server";

type MessageStats = DB["message_stats"];

Expand Down
2 changes: 1 addition & 1 deletion app/models/discord.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { GuildMember } from "discord.js";
import type { AccessToken } from "simple-oauth2";
import { fetchSettings, SETTINGS } from "~/models/guilds.server";
import { fetchSettings, SETTINGS } from "#~/models/guilds.server";

export interface DiscordUserInfo {
id: string;
Expand Down
4 changes: 2 additions & 2 deletions app/models/guilds.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Guild as DiscordGuild } from "discord.js";
import db, { SqliteError } from "~/db.server";
import type { DB } from "~/db.server";
import db, { SqliteError } from "#~/db.server";
import type { DB } from "#~/db.server";

export type Guild = DB["guilds"];

Expand Down
10 changes: 5 additions & 5 deletions app/models/session.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ import {
import { randomUUID } from "crypto";
import { AuthorizationCode } from "simple-oauth2";

import db from "~/db.server";
import type { DB } from "~/db.server";
import db from "#~/db.server";
import type { DB } from "#~/db.server";
import {
createUser,
getUserByExternalId,
getUserById,
} from "~/models/user.server";
import { fetchUser } from "~/models/discord.server";
} from "#~/models/user.server";
import { fetchUser } from "#~/models/discord.server";
import {
applicationId,
discordSecret,
sessionSecret,
} from "~/helpers/env.server";
} from "#~/helpers/env.server";

export type Sessions = DB["sessions"];

Expand Down
4 changes: 2 additions & 2 deletions app/models/user.server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { randomUUID } from "crypto";

import type { DB } from "~/db.server";
import db from "~/db.server";
import type { DB } from "#~/db.server";
import db from "#~/db.server";

export type User = DB["users"];

Expand Down
8 changes: 4 additions & 4 deletions app/routes/__auth.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Outlet, useLoaderData, useLocation } from "react-router";

import { Login } from "~/components/login";
import { isProd } from "~/helpers/env.server";
import { getUser } from "~/models/session.server";
import { useOptionalUser } from "~/utils";
import { Login } from "#~/components/login";
import { isProd } from "#~/helpers/env.server";
import { getUser } from "#~/models/session.server";
import { useOptionalUser } from "#~/utils";

export async function loader({ request }: { request: Request }) {
return { user: await getUser(request), isProd: isProd() };
Expand Down
2 changes: 1 addition & 1 deletion app/routes/__auth/dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ActionFunction, LoaderFunction } from "react-router";
import { data, useLoaderData } from "react-router";
import type { LabelHTMLAttributes } from "react";
import { getTopParticipants } from "~/models/activity.server";
import { getTopParticipants } from "#~/models/activity.server";

export const loader = async ({
request,
Expand Down
4 changes: 2 additions & 2 deletions app/routes/auth.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { ActionFunction, LoaderFunction } from "react-router";
import { redirect } from "react-router";

import { initOauthLogin } from "~/models/session.server";
import { Login } from "~/components/login";
import { initOauthLogin } from "#~/models/session.server";
import { Login } from "#~/components/login";

export const loader: LoaderFunction = async () => {
return redirect("/");
Expand Down
2 changes: 1 addition & 1 deletion app/routes/discord-oauth.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { redirect, type LoaderFunction } from "react-router";
import { completeOauthLogin } from "~/models/session.server";
import { completeOauthLogin } from "#~/models/session.server";

export const loader: LoaderFunction = async ({ request }) => {
const url = new URL(request.url);
Expand Down
2 changes: 1 addition & 1 deletion app/routes/healthcheck.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// learn more: https://fly.io/docs/reference/configuration/#services-http_checks
import type { LoaderFunction } from "react-router";
import db from "~/db.server";
import db from "#~/db.server";

export const loader: LoaderFunction = async ({ request }) => {
const host =
Expand Down
6 changes: 3 additions & 3 deletions app/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Login } from "~/components/login";
import { Logout } from "~/components/logout";
import { Login } from "#~/components/login";
import { Logout } from "#~/components/logout";

import { useOptionalUser } from "~/utils";
import { useOptionalUser } from "#~/utils";

export default function Index() {
const user = useOptionalUser();
Expand Down
2 changes: 1 addition & 1 deletion app/routes/logout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ActionFunction } from "react-router";

import { logout } from "~/models/session.server";
import { logout } from "#~/models/session.server";

export const action: ActionFunction = async ({ request }) => {
return await logout(request);
Expand Down
16 changes: 8 additions & 8 deletions app/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import { createRequestHandler } from "@react-router/express";
import express from "express";
import bodyParser from "body-parser";

import { applicationKey } from "~/helpers/env.server";
import { applicationKey } from "#~/helpers/env.server";

import discordBot from "~/discord/gateway";
import { registerCommand } from "~/discord/deployCommands.server";
import discordBot from "#~/discord/gateway";
import { registerCommand } from "#~/discord/deployCommands.server";

import * as convene from "~/commands/convene";
import * as setup from "~/commands/setup";
import * as report from "~/commands/report";
import * as track from "~/commands/track";
import setupTicket from "~/commands/setupTickets";
import * as convene from "#~/commands/convene";
import * as setup from "#~/commands/setup";
import * as report from "#~/commands/report";
import * as track from "#~/commands/track";
import setupTicket from "#~/commands/setupTickets";

export const app = express();
app.use(
Expand Down
Loading
Loading