const { ActivityType, Events } = require('discord.js'); const { getNextStatus } = require('./db-status'); function formatStatusName(template, client) { return String(template || '') .replace(/\{guilds\}/g, String(client.guilds.cache.size)); // Add more tokens as you like, e.g. {users} } module.exports = { name: Events.ClientReady, async execute(client) { //console.log(`Ready as ${client.user.tag}`); setInterval(() => { // Global rotation (you can also do per-guild if you want) const row = getNextStatus(); // or per-guild: getNextStatus(someGuildId) if (!row) return; const name = formatStatusName(row.name, client); try { client.user.setActivity({ name, type: row.activity_type ?? ActivityType.Watching }); console.log(row) } catch (e) { console.error('setActivity error:', e); } }, 30_000); } };