feat: move from discord to web forms

This commit is contained in:
2025-01-22 17:02:16 -08:00
parent d7cd3ffaab
commit 2e00e2ed6a
21 changed files with 280 additions and 538 deletions

View File

@ -4,45 +4,14 @@
* @author Naomi Carrigan
*/
import { PrismaClient } from "@prisma/client";
import { Client, Events, GatewayIntentBits } from "discord.js";
import { log } from "./commands/log.js";
import { revoke } from "./commands/revoke.js";
import { updateCache } from "./modules/updateCache.js";
import { serve } from "./server/serve.js";
import { sendDebugLog } from "./utils/sendDebugLog.js";
import type { App } from "./interfaces/app.js";
const database = new PrismaClient();
const app = {
const app: App = {
cacheUpdated: new Date(),
database: database,
discord: new Client({
intents: [ GatewayIntentBits.Guilds ],
}),
sanctions: await database.sanctions.findMany(),
sanctions: await database.sanctions.findMany(),
};
app.discord.once(Events.ClientReady, () => {
void sendDebugLog({ content: "Bot is online!" });
setInterval(() => {
void updateCache(app);
}, 1000 * 60 * 60 * 24);
});
app.discord.on(Events.InteractionCreate, (interaction) => {
if (interaction.isChatInputCommand()) {
const target = [ log, revoke ].find((command) => {
return command.data.name === interaction.commandName;
});
if (!target) {
void interaction.reply({
content: `Command ${interaction.commandName} not found.`,
ephemeral: true,
});
return;
}
void target.run(app, interaction);
}
});
await app.discord.login(process.env.DISCORD_TOKEN);
serve(app);
await serve(app);