mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-24 01:55:03 +00:00
clean up
This commit is contained in:
parent
cf1ffbe71e
commit
90b9d31320
2 changed files with 40 additions and 9 deletions
|
@ -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(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue