mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-24 18:15:02 +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:
parent
f9c0e661af
commit
2d3bd38e5b
1 changed files with 13 additions and 0 deletions
|
@ -17,6 +17,19 @@ export const RunAutomodOnThreadCreate = typedGuildEventListener<AutomodPluginTyp
|
||||||
user,
|
user,
|
||||||
channel: thread,
|
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.queue.add(() => {
|
||||||
runAutomod(pluginData, context);
|
runAutomod(pluginData, context);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue