mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-14 22:05:01 +00:00
33 lines
988 B
TypeScript
33 lines
988 B
TypeScript
import { GuildPluginData } from "knub";
|
|
import { resolveMember, resolveUser, UnknownUser } from "../../../utils.js";
|
|
import { ModActionType } from "../../ModActions/types.js";
|
|
import { runAutomod } from "../functions/runAutomod.js";
|
|
import { AutomodContext, AutomodPluginType } from "../types.js";
|
|
|
|
export async function runAutomodOnModAction(
|
|
pluginData: GuildPluginData<AutomodPluginType>,
|
|
modAction: ModActionType,
|
|
userId: string,
|
|
reason?: string,
|
|
isAutomodAction = false,
|
|
) {
|
|
const [user, member] = await Promise.all([
|
|
resolveUser(pluginData.client, userId),
|
|
resolveMember(pluginData.client, pluginData.guild, userId),
|
|
]);
|
|
|
|
const context: AutomodContext = {
|
|
timestamp: Date.now(),
|
|
user: user instanceof UnknownUser ? undefined : user,
|
|
member: member ?? undefined,
|
|
modAction: {
|
|
type: modAction,
|
|
reason,
|
|
isAutomodAction,
|
|
},
|
|
};
|
|
|
|
pluginData.state.queue.add(async () => {
|
|
await runAutomod(pluginData, context);
|
|
});
|
|
}
|