const { sqlQuery } = require('@functions/sqlQuery'); module.exports = { name: 'stats', category: 'Info', description: 'Bot or Website Statistics', userPerms: [''], basePerms: [''], options: [ { name: 'type', description: 'Bot or Website Stats?', required: true, choices: [ { name: 'bot', value: 'bot_stats' }, { name: 'website', value: 'website_stats' } ], type: 3 } ], run: async(client) => { let method = await client.interaction.options.get('type')?.value; switch (method) { case "bot_stats": return client.interaction.reply({ embeds: [ new client.Gateway.EmbedBuilder() .setTitle('Bot statistics') .setColor(client.colors.base) .setThumbnail(client.logo) .setDescription('Here are my stats chief!') .addFields( { name: 'User Count', value: `${client.users.cache.size} users`, inline: true }, { name: 'Channel Count', value: `${client.channels.cache.size} channels`, inline: true }, { name: 'Guild Count', value: `${client.guilds.cache.size}`, inline: true } ) .setTimestamp() .setFooter({ text: client.footer, iconURL: client.logo }) ] }); case "website_stats": let users = await sqlQuery({ query: 'SELECT * FROM users'}).then(u => u); let images = await sqlQuery({ query: 'SELECT * FROM images'}).then(i => i); let downloads = await sqlQuery({ query: 'SELECT * FROM downloads'}).then(d => d); if (!users) users = 0; if (!images) images = 0; if (!downloads) downloads = 0; return client.interaction.reply({ embeds: [ new client.Gateway.EmbedBuilder() .setTitle('Website statistics') .setColor(client.colors.base) .setThumbnail(client.logo) .setDescription('NOTE: these stats only reflect our dev and beta websites') .addFields( { name: 'User Count', value: `${users.length ? users.length : 0} users`, inline: true }, { name: 'Image Count', value: `${images.length ? images.length : 0} images`, inline: true }, { name: 'Download Count', value: `${downloads.length ? downloads.length : 0} downloads`, inline: true } ) .setTimestamp() .setFooter({ text: client.footer, iconURL: client.logo }) ] }) default: return client.interaction.reply({ ephemeral: true, embeds: [ new client.Gateway.EmbedBuilder() .setTitle('Error: invalid params') .setColor(client.colors.error) .setThumbnail(client.logo) .setDescription('Please provide some valid command params') .setTimestamp() .setFooter({ text: client.footer, iconURL: client.logo }) ] }) } } }