3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-13 21:35:02 +00:00
zeppelin/backend/src/plugins/ModActions/commands/massmute/MassMuteMsgCmd.ts
2024-04-15 15:51:45 +02:00

35 lines
1.2 KiB
TypeScript

import { waitForReply } from "knub/helpers";
import { commandTypeHelpers as ct } from "../../../../commandTypes";
import { getContextChannel, sendContextResponse } from "../../../../pluginUtils";
import { actualMassMuteCmd } from "./actualMassMuteCmd";
import { modActionsMsgCmd } from "../../types";
export const MassMuteMsgCmd = modActionsMsgCmd({
trigger: "massmute",
permission: "can_massmute",
description: "Mass-mute a list of user IDs",
signature: [
{
userIds: ct.string({ rest: true }),
},
],
async run({ pluginData, message: msg, args }) {
// Ask for mute reason
sendContextResponse(msg, "Mute reason? `cancel` to cancel");
const muteReasonReceived = await waitForReply(pluginData.client, await getContextChannel(msg), msg.author.id);
if (
!muteReasonReceived ||
!muteReasonReceived.content ||
muteReasonReceived.content.toLowerCase().trim() === "cancel"
) {
pluginData.state.common.sendErrorMessage(msg, "Cancelled");
return;
}
actualMassMuteCmd(pluginData, msg, args.userIds, msg.member, muteReasonReceived.content, [
...muteReasonReceived.attachments.values(),
]);
},
});