From d765b166492dad3785e6d4ef114f737b0550a30a Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 28 Jul 2016 16:19:44 +0200 Subject: [PATCH] return if there is an error assigning roles --- .../Administration/Commands/SelfAssignedRolesCommand.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs b/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs index 2ef54772..1890eb5b 100644 --- a/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs +++ b/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs @@ -76,7 +76,7 @@ namespace NadekoBot.Modules.Administration.Commands var config = SpecificConfigurations.Default.Of(e.Server.Id); var msg = new StringBuilder($"There are `{config.ListOfSelfAssignableRoles.Count}` self assignable roles:\n"); var toRemove = new HashSet(); - foreach (var roleId in config.ListOfSelfAssignableRoles.OrderBy(r=>r.ToString())) + foreach (var roleId in config.ListOfSelfAssignableRoles.OrderBy(r => r.ToString())) { var role = e.Server.GetRole(roleId); if (role == null) @@ -98,7 +98,7 @@ namespace NadekoBot.Modules.Administration.Commands - cgb.CreateCommand(Module.Prefix + "togglexclsar").Alias(Module.Prefix +"tesar") + 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 => @@ -146,12 +146,13 @@ namespace NadekoBot.Modules.Administration.Commands { await e.User.AddRoles(role).ConfigureAwait(false); } - catch(HttpException ex) when (ex.StatusCode == System.Net.HttpStatusCode.InternalServerError) + catch (HttpException ex) when (ex.StatusCode == System.Net.HttpStatusCode.InternalServerError) { } - catch (Exception) + catch (Exception ex) { await e.Channel.SendMessage($":anger:`I am unable to add that role to you. I can't add roles to owners or other roles higher than my role in the role hierarchy.`").ConfigureAwait(false); + return; } var msg = await e.Channel.SendMessage($":ok:You now have {role.Name} role.").ConfigureAwait(false); await Task.Delay(3000).ConfigureAwait(false);