From 622c8fb676daa66b637188dd2e647de6472de64b Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Sun, 24 Apr 2016 14:38:18 +0200 Subject: [PATCH] .rc won't fail anymore if prefixed by # Hopefuly didn't break the command --- .../Modules/Administration/AdministrationModule.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/NadekoBot/Modules/Administration/AdministrationModule.cs b/NadekoBot/Modules/Administration/AdministrationModule.cs index 04452192..eb8ce6bf 100644 --- a/NadekoBot/Modules/Administration/AdministrationModule.cs +++ b/NadekoBot/Modules/Administration/AdministrationModule.cs @@ -124,7 +124,7 @@ namespace NadekoBot.Modules.Administration }); cgb.CreateCommand(Prefix + "r").Alias(Prefix + "role").Alias(Prefix + "cr") - .Description("Creates a role with a given name.**Usage**: .r Awesome Role") + .Description("Creates a role with a given name.**Usage**: `.r Awesome Role`") .Parameter("role_name", ParameterType.Unparsed) .AddCheck(SimpleCheckers.CanManageRoles) .Do(async e => @@ -147,7 +147,7 @@ namespace NadekoBot.Modules.Administration .Parameter("r", ParameterType.Optional) .Parameter("g", ParameterType.Optional) .Parameter("b", ParameterType.Optional) - .Description("Set a role's color to the hex or 0-255 rgb color value provided.\n**Usage**: .color Admin 255 200 100 or .color Admin ffba55") + .Description("Set a role's color to the hex or 0-255 rgb color value provided.\n**Usage**: `.color Admin 255 200 100` or `.color Admin ffba55`") .Do(async e => { if (!e.User.ServerPermissions.ManageRoles) @@ -174,10 +174,11 @@ namespace NadekoBot.Modules.Administration try { var rgb = args.Count() == 4; + var arg1 = e.Args[1].Replace("#", ""); - var red = Convert.ToByte(rgb ? int.Parse(e.Args[1]) : Convert.ToInt32(e.Args[1].Substring(0, 2), 16)); - var green = Convert.ToByte(rgb ? int.Parse(e.Args[2]) : Convert.ToInt32(e.Args[1].Substring(2, 2), 16)); - var blue = Convert.ToByte(rgb ? int.Parse(e.Args[3]) : Convert.ToInt32(e.Args[1].Substring(4, 2), 16)); + var red = Convert.ToByte(rgb ? int.Parse(arg1) : Convert.ToInt32(arg1.Substring(0, 2), 16)); + var green = Convert.ToByte(rgb ? int.Parse(e.Args[2]) : Convert.ToInt32(arg1.Substring(2, 2), 16)); + var blue = Convert.ToByte(rgb ? int.Parse(e.Args[3]) : Convert.ToInt32(arg1.Substring(4, 2), 16)); await role.Edit(color: new Color(red, green, blue)).ConfigureAwait(false); await e.Channel.SendMessage($"Role {role.Name}'s color has been changed.").ConfigureAwait(false);