From 7f194e8d3fcc850a6cc1bf73e3af7cbba69b132c Mon Sep 17 00:00:00 2001 From: ZR2 Date: Tue, 26 Jan 2016 04:47:28 +1030 Subject: [PATCH 1/2] Added new command Added a color command so admins with the role ManageRoles can set colors took me a long time to make hope you like it --- NadekoBot/Modules/Administration.cs | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/NadekoBot/Modules/Administration.cs b/NadekoBot/Modules/Administration.cs index 10097520..099f81d1 100644 --- a/NadekoBot/Modules/Administration.cs +++ b/NadekoBot/Modules/Administration.cs @@ -105,6 +105,43 @@ namespace NadekoBot.Modules } catch (Exception) { } }); + + + + + cgb.CreateCommand(".color").Alias(".c") + .Parameter("Rolename", ParameterType.Required) + .Parameter("r", ParameterType.Optional) + .Parameter("g", ParameterType.Optional) + .Parameter("b", ParameterType.Optional) + .Description("Set a role's color to the rgb(0-255 0-255 0-255) color value provided.") + .Do(async e => + { + + + if (!e.User.ServerPermissions.ManageRoles) + { + await e.Channel.SendMessage("You don't have permission to use this!"); + return; + } + + + + if (e.Args.Count() == 2 || e.Args.Count() == 4) + { + bool rgb = e.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 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 e.Channel.SendMessage($"Role {role.Name}'s color has been changed."); + } + else + await e.Channel.SendMessage("The parameters are invalid."); + }); + + cgb.CreateCommand(".b").Alias(".ban") .Parameter("everything",ParameterType.Unparsed) .Description("Bans a mentioned user") From 5803b56680f62929e0c6ffe7f866921e8cbec29c Mon Sep 17 00:00:00 2001 From: ZR2 Date: Tue, 26 Jan 2016 04:49:37 +1030 Subject: [PATCH 2/2] Updated readme with color command --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 97a883cc..39686879 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ Command and aliases | Description | Usage `.sr`, `.setrole` | Sets a role for a given user. | .sr @User Guest `.rr`, `.removerole` | Removes a role from a given user. | .rr @User Admin `.r`, `.role`, `.cr` | Creates a role with a given name, and color. | .r AwesomeRole Orange +`.color`, `.c` | Set a role's color to the rgb(0-255 0-255 0-255) color value provided. | .color Admin 255 255 255 `.b`, `.ban` | Bans a mentioned user `.ub`, `.unban` | Unbans a mentioned user `.k`, `.kick` | Kicks a mentioned user.