fixed setcolor
This commit is contained in:
parent
ca0489928d
commit
5bfdd27d93
@ -105,40 +105,45 @@ namespace NadekoBot.Modules
|
|||||||
} catch (Exception) { }
|
} catch (Exception) { }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
cgb.CreateCommand(".rolecolor").Alias(".rc")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cgb.CreateCommand(".color").Alias(".c")
|
|
||||||
.Parameter("Rolename", ParameterType.Required)
|
.Parameter("Rolename", ParameterType.Required)
|
||||||
.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 rgb(0-255 0-255 0-255) color value provided.")
|
.Description("Set a role's color to the hex or 0-255 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)
|
|
||||||
{
|
|
||||||
await e.Channel.SendMessage("You don't have permission to use this!");
|
await e.Channel.SendMessage("You don't have permission to use this!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var args = e.Args.Where(s => s != String.Empty);
|
||||||
|
|
||||||
|
if (args.Count() != 2 && args.Count() != 4) {
|
||||||
|
await e.Send("The parameters are invalid.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (e.Args.Count() == 2 || e.Args.Count() == 4)
|
Role role = e.Server.FindRoles(e.Args[0]).FirstOrDefault();
|
||||||
{
|
|
||||||
bool rgb = e.Args.Count() == 4;
|
if (role == null) {
|
||||||
byte red = Convert.ToByte(rgb ? int.Parse(e.Args[1]) : Convert.ToInt32(e.Args[1].Substring(0, 2), 16));
|
await e.Send("That role does not exist.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
bool rgb = args.Count() == 4;
|
||||||
|
|
||||||
|
byte red = Convert.ToByte(rgb ? int.Parse(e.Args[1]) : Convert.ToInt32(e.Args[1].Substring(0,2), 16));
|
||||||
byte green = Convert.ToByte(rgb ? int.Parse(e.Args[2]) : Convert.ToInt32(e.Args[1].Substring(2, 2), 16));
|
byte green = Convert.ToByte(rgb ? int.Parse(e.Args[2]) : Convert.ToInt32(e.Args[1].Substring(2, 2), 16));
|
||||||
byte blue = Convert.ToByte(rgb ? int.Parse(e.Args[3]) : Convert.ToInt32(e.Args[1].Substring(4, 2), 16));
|
byte blue = Convert.ToByte(rgb ? int.Parse(e.Args[3]) : Convert.ToInt32(e.Args[1].Substring(4, 2), 16));
|
||||||
Role role = e.Server.FindRoles(e.Args[0]).FirstOrDefault();
|
|
||||||
await role.Edit(color: new Color(red, green, blue));
|
await role.Edit(color: new Color(red, green, blue));
|
||||||
await e.Channel.SendMessage($"Role {role.Name}'s color has been changed.");
|
await e.Channel.SendMessage($"Role {role.Name}'s color has been changed.");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
await e.Send(":warning: Unspecified error, please report this.");
|
||||||
|
Console.WriteLine($".rolecolor error: {ex}");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
await e.Channel.SendMessage("The parameters are invalid.");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -369,8 +374,6 @@ namespace NadekoBot.Modules
|
|||||||
}
|
}
|
||||||
output += "```";
|
output += "```";
|
||||||
await e.User.SendMessage(output);
|
await e.User.SendMessage(output);
|
||||||
|
|
||||||
//await e.Send("```\n" + e.User.ServerPermissions.+"\n```");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Server commsServer = null;
|
Server commsServer = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user