mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-11-24 23:31:05 +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 { ActionRow, Button } from "@lilybird/jsx";
|
||||||
import { extname, basename } from "node:path";
|
import { extname, basename } from "node:path";
|
||||||
import { Event } from "@lilybird/handlers";
|
import { Event } from "@lilybird/handlers";
|
||||||
import { isBunOnlyLikeMessage, safeSlice } from "../util.ts";
|
import { getRandomBunEmoji, isBunOnlyLikeMessage, safeSlice } from "../util.ts";
|
||||||
|
|
||||||
const GITHUB_LINE_URL_REGEX =
|
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;
|
/(?: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;
|
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("🐰");
|
message.react("🐰");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Event } from "@lilybird/handlers";
|
import { Event } from "@lilybird/handlers";
|
||||||
import { PartialMessage } from "lilybird";
|
import { PartialMessage } from "lilybird";
|
||||||
import { getRandomBunEmoji } from "src/util.ts";
|
import { getRandomBunEmoji, isBunOnlyLikeMessage } from "src/util.ts";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
event: "messageUpdate",
|
event: "messageUpdate",
|
||||||
|
@ -12,11 +12,14 @@ export default {
|
||||||
function handleBunOnlyChannel(message: PartialMessage): boolean {
|
function handleBunOnlyChannel(message: PartialMessage): boolean {
|
||||||
if (message.channelId !== process.env.BUN_ONLY_CHANNEL_ID) return false;
|
if (message.channelId !== process.env.BUN_ONLY_CHANNEL_ID) return false;
|
||||||
|
|
||||||
if (message.content !== "bun") {
|
if (!isBunOnlyLikeMessage(message.content)) {
|
||||||
message.delete();
|
message.delete();
|
||||||
return true;
|
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
|
// 1% chance to react with a random bun emoji
|
||||||
if (Math.floor(Math.random() * 100) === 0) {
|
if (Math.floor(Math.random() * 100) === 0) {
|
||||||
message.react(getRandomBunEmoji().id, true);
|
message.react(getRandomBunEmoji().id, true);
|
||||||
|
|
Loading…
Reference in a new issue