Added New Db Stuff

This commit is contained in:
2025-11-01 16:02:14 -05:00
parent 07f75bbd93
commit 69aae83784
6 changed files with 329 additions and 182 deletions

View File

@ -1,41 +1,29 @@
const { Client, Guild, Events, ActivityType, PresenceUpdateStatus } = require('discord.js');
const { ActivityType, Events } = require('discord.js');
const { getNextStatus } = require('./db-status');
/**
*
* @param {Client} client
* @param {Guild} guild
*/
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) {
const guildsCount = client.guilds.cache.size;
name: Events.ClientReady,
async execute(client) {
//console.log(`Ready as ${client.user.tag}`);
let status = [
{
name: "I am Live",
type: ActivityType.Watching,
},
{
name: "Choo Choo 🚂",
},
{
name: 'Hippity Hoppity',
},
{
name: `I am in ${guildsCount} Server(s)`,
},
{
name: 'Yippe 🐻'
},
];
setInterval(() => {
// Global rotation (you can also do per-guild if you want)
const row = getNextStatus(); // or per-guild: getNextStatus(someGuildId)
if (!row) return;
setInterval(() => {
let random = Math.floor(Math.random() * status.length);
client.user.setActivity(status[random]);
}, 30000);
}
};
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);
}
};