import { typedGuildEventListener } from "knub"; import { runAutomod } from "../functions/runAutomod"; import { AutomodContext, AutomodPluginType } from "../types"; export const RunAutomodOnThreadCreate = typedGuildEventListener()({ event: "threadCreate", async listener({ pluginData, args: { thread } }) { const user = thread.ownerId ? await pluginData.client.users.fetch(thread.ownerId).catch(() => undefined) : undefined; const context: AutomodContext = { timestamp: Date.now(), threadChange: { created: thread, }, user, channel: thread, }; pluginData.state.queue.add(() => { runAutomod(pluginData, context); }); }, }); export const RunAutomodOnThreadDelete = typedGuildEventListener()({ event: "threadDelete", async listener({ pluginData, args: { thread } }) { const user = thread.ownerId ? await pluginData.client.users.fetch(thread.ownerId).catch(() => undefined) : undefined; const context: AutomodContext = { timestamp: Date.now(), threadChange: { deleted: thread, }, user, channel: thread, }; pluginData.state.queue.add(() => { runAutomod(pluginData, context); }); }, });