Discord-Bot/src/events/client/clientReady.js
2023-01-02 20:32:42 +01:00

54 lines
2.2 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const Discord = require('discord.js');
const chalk = require('chalk');
const { random } = require('mathjs');
module.exports = async (client) => {
const startLogs = new Discord.WebhookClient({
id: client.webhooks.startLogs.id,
token: client.webhooks.startLogs.token,
});
console.log(`\u001b[0m`);
console.log(chalk.blue(chalk.bold(`System`)), (chalk.white(`>>`)), chalk.red(`Shard #${client.shard.ids[0] + 1}`), chalk.green(`is ready!`))
console.log(chalk.blue(chalk.bold(`Bot`)), (chalk.white(`>>`)), chalk.green(`Started on`), chalk.red(`${client.guilds.cache.size}`), chalk.green(`servers!`))
let embed = new Discord.EmbedBuilder()
.setTitle(`🆙・Finishing shard`)
.setDescription(`A shard just finished`)
.addFields(
{ name: "🆔┆ID", value: `${client.shard.ids[0] + 1}/${client.options.shardCount}`, inline: true },
{ name: "📃┆State", value: `Ready`, inline: true },
)
.setColor(client.config.colors.normal)
startLogs.send({
username: 'Bot Logs',
embeds: [embed],
});
setInterval(async function () {
const promises = [
client.shard.fetchClientValues('guilds.cache.size'),
];
return Promise.all(promises)
.then(results => {
const totalGuilds = results[0].reduce((acc, guildCount) => acc + guildCount, 0);
let statuttext;
if (process.env.DISCORD_STATUS) {
statuttext = process.env.DISCORD_STATUS.split(', ');
} else {
statuttext = [
`・❓┆/help`,
`・💻┆${totalGuilds} servers`,
`・📨┆discord.gg/corwindev`,
`・🎉┆400+ commands`,
`・🏷┆Version ${require(`${process.cwd()}/package.json`).version}`
];
}
const randomText = statuttext[Math.floor(Math.random() * statuttext.length)];
client.user.setPresence({ activities: [{ name: randomText, type: Discord.ActivityType.Playing }], status: 'online' });
})
}, 50000)
client.player.init(client.user.id);
}