2022-06-17 01:25:05 +02:00
|
|
|
import { exec } from 'node:child_process';
|
|
|
|
import https from 'node:https';
|
2022-06-17 02:14:14 +02:00
|
|
|
import dotenv from 'dotenv';
|
2022-06-17 01:25:05 +02:00
|
|
|
dotenv.config();
|
2022-06-16 13:29:07 +02:00
|
|
|
const { uptimeURL, uptimeInterval } = process.env;
|
2022-06-16 09:18:39 +02:00
|
|
|
|
2022-06-17 01:25:05 +02:00
|
|
|
export default {
|
2022-06-16 09:18:39 +02:00
|
|
|
name: 'ready',
|
|
|
|
once: true,
|
|
|
|
async execute(client) {
|
|
|
|
const ytdlpVersion = await new Promise((resolve, reject) => {
|
|
|
|
exec('./bin/yt-dlp --version', (err, stdout, stderr) => {
|
|
|
|
if (err) {
|
|
|
|
reject(stderr);
|
|
|
|
}
|
|
|
|
if (stderr) {
|
|
|
|
console.error(stderr);
|
|
|
|
}
|
|
|
|
resolve(stdout);
|
|
|
|
});
|
|
|
|
});
|
2022-06-16 13:29:07 +02:00
|
|
|
|
2022-06-16 09:18:39 +02:00
|
|
|
const commandSize = client.commands.size;
|
|
|
|
const clientTag = client.user.tag;
|
|
|
|
const guildSize = client.guilds.cache.size;
|
|
|
|
const channelSize = client.channels.cache.size;
|
|
|
|
const clientID = client.user.id;
|
|
|
|
|
|
|
|
console.log('===========[ READY ]===========');
|
|
|
|
console.log(`\x1b[32mLogged in as \x1b[34m${clientTag}\x1b[0m! (\x1b[33m${clientID}\x1b[0m)`);
|
|
|
|
console.log(`Ready to serve in \x1b[33m${channelSize}\x1b[0m channels on \x1b[33m${guildSize}\x1b[0m servers.`);
|
|
|
|
console.log(`${client.readyAt}`);
|
|
|
|
console.log(`There is \x1b[33m${commandSize}\x1b[0m command loaded.`);
|
2022-06-16 13:29:07 +02:00
|
|
|
console.log(`Running yt-dlp \x1b[33m${ytdlpVersion.replace('\n', '')}\x1b[0m`);
|
2022-06-16 09:18:39 +02:00
|
|
|
console.log('===========[ READY ]===========');
|
2022-06-16 13:29:07 +02:00
|
|
|
|
|
|
|
if (uptimeURL != '') {
|
|
|
|
pingStatus(client, 'Starting up');
|
|
|
|
|
|
|
|
setInterval(() => {
|
|
|
|
pingStatus(client, 'OK');
|
|
|
|
}, uptimeInterval * 1000);
|
|
|
|
}
|
2022-06-16 09:18:39 +02:00
|
|
|
},
|
|
|
|
};
|
2022-06-16 13:29:07 +02:00
|
|
|
|
|
|
|
async function pingStatus(client, msg) {
|
|
|
|
https.get(`${uptimeURL}msg=${msg}&ping=${Math.round(client.ws.ping)}`);
|
|
|
|
}
|