diff --git a/commands/ping.js b/commands/ping.js index c8efe37..99a510f 100644 --- a/commands/ping.js +++ b/commands/ping.js @@ -24,10 +24,8 @@ module.exports = { } const end = new Date().getTime(); - const time = end - start; - const pingEmbed = new MessageEmbed() - .setDescription(`**Pong!** Bot ping: ${time}ms`) + .setDescription(`🏓 **Pong!** Bot ping: ${end - start}ms`) .setColor(client.config.EmbedColor); return interaction.send({ embeds: [pingEmbed] }); diff --git a/commands/stats.js b/commands/stats.js index 6b20f63..786200d 100644 --- a/commands/stats.js +++ b/commands/stats.js @@ -18,28 +18,24 @@ module.exports = { * @param {string[]} args * @param {*} param3 */ - run: async (client, interaction, args, { GuildDB }) => { + run: async (client, interaction, args, { GuildDB }, start) => { if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) { return interaction.send(`You are not allowed to use the bot in this channel.`); } - - const data = ` - \`\`\` - \n 𝗤𝘂𝗮𝗿𝗸𝘀𝗕𝗼𝘁 𝗦𝘁𝗮𝘁𝗶𝘀𝘁𝗶𝗰𝘀 - ╔══════════════╦══════════════╗ - ║ Channels ║${client.padding(client.channels.cache.size)}║ - ╠══════════════╬══════════════╣ - ║ Servers ║${client.padding(client.guilds.cache.size)}║ - ╠══════════════╬══════════════╣ - ║ Users ║${client.padding(client.users.cache.size)}║ - ╚══════════════╩══════════════╝ - \`\`\` - ` + const end = new Date().getTime(); const stats = new MessageEmbed() .setColor(client.config.EmbedColor) - .setDescription(data) - + .setTitle('QuarksBot Statistics') + .addFields( + { name: 'Guilds', value: `${client.guilds.cache.size}`, inline: true }, + { name: 'Channels', value: `${client.channels.cache.size}`, inline: true }, + { name: 'Users', value: `${client.users.cache.size}`, inline: true }, + { name: 'Latency', value: `${end - start}ms`, inline: true }, + { name: 'Uptime', value: `${client.secondsToDhms(process.uptime().toFixed(2))}`, inline: true }, + { name: 'Commands run', value: `${client.commandsRun}`, inline: true } + ) + return interaction.send({ embeds: [stats] }) }, }, diff --git a/structures/QuarksBot.js b/structures/QuarksBot.js index ccd7f45..66e9262 100644 --- a/structures/QuarksBot.js +++ b/structures/QuarksBot.js @@ -13,6 +13,7 @@ class QuarksBot extends Client { this.config = config; this.commands = new Collection(); this.logger = new Logger(path.join(__dirname, "..", "logs/Logs.log")); + this.commandsRun = 0; if (this.config.Token === "") return new TypeError( @@ -28,6 +29,7 @@ class QuarksBot extends Client { this.Ready = false; this.ws.on("INTERACTION_CREATE", async (interaction) => { + this.commandsRun++; const start = new Date().getTime(); if (interaction.type!=3) { client.log("Interaction") @@ -54,7 +56,7 @@ class QuarksBot extends Client { }); }; let cmd = client.commands.get(command); - if (cmd.name == 'ping' && cmd.SlashCommand && cmd.SlashCommand.run) cmd.SlashCommand.run(this, interaction, args, { GuildDB }, start); + if ((cmd.name == 'ping' || cmd.name == 'stats') && cmd.SlashCommand && cmd.SlashCommand.run) cmd.SlashCommand.run(this, interaction, args, { GuildDB }, start); else if (cmd.SlashCommand && cmd.SlashCommand.run) cmd.SlashCommand.run(this, interaction, args, { GuildDB }); } }); @@ -73,7 +75,19 @@ class QuarksBot extends Client { exists(n) {return null != n && undefined != n && "" != n} - padding(data) {return (` ${data}` + " ".repeat((9-data.toString().length)))} + secondsToDhms(seconds) { + seconds = Number(seconds); + const d = Math.floor(seconds / (3600*24)); + const h = Math.floor(seconds % (3600*24) / 3600); + const m = Math.floor(seconds % 3600 / 60); + const s = Math.floor(seconds % 60); + + const dDisplay = d > 0 ? d + (d == 1 ? " day, " : " days, ") : ""; + const hDisplay = h > 0 ? h + (h == 1 ? " hour, " : " hours, ") : ""; + const mDisplay = m > 0 ? m + (m == 1 ? " minute, " : " minutes, ") : ""; + const sDisplay = s > 0 ? s + (s == 1 ? " second" : " seconds") : ""; + return dDisplay + hDisplay + mDisplay + sDisplay; + } LoadCommands() { let CommandsDir = path.join(__dirname, '..', 'commands');