Slowmode fixed, fixed description/usage, adding new one overrides old one
This commit is contained in:
parent
7d4db46fe7
commit
31bbe5ba98
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -6414,7 +6414,7 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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..
|
||||
/// </summary>
|
||||
public static string slowmode_desc {
|
||||
get {
|
||||
@ -6423,7 +6423,7 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to `.slowmode`.
|
||||
/// Looks up a localized string similar to `.slowmode 1 5`.
|
||||
/// </summary>
|
||||
public static string slowmode_usage {
|
||||
get {
|
||||
|
@ -328,10 +328,10 @@
|
||||
<value>slowmode</value>
|
||||
</data>
|
||||
<data name="slowmode_desc" xml:space="preserve">
|
||||
<value>Toggles slow mode. When ON, users will be able to send only 1 message every 5 seconds. </value>
|
||||
<value>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.</value>
|
||||
</data>
|
||||
<data name="slowmode_usage" xml:space="preserve">
|
||||
<value>`.slowmode`</value>
|
||||
<value>`.slowmode 1 5`</value>
|
||||
</data>
|
||||
<data name="cleanvplust_cmd" xml:space="preserve">
|
||||
<value>cleanvplust cv+t</value>
|
||||
|
Loading…
Reference in New Issue
Block a user