mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-11-10 01:08:07 +01:00
fix: handle message update
This commit is contained in:
parent
aef0561266
commit
8ff1bdaee3
4 changed files with 25 additions and 3 deletions
|
@ -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"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import "./ready.ts";
|
||||
import "./interaction_create.ts";
|
||||
import "./message_create.ts";
|
||||
import "./message_update.ts";
|
||||
import "./nickname_moderation.ts";
|
||||
|
|
|
@ -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,
|
||||
|
|
22
src/listeners/message_update.ts
Normal file
22
src/listeners/message_update.ts
Normal 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;
|
||||
}
|
Loading…
Reference in a new issue