generated from nhcarrigan/template
feat: move from discord to web forms
This commit is contained in:
39
src/index.ts
39
src/index.ts
@ -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);
|
||||
|
Reference in New Issue
Block a user