3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-23 17:45:03 +00:00

Thread events - attempt to pass message object in context (#3)

* initial

* rmv console log

* Update backend/src/plugins/Automod/events/runAutomodOnThreadEvents.ts

Co-authored-by: Almeida <almeidx@pm.me>
This commit is contained in:
metal 2021-09-01 13:35:27 +01:00 committed by almeidx
parent 8052a6f2d8
commit cf1ffbe71e
No known key found for this signature in database
GPG key ID: F403F80B79353CB4

View file

@ -19,6 +19,20 @@ export const RunAutomodOnThreadCreate = typedGuildEventListener<AutomodPluginTyp
channel: thread,
};
const sourceChannel = pluginData.client.channels.cache.find((c) => c.id === thread.parentId);
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;
}
}
}
pluginData.state.queue.add(() => {
pluginData.state.recentActions.push({
type: RecentActionType.ThreadCreate,