summary refs log tree commit diff
path: root/slowcord/bot/src
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-25 18:24:21 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-25 23:35:18 +1000
commit0d23eaba09a4878520bf346af4cead90d76829fc (patch)
treed930eacceff0b407b44abe55f01d8e3c5dfbfa34 /slowcord/bot/src
parentAllow edited_timestamp to passthrough in handleMessage (diff)
downloadserver-0d23eaba09a4878520bf346af4cead90d76829fc.tar.xz
Refactor to mono-repo + upgrade packages
Diffstat (limited to 'slowcord/bot/src')
-rw-r--r--slowcord/bot/src/Bot.ts48
-rw-r--r--slowcord/bot/src/commands/index.ts37
-rw-r--r--slowcord/bot/src/commands/instance.ts36
-rw-r--r--slowcord/bot/src/index.ts24
4 files changed, 0 insertions, 145 deletions
diff --git a/slowcord/bot/src/Bot.ts b/slowcord/bot/src/Bot.ts
deleted file mode 100644
index 45938846..00000000
--- a/slowcord/bot/src/Bot.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-import { Message } from "discord.js";
-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; } = {};
-
-	constructor(client: Client) {
-		this.client = client;
-	}
-
-	onReady = async () => {
-		this.commands = await getCommands();
-
-		console.log(`Logged in as ${this.client.user!.tag}`);
-
-		this.client.user!.setPresence({
-			activities: [{
-				name: "EVERYTHING",
-				type: "WATCHING",
-			}]
-		});
-	};
-
-	onMessageCreate = async (msg: Message) => {
-		const prefix = process.env.PREFIX as string;
-		if (msg.author.bot) return;
-		if (!msg.content || msg.content.indexOf(prefix) === -1) return;
-
-		const content = msg.content.slice(prefix.length).split(" ");
-		const cmd = content.shift();
-		if (!cmd) return;
-		const args = content;
-
-		const command = this.commands[cmd];
-		if (!command) return;
-
-		await command.exec({
-			user: msg.author,
-			member: msg.member,
-			guild: msg.guild,
-			message: msg,
-			args: args,
-		});
-	};
-}
\ No newline at end of file
diff --git a/slowcord/bot/src/commands/index.ts b/slowcord/bot/src/commands/index.ts
deleted file mode 100644
index d3b39e0f..00000000
--- a/slowcord/bot/src/commands/index.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-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[],
-};
-
-export type Command = {
-	name: string;
-	exec: (ctx: CommandContext) => any;
-};
-
-const walk = async (path: string) => {
-	const files = fs.readdirSync(path);
-	const out = [];
-	for (var file of files) {
-		if (fs.statSync(`${path}/${file}`).isDirectory()) continue;
-		if (file.indexOf("index") !== -1)
-			continue;
-		if (file.indexOf(".js") !== file.length - 3) continue;
-		var imported = (await import(`./${file}`)).default;
-		out.push(imported);
-	}
-	return out;
-};
-
-export const getCommands = async () => {
-	const map: { [key: string]: Command } = {};
-	for (var cmd of await walk("./build/commands")) {
-		map[cmd.name] = cmd;
-	}
-	return map;
-};
diff --git a/slowcord/bot/src/commands/instance.ts b/slowcord/bot/src/commands/instance.ts
deleted file mode 100644
index ac0c9b2d..00000000
--- a/slowcord/bot/src/commands/instance.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-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: 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",
-				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() },
-				]
-			}]
-		});
-	}
-} as Command;
\ No newline at end of file
diff --git a/slowcord/bot/src/index.ts b/slowcord/bot/src/index.ts
deleted file mode 100644
index ae69111b..00000000
--- a/slowcord/bot/src/index.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import "dotenv/config";
-import Fosscord from "fosscord-gopnik";
-import Bot from "./Bot.js";	// huh?
-import { initDatabase } from "@fosscord/util";
-
-const client = new Fosscord.Client({
-	intents: ["GUILD_MESSAGES"],
-
-	http: {
-		api: process.env.ENDPOINT_API,
-		cdn: process.env.ENDPOINT_CDN,
-		invite: process.env.ENDPOINT_INV,
-	},
-});
-
-const bot = new Bot(client);
-
-client.on("ready", bot.onReady);
-client.on("messageCreate", bot.onMessageCreate);
-
-(async () => {
-	await initDatabase();
-	await client.login(process.env.TOKEN);
-})();
\ No newline at end of file