/[sudobot]/trunk/src/commands/information/StatsCommand.ts
ViewVC logotype

Contents of /trunk/src/commands/information/StatsCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 344 - (show annotations)
Mon Jul 29 17:29:40 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 2009 byte(s)
chore: eslint autofix
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 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26