diff --git a/src/listeners/message_create.tsx b/src/listeners/message_create.tsx index aa92fd9..f85eefe 100644 --- a/src/listeners/message_create.tsx +++ b/src/listeners/message_create.tsx @@ -2,7 +2,7 @@ import { Message, ButtonStyle } from "lilybird"; import { ActionRow, Button } from "@lilybird/jsx"; import { extname, basename } from "node:path"; import { Event } from "@lilybird/handlers"; -import { isBunOnlyLikeMessage, safeSlice } from "../util.ts"; +import { getRandomBunEmoji, isBunOnlyLikeMessage, 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; @@ -28,6 +28,12 @@ function handleBunOnlyChannel(message: Message): boolean { return true; } + // 1% chance to react with a random bun emoji + if (Math.floor(Math.random() * 100) === 0) { + message.react(getRandomBunEmoji().id, true); + return true; + } + message.react("🐰"); return true; } diff --git a/src/listeners/message_update.ts b/src/listeners/message_update.ts index af183bb..0b36289 100644 --- a/src/listeners/message_update.ts +++ b/src/listeners/message_update.ts @@ -1,6 +1,6 @@ import { Event } from "@lilybird/handlers"; import { PartialMessage } from "lilybird"; -import { getRandomBunEmoji } from "src/util.ts"; +import { getRandomBunEmoji, isBunOnlyLikeMessage } from "src/util.ts"; export default { event: "messageUpdate", @@ -12,11 +12,14 @@ export default { function handleBunOnlyChannel(message: PartialMessage): boolean { if (message.channelId !== process.env.BUN_ONLY_CHANNEL_ID) return false; - if (message.content !== "bun") { + if (!isBunOnlyLikeMessage(message.content)) { message.delete(); return true; } + // check if there's reaction from bot + if (message.reactions?.some((reaction) => reaction.me)) return true; + // 1% chance to react with a random bun emoji if (Math.floor(Math.random() * 100) === 0) { message.react(getRandomBunEmoji().id, true);