.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:
parent
0bf6459e6a
commit
6c5ea68032
@ -34,8 +34,8 @@ namespace NadekoBot.Modules.Administration
|
|||||||
if (string.IsNullOrWhiteSpace(ignoredString))
|
if (string.IsNullOrWhiteSpace(ignoredString))
|
||||||
ignoredString = "none";
|
ignoredString = "none";
|
||||||
return GetText("spam_stats",
|
return GetText("spam_stats",
|
||||||
Format.Bold(stats.AntiSpamSettings.MessageThreshold.ToString()),
|
Format.Bold(stats.AntiSpamSettings.MessageThreshold.ToString()),
|
||||||
Format.Bold(stats.AntiSpamSettings.Action.ToString()),
|
Format.Bold(stats.AntiSpamSettings.Action.ToString()),
|
||||||
ignoredString);
|
ignoredString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
await ReplyErrorLocalized("raid_time", 2, 300).ConfigureAwait(false);
|
await ReplyErrorLocalized("raid_time", 2, 300).ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_service.AntiRaidGuilds.TryRemove(Context.Guild.Id, out _))
|
if (_service.AntiRaidGuilds.TryRemove(Context.Guild.Id, out _))
|
||||||
{
|
{
|
||||||
using (var uow = _db.UnitOfWork)
|
using (var uow = _db.UnitOfWork)
|
||||||
@ -112,14 +112,9 @@ namespace NadekoBot.Modules.Administration
|
|||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
[RequireUserPermission(GuildPermission.Administrator)]
|
[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))
|
if (_service.AntiSpamGuilds.TryRemove(Context.Guild.Id, out var removed))
|
||||||
{
|
{
|
||||||
removed.UserStats.ForEach(x => x.Value.Dispose());
|
removed.UserStats.ForEach(x => x.Value.Dispose());
|
||||||
@ -135,6 +130,21 @@ namespace NadekoBot.Modules.Administration
|
|||||||
return;
|
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
|
try
|
||||||
{
|
{
|
||||||
await _mute.GetMuteRole(Context.Guild).ConfigureAwait(false);
|
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)
|
using (var uow = _db.UnitOfWork)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user