/** * Gives list of discord users sorted by roles */ public async Task userlist(bool everyone) { SocketGuild Guild = Context.Guild as SocketGuild; SocketGuildUser User = Context.User as SocketGuildUser; if ((User.Roles.Contains(Guild.GetRole(leadership) as SocketRole) || User.Roles.Contains(Guild.GetRole(offier) as SocketRole))) { List <SocketRole> roleList = Guild.Roles.ToList(); List <List <SocketGuildUser> > roles = new List <List <SocketGuildUser> >(); //for (int i = 0; i < roleList.Count(); i++) //roles.Add(new List<SocketGuildUser>()); SocketRole[] orderedRoles = new SocketRole[5]; for (int i = 0; i < roleList.Count(); i++) { if (roleList[i].Name == "Leadership") { orderedRoles[0] = roleList[i]; } if (roleList[i].Name == "Officer") { orderedRoles[1] = roleList[i]; } if (roleList[i].Name == "member") { orderedRoles[2] = roleList[i]; } if (roleList[i].Name == "Allies") { orderedRoles[3] = roleList[i]; } if (roleList[i].Name == "@everyone") { orderedRoles[4] = roleList[i]; } } string output = ""; string output2 = ""; for (int i = 0; i < orderedRoles.Count(); i++) { if (orderedRoles[i].Name == "@everyone") { output2 += "**" + "no role" + "**" + Environment.NewLine; } else { output += "**" + orderedRoles[i].Name + "**" + Environment.NewLine; } List <SocketGuildUser> userList = orderedRoles[i].Members.ToList(); for (int a = 0; a < userList.Count(); a++) { List <SocketRole> OrRoleL = orderedRoles.ToList(); if ((i == 2 && (orderedRoles[0].Members.Contains(userList[a]) || orderedRoles[1].Members.Contains(userList[a])) || (i == 4 && (orderedRoles[0].Members.Contains(userList[a]) || orderedRoles[2].Members.Contains(userList[a]) || orderedRoles[3].Members.Contains(userList[a]))))) { } else if (i == 4) { if (userList[a].Nickname == null) { output2 += userList[a].Username + Environment.NewLine; } else { output2 += userList[a].Nickname + Environment.NewLine; } } else { if (userList[a].Nickname == null) { output += userList[a].Username + Environment.NewLine; } else { output += userList[a].Nickname + Environment.NewLine; } } } output += Environment.NewLine; } ; SocketTextChannel channel = Guild.GetTextChannel(466373989854347264); await channel.SendMessageAsync(output); if (everyone) { await channel.SendMessageAsync(output2); } } else { await Context.Channel.SendMessageAsync("You don't have the correct roles"); } }