Merged branch dev into dev

This commit is contained in:
Kwoth 2016-07-19 13:37:32 +02:00
commit 3b8e9a6af7
2 changed files with 34 additions and 0 deletions

View File

@ -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<StreamNotificationConfig> observingStreams;

View File

@ -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);