From 0b4369f0c895d3e377a901d9fd9038ca7995bf10 Mon Sep 17 00:00:00 2001 From: metal Date: Wed, 1 Sep 2021 13:35:27 +0100 Subject: [PATCH] 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 --- .../Automod/events/runAutomodOnThreadEvents.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/src/plugins/Automod/events/runAutomodOnThreadEvents.ts b/backend/src/plugins/Automod/events/runAutomodOnThreadEvents.ts index 71b9fbd7..966f8255 100644 --- a/backend/src/plugins/Automod/events/runAutomodOnThreadEvents.ts +++ b/backend/src/plugins/Automod/events/runAutomodOnThreadEvents.ts @@ -6,7 +6,6 @@ export const RunAutomodOnThreadCreate = typedGuildEventListener void 0) : void 0; - const context: AutomodContext = { timestamp: Date.now(), threadChange: { @@ -14,6 +13,19 @@ export const RunAutomodOnThreadCreate = typedGuildEventListener 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(() => { runAutomod(pluginData, context);