This commit is contained in:
Christopher Cookman 2024-05-08 00:17:50 -06:00
parent 47614c7850
commit 3f9b882cf7
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

View file

@ -52,6 +52,17 @@ const convertDate = function (date) {
return new Date(Date.UTC(year, month - 1, day, hours, mins));
}
// Get number of unique channels in the database
const getUniqueChannels = function () {
return new Promise((resolve, reject) => {
db.all(`SELECT DISTINCT channelid FROM channels`, (err, rows) => {
if (err) {
console.error(err.message);
}
resolve(rows.length);
});
});
}
@ -65,12 +76,16 @@ const xmpp = client({
xmpp.on("error", (err) => {
console.log("ERROR")
console.error(err);
setTimeout(() => {
start();
}, 5000);
});
xmpp.on("offline", () => {
console.log("offline");
setTimeout(() => {
start();
}, 5000);
});
@ -328,8 +343,13 @@ discord.on("interactionCreate", async (interaction) => {
// Send an embed showing info about the bot, including number of guilds, number of subscribed rooms, etc
let guilds = discord.guilds.cache.size;
let channels = 0;
await db.get(`SELECT COUNT(*) as count FROM channels`, (err, row) => {
let uniques = 0;
await db.get(`SELECT COUNT(*) as count FROM channels`, async (err, row) => {
channels = row.count
await getUniqueChannels().then((unique) => {
uniques = unique;
});
const embed = {
title: "About Me!",
thumbnail: {
@ -344,6 +364,10 @@ discord.on("interactionCreate", async (interaction) => {
{
name: "Subscribed Rooms",
value: channels
},
{
name: "Unique Channels",
value: uniques
}
],
color: 0x00ff00,