summary refs log tree commit diff
path: root/slowcord/bot/src/commands/instance.ts
diff options
context:
space:
mode:
Diffstat (limited to 'slowcord/bot/src/commands/instance.ts')
-rw-r--r--slowcord/bot/src/commands/instance.ts31
1 files changed, 29 insertions, 2 deletions
diff --git a/slowcord/bot/src/commands/instance.ts b/slowcord/bot/src/commands/instance.ts

index 7fcfaef4..d1b08cef 100644 --- a/slowcord/bot/src/commands/instance.ts +++ b/slowcord/bot/src/commands/instance.ts
@@ -1,8 +1,35 @@ import { Command } from "./index.js"; +import { User, Guild, Message } from "@fosscord/util"; + +const cache: { [key: string]: number; } = { + users: 0, + guilds: 0, + messages: 0, + lastChecked: 0, +}; export default { name: "instance", - exec: ({ message }) => { - message.reply("Test"); + exec: async ({ message }) => { + if (Date.now() > cache.lastChecked + parseInt(process.env.CACHE_TTL as string)) { + cache.users = await User.count(); + cache.guilds = await Guild.count(); + cache.messages = await Message.count(); + cache.lastChecked = Date.now(); + } + + return message.reply({ + embeds: [{ + title: "Instance Stats", + footer: { + text: `Last checked: ${Math.floor((Date.now() - cache.lastChecked) / (1000 * 60))} minutes ago`, + }, + fields: [ + { inline: true, name: "Total Users", value: cache.users.toString() }, + { inline: true, name: "Total Guilds", value: cache.guilds.toString() }, + { inline: true, name: "Total Messages", value: cache.messages.toString() }, + ] + }] + }); } } as Command; \ No newline at end of file