Merge pull request #415 from appelemac/selfassignedtoggle
.togglexclsar - make self-assignable roles exclusive (can have only 1 of them)
This commit is contained in:
commit
8d46ab762f
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user