3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-11 13:07:20 +00:00
This commit is contained in:
almeidx 2021-09-01 17:04:56 +01:00
parent 0b4369f0c8
commit 0d69402602
No known key found for this signature in database
GPG key ID: 01C5E03866747F46
2 changed files with 38 additions and 10 deletions

View file

@ -1,4 +1,5 @@
import { typedGuildEventListener } from "knub";
import { GuildSavedMessages } from "../../../data/GuildSavedMessages";
import { runAutomod } from "../functions/runAutomod";
import { AutomodContext, AutomodPluginType } from "../types";
@ -13,18 +14,18 @@ export const RunAutomodOnThreadCreate = typedGuildEventListener<AutomodPluginTyp
},
user,
};
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,
(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 = pluginData.state.savedMessages.msgToSavedMessage(sourceMessage);
savedMessage.channel_id = thread.id;
context.message = savedMessage;
}
pluginData.state.queue.add(() => {