mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-23 09:35:02 +00:00
Move forceban over to banUserId
This commit is contained in:
parent
a5cdf250b8
commit
6e475324ce
1 changed files with 21 additions and 4 deletions
|
@ -11,6 +11,10 @@ import { ignoreEvent } from "../functions/ignoreEvent";
|
||||||
import { isBanned } from "../functions/isBanned";
|
import { isBanned } from "../functions/isBanned";
|
||||||
import { IgnoredEventType, modActionsCmd } from "../types";
|
import { IgnoredEventType, modActionsCmd } from "../types";
|
||||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||||
|
import { LogType } from "../../../data/LogType";
|
||||||
|
import { CaseTypes } from "../../../data/CaseTypes";
|
||||||
|
import { CasesPlugin } from "../../../plugins/Cases/CasesPlugin";
|
||||||
|
import { banLock } from "../../../utils/lockNameHelpers";
|
||||||
|
|
||||||
const opts = {
|
const opts = {
|
||||||
mod: ct.member({ option: true }),
|
mod: ct.member({ option: true }),
|
||||||
|
@ -63,18 +67,30 @@ export const ForcebanCmd = modActionsCmd({
|
||||||
}
|
}
|
||||||
|
|
||||||
const reason = formatReasonWithAttachments(args.reason, [...msg.attachments.values()]);
|
const reason = formatReasonWithAttachments(args.reason, [...msg.attachments.values()]);
|
||||||
|
const lock = await pluginData.locks.acquire(banLock(user));
|
||||||
|
|
||||||
ignoreEvent(pluginData, IgnoredEventType.Ban, user.id);
|
ignoreEvent(pluginData, IgnoredEventType.Ban, user.id);
|
||||||
pluginData.state.serverLogs.ignoreLog(LogType.MEMBER_BAN, user.id);
|
pluginData.state.serverLogs.ignoreLog(LogType.MEMBER_BAN, user.id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// FIXME: Use banUserId()?
|
const deleteMessageDays = args["delete-days"] ?? pluginData.config.getForMessage(msg).ban_delete_message_days;
|
||||||
await pluginData.guild.bans.create(user.id as Snowflake, {
|
const banResult = await banUserId(pluginData, user.id, reason, {
|
||||||
days: 1,
|
contactMethods: [],
|
||||||
reason: reason ?? undefined,
|
caseArgs: {
|
||||||
|
modId: mod.id,
|
||||||
|
ppId: mod.id !== msg.author.id ? msg.author.id : undefined,
|
||||||
|
},
|
||||||
|
deleteMessageDays,
|
||||||
|
modId: mod.id,
|
||||||
});
|
});
|
||||||
|
if (banResult.status === "failed") {
|
||||||
|
sendErrorMessage(pluginData, msg.channel, `Failed to ban member: ${banResult.error}`);
|
||||||
|
lock.unlock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
sendErrorMessage(pluginData, msg.channel, "Failed to forceban member");
|
sendErrorMessage(pluginData, msg.channel, "Failed to forceban member");
|
||||||
|
lock.unlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +106,7 @@ export const ForcebanCmd = modActionsCmd({
|
||||||
|
|
||||||
// Confirm the action
|
// Confirm the action
|
||||||
sendSuccessMessage(pluginData, msg.channel, `Member forcebanned (Case #${createdCase.case_number})`);
|
sendSuccessMessage(pluginData, msg.channel, `Member forcebanned (Case #${createdCase.case_number})`);
|
||||||
|
lock.unlock();
|
||||||
|
|
||||||
// Log the action
|
// Log the action
|
||||||
pluginData.getPlugin(LogsPlugin).logMemberForceban({
|
pluginData.getPlugin(LogsPlugin).logMemberForceban({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue