summary refs log tree commit diff
path: root/events
diff options
context:
space:
mode:
authorAmygdala Peanut-Almond <amygdala@almond.desloratadyna.net>2026-04-22 22:49:01 +0200
committerAmygdala Peanut-Almond <amygdala@almond.desloratadyna.net>2026-04-22 22:49:01 +0200
commit3572b97661a3f7c6c29e958b63c20d9f2ef936ac (patch)
treeb3ee056039cf792edd467e5172feee25a07dd56c /events
initialise repository
Signed-off-by: Amygdala Peanut-Almond <amygdala@almond.desloratadyna.net>
Diffstat (limited to 'events')
-rw-r--r--events/00ready.js13
-rw-r--r--events/cat.js9
-rw-r--r--events/dphoque.js11
-rw-r--r--events/messageCommands.js71
-rw-r--r--events/messageDelete.js35
-rw-r--r--events/spambot-fucker.js10
6 files changed, 149 insertions, 0 deletions
diff --git a/events/00ready.js b/events/00ready.js
new file mode 100644
index 0000000..0a45a16
--- /dev/null
+++ b/events/00ready.js
@@ -0,0 +1,13 @@
+const Discord = require("discord.js");
+const postgresql = require("pg");
+
+global.database = new postgresql.Pool();
+
+module.exports = {
+	name: 'clientReady',
+	async execute() {
+		globalThis.client.user.setActivity("a ball of yarn!! >w<", { type: Discord.ActivityType.Playing });
+		console.log("clientReady");
+	}
+}
+
diff --git a/events/cat.js b/events/cat.js
new file mode 100644
index 0000000..1e1f561
--- /dev/null
+++ b/events/cat.js
@@ -0,0 +1,9 @@
+module.exports = {
+	name: 'messageCreate',
+	async execute(message) {
+		if (message.content.includes('cat') || message.content.includes("meow")) {
+			await message.react("🐈");
+		}
+	}
+}
+
diff --git a/events/dphoque.js b/events/dphoque.js
new file mode 100644
index 0000000..15a3f84
--- /dev/null
+++ b/events/dphoque.js
@@ -0,0 +1,11 @@
+module.exports = {
+	name: 'messageCreate',
+	async execute(message) {
+		if (message.content.includes('d\'phoque') || message.content.includes('dphoque')) {
+			return await message.channel.send({
+				content: `shut your bitch ass up <@!${message.author.id}> 💜 I PURPLE YOU 🫰`
+			});
+		}
+	}
+}
+
diff --git a/events/messageCommands.js b/events/messageCommands.js
new file mode 100644
index 0000000..25f1260
--- /dev/null
+++ b/events/messageCommands.js
@@ -0,0 +1,71 @@
+const path = require('node:path');
+const util = require('node:util');
+const fs = require('node:fs');
+
+const { Collection } = require('discord.js');
+
+globalThis.commands = new Collection();
+
+globalThis.commandsReload = () => {
+	globalThis.commands = new Collection();
+
+	console.error('commands:');
+
+	const commandsDir = fs.readdirSync(config.directories.commandsDir).filter((fileName) => fileName.endsWith('.js'));
+
+	for (let i = 0; i < commandsDir.length; i += 1) {
+		const commandModulePath = path.join(process.cwd(), config.directories.commandsDir, commandsDir[i]);
+		delete require.cache[require.resolve(commandModulePath)];
+
+		const commandModule = require(commandModulePath);
+
+		if (typeof commandModule.name !== 'string' || typeof commandModule.execute !== 'function') {
+			console.error(`${commandModulePath} is not a valid command module`);
+			continue;
+		}
+
+		commands.set(commandModule.name, commandModule);
+
+		console.log(`\t${commandsDir[i]} -> ${commandModule.name}`);
+	}
+}
+
+globalThis.commandsReload();
+
+module.exports = {
+	name: 'messageCreate',
+	async execute(message) {
+		if (message.author.bot) return;
+
+		let prefix = false;
+		for (let i = 0; i < config.prefixes.length; i += 1) {
+			const configuredPrefix = config.prefixes[i];
+
+			if (message.content.startsWith(configuredPrefix)) {
+				prefix = configuredPrefix;
+				break;
+			}
+		}
+
+		if (!prefix) {
+			return;
+		}
+
+		const args = message.content.slice(prefix.length).trim().split(/ +/gmi);
+		const command = globalThis.commands.get(args[0]);
+
+		if (!command) {
+			return;
+		}
+
+		try {
+			await command.execute(message, args.slice(1), globalThis.client);
+		} catch (e) {
+			console.error(e);
+			return await message.reply({
+				content: `an error occurred\n${e}\nplease contact the bot developer`
+			});
+		}
+	}
+}
+
diff --git a/events/messageDelete.js b/events/messageDelete.js
new file mode 100644
index 0000000..cfba446
--- /dev/null
+++ b/events/messageDelete.js
@@ -0,0 +1,35 @@
+const { getWebhook } = require("../libs/webhook.js");
+
+module.exports = {
+	name: "messageDelete",
+	async execute(msg) {
+		if (msg.webhookId !== null) return;
+
+		console.log("a");
+		const wh = await getWebhook(msg.guild.id);
+		if (wh === null) return;
+		console.log("b");
+
+		await wh.send({
+			content: `Message deleted in <#${msg.channel.id}>`,
+			embeds: [
+				{
+					title: "Deleted message",
+					author: {
+						name: `${msg.author.globalName} (${msg.author.username}; ${msg.author.id})`
+					},
+					fields: [
+						{
+							name: "Content",
+							value: msg.content
+						}
+					],
+					timestamp: msg.createdAt
+				}
+			]
+		});
+		delete wh;
+		console.log("d");
+	}
+}
+
diff --git a/events/spambot-fucker.js b/events/spambot-fucker.js
new file mode 100644
index 0000000..c343865
--- /dev/null
+++ b/events/spambot-fucker.js
@@ -0,0 +1,10 @@
+module.exports = {
+	name: 'messageCreate',
+	async execute(msg) {
+		if (msg.channel.id === "1491056218498793552") {
+			await msg.member.timeout(2_419_200_000);
+		}
+	}
+}
+
+