mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-07 19:17:19 +00:00
Made mass action reason part of the slash command options
This commit is contained in:
parent
4d8b6b5cd7
commit
91025d8569
19 changed files with 213 additions and 88 deletions
|
@ -1,10 +1,9 @@
|
|||
import { ChatInputCommandInteraction, GuildMember, Message, Snowflake } from "discord.js";
|
||||
import { Attachment, ChatInputCommandInteraction, GuildMember, Message, Snowflake } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { waitForReply } from "knub/helpers";
|
||||
import { CaseTypes } from "../../../../data/CaseTypes";
|
||||
import { LogType } from "../../../../data/LogType";
|
||||
import { getContextChannel, sendContextResponse } from "../../../../pluginUtils";
|
||||
import { MINUTES } from "../../../../utils";
|
||||
import { isContextInteraction, sendContextResponse } from "../../../../pluginUtils";
|
||||
import { MINUTES, noop } from "../../../../utils";
|
||||
import { CasesPlugin } from "../../../Cases/CasesPlugin";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin";
|
||||
|
@ -19,6 +18,8 @@ export async function actualMassUnbanCmd(
|
|||
context: Message | ChatInputCommandInteraction,
|
||||
userIds: string[],
|
||||
author: GuildMember,
|
||||
reason: string,
|
||||
attachments: Attachment[],
|
||||
) {
|
||||
// Limit to 100 users at once (arbitrary?)
|
||||
if (userIds.length > 100) {
|
||||
|
@ -26,21 +27,11 @@ export async function actualMassUnbanCmd(
|
|||
return;
|
||||
}
|
||||
|
||||
// Ask for unban reason (cleaner this way instead of trying to cram it into the args)
|
||||
sendContextResponse(context, "Unban reason? `cancel` to cancel");
|
||||
const unbanReasonReply = await waitForReply(pluginData.client, await getContextChannel(context), author.id);
|
||||
if (!unbanReasonReply || !unbanReasonReply.content || unbanReasonReply.content.toLowerCase().trim() === "cancel") {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, "Cancelled");
|
||||
if (await handleAttachmentLinkDetectionAndGetRestriction(pluginData, context, reason)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await handleAttachmentLinkDetectionAndGetRestriction(pluginData, context, unbanReasonReply.content)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const unbanReason = await formatReasonWithMessageLinkForAttachments(pluginData, unbanReasonReply.content, context, [
|
||||
...unbanReasonReply.attachments.values(),
|
||||
]);
|
||||
const unbanReason = await formatReasonWithMessageLinkForAttachments(pluginData, reason, context, attachments);
|
||||
|
||||
// Ignore automatic unban cases and logs for these users
|
||||
// We'll create our own cases below and post a single "mass unbanned" log instead
|
||||
|
@ -51,7 +42,7 @@ export async function actualMassUnbanCmd(
|
|||
});
|
||||
|
||||
// Show a loading indicator since this can take a while
|
||||
const loadingMsg = await sendContextResponse(context, "Unbanning...");
|
||||
const loadingMsg = await sendContextResponse(context, { content: "Unbanning...", ephemeral: true });
|
||||
|
||||
// Unban each user and count failed unbans (if any)
|
||||
const failedUnbans: Array<{ userId: string; reason: UnbanFailReasons }> = [];
|
||||
|
@ -77,8 +68,10 @@ export async function actualMassUnbanCmd(
|
|||
}
|
||||
}
|
||||
|
||||
// Clear loading indicator
|
||||
loadingMsg.delete();
|
||||
if (!isContextInteraction(context)) {
|
||||
// Clear loading indicator
|
||||
loadingMsg.delete().catch(noop);
|
||||
}
|
||||
|
||||
const successfulUnbanCount = userIds.length - failedUnbans.length;
|
||||
if (successfulUnbanCount === 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue