2024-02-02 03:28:46 +01:00
|
|
|
import { execFile } from 'node:child_process';
|
2022-08-17 16:22:49 +02:00
|
|
|
const { statusChannel, NODE_ENV } = process.env;
|
2024-01-12 23:59:22 +01:00
|
|
|
import { version } from 'discord.js';
|
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) {
|
2022-12-18 22:53:31 +01:00
|
|
|
// Init global variables.
|
|
|
|
global.boards = {};
|
|
|
|
|
2024-07-07 00:56:09 +02:00
|
|
|
const commandSize = client.commands.size;
|
|
|
|
const clientTag = client.user.username;
|
|
|
|
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.`);
|
|
|
|
console.log(`Running Discord.js \x1b[33m${version}\x1b[0m`);
|
|
|
|
|
2022-06-16 09:18:39 +02:00
|
|
|
const ytdlpVersion = await new Promise((resolve, reject) => {
|
2024-02-02 03:28:46 +01:00
|
|
|
execFile('./bin/yt-dlp', ['--version'], (err, stdout, stderr) => {
|
2022-06-16 09:18:39 +02:00
|
|
|
if (err) {
|
|
|
|
reject(stderr);
|
|
|
|
}
|
|
|
|
if (stderr) {
|
|
|
|
console.error(stderr);
|
|
|
|
}
|
|
|
|
resolve(stdout);
|
|
|
|
});
|
|
|
|
});
|
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-08-15 17:25:52 +02:00
|
|
|
|
|
|
|
// If stats channel settings exist, send bot stats to it
|
2022-08-17 16:22:49 +02:00
|
|
|
if (statusChannel && NODE_ENV !== 'development') {
|
2022-08-15 17:25:52 +02:00
|
|
|
const channel = client.channels.resolve(statusChannel);
|
2024-01-12 23:59:22 +01:00
|
|
|
channel.send(
|
|
|
|
`Ready to serve in ${channelSize} channels on ${guildSize} servers.\n` +
|
|
|
|
`There is ${commandSize} command loaded.\n` +
|
|
|
|
`Running yt-dlp ${ytdlpVersion.replace('\n', '')}\n` +
|
|
|
|
`${client.readyAt}`);
|
2022-08-15 17:25:52 +02:00
|
|
|
}
|
2022-06-16 09:18:39 +02:00
|
|
|
},
|
2022-08-14 22:28:14 +02:00
|
|
|
};
|