This commit is contained in:
Madeline
2022-09-26 22:41:21 +10:00
parent fcc0884e36
commit 99ee7e9400
280 changed files with 6800 additions and 3908 deletions
+9 -7
View File
@@ -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,
});
};
}
}
+6 -7
View File
@@ -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);
+35 -15
View File
@@ -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;
},
} as Command;
+2 -2
View File
@@ -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);
})();
})();