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:
parent
6e3a6249c7
commit
92dfbca362
7 changed files with 177 additions and 5 deletions
|
@ -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);
|
||||
});
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue