inrole changed to not require permissions. Will require manage messages for long roles.
Won't work with [at]everyone too.
This commit is contained in:
parent
c1632da0f0
commit
5db1214440
@ -52,16 +52,15 @@ namespace NadekoBot.Modules.Utility
|
|||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "inrole")
|
cgb.CreateCommand(Prefix + "inrole")
|
||||||
.Description("Lists every person from the provided role or roles (separated by a ',') on this server.")
|
.Description("Lists every person from the provided role or roles (separated by a ',') on this server. If the list is too long for 1 message, you must have Manage Messages permission.")
|
||||||
.Parameter("roles", ParameterType.Unparsed)
|
.Parameter("roles", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
await Task.Run(async () =>
|
await Task.Run(async () =>
|
||||||
{
|
{
|
||||||
if (!e.User.ServerPermissions.MentionEveryone) return;
|
|
||||||
var arg = e.GetArg("roles").Split(',').Select(r => r.Trim());
|
var arg = e.GetArg("roles").Split(',').Select(r => r.Trim());
|
||||||
string send = $"`Here is a list of users in a specfic role:`";
|
string send = $"`Here is a list of users in a specfic role:`";
|
||||||
foreach (var roleStr in arg.Where(str => !string.IsNullOrWhiteSpace(str)))
|
foreach (var roleStr in arg.Where(str => !string.IsNullOrWhiteSpace(str) && str != "@everyone" && str != "everyone"))
|
||||||
{
|
{
|
||||||
var role = e.Server.FindRoles(roleStr).FirstOrDefault();
|
var role = e.Server.FindRoles(roleStr).FirstOrDefault();
|
||||||
if (role == null) continue;
|
if (role == null) continue;
|
||||||
@ -71,6 +70,11 @@ namespace NadekoBot.Modules.Utility
|
|||||||
|
|
||||||
while (send.Length > 2000)
|
while (send.Length > 2000)
|
||||||
{
|
{
|
||||||
|
if (!e.User.ServerPermissions.ManageMessages)
|
||||||
|
{
|
||||||
|
await e.Channel.SendMessage($"{e.User.Mention} you are not allowed to use this command on roles with a lot of users in them to prevent abuse.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
var curstr = send.Substring(0, 2000);
|
var curstr = send.Substring(0, 2000);
|
||||||
await
|
await
|
||||||
e.Channel.Send(curstr.Substring(0,
|
e.Channel.Send(curstr.Substring(0,
|
||||||
|
Loading…
Reference in New Issue
Block a user