.rc won't fail anymore if prefixed by #

Hopefuly didn't break the command
This commit is contained in:
Master Kwoth 2016-04-24 14:38:18 +02:00
parent a7e2771fcc
commit 622c8fb676

View File

@ -124,7 +124,7 @@ namespace NadekoBot.Modules.Administration
}); });
cgb.CreateCommand(Prefix + "r").Alias(Prefix + "role").Alias(Prefix + "cr") 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) .Parameter("role_name", ParameterType.Unparsed)
.AddCheck(SimpleCheckers.CanManageRoles) .AddCheck(SimpleCheckers.CanManageRoles)
.Do(async e => .Do(async e =>
@ -147,7 +147,7 @@ namespace NadekoBot.Modules.Administration
.Parameter("r", ParameterType.Optional) .Parameter("r", ParameterType.Optional)
.Parameter("g", ParameterType.Optional) .Parameter("g", ParameterType.Optional)
.Parameter("b", 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 => .Do(async e =>
{ {
if (!e.User.ServerPermissions.ManageRoles) if (!e.User.ServerPermissions.ManageRoles)
@ -174,10 +174,11 @@ namespace NadekoBot.Modules.Administration
try try
{ {
var rgb = args.Count() == 4; 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 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(e.Args[1].Substring(2, 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(e.Args[1].Substring(4, 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 role.Edit(color: new Color(red, green, blue)).ConfigureAwait(false);
await e.Channel.SendMessage($"Role {role.Name}'s color has been changed.").ConfigureAwait(false); await e.Channel.SendMessage($"Role {role.Name}'s color has been changed.").ConfigureAwait(false);