From 7311bc7f616ff97a650298c79a806099959f7c3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Steinh=C3=BCbl=20=28xHyroM=29?= Date: Tue, 10 Oct 2023 10:41:46 +0200 Subject: [PATCH] feat: bun only channel --- src/listeners/message_create.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/listeners/message_create.ts b/src/listeners/message_create.ts index 2ccea8f..8fca67a 100644 --- a/src/listeners/message_create.ts +++ b/src/listeners/message_create.ts @@ -7,6 +7,7 @@ import { extname } from "node:path"; import { safeSlice } from "../util.ts"; const GITHUB_LINE_URL_REGEX = /(?:https?:\/\/)?(?:www\.)?(?:github)\.com\/(?[a-zA-Z0-9-_]+\/[A-Za-z0-9_.-]+)\/blob\/(?.+?)#L(?\d+)[-~]?L?(?\d*)/i; +const BUN_ONLY_CHANNEL_ID = "1161157663867027476"; defineListener({ event: Events.MessageCreate, @@ -37,9 +38,23 @@ defineListener({ }); function handleOthers(message: Message) { + if (handleBunOnlyChannel(message)) return; + handleGithubLink(message); } +function handleBunOnlyChannel(message: Message) { + if (message.channel.id !== BUN_ONLY_CHANNEL_ID) return false; + + if (message.content !== "bun") { + message.delete(); + return true; + } + + message.react("🐰"); + return true; +} + async function handleGithubLink(message: Message) { const match = GITHUB_LINE_URL_REGEX.exec(message.content); const groups = match?.groups;