From 26c9005034eba7cb0cc5dad9f6e9b09abbe95d28 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Tue, 26 Apr 2016 10:41:14 +0200 Subject: [PATCH] .rar added --- .../Administration/AdministrationModule.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/NadekoBot/Modules/Administration/AdministrationModule.cs b/NadekoBot/Modules/Administration/AdministrationModule.cs index eb8ce6bf..b8fc870b 100644 --- a/NadekoBot/Modules/Administration/AdministrationModule.cs +++ b/NadekoBot/Modules/Administration/AdministrationModule.cs @@ -123,6 +123,32 @@ namespace NadekoBot.Modules.Administration } }); + cgb.CreateCommand(Prefix + "rar").Alias(Prefix + "removeallroles") + .Description("Removes all roles from a mentioned user.\n**Usage**: .rar @User") + .Parameter("user_name", ParameterType.Required) + .AddCheck(SimpleCheckers.CanManageRoles) + .Do(async e => + { + var userName = e.GetArg("user_name"); + + var usr = e.Server.FindUsers(userName).FirstOrDefault(); + if (usr == null) + { + await e.Channel.SendMessage("You failed to supply a valid username").ConfigureAwait(false); + return; + } + + try + { + await usr.RemoveRoles(usr.Roles.ToArray()).ConfigureAwait(false); + await e.Channel.SendMessage($"Successfully removed **all** roles from user **{usr.Name}**").ConfigureAwait(false); + } + catch + { + await e.Channel.SendMessage("Failed to remove roles. Most likely reason: Insufficient permissions.").ConfigureAwait(false); + } + }); + cgb.CreateCommand(Prefix + "r").Alias(Prefix + "role").Alias(Prefix + "cr") .Description("Creates a role with a given name.**Usage**: `.r Awesome Role`") .Parameter("role_name", ParameterType.Unparsed)