3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-11 13:07:20 +00:00

added thread_create and thread_delete automod triggers

This commit is contained in:
almeidx 2021-08-29 15:05:02 +01:00
parent 831ff1893a
commit fcfc96c30d
No known key found for this signature in database
GPG key ID: 01C5E03866747F46
7 changed files with 170 additions and 2 deletions

View file

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