.antispam should now update when you use it with new parameters. Use no parameters to disable it if it exists, or run it with default values if it doesn't

This commit is contained in:
Master Kwoth 2017-08-06 18:01:10 +02:00
parent 0bf6459e6a
commit 6c5ea68032

View File

@ -112,14 +112,9 @@ namespace NadekoBot.Modules.Administration
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
[RequireUserPermission(GuildPermission.Administrator)]
public async Task AntiSpam(int messageCount = 3, PunishmentAction action = PunishmentAction.Mute, int time = 0)
[Priority(1)]
public async Task AntiSpam()
{
if (messageCount < 2 || messageCount > 10)
return;
if (time < 0 || time > 60 * 12)
return;
if (_service.AntiSpamGuilds.TryRemove(Context.Guild.Id, out var removed))
{
removed.UserStats.ForEach(x => x.Value.Dispose());
@ -135,6 +130,21 @@ namespace NadekoBot.Modules.Administration
return;
}
await AntiSpam(3).ConfigureAwait(false);
}
[NadekoCommand, Usage, Description, Aliases]
[RequireContext(ContextType.Guild)]
[RequireUserPermission(GuildPermission.Administrator)]
[Priority(0)]
public async Task AntiSpam(int messageCount, PunishmentAction action = PunishmentAction.Mute, int time = 0)
{
if (messageCount < 2 || messageCount > 10)
return;
if (time < 0 || time > 60 * 12)
return;
try
{
await _mute.GetMuteRole(Context.Guild).ConfigureAwait(false);
@ -155,7 +165,12 @@ namespace NadekoBot.Modules.Administration
}
};
_service.AntiSpamGuilds.AddOrUpdate(Context.Guild.Id, stats, (key, old) => stats);
_service.AntiSpamGuilds.AddOrUpdate(Context.Guild.Id, stats, (key, old) =>
{
stats.AntiSpamSettings.MessageThreshold = messageCount;
stats.AntiSpamSettings.Action = action;
return stats;
});
using (var uow = _db.UnitOfWork)
{