mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-13 13:25:03 +00:00
Port Mutes plugin
This commit is contained in:
parent
479cb56928
commit
ccff7384ba
11 changed files with 797 additions and 0 deletions
39
backend/src/plugins/Mutes/commands/ClearMutesCmd.ts
Normal file
39
backend/src/plugins/Mutes/commands/ClearMutesCmd.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
import { command } from "knub";
|
||||
import { MutesPluginType } from "../types";
|
||||
import { User } from "eris";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
|
||||
export const ClearMutesCmd = command<MutesPluginType>()({
|
||||
trigger: "clear_mutes",
|
||||
permission: "can_cleanup",
|
||||
description: "Clear dangling mute records from the bot. Be careful not to clear valid mutes.",
|
||||
|
||||
signature: {
|
||||
userIds: ct.string({ rest: true }),
|
||||
},
|
||||
|
||||
async run({ pluginData, message: msg, args }) {
|
||||
const failed = [];
|
||||
for (const id of args.userIds) {
|
||||
const mute = await pluginData.state.mutes.findExistingMuteForUserId(id);
|
||||
if (!mute) {
|
||||
failed.push(id);
|
||||
continue;
|
||||
}
|
||||
await pluginData.state.mutes.clear(id);
|
||||
}
|
||||
|
||||
if (failed.length !== args.userIds.length) {
|
||||
sendSuccessMessage(pluginData, msg.channel, `**${args.userIds.length - failed.length} active mute(s) cleared**`);
|
||||
}
|
||||
|
||||
if (failed.length) {
|
||||
sendErrorMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
`**${failed.length}/${args.userIds.length} IDs failed**, they are not muted: ${failed.join(" ")}`,
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue