3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

feat: add thread_create and thread_delete automod triggers (#272)

Co-authored-by: metal <admin@metalruller.com>
This commit is contained in:
Almeida 2021-10-31 15:21:53 +00:00 committed by GitHub
parent 6e3a6249c7
commit 92dfbca362
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 177 additions and 5 deletions

View file

@ -0,0 +1,47 @@
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(() => 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<AutomodPluginType>()({
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);
});
},
});