mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-11-22 14:41:05 +01:00
feat: bun only channel
This commit is contained in:
parent
9af4671f43
commit
7311bc7f61
1 changed files with 15 additions and 0 deletions
|
@ -7,6 +7,7 @@ import { extname } from "node:path";
|
||||||
import { safeSlice } from "../util.ts";
|
import { 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;
|
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;
|
||||||
|
const BUN_ONLY_CHANNEL_ID = "1161157663867027476";
|
||||||
|
|
||||||
defineListener({
|
defineListener({
|
||||||
event: Events.MessageCreate,
|
event: Events.MessageCreate,
|
||||||
|
@ -37,9 +38,23 @@ defineListener({
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleOthers(message: Message) {
|
function handleOthers(message: Message) {
|
||||||
|
if (handleBunOnlyChannel(message)) return;
|
||||||
|
|
||||||
handleGithubLink(message);
|
handleGithubLink(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleBunOnlyChannel(message: Message) {
|
||||||
|
if (message.channel.id !== BUN_ONLY_CHANNEL_ID) return false;
|
||||||
|
|
||||||
|
if (message.content !== "bun") {
|
||||||
|
message.delete();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
message.react("🐰");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
async function handleGithubLink(message: Message) {
|
async function handleGithubLink(message: Message) {
|
||||||
const match = GITHUB_LINE_URL_REGEX.exec(message.content);
|
const match = GITHUB_LINE_URL_REGEX.exec(message.content);
|
||||||
const groups = match?.groups;
|
const groups = match?.groups;
|
||||||
|
|
Loading…
Reference in a new issue