summary refs log tree commit diff
path: root/src-slowcord/bot/src
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-26 22:29:30 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-26 22:41:21 +1000
commit99ee7e9400f06e8718612d8b52d15215dc620774 (patch)
tree08de8c5d3985b9c2eaa419f5198f891ecd82d012 /src-slowcord/bot/src
parentRemove the cdn storage location log (diff)
downloadserver-99ee7e9400f06e8718612d8b52d15215dc620774.tar.xz
Prettier
Diffstat (limited to 'src-slowcord/bot/src')
-rw-r--r--src-slowcord/bot/src/Bot.ts16
-rw-r--r--src-slowcord/bot/src/commands/index.ts13
-rw-r--r--src-slowcord/bot/src/commands/instance.ts50
-rw-r--r--src-slowcord/bot/src/index.ts4
4 files changed, 52 insertions, 31 deletions
diff --git a/src-slowcord/bot/src/Bot.ts b/src-slowcord/bot/src/Bot.ts

index 45938846..cf3ff09f 100644 --- a/src-slowcord/bot/src/Bot.ts +++ b/src-slowcord/bot/src/Bot.ts
@@ -1,11 +1,11 @@ import { Message } from "discord.js"; -import { Client } from "fosscord-gopnik/build/lib"; // huh? oh well. some bugs in my lib Ig +import { Client } from "fosscord-gopnik/build/lib"; // huh? oh well. some bugs in my lib Ig import { Command, getCommands } from "./commands/index.js"; export default class Bot { client: Client; - commands: { [key: string]: Command; } = {}; + commands: { [key: string]: Command } = {}; constructor(client: Client) { this.client = client; @@ -17,10 +17,12 @@ export default class Bot { console.log(`Logged in as ${this.client.user!.tag}`); this.client.user!.setPresence({ - activities: [{ - name: "EVERYTHING", - type: "WATCHING", - }] + activities: [ + { + name: "EVERYTHING", + type: "WATCHING", + }, + ], }); }; @@ -45,4 +47,4 @@ export default class Bot { args: args, }); }; -} \ No newline at end of file +} diff --git a/src-slowcord/bot/src/commands/index.ts b/src-slowcord/bot/src/commands/index.ts
index d3b39e0f..0130b2bc 100644 --- a/src-slowcord/bot/src/commands/index.ts +++ b/src-slowcord/bot/src/commands/index.ts
@@ -2,11 +2,11 @@ import { Message, GuildMember, Guild, User } from "discord.js"; import fs from "fs"; export type CommandContext = { - user: User, - guild: Guild | null, - member: GuildMember | null, - message: Message, - args: string[], + user: User; + guild: Guild | null; + member: GuildMember | null; + message: Message; + args: string[]; }; export type Command = { @@ -19,8 +19,7 @@ const walk = async (path: string) => { const out = []; for (var file of files) { if (fs.statSync(`${path}/${file}`).isDirectory()) continue; - if (file.indexOf("index") !== -1) - continue; + if (file.indexOf("index") !== -1) continue; if (file.indexOf(".js") !== file.length - 3) continue; var imported = (await import(`./${file}`)).default; out.push(imported); diff --git a/src-slowcord/bot/src/commands/instance.ts b/src-slowcord/bot/src/commands/instance.ts
index ac0c9b2d..170d8f76 100644 --- a/src-slowcord/bot/src/commands/instance.ts +++ b/src-slowcord/bot/src/commands/instance.ts
@@ -1,7 +1,7 @@ import { Command } from "./index.js"; import { User, Guild, Message } from "@fosscord/util"; -const cache: { [key: string]: number; } = { +const cache: { [key: string]: number } = { users: 0, guilds: 0, messages: 0, @@ -11,7 +11,10 @@ const cache: { [key: string]: number; } = { export default { name: "instance", exec: async ({ message }) => { - if (Date.now() > cache.lastChecked + parseInt(process.env.CACHE_TTL as string)) { + 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(); @@ -19,18 +22,35 @@ export default { } return message.reply({ - embeds: [{ - title: "Instance Stats", - description: "For more indepth information, check out https://grafana.understars.dev", - footer: { - text: `Last checked: ${Math.floor((Date.now() - cache.lastChecked) / (1000 * 60))} minutes ago`, + embeds: [ + { + title: "Instance Stats", + description: + "For more indepth information, check out https://grafana.understars.dev", + 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(), + }, + ], }, - 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 + }, +} as Command; diff --git a/src-slowcord/bot/src/index.ts b/src-slowcord/bot/src/index.ts
index 253f759c..fa97313f 100644 --- a/src-slowcord/bot/src/index.ts +++ b/src-slowcord/bot/src/index.ts
@@ -1,6 +1,6 @@ import "dotenv/config"; import Fosscord from "fosscord-gopnik"; -import Bot from "./Bot.js"; // huh? +import Bot from "./Bot.js"; // huh? import { initDatabase } from "fosscord-server/src/util"; const client = new Fosscord.Client({ @@ -21,4 +21,4 @@ client.on("messageCreate", bot.onMessageCreate); (async () => { await initDatabase(); await client.login(process.env.TOKEN); -})(); \ No newline at end of file +})();