forked from ChrisChrome/weather-bot
Guh
This commit is contained in:
parent
47614c7850
commit
3f9b882cf7
26
index.js
26
index.js
|
@ -52,6 +52,17 @@ const convertDate = function (date) {
|
||||||
return new Date(Date.UTC(year, month - 1, day, hours, mins));
|
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) => {
|
xmpp.on("error", (err) => {
|
||||||
console.log("ERROR")
|
console.log("ERROR")
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
setTimeout(() => {
|
||||||
start();
|
start();
|
||||||
|
}, 5000);
|
||||||
});
|
});
|
||||||
|
|
||||||
xmpp.on("offline", () => {
|
xmpp.on("offline", () => {
|
||||||
console.log("offline");
|
console.log("offline");
|
||||||
|
setTimeout(() => {
|
||||||
start();
|
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
|
// Send an embed showing info about the bot, including number of guilds, number of subscribed rooms, etc
|
||||||
let guilds = discord.guilds.cache.size;
|
let guilds = discord.guilds.cache.size;
|
||||||
let channels = 0;
|
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
|
channels = row.count
|
||||||
|
|
||||||
|
await getUniqueChannels().then((unique) => {
|
||||||
|
uniques = unique;
|
||||||
|
});
|
||||||
const embed = {
|
const embed = {
|
||||||
title: "About Me!",
|
title: "About Me!",
|
||||||
thumbnail: {
|
thumbnail: {
|
||||||
|
@ -344,6 +364,10 @@ discord.on("interactionCreate", async (interaction) => {
|
||||||
{
|
{
|
||||||
name: "Subscribed Rooms",
|
name: "Subscribed Rooms",
|
||||||
value: channels
|
value: channels
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Unique Channels",
|
||||||
|
value: uniques
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
color: 0x00ff00,
|
color: 0x00ff00,
|
||||||
|
|
Loading…
Reference in a new issue