diff --git a/src/NadekoBot/Modules/Administration/Commands/RatelimitCommand.cs b/src/NadekoBot/Modules/Administration/Commands/RatelimitCommand.cs index 1ca14edf..08e75743 100644 --- a/src/NadekoBot/Modules/Administration/Commands/RatelimitCommand.cs +++ b/src/NadekoBot/Modules/Administration/Commands/RatelimitCommand.cs @@ -90,7 +90,7 @@ namespace NadekoBot.Modules.Administration [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] [RequirePermission(GuildPermission.ManageMessages)] - public async Task Slowmode(IUserMessage umsg, int msg = 1, int perSec = 5) + public async Task Slowmode(IUserMessage umsg) { var channel = (ITextChannel)umsg.Channel; @@ -101,21 +101,31 @@ namespace NadekoBot.Modules.Administration await channel.SendMessageAsync("`Slow mode disabled.`").ConfigureAwait(false); return; } + } - if (msg < 1 || perSec < 1) + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + [RequirePermission(GuildPermission.ManageMessages)] + public async Task Slowmode(IUserMessage umsg, int msg, int perSec) + { + await Slowmode(umsg).ConfigureAwait(false); // disable if exists + var channel = (ITextChannel)umsg.Channel; + + if (msg < 1 || perSec < 1 || msg > 100 || perSec > 3600) { await channel.SendMessageAsync("`Invalid parameters.`"); return; } - - if (RatelimitingChannels.TryAdd(channel.Id,throwaway = new Ratelimiter() { + var toAdd = new Ratelimiter() + { ChannelId = channel.Id, MaxMessages = msg, PerSeconds = perSec, - })) + }; + if(RatelimitingChannels.TryAdd(channel.Id, toAdd)) { await channel.SendMessageAsync("`Slow mode initiated.` " + - $"Users can't send more than {throwaway.MaxMessages} message(s) every {throwaway.PerSeconds} second(s).") + $"Users can't send more than {toAdd.MaxMessages} message(s) every {toAdd.PerSeconds} second(s).") .ConfigureAwait(false); } } diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index 811dc7b1..72373999 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -6414,7 +6414,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Toggles slow mode. When ON, users will be able to send only 1 message every 5 seconds. . + /// Looks up a localized string similar to Toggles slowmode. Disable by specifying no parameters. To enable, specify a number of messages each user can send, and an interval in seconds. For example 1 message every 5 seconds.. /// public static string slowmode_desc { get { @@ -6423,7 +6423,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `.slowmode`. + /// Looks up a localized string similar to `.slowmode 1 5`. /// public static string slowmode_usage { get { diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 2538e463..3ae7c1a8 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -328,10 +328,10 @@ slowmode - Toggles slow mode. When ON, users will be able to send only 1 message every 5 seconds. + Toggles slowmode. Disable by specifying no parameters. To enable, specify a number of messages each user can send, and an interval in seconds. For example 1 message every 5 seconds. - `.slowmode` + `.slowmode 1 5` cleanvplust cv+t