.inrole nerfed, takes only one role, prettier
This commit is contained in:
parent
2c029aab18
commit
74ac9858dc
@ -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]
|
||||
|
@ -3552,7 +3552,7 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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..
|
||||
/// </summary>
|
||||
public static string inrole_desc {
|
||||
get {
|
||||
@ -3561,7 +3561,7 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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`.
|
||||
/// </summary>
|
||||
public static string inrole_usage {
|
||||
get {
|
||||
|
@ -841,10 +841,10 @@
|
||||
<value>inrole</value>
|
||||
</data>
|
||||
<data name="inrole_desc" xml:space="preserve">
|
||||
<value>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.</value>
|
||||
<value>Lists every person from the specified role on this server. You can use role ID, role name.</value>
|
||||
</data>
|
||||
<data name="inrole_usage" xml:space="preserve">
|
||||
<value>`{0}inrole Role` or `{0}inrole Role1 "Role 2" @role3`</value>
|
||||
<value>`{0}inrole Some Role`</value>
|
||||
</data>
|
||||
<data name="checkmyperms_cmd" xml:space="preserve">
|
||||
<value>checkmyperms</value>
|
||||
|
@ -5702,7 +5702,7 @@ namespace NadekoBot.Resources {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public static string utility_inrole_list {
|
||||
get {
|
||||
|
@ -2002,7 +2002,7 @@ Don't forget to leave your discord name or id in the message.
|
||||
<value>Index out of range.</value>
|
||||
</data>
|
||||
<data name="utility_inrole_list" xml:space="preserve">
|
||||
<value>Here is a list of users in those roles:</value>
|
||||
<value>List of users in {0} role</value>
|
||||
</data>
|
||||
<data name="utility_inrole_not_allowed" xml:space="preserve">
|
||||
<value>You are not allowed to use this command on roles with a lot of users in them to prevent abuse.</value>
|
||||
|
Loading…
Reference in New Issue
Block a user