use of ws.nmathe.saber.core.schedule.ScheduleEntry in project Saber-Bot by notem.
the class ParsingUtilities method compileUserList.
/**
* generates a list of user IDs for a given RSVP category of an event
* @param entry ScheduleEntry object
* @param name name of RSVP category
* @return List of Stings or null if category is invalid
*/
private static List<String> compileUserList(ScheduleEntry entry, String name) {
List<String> users = null;
if (name.toLowerCase().equals("no-input")) {
List<String> rsvped = new ArrayList<>();
Set<String> keys = entry.getRsvpMembers().keySet();
for (String key : keys) {
rsvped.addAll(entry.getRsvpMembersOfType(key));
}
JDA shard = Main.getShardManager().getJDA(entry.getGuildId());
Guild guild = shard.getGuildById(entry.getGuildId());
Channel channel = shard.getTextChannelById(entry.getChannelId());
users = guild.getMembers().stream().filter(member -> member.getPermissions(channel).contains(Permission.MESSAGE_READ)).map(member -> member.getUser().getId()).filter(memberId -> !rsvped.contains(memberId)).collect(Collectors.toList());
} else {
List<String> members = entry.getRsvpMembers().get(name);
if (members != null)
users = entry.getRsvpMembersOfType(name);
}
return users;
}
Aggregations