diff --git a/src/NadekoBot/Modules/Administration/ProtectionCommands.cs b/src/NadekoBot/Modules/Administration/ProtectionCommands.cs index ea97a089..c9d021ad 100644 --- a/src/NadekoBot/Modules/Administration/ProtectionCommands.cs +++ b/src/NadekoBot/Modules/Administration/ProtectionCommands.cs @@ -34,8 +34,8 @@ namespace NadekoBot.Modules.Administration if (string.IsNullOrWhiteSpace(ignoredString)) ignoredString = "none"; return GetText("spam_stats", - Format.Bold(stats.AntiSpamSettings.MessageThreshold.ToString()), - Format.Bold(stats.AntiSpamSettings.Action.ToString()), + Format.Bold(stats.AntiSpamSettings.MessageThreshold.ToString()), + Format.Bold(stats.AntiSpamSettings.Action.ToString()), ignoredString); } @@ -60,7 +60,7 @@ namespace NadekoBot.Modules.Administration await ReplyErrorLocalized("raid_time", 2, 300).ConfigureAwait(false); return; } - + if (_service.AntiRaidGuilds.TryRemove(Context.Guild.Id, out _)) { using (var uow = _db.UnitOfWork) @@ -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) {