mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-11 04:57:19 +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
723995f30c
commit
0b4369f0c8
1 changed files with 13 additions and 1 deletions
|
@ -6,7 +6,6 @@ export const RunAutomodOnThreadCreate = typedGuildEventListener<AutomodPluginTyp
|
||||||
event: "threadCreate",
|
event: "threadCreate",
|
||||||
async listener({ pluginData, args: { thread } }) {
|
async listener({ pluginData, args: { thread } }) {
|
||||||
const user = thread.ownerId ? await pluginData.client.users.fetch(thread.ownerId).catch(() => void 0) : void 0;
|
const user = thread.ownerId ? await pluginData.client.users.fetch(thread.ownerId).catch(() => void 0) : void 0;
|
||||||
|
|
||||||
const context: AutomodContext = {
|
const context: AutomodContext = {
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
threadChange: {
|
threadChange: {
|
||||||
|
@ -14,6 +13,19 @@ export const RunAutomodOnThreadCreate = typedGuildEventListener<AutomodPluginTyp
|
||||||
},
|
},
|
||||||
user,
|
user,
|
||||||
};
|
};
|
||||||
|
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