From d4843ecbeeb87155364ef48b6f39a8c611a41360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Steinh=C3=BCbl=20=28xHyroM=29?= Date: Sat, 30 Dec 2023 17:33:05 +0100 Subject: [PATCH] feat: achievements for sending things into bun only channel --- src/constants.ts | 36 ++++++++++++++++----------------- src/listeners/message_update.ts | 7 +++++++ src/util.ts | 8 +++++++- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index ed8e403..835afb1 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -13,22 +13,22 @@ export const LILYBIRD_HANDLERS_VERSION = export const PRODUCTION = process.env.NODE_ENV === "production"; export const BUN_EMOJIS = [ - "awesomebun:1136571782472683571", - "beno:1152544141323010049", - "bun:994093611065024512", - "bunUwU:1152543655035412602", - "bunana:1118962978088304741", - "bundough:1152673360224993383", - "bundows:1180836292657942598", - "bunlove:1001784944068145213", - "bunx:1151197324299739146", - "buxmas:1180860721672757308", - "grabbun:995824913418027118", - "lickbun:1118962491653898311", - "nomouth_bun:995824878227820687", - "nostalgiabun:995824933236129912", - "peekbun:995823659786711082", - "rainbowbun:995824310860128326", - "uwubun:995823895175233587", - "bupple:1190690285852839976", + { name: "awesomebun", id: "1136571782472683571" }, + { name: "beno", id: "1152544141323010049" }, + { name: "bun", id: "994093611065024512" }, + { name: "bunUwU", id: "1152543655035412602" }, + { name: "bunana", id: "1118962978088304741" }, + { name: "bundough", id: "1152673360224993383" }, + { name: "bundows", id: "1180836292657942598" }, + { name: "bunlove", id: "1001784944068145213" }, + { name: "bunx", id: "1151197324299739146" }, + { name: "buxmas", id: "1180860721672757308" }, + { name: "grabbun", id: "995824913418027118" }, + { name: "lickbun", id: "1118962491653898311" }, + { name: "nomouth_bun", id: "995824878227820687" }, + { name: "nostalgiabun", id: "995824933236129912" }, + { name: "peekbun", id: "995823659786711082" }, + { name: "rainbowbun", id: "995824310860128326" }, + { name: "uwubun", id: "995823895175233587" }, + { name: "bupple", id: "1190690285852839976" }, ]; diff --git a/src/listeners/message_update.ts b/src/listeners/message_update.ts index 5f8e93b..af183bb 100644 --- a/src/listeners/message_update.ts +++ b/src/listeners/message_update.ts @@ -1,5 +1,6 @@ import { Event } from "@lilybird/handlers"; import { PartialMessage } from "lilybird"; +import { getRandomBunEmoji } from "src/util.ts"; export default { event: "messageUpdate", @@ -16,6 +17,12 @@ function handleBunOnlyChannel(message: PartialMessage): 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/util.ts b/src/util.ts index b1fa8bf..147d0eb 100644 --- a/src/util.ts +++ b/src/util.ts @@ -32,5 +32,11 @@ export function isBunOnlyLikeMessage(content?: string) { if (!content) return false; if (content === "bun") return true; - return BUN_EMOJIS.some((emoji) => content.replace(/<:|>/g, "") == emoji); + return BUN_EMOJIS.some( + (emoji) => content.replace(/<:|>/g, "") == `${emoji.name}:${emoji.id}` + ); +} + +export function getRandomBunEmoji() { + return BUN_EMOJIS[Math.floor(Math.random() * BUN_EMOJIS.length)]; }