feat: allow emojis in bun only channel

This commit is contained in:
Jozef Steinhübl 2023-12-30 17:15:04 +01:00
parent a787a65bd9
commit 30acd2cb62
No known key found for this signature in database
GPG key ID: E944BC293F5FF7E7
2 changed files with 11 additions and 2 deletions

View file

@ -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 { safeSlice } from "../util.ts";
import { isBunOnlyLikeMessage, safeSlice } from "../util.ts";
const GITHUB_LINE_URL_REGEX =
/(?:https?:\/\/)?(?:www\.)?(?:github)\.com\/(?<repo>[a-zA-Z0-9-_]+\/[A-Za-z0-9_.-]+)\/blob\/(?<path>.+?)#L(?<first_line_number>\d+)[-~]?L?(?<second_line_number>\d*)/i;
@ -23,7 +23,7 @@ function handleOthers(message: Message): void {
function handleBunOnlyChannel(message: Message): boolean {
if (message.channelId !== process.env.BUN_ONLY_CHANNEL_ID) return false;
if (message.content !== "bun") {
if (!isBunOnlyLikeMessage(message.content)) {
message.delete();
return true;
}

View file

@ -26,3 +26,12 @@ export async function moderateNick(member: GuildMember) {
})
);
}
const BUN_ONLY_LIKE_MESSAGE_REGEX =
/^<:(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)>$/i;
export function isBunOnlyLikeMessage(content?: string) {
if (!content) return false;
if (content === "bun") return true;
return BUN_ONLY_LIKE_MESSAGE_REGEX.test(content);
}