Something went wrong. Try again.
Something went wrong. Try again.
12345678910111213141516171819202122232425import { db, _dispatchGateClause } from './db.js';
let cache = new Set();
const stmt = db.prepare(` SELECT DISTINCT r.guild_id FROM rules r JOIN jobs j ON j.id = r.job_id JOIN users u ON u.id = j.user_id WHERE r.enabled = 1 AND u.active = 1 AND r.guild_id IS NOT NULL AND ${_dispatchGateClause}`);
export function refreshActiveGuilds() { cache = new Set(stmt.all().map(r => r.guild_id)); return cache.size;}
export function isActiveGuild(guildId) { return cache.has(guildId);}
// Load once at module init so the bot is correct from the first message.refreshActiveGuilds();