From 74ac9858dcd0643641482a791c06038f5c5b1f53 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Mon, 6 Mar 2017 19:19:23 +0100 Subject: [PATCH] .inrole nerfed, takes only one role, prettier --- src/NadekoBot/Modules/Utility/Utility.cs | 33 ++++--------------- .../Resources/CommandStrings.Designer.cs | 4 +-- src/NadekoBot/Resources/CommandStrings.resx | 4 +-- .../Resources/ResponseStrings.Designer.cs | 2 +- src/NadekoBot/Resources/ResponseStrings.resx | 2 +- 5 files changed, 13 insertions(+), 32 deletions(-) diff --git a/src/NadekoBot/Modules/Utility/Utility.cs b/src/NadekoBot/Modules/Utility/Utility.cs index 38951dd5..fefa35bd 100644 --- a/src/NadekoBot/Modules/Utility/Utility.cs +++ b/src/NadekoBot/Modules/Utility/Utility.cs @@ -217,34 +217,15 @@ namespace NadekoBot.Modules.Utility [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] - public async Task InRole(params IRole[] roles) + public async Task InRole([Remainder] IRole role) { - if (roles.Length == 0) - return; - var send = "ℹ️ " + Format.Bold(GetText("inrole_list")); + var usrs = (await Context.Guild.GetUsersAsync()).ToArray(); - foreach (var role in roles.Where(r => r.Id != Context.Guild.Id)) - { - var roleUsers = usrs.Where(u => u.RoleIds.Contains(role.Id)).Select(u => u.ToString()).ToArray(); - send += $"```css\n[{role.Name}] ({roleUsers.Length})\n"; - send += string.Join(", ", roleUsers); - send += "\n```"; - } - var usr = (IGuildUser)Context.User; - while (send.Length > 2000) - { - if (!usr.GetPermissions((ITextChannel)Context.Channel).ManageMessages) - { - await ReplyErrorLocalized("inrole_not_allowed").ConfigureAwait(false); - return; - } - var curstr = send.Substring(0, 2000); - await Context.Channel.SendConfirmAsync(curstr.Substring(0, - curstr.LastIndexOf(", ", StringComparison.Ordinal) + 1)).ConfigureAwait(false); - send = curstr.Substring(curstr.LastIndexOf(", ", StringComparison.Ordinal) + 1) + - send.Substring(2000); - } - await Context.Channel.SendConfirmAsync(send).ConfigureAwait(false); + var roleUsers = usrs.Where(u => u.RoleIds.Contains(role.Id)).Select(u => u.ToString()).ToArray(); + var embed = new EmbedBuilder().WithOkColor() + .WithTitle("ℹ️ " + Format.Bold(GetText("inrole_list")) + $" - {roleUsers.Length}") + .WithDescription(string.Join(", ", roleUsers)); + await Context.Channel.EmbedAsync(embed).ConfigureAwait(false); } [NadekoCommand, Usage, Description, Aliases] diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index 41965836..3b42debd 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -3552,7 +3552,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Lists every person from the provided role or roles, separated with space, on this server. You can use role IDs, role names (in quotes if it has multiple words), or role mention If the list is too long for 1 message, you must have Manage Messages permission.. + /// Looks up a localized string similar to Lists every person from the specified role on this server. You can use role ID, role name.. /// public static string inrole_desc { get { @@ -3561,7 +3561,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to `{0}inrole Role` or `{0}inrole Role1 "Role 2" @role3`. + /// Looks up a localized string similar to `{0}inrole Some Role`. /// public static string inrole_usage { get { diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 3379b98b..528700c3 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -841,10 +841,10 @@ inrole - Lists every person from the provided role or roles, separated with space, on this server. You can use role IDs, role names (in quotes if it has multiple words), or role mention If the list is too long for 1 message, you must have Manage Messages permission. + Lists every person from the specified role on this server. You can use role ID, role name. - `{0}inrole Role` or `{0}inrole Role1 "Role 2" @role3` + `{0}inrole Some Role` checkmyperms diff --git a/src/NadekoBot/Resources/ResponseStrings.Designer.cs b/src/NadekoBot/Resources/ResponseStrings.Designer.cs index 7e2b3173..44f51416 100644 --- a/src/NadekoBot/Resources/ResponseStrings.Designer.cs +++ b/src/NadekoBot/Resources/ResponseStrings.Designer.cs @@ -5702,7 +5702,7 @@ namespace NadekoBot.Resources { } /// - /// Looks up a localized string similar to Here is a list of users in those roles:. + /// Looks up a localized string similar to List of users in {0} role. /// public static string utility_inrole_list { get { diff --git a/src/NadekoBot/Resources/ResponseStrings.resx b/src/NadekoBot/Resources/ResponseStrings.resx index 8f964f3a..a74c16db 100644 --- a/src/NadekoBot/Resources/ResponseStrings.resx +++ b/src/NadekoBot/Resources/ResponseStrings.resx @@ -2002,7 +2002,7 @@ Don't forget to leave your discord name or id in the message. Index out of range. - Here is a list of users in those roles: + List of users in {0} role You are not allowed to use this command on roles with a lot of users in them to prevent abuse.