/** * 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 { 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 () => { console.log('[bot] Ready.'); for (let i = 0; i < reactionEmojis.length; ++i) console.log(`[bot] config: reaction_${i + 1} = ${reactionEmojis[i]}`); }); async function startup() { console.log("[db] Opening..."); await openDb(); console.log("[db] Migrating..."); await db.migrate(); console.log("[db] Ready."); console.log("[bot] Logging in..."); await client.login(process.env.TOKEN); await sync(client.guilds); process.exit(0); } startup();