Files
FemScoreboard/discord/sync.ts
2026-02-27 02:48:25 -08:00

39 lines
1.1 KiB
TypeScript

/**
* sync.ts
* Syncs message reactions in chat with the database.
* The bot will do the same thing automatically upon startup, but this is just in the form of a standalone script.
*/
import { Client, Events, GatewayIntentBits, IntentsBitField, Partials } from 'discord.js';
import { logInfo } from '../logging';
import { db, openDb, reactionEmojis, sync } from './util';
const client = new Client({
intents: [
GatewayIntentBits.MessageContent,
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMessages,
],
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
});
client.once(Events.ClientReady, async () => {
logInfo('[bot] Ready.');
for (let i = 0; i < reactionEmojis.length; ++i)
logInfo(`[bot] config: reaction_${i + 1} = ${reactionEmojis[i]}`);
});
async function startup() {
logInfo('[db] Opening...');
await openDb();
logInfo('[db] Migrating...');
await db.migrate();
logInfo('[db] Ready.');
logInfo('[bot] Logging in...');
await client.login(process.env.TOKEN);
await sync(client.guilds);
process.exit(0);
}
startup();