fix: handle message update

This commit is contained in:
Jozef Steinhübl 2023-10-12 21:24:21 +02:00
parent aef0561266
commit 8ff1bdaee3
No known key found for this signature in database
GPG key ID: E944BC293F5FF7E7
4 changed files with 25 additions and 3 deletions

View file

@ -8,4 +8,4 @@ export const PRODUCTION = process.env.NODE_ENV === "production";
export const MESSAGE_PREFIX = PRODUCTION ? "b" : "<>";
export const BUN_ONLY_CHANNEL_ID = "1161157663867027476"

View file

@ -1,4 +1,5 @@
import "./ready.ts";
import "./interaction_create.ts";
import "./message_create.ts";
import "./message_update.ts";
import "./nickname_moderation.ts";

View file

@ -1,13 +1,12 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, Events, Message } from "discord.js";
import { defineListener } from "../loaders/listeners.ts";
import { MESSAGE_PREFIX } from "../constants.ts";
import { MESSAGE_PREFIX, BUN_ONLY_CHANNEL_ID } from "../constants.ts";
import { COMMANDS } from "../loaders/commands.ts";
import { MessageCommandContext } from "../structs/context/CommandContext.ts";
import { extname } from "node:path";
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 BUN_ONLY_CHANNEL_ID = "1161157663867027476";
defineListener({
event: Events.MessageCreate,

View file

@ -0,0 +1,22 @@
import { Events, Message } from "discord.js";
import { defineListener } from "../loaders/listeners.ts";
import { BUN_ONLY_CHANNEL_ID } from "../constants.ts";
defineListener({
event: Events.MessageUpdate,
run: async(_: Message, message: Message) => {
if (handleBunOnlyChannel(message)) return;
}
});
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;
}