/** * Gets a list of {@link Role} that match a string. Case doesn't matter. * * @param string The String to get a list of {@link Role} from. * @param guild The {@link Guild} to get the roles from. * @return an empty if no role matches, otherwise a list of roles matching the string. */ public static List<Role> getRole(String string, Guild guild) { return guild.getRolesByName(string, true); }
/** * Gets the role from the mentioned roles list, if no roles was mentions * the role will be fetch from the guilds role list by name instead, * if no roles was found null is returned. * * @param message The JDA message object for the current guild. * @param roleName The name of the role that should be fetched if no role was mentioned. * @return Possibly-null, if a role was mentioned the role will be returned, otherwise the role will be fetched from the guilds role list. */ public static Role getRoleFromMentionsOrName(@Nonnull Message message, @Nonnull String roleName) { if (!message.getMentionedRoles().isEmpty()) { return message.getMentionedRoles().get(0); } List<Role> roles = message.getGuild().getRolesByName(roleName, true); return roles.isEmpty() ? null : roles.get(0); }
if (guild.getRolesByName(s, true).isEmpty()) { String closest = null; int distance = LEVENSHTEIN_DISTANCE; return null; } else { return guild.getRolesByName(s, true).get(0);
List<Role> roleList = guild.getRolesByName(RoleRankings.getFullName(guild, targetRole), true); if (roleList.size() > 0) { bot.out.addRole(user, roleList.get(0));
} else { List<Role> roles = isCrossGuild ? jda.getRolesByName(arg, true) : c.issuer.getIssuer().getGuild().getRolesByName(arg, true); if (roles.size() > 1) { throw new InvalidCommandArgument("Too many roles were found with the given name. Try with the `@role` syntax.", false);
String roleReq = settings.getOrDefault(GSetting.MUSIC_ROLE_REQUIREMENT); if (!(roleReq.equalsIgnoreCase("none") || roleReq.equals("false"))) { List<Role> roles = guild.getRolesByName(roleReq, true); if (!roles.isEmpty()) { requiredRole = roles.get(0);
List<Role> rolesByName = guild.getRolesByName(getFullName(guild, rank), true); Role role; boolean needsUpdate = false;