This commit is contained in:
appelemac 2016-07-17 20:42:41 +02:00
parent 112cf972ac
commit e28c705bfd
2 changed files with 34 additions and 0 deletions

View File

@ -97,6 +97,8 @@ namespace NadekoBot.Classes
} }
} }
[JsonIgnore] [JsonIgnore]
private ulong autoAssignedRole = 0; private ulong autoAssignedRole = 0;
public ulong AutoAssignedRole { public ulong AutoAssignedRole {
@ -122,6 +124,19 @@ namespace NadekoBot.Classes
} }
} }
[JsonIgnore]
private bool exclusiveSelfAssignedRoles = false;
public bool ExclusiveSelfAssignedRoles
{
get { return exclusiveSelfAssignedRoles; }
set
{
exclusiveSelfAssignedRoles = value;
if (!SpecificConfigurations.Instantiated) return;
OnPropertyChanged();
}
}
public ObservableCollection<StreamNotificationConfig> ObservingStreams { public ObservableCollection<StreamNotificationConfig> ObservingStreams {
get { return observingStreams; } get { return observingStreams; }
set { set {

View File

@ -94,6 +94,19 @@ namespace NadekoBot.Modules.Administration.Commands
await e.Channel.SendMessage(msg.ToString()).ConfigureAwait(false); 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") cgb.CreateCommand(Module.Prefix + "iam")
.Description("Adds a role to you that you choose. " + .Description("Adds a role to you that you choose. " +
"Role must be on a list of self-assignable roles." + "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); await e.Channel.SendMessage($":anger:You already have {role.Name} role.").ConfigureAwait(false);
return; 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 try
{ {
await e.User.AddRoles(role).ConfigureAwait(false); await e.User.AddRoles(role).ConfigureAwait(false);