mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-11-21 22:21:05 +01:00
perf: use array instead regex
This commit is contained in:
parent
2babbc9861
commit
1568580431
2 changed files with 23 additions and 3 deletions
|
@ -11,3 +11,24 @@ export const LILYBIRD_HANDLERS_VERSION =
|
|||
dependencies["@lilybird/handlers"].slice(1);
|
||||
|
||||
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",
|
||||
];
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { GuildMember } from "lilybird";
|
||||
import { BUN_EMOJIS } from "./constants.ts";
|
||||
|
||||
export function safeSlice<T extends string | Array<any>>(
|
||||
input: T,
|
||||
|
@ -27,11 +28,9 @@ 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|bupple:1190690285852839976)>$/i;
|
||||
export function isBunOnlyLikeMessage(content?: string) {
|
||||
if (!content) return false;
|
||||
if (content === "bun") return true;
|
||||
|
||||
return BUN_ONLY_LIKE_MESSAGE_REGEX.test(content);
|
||||
return BUN_EMOJIS.some((emoji) => content.replace(/[<>]/g, "") == emoji);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue