mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 04:25:01 +00:00
30 lines
856 B
TypeScript
30 lines
856 B
TypeScript
import { User } from "discord.js";
|
|
import { GuildPluginData } from "knub";
|
|
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
|
import { runAutomodOnAntiraidLevel } from "../events/runAutomodOnAntiraidLevel";
|
|
import { AutomodPluginType } from "../types";
|
|
|
|
export async function setAntiraidLevel(
|
|
pluginData: GuildPluginData<AutomodPluginType>,
|
|
newLevel: string | null,
|
|
user?: User,
|
|
) {
|
|
const oldLevel = pluginData.state.cachedAntiraidLevel;
|
|
pluginData.state.cachedAntiraidLevel = newLevel;
|
|
await pluginData.state.antiraidLevels.set(newLevel);
|
|
|
|
runAutomodOnAntiraidLevel(pluginData, newLevel, oldLevel, user);
|
|
|
|
const logs = pluginData.getPlugin(LogsPlugin);
|
|
|
|
if (user) {
|
|
logs.logSetAntiraidUser({
|
|
level: newLevel ?? "off",
|
|
user,
|
|
});
|
|
} else {
|
|
logs.logSetAntiraidAuto({
|
|
level: newLevel ?? "off",
|
|
});
|
|
}
|
|
}
|