diff --git a/NadekoBot/Classes/ServerSpecificConfig.cs b/NadekoBot/Classes/ServerSpecificConfig.cs index b92915f1..ff42f0fd 100644 --- a/NadekoBot/Classes/ServerSpecificConfig.cs +++ b/NadekoBot/Classes/ServerSpecificConfig.cs @@ -157,6 +157,8 @@ namespace NadekoBot.Classes } } + + [JsonIgnore] private ulong autoAssignedRole = 0; public ulong AutoAssignedRole { @@ -194,6 +196,19 @@ namespace NadekoBot.Classes } } + [JsonIgnore] + private bool exclusiveSelfAssignedRoles = false; + public bool ExclusiveSelfAssignedRoles + { + get { return exclusiveSelfAssignedRoles; } + set + { + exclusiveSelfAssignedRoles = value; + if (!SpecificConfigurations.Instantiated) return; + OnPropertyChanged(); + } + } + [JsonIgnore] private ObservableCollection observingStreams; diff --git a/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs b/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs index 94c695e8..51bf8859 100644 --- a/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs +++ b/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs @@ -94,6 +94,19 @@ namespace NadekoBot.Modules.Administration.Commands await e.Channel.SendMessage(msg.ToString()).ConfigureAwait(false); }); + + + cgb.CreateCommand(Module.Prefix + "togglexclsar").Alias(Module.Prefix +"tesar") + .Description("toggle whether the self-assigned roles should be exclusive") + .AddCheck(SimpleCheckers.CanManageRoles) + .Do(async e => + { + var config = SpecificConfigurations.Default.Of(e.Server.Id); + config.ExclusiveSelfAssignedRoles = !config.ExclusiveSelfAssignedRoles; + string exl = config.ExclusiveSelfAssignedRoles ? "exclusive" : "not exclusive"; + await e.Channel.SendMessage("Self assigned roles are now " + exl); + }); + cgb.CreateCommand(Module.Prefix + "iam") .Description("Adds a role to you that you choose. " + "Role must be on a list of self-assignable roles." + @@ -121,6 +134,12 @@ namespace NadekoBot.Modules.Administration.Commands await e.Channel.SendMessage($":anger:You already have {role.Name} role.").ConfigureAwait(false); return; } + var sameRoles = e.User.Roles.Where(r => config.ListOfSelfAssignableRoles.Contains(r.Id)); + if (config.ExclusiveSelfAssignedRoles && sameRoles.Any()) + { + await e.Channel.SendMessage($":anger:You already have {sameRoles.FirstOrDefault().Name} role.").ConfigureAwait(false); + return; + } try { await e.User.AddRoles(role).ConfigureAwait(false);