changing mute role no longer requires restart of .antispam/.antiraid
This commit is contained in:
parent
b1b4afc0e8
commit
47bc208826
@ -36,7 +36,6 @@ namespace NadekoBot.Modules.Administration
|
||||
public int UserThreshold { get; set; }
|
||||
public int Seconds { get; set; }
|
||||
public PunishmentAction Action { get; set; }
|
||||
public IRole MuteRole { get; set; }
|
||||
public int UsersCount { get; set; }
|
||||
public ConcurrentHashSet<IGuildUser> RaidUsers { get; set; } = new ConcurrentHashSet<IGuildUser>();
|
||||
}
|
||||
@ -45,7 +44,6 @@ namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
public PunishmentAction Action { get; set; }
|
||||
public int MessageThreshold { get; set; } = 3;
|
||||
public IRole MuteRole { get; set; }
|
||||
public ConcurrentDictionary<ulong, UserSpamStats> UserStats { get; set; }
|
||||
= new ConcurrentDictionary<ulong, UserSpamStats>();
|
||||
}
|
||||
@ -114,7 +112,7 @@ namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
if (spamSettings.UserStats.TryRemove(msg.Author.Id, out stats))
|
||||
{
|
||||
await PunishUsers(spamSettings.Action, spamSettings.MuteRole, ProtectionType.Spamming, (IGuildUser)msg.Author)
|
||||
await PunishUsers(spamSettings.Action, await GetMuteRole(channel.Guild), ProtectionType.Spamming, (IGuildUser)msg.Author)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@ -145,7 +143,7 @@ namespace NadekoBot.Modules.Administration
|
||||
var users = settings.RaidUsers.ToArray();
|
||||
settings.RaidUsers.Clear();
|
||||
|
||||
await PunishUsers(settings.Action, settings.MuteRole, ProtectionType.Raiding, users).ConfigureAwait(false);
|
||||
await PunishUsers(settings.Action, await GetMuteRole(usr.Guild), ProtectionType.Raiding, users).ConfigureAwait(false);
|
||||
}
|
||||
await Task.Delay(1000 * settings.Seconds).ConfigureAwait(false);
|
||||
|
||||
@ -221,10 +219,9 @@ namespace NadekoBot.Modules.Administration
|
||||
return;
|
||||
}
|
||||
|
||||
IRole muteRole;
|
||||
try
|
||||
{
|
||||
muteRole = await GetMuteRole(channel.Guild).ConfigureAwait(false);
|
||||
await GetMuteRole(channel.Guild).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -240,7 +237,6 @@ namespace NadekoBot.Modules.Administration
|
||||
Action = action,
|
||||
Seconds = seconds,
|
||||
UserThreshold = userThreshold,
|
||||
MuteRole = muteRole,
|
||||
};
|
||||
antiRaidGuilds.AddOrUpdate(channel.Guild.Id, setting, (id, old) => setting);
|
||||
|
||||
@ -265,10 +261,22 @@ namespace NadekoBot.Modules.Administration
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
await GetMuteRole(channel.Guild).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await channel.SendMessageAsync("Failed creating a mute role. Give me ManageRoles permission" +
|
||||
"or create 'nadeko-mute' role with disabled SendMessages and try again.")
|
||||
.ConfigureAwait(false);
|
||||
_log.Warn(ex);
|
||||
return;
|
||||
}
|
||||
|
||||
if (antiSpamGuilds.TryAdd(channel.Guild.Id, new AntiSpamSetting()
|
||||
{
|
||||
Action = action,
|
||||
MuteRole = await GetMuteRole(channel.Guild).ConfigureAwait(false),
|
||||
MessageThreshold = messageCount,
|
||||
}))
|
||||
await channel.SendMessageAsync("`Anti-Spam feature enabled on this server.`").ConfigureAwait(false);
|
||||
|
@ -2470,7 +2470,7 @@
|
||||
<value>setmuterole</value>
|
||||
</data>
|
||||
<data name="setmuterole_desc" xml:space="preserve">
|
||||
<value>Sets a name of the role which will be assigned to people who should be muted. Default is nadeko-mute. After specifying this role, restart commands which use mute as punishment.</value>
|
||||
<value>Sets a name of the role which will be assigned to people who should be muted. Default is nadeko-mute.</value>
|
||||
</data>
|
||||
<data name="setmuterole_usage" xml:space="preserve">
|
||||
<value>`{0}setmuterole Silenced`</value>
|
||||
|
Loading…
Reference in New Issue
Block a user