dm forwarding fluxer

This commit is contained in:
mo
2026-03-09 21:59:52 +01:00
parent dfb8b2781d
commit 330aabd928

View File

@@ -1,7 +1,13 @@
import { CommandKeys } from "@avocadi/bot-core/entities/commands/commands.schema";
import { Events, type Message } from "@fluxerjs/core";
import {
ChannelManager,
type DMChannel,
Events,
type Message,
} from "@fluxerjs/core";
import { config } from "config";
import { messagesService } from "entities/messages/messages.service";
import { logChannelService } from "features/log-channel/log-channel.service";
import client from "lib/client";
import { logger } from "lib/common-logger";
import { handleCommand } from "./handle-command";
@@ -9,10 +15,17 @@ import { handleCommand } from "./handle-command";
// https://fluxerjs.blstmo.com/v/latest/docs/classes/DMChannel
client.on(Events.MessageCreate, async (message: Message) => {
const channel =
client.channels.get(message.channelId) ??
(await client.channels.fetch(message.channelId));
const messageAuthor = message.author;
const messageReceiver = message.type;
logger.info("got msg");
if (message.content?.startsWith(config.commandPrefix) && message.channel) {
if (channel?.isDM()) {
await logChannelService.sendLogMessage(
`<@${messageAuthor?.id}> wrote to <@${client.user?.id}>\n"${message.content}"`,
);
return;
}
if (message.content?.startsWith(config.commandPrefix) && channel) {
await messagesService.logMessage(message);
logger.info(
`Command received: ${message.content} from user ${message.author.id}`,