3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

Add command to clear dangling active mutes

This commit is contained in:
Dragory 2019-01-13 16:54:31 +02:00
parent dcb00d74f8
commit 10d757f588

View file

@ -4,7 +4,7 @@ import moment from "moment-timezone";
import { ZeppelinPlugin } from "./ZeppelinPlugin";
import { GuildActions } from "../data/GuildActions";
import { GuildMutes } from "../data/GuildMutes";
import { DBDateFormat, chunkMessageLines, stripObjectToScalars, successMessage } from "../utils";
import { DBDateFormat, chunkMessageLines, stripObjectToScalars, successMessage, errorMessage } from "../utils";
import humanizeDuration from "humanize-duration";
import { LogType } from "../data/LogType";
import { GuildLogs } from "../data/GuildLogs";
@ -235,6 +235,19 @@ export class MutesPlugin extends ZeppelinPlugin {
msg.channel.createMessage(successMessage(`Cleared ${cleared} mutes from members that don't have the mute role`));
}
@d.command("clear_mute", "<userId:string>")
@d.permission("cleanup")
async clearMuteCmd(msg: Message, args: { userId: string }) {
const mute = await this.mutes.findExistingMuteForUserId(args.userId);
if (!mute) {
msg.channel.createMessage(errorMessage("No active mutes found for that user id"));
return;
}
await this.mutes.clear(args.userId);
msg.channel.createMessage(successMessage(`Active mute cleared`));
}
protected async clearExpiredMutes() {
const expiredMutes = await this.mutes.getExpiredMutes();
for (const mute of expiredMutes) {