1 |
import { CommandInteraction, Message } from 'discord.js'; |
2 |
import BaseCommand from '../../utils/structures/BaseCommand'; |
3 |
import DiscordClient from '../../client/Client'; |
4 |
import CommandOptions from '../../types/CommandOptions'; |
5 |
import InteractionOptions from '../../types/InteractionOptions'; |
6 |
import MessageEmbed from '../../client/MessageEmbed'; |
7 |
|
8 |
export default class StatsCommand extends BaseCommand { |
9 |
supportsInteractions: boolean = true; |
10 |
|
11 |
constructor() { |
12 |
super('stats', 'information', []); |
13 |
} |
14 |
|
15 |
async run(client: DiscordClient, msg: Message | CommandInteraction, options: CommandOptions | InteractionOptions) { |
16 |
let members = 0; |
17 |
let bots = 0; |
18 |
|
19 |
msg.guild!.members.cache.forEach(m => { |
20 |
if (m.user.bot) |
21 |
bots++; |
22 |
else |
23 |
members++; |
24 |
}); |
25 |
|
26 |
await msg.reply({ |
27 |
embeds: [ |
28 |
new MessageEmbed() |
29 |
.setAuthor({ |
30 |
name: msg.guild!.name, |
31 |
iconURL: msg.guild!.iconURL()!, |
32 |
}) |
33 |
.addFields([ |
34 |
{ |
35 |
name: "Members", |
36 |
inline: true, |
37 |
value: members + '' |
38 |
}, |
39 |
{ |
40 |
name: "Bots", |
41 |
inline: true, |
42 |
value: bots + '' |
43 |
}, |
44 |
{ |
45 |
name: "Total Members", |
46 |
inline: true, |
47 |
value: (members + bots) + '' |
48 |
} |
49 |
]) |
50 |
.addField('Roles', msg.guild!.roles.cache.size + '') |
51 |
.addField('Text Channels', msg.guild!.channels.cache.filter(c => c.type === 'GUILD_TEXT').size + '') |
52 |
.addField('Emojis', msg.guild!.emojis.cache.size + '') |
53 |
.addField('Stickers', msg.guild!.stickers?.cache.size + '') |
54 |
] |
55 |
}); |
56 |
} |
57 |
} |