stats.js
· 4.7 KiB · JavaScript
Sin formato
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
})
]
})
}
}
}
1 | const { sqlQuery } = require('@functions/sqlQuery'); |
2 | |
3 | module.exports = { |
4 | name: 'stats', |
5 | category: 'Info', |
6 | description: 'Bot or Website Statistics', |
7 | userPerms: [''], |
8 | basePerms: [''], |
9 | options: [ |
10 | { |
11 | name: 'type', |
12 | description: 'Bot or Website Stats?', |
13 | required: true, |
14 | choices: [ |
15 | { |
16 | name: 'bot', |
17 | value: 'bot_stats' |
18 | }, |
19 | { |
20 | name: 'website', |
21 | value: 'website_stats' |
22 | } |
23 | ], |
24 | type: 3 |
25 | } |
26 | ], |
27 | |
28 | run: async(client) => { |
29 | |
30 | let method = await client.interaction.options.get('type')?.value; |
31 | |
32 | switch (method) { |
33 | |
34 | case "bot_stats": |
35 | |
36 | return client.interaction.reply({ |
37 | embeds: [ |
38 | new client.Gateway.EmbedBuilder() |
39 | .setTitle('Bot statistics') |
40 | .setColor(client.colors.base) |
41 | .setThumbnail(client.logo) |
42 | .setDescription('Here are my stats chief!') |
43 | .addFields( |
44 | { |
45 | name: 'User Count', |
46 | value: `${client.users.cache.size} users`, |
47 | inline: true |
48 | }, |
49 | { |
50 | name: 'Channel Count', |
51 | value: `${client.channels.cache.size} channels`, |
52 | inline: true |
53 | }, |
54 | { |
55 | name: 'Guild Count', |
56 | value: `${client.guilds.cache.size}`, |
57 | inline: true |
58 | } |
59 | ) |
60 | .setTimestamp() |
61 | .setFooter({ |
62 | text: client.footer, |
63 | iconURL: client.logo |
64 | }) |
65 | ] |
66 | }); |
67 | |
68 | case "website_stats": |
69 | |
70 | let users = await sqlQuery({ query: 'SELECT * FROM users'}).then(u => u); |
71 | let images = await sqlQuery({ query: 'SELECT * FROM images'}).then(i => i); |
72 | let downloads = await sqlQuery({ query: 'SELECT * FROM downloads'}).then(d => d); |
73 | |
74 | if (!users) users = 0; |
75 | if (!images) images = 0; |
76 | if (!downloads) downloads = 0; |
77 | |
78 | return client.interaction.reply({ |
79 | embeds: [ |
80 | new client.Gateway.EmbedBuilder() |
81 | .setTitle('Website statistics') |
82 | .setColor(client.colors.base) |
83 | .setThumbnail(client.logo) |
84 | .setDescription('NOTE: these stats only reflect our dev and beta websites') |
85 | .addFields( |
86 | { |
87 | name: 'User Count', |
88 | value: `${users.length ? users.length : 0} users`, |
89 | inline: true |
90 | }, |
91 | { |
92 | name: 'Image Count', |
93 | value: `${images.length ? images.length : 0} images`, |
94 | inline: true |
95 | }, |
96 | { |
97 | name: 'Download Count', |
98 | value: `${downloads.length ? downloads.length : 0} downloads`, |
99 | inline: true |
100 | } |
101 | ) |
102 | .setTimestamp() |
103 | .setFooter({ |
104 | text: client.footer, |
105 | iconURL: client.logo |
106 | }) |
107 | ] |
108 | }) |
109 | |
110 | default: |
111 | |
112 | return client.interaction.reply({ |
113 | ephemeral: true, |
114 | embeds: [ |
115 | new client.Gateway.EmbedBuilder() |
116 | .setTitle('Error: invalid params') |
117 | .setColor(client.colors.error) |
118 | .setThumbnail(client.logo) |
119 | .setDescription('Please provide some valid command params') |
120 | .setTimestamp() |
121 | .setFooter({ |
122 | text: client.footer, |
123 | iconURL: client.logo |
124 | }) |
125 | ] |
126 | }) |
127 | } |
128 | } |
129 | } |