mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 14:11:50 +00:00
Allow ban to be upgraded to forceban if the member is not on the server
This commit is contained in:
parent
bc5455bf9f
commit
5e636b485a
1 changed files with 25 additions and 8 deletions
|
@ -8,6 +8,7 @@ import { formatReasonWithAttachments } from "../functions/formatReasonWithAttach
|
||||||
import { banUserId } from "../functions/banUserId";
|
import { banUserId } from "../functions/banUserId";
|
||||||
import { ignoreEvent } from "../functions/ignoreEvent";
|
import { ignoreEvent } from "../functions/ignoreEvent";
|
||||||
import { LogType } from "../../../data/LogType";
|
import { LogType } from "../../../data/LogType";
|
||||||
|
import { waitForReaction } from "knub/dist/helpers";
|
||||||
|
|
||||||
const opts = {
|
const opts = {
|
||||||
mod: ct.member({ option: true }),
|
mod: ct.member({ option: true }),
|
||||||
|
@ -36,19 +37,30 @@ export const BanCmd = modActionsCmd({
|
||||||
|
|
||||||
const memberToBan = await resolveMember(pluginData.client, pluginData.guild, user.id);
|
const memberToBan = await resolveMember(pluginData.client, pluginData.guild, user.id);
|
||||||
|
|
||||||
|
let forceban = false;
|
||||||
if (!memberToBan) {
|
if (!memberToBan) {
|
||||||
const banned = await isBanned(pluginData, user.id);
|
const banned = await isBanned(pluginData, user.id);
|
||||||
|
|
||||||
if (banned) {
|
if (banned) {
|
||||||
sendErrorMessage(pluginData, msg.channel, `User is already banned`);
|
sendErrorMessage(pluginData, msg.channel, `User is already banned`);
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
sendErrorMessage(pluginData, msg.channel, `User not found on the server`);
|
// Ask the mod if we should upgrade to a forceban as the user is not on the server
|
||||||
}
|
const notOnServerMsg = await msg.channel.createMessage("User not found on the server, forceban instead?");
|
||||||
|
const reply = await waitForReaction(pluginData.client, notOnServerMsg, ["✅", "❌"], msg.author.id);
|
||||||
|
|
||||||
return;
|
notOnServerMsg.delete();
|
||||||
|
if (!reply || reply.name === "❌") {
|
||||||
|
sendErrorMessage(pluginData, msg.channel, "User not on server, ban cancelled by moderator");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
forceban = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we're allowed to ban this member
|
// Make sure we're allowed to ban this member if they are on the server
|
||||||
if (!canActOn(pluginData, msg.member, memberToBan)) {
|
if (!forceban && !canActOn(pluginData, msg.member, memberToBan!)) {
|
||||||
sendErrorMessage(pluginData, msg.channel, "Cannot ban: insufficient permissions");
|
sendErrorMessage(pluginData, msg.channel, "Cannot ban: insufficient permissions");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +86,7 @@ export const BanCmd = modActionsCmd({
|
||||||
|
|
||||||
const deleteMessageDays = args["delete-days"] ?? pluginData.config.getForMessage(msg).ban_delete_message_days;
|
const deleteMessageDays = args["delete-days"] ?? pluginData.config.getForMessage(msg).ban_delete_message_days;
|
||||||
const reason = formatReasonWithAttachments(args.reason, msg.attachments);
|
const reason = formatReasonWithAttachments(args.reason, msg.attachments);
|
||||||
const banResult = await banUserId(pluginData, memberToBan.id, reason, {
|
const banResult = await banUserId(pluginData, user.id, reason, {
|
||||||
contactMethods,
|
contactMethods,
|
||||||
caseArgs: {
|
caseArgs: {
|
||||||
modId: mod.id,
|
modId: mod.id,
|
||||||
|
@ -89,9 +101,14 @@ export const BanCmd = modActionsCmd({
|
||||||
}
|
}
|
||||||
|
|
||||||
// Confirm the action to the moderator
|
// Confirm the action to the moderator
|
||||||
let response = `Banned **${memberToBan.user.username}#${memberToBan.user.discriminator}** (Case #${banResult.case.case_number})`;
|
let response = "";
|
||||||
|
if (!forceban) {
|
||||||
|
response = `Banned **${user.username}#${user.discriminator}** (Case #${banResult.case.case_number})`;
|
||||||
|
if (banResult.notifyResult.text) response += ` (${banResult.notifyResult.text})`;
|
||||||
|
} else {
|
||||||
|
response = `Member forcebanned (Case #${banResult.case.case_number})`;
|
||||||
|
}
|
||||||
|
|
||||||
if (banResult.notifyResult.text) response += ` (${banResult.notifyResult.text})`;
|
|
||||||
sendSuccessMessage(pluginData, msg.channel, response);
|
sendSuccessMessage(pluginData, msg.channel, response);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue