mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-12-22 04:01:07 +01:00
fix: allow bun emojis in update
This commit is contained in:
parent
90ce3fd156
commit
0549763a3e
2 changed files with 12 additions and 3 deletions
|
@ -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\/(?<repo>[a-zA-Z0-9-_]+\/[A-Za-z0-9_.-]+)\/blob\/(?<path>.+?)#L(?<first_line_number>\d+)[-~]?L?(?<second_line_number>\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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue