From ae158d6b48fcde6ad5307f45645a11836a43784f Mon Sep 17 00:00:00 2001 From: Dragory Date: Thu, 3 Jan 2019 04:15:18 +0200 Subject: [PATCH] slowmode: add !slowmode clear to clear slowmode from specific users --- src/plugins/Slowmode.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/plugins/Slowmode.ts b/src/plugins/Slowmode.ts index 996731e4..f8225db6 100644 --- a/src/plugins/Slowmode.ts +++ b/src/plugins/Slowmode.ts @@ -1,5 +1,5 @@ import { Plugin, decorators as d } from "knub"; -import { GuildChannel, Message, TextChannel, Constants as ErisConstants } from "eris"; +import { GuildChannel, Message, TextChannel, Constants as ErisConstants, User } from "eris"; import { convertDelayStringToMS, errorMessage, noop, successMessage } from "../utils"; import { GuildSlowmodes } from "../data/GuildSlowmodes"; import humanizeDuration from "humanize-duration"; @@ -116,6 +116,26 @@ export class SlowmodePlugin extends Plugin { } } + /** + * COMMAND: Clear slowmode from a specific user on a specific channel + */ + @d.command("slowmode clear", " ") + @d.permission("manage") + async clearSlowmodeCmd(msg: Message, args: { channel: GuildChannel & TextChannel; user: User }) { + const channelSlowmode = await this.slowmodes.getChannelSlowmode(args.channel.id); + if (!channelSlowmode) { + msg.channel.createMessage(errorMessage("Channel doesn't have slowmode!")); + return; + } + + await this.removeSlowmodeFromUserId(args.channel, args.user.id); + msg.channel.createMessage( + successMessage( + `Slowmode cleared from **${args.user.username}#${args.user.discriminator}** in <#${args.channel.id}>` + ) + ); + } + /** * COMMAND: Enable slowmode on the specified channel */