3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-24 01:55:03 +00:00
This commit is contained in:
almeidx 2021-09-01 17:04:56 +01:00
parent cf1ffbe71e
commit 90b9d31320
No known key found for this signature in database
GPG key ID: F403F80B79353CB4
2 changed files with 40 additions and 9 deletions

View file

@ -1,5 +1,6 @@
import { typedGuildEventListener } from "knub";
import { RecentActionType } from "../constants";
import { GuildSavedMessages } from "../../../data/GuildSavedMessages";
import { runAutomod } from "../functions/runAutomod";
import { AutomodContext, AutomodPluginType } from "../types";
@ -19,18 +20,17 @@ export const RunAutomodOnThreadCreate = typedGuildEventListener<AutomodPluginTyp
channel: thread,
};
const sourceChannel = pluginData.client.channels.cache.find((c) => c.id === thread.parentId);
if (sourceChannel?.isText()) {
// This is a hack to make this trigger compatible with the reply action
const sourceChannel = thread.parent ?? pluginData.client.channels.cache.find((c) => c.id === thread.parentId);
messageBlock: if (sourceChannel?.isText()) {
const sourceMessage = sourceChannel.messages.cache.find(
(m) => m.thread?.id === thread.id || m.reference?.channelId === thread.id,
);
if (sourceMessage) {
const message = await pluginData.state.savedMessages.find(sourceMessage.id);
if (message) {
message.channel_id = thread.id;
context.message = message;
}
}
if (!sourceMessage) break messageBlock;
const savedMessage = GuildSavedMessages.msgToSavedMessage(sourceMessage);
savedMessage.channel_id = thread.id;
context.message = savedMessage;
}
pluginData.state.queue.add(() => {