Merge branch 'DarkView-allowMultipleIDsOnClearmute'

This commit is contained in:
Dragory 2020-05-22 21:19:29 +03:00
commit f9d261e25a
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -617,17 +617,29 @@ export class MutesPlugin extends ZeppelinPlugin<TConfigSchema> {
this.sendSuccessMessage(msg.channel, `Cleared ${cleared} mutes from members that don't have the mute role`); this.sendSuccessMessage(msg.channel, `Cleared ${cleared} mutes from members that don't have the mute role`);
} }
@d.command("clear_mute", "<userId:string>") @d.command("clear_mute", "<userIds:string...>")
@d.permission("can_cleanup") @d.permission("can_cleanup")
protected async clearMuteCmd(msg: Message, args: { userId: string }) { protected async clearMuteCmd(msg: Message, args: { userIds: string[] }) {
const mute = await this.mutes.findExistingMuteForUserId(args.userId); const failed = [];
if (!mute) { for (const id of args.userIds) {
msg.channel.createMessage(errorMessage("No active mutes found for that user id")); const mute = await this.mutes.findExistingMuteForUserId(id);
return; if (!mute) {
failed.push(id);
continue;
}
await this.mutes.clear(id);
} }
await this.mutes.clear(args.userId); if (failed.length !== args.userIds.length) {
this.sendSuccessMessage(msg.channel, `Active mute cleared`); this.sendSuccessMessage(msg.channel, `**${args.userIds.length - failed.length} active mute(s) cleared**`);
}
if (failed.length) {
this.sendErrorMessage(
msg.channel,
`**${failed.length}/${args.userIds.length} IDs failed**, they are not muted: ${failed.join(" ")}`,
);
}
} }
protected async clearExpiredMutes() { protected async clearExpiredMutes() {