mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-15 14:15:03 +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,9 +1,8 @@
|
|||
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 { LogType } from "../../../../data/LogType";
|
||||
import { logger } from "../../../../logger";
|
||||
import { canActOn, getContextChannel, sendContextResponse } from "../../../../pluginUtils";
|
||||
import { canActOn, isContextInteraction, sendContextResponse } from "../../../../pluginUtils";
|
||||
import { CommonPlugin } from "../../../Common/CommonPlugin";
|
||||
import { LogsPlugin } from "../../../Logs/LogsPlugin";
|
||||
import { MutesPlugin } from "../../../Mutes/MutesPlugin";
|
||||
|
@ -16,6 +15,8 @@ export async function actualMassMuteCmd(
|
|||
context: Message | ChatInputCommandInteraction,
|
||||
userIds: string[],
|
||||
author: GuildMember,
|
||||
reason: string,
|
||||
attachments: Attachment[],
|
||||
) {
|
||||
// Limit to 100 users at once (arbitrary?)
|
||||
if (userIds.length > 100) {
|
||||
|
@ -23,28 +24,12 @@ export async function actualMassMuteCmd(
|
|||
return;
|
||||
}
|
||||
|
||||
// Ask for mute reason
|
||||
sendContextResponse(context, "Mute reason? `cancel` to cancel");
|
||||
const muteReasonReceived = await waitForReply(pluginData.client, await getContextChannel(context), author.id);
|
||||
if (
|
||||
!muteReasonReceived ||
|
||||
!muteReasonReceived.content ||
|
||||
muteReasonReceived.content.toLowerCase().trim() === "cancel"
|
||||
) {
|
||||
pluginData.getPlugin(CommonPlugin).sendErrorMessage(context, "Cancelled");
|
||||
if (await handleAttachmentLinkDetectionAndGetRestriction(pluginData, context, reason)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (await handleAttachmentLinkDetectionAndGetRestriction(pluginData, context, muteReasonReceived.content)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const muteReason = await formatReasonWithMessageLinkForAttachments(pluginData, muteReasonReceived.content, context, [
|
||||
...muteReasonReceived.attachments.values(),
|
||||
]);
|
||||
const muteReasonWithAttachments = formatReasonWithAttachments(muteReasonReceived.content, [
|
||||
...muteReasonReceived.attachments.values(),
|
||||
]);
|
||||
const muteReason = await formatReasonWithMessageLinkForAttachments(pluginData, reason, context, attachments);
|
||||
const muteReasonWithAttachments = formatReasonWithAttachments(reason, attachments);
|
||||
|
||||
// Verify we can act upon all users
|
||||
for (const userId of userIds) {
|
||||
|
@ -65,7 +50,7 @@ export async function actualMassMuteCmd(
|
|||
});
|
||||
|
||||
// Show loading indicator
|
||||
const loadingMsg = await sendContextResponse(context, "Muting...");
|
||||
const loadingMsg = await sendContextResponse(context, { content: "Muting...", ephemeral: true });
|
||||
|
||||
// Mute everyone and count fails
|
||||
const modId = author.id;
|
||||
|
@ -84,8 +69,10 @@ export async function actualMassMuteCmd(
|
|||
}
|
||||
}
|
||||
|
||||
// Clear loading indicator
|
||||
loadingMsg.delete();
|
||||
if (!isContextInteraction(context)) {
|
||||
// Clear loading indicator
|
||||
loadingMsg.delete();
|
||||
}
|
||||
|
||||
const successfulMuteCount = userIds.length - failedMutes.length;
|
||||
if (successfulMuteCount === 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue