/[sudobot]/branches/2.x/src/commands/information/StatsCommand.ts
ViewVC logotype

Contents of /branches/2.x/src/commands/information/StatsCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (show annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 2118 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
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 axios from 'axios';
7 import path from 'path';
8 import { deleteFile, download } from '../../utils/util';
9 import MessageEmbed from '../../client/MessageEmbed';
10
11 export default class StatsCommand extends BaseCommand {
12 supportsInteractions: boolean = true;
13
14 constructor() {
15 super('stats', 'information', []);
16 }
17
18 async run(client: DiscordClient, msg: Message | CommandInteraction, options: CommandOptions | InteractionOptions) {
19 let members = 0;
20 let bots = 0;
21
22 msg.guild!.members.cache.forEach(m => {
23 if (m.user.bot)
24 bots++;
25 else
26 members++;
27 });
28
29 await msg.reply({
30 embeds: [
31 new MessageEmbed()
32 .setAuthor({
33 name: msg.guild!.name,
34 iconURL: msg.guild!.iconURL()!,
35 })
36 .addFields([
37 {
38 name: "Members",
39 inline: true,
40 value: members + ''
41 },
42 {
43 name: "Bots",
44 inline: true,
45 value: bots + ''
46 },
47 {
48 name: "Total Members",
49 inline: true,
50 value: (members + bots) + ''
51 }
52 ])
53 .addField('Roles', msg.guild!.roles.cache.size + '')
54 .addField('Text Channels', msg.guild!.channels.cache.filter(c => c.type === 'GUILD_TEXT').size + '')
55 .addField('Emojis', msg.guild!.emojis.cache.size + '')
56 .addField('Stickers', msg.guild!.stickers?.cache.size + '')
57 ]
58 });
59 }
60 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26