2022-03-03 20:56:49 +07:00
|
|
|
import DiscordModule, { HybridInteractionMessage } from "../utils/DiscordModule";
|
|
|
|
|
|
2022-02-05 00:46:35 +07:00
|
|
|
import { Message, CommandInteraction, Interaction } from "discord.js";
|
2022-03-03 20:56:49 +07:00
|
|
|
import { sendHybridInteractionMessageResponse, makeInfoEmbed } from "../utils/DiscordMessage";
|
2022-02-05 00:46:35 +07:00
|
|
|
import DiscordProvider from "../providers/Discord";
|
2022-02-07 10:41:55 +07:00
|
|
|
import os from "os-utils";
|
2022-02-05 00:46:35 +07:00
|
|
|
|
|
|
|
|
const EMBEDS = {
|
|
|
|
|
STATS_INFO: (data: Message | Interaction) => {
|
|
|
|
|
let message;
|
|
|
|
|
|
|
|
|
|
return makeInfoEmbed({
|
|
|
|
|
title: `Stats`,
|
|
|
|
|
icon: '📊',
|
2022-02-07 10:41:55 +07:00
|
|
|
description: 'Stats of the bot',
|
|
|
|
|
fields: [
|
|
|
|
|
{
|
|
|
|
|
name: '🌐 Users',
|
|
|
|
|
value: `${DiscordProvider.client.guilds.cache.size} servers\n${DiscordProvider.client.guilds.cache.map((g) => g.memberCount).reduce((a, c) => a + c)} users`,
|
|
|
|
|
inline: true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '🟢 Uptime since',
|
|
|
|
|
value: `System: <t:${(Math.round(new Date().getTime() / 1000)) - Math.round(os.sysUptime())}:R>\nProcess: <t:${(Math.round(new Date().getTime() / 1000)) - Math.round(os.processUptime())}:R>`,
|
|
|
|
|
inline: true
|
|
|
|
|
}
|
|
|
|
|
],
|
2022-02-05 00:46:35 +07:00
|
|
|
user: (data instanceof Interaction) ? data.user : data.author
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-03 20:56:49 +07:00
|
|
|
export default class Stats extends DiscordModule {
|
2022-02-05 00:46:35 +07:00
|
|
|
|
2022-03-03 20:56:49 +07:00
|
|
|
public id = "Discord_Stats";
|
|
|
|
|
public commands = ["stats"];
|
|
|
|
|
public commandInteractionName = "stats";
|
|
|
|
|
|
|
|
|
|
async GuildOnModuleCommand(args: any, message: Message) {
|
|
|
|
|
await this.run(new HybridInteractionMessage(message), args);
|
2022-02-05 00:46:35 +07:00
|
|
|
}
|
|
|
|
|
|
2022-03-03 20:56:49 +07:00
|
|
|
async GuildModuleCommandInteractionCreate(interaction: CommandInteraction) {
|
|
|
|
|
await this.run(new HybridInteractionMessage(interaction), interaction.options);
|
2022-02-05 00:46:35 +07:00
|
|
|
}
|
|
|
|
|
|
2022-03-03 20:56:49 +07:00
|
|
|
async run(data: HybridInteractionMessage, args: any) {
|
|
|
|
|
return await sendHybridInteractionMessageResponse(data, { embeds:[EMBEDS.STATS_INFO(data.getRaw())] });
|
2022-02-05 00:46:35 +07:00
|
|
|
}
|
|
|
|
|
}
|