diff --git a/src/constants.ts b/src/constants.ts index 53c9f63..05e293c 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -8,4 +8,4 @@ export const PRODUCTION = process.env.NODE_ENV === "production"; export const MESSAGE_PREFIX = PRODUCTION ? "b" : "<>"; - +export const BUN_ONLY_CHANNEL_ID = "1161157663867027476" diff --git a/src/listeners/index.ts b/src/listeners/index.ts index 29e628b..f96423d 100644 --- a/src/listeners/index.ts +++ b/src/listeners/index.ts @@ -1,4 +1,5 @@ import "./ready.ts"; import "./interaction_create.ts"; import "./message_create.ts"; +import "./message_update.ts"; import "./nickname_moderation.ts"; diff --git a/src/listeners/message_create.ts b/src/listeners/message_create.ts index ef5f8b0..e309ce3 100644 --- a/src/listeners/message_create.ts +++ b/src/listeners/message_create.ts @@ -1,13 +1,12 @@ import { ActionRowBuilder, ButtonBuilder, ButtonStyle, Events, Message } from "discord.js"; import { defineListener } from "../loaders/listeners.ts"; -import { MESSAGE_PREFIX } from "../constants.ts"; +import { MESSAGE_PREFIX, BUN_ONLY_CHANNEL_ID } from "../constants.ts"; import { COMMANDS } from "../loaders/commands.ts"; import { MessageCommandContext } from "../structs/context/CommandContext.ts"; 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, diff --git a/src/listeners/message_update.ts b/src/listeners/message_update.ts new file mode 100644 index 0000000..f08a1e1 --- /dev/null +++ b/src/listeners/message_update.ts @@ -0,0 +1,22 @@ +import { Events, Message } from "discord.js"; +import { defineListener } from "../loaders/listeners.ts"; +import { BUN_ONLY_CHANNEL_ID } from "../constants.ts"; + +defineListener({ + event: Events.MessageUpdate, + run: async(_: Message, message: Message) => { + if (handleBunOnlyChannel(message)) return; + } +}); + +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; +}