public final Role getRole(int index, boolean consume) { if (guild == null) { return null; } final String temp = getRaw(index); if (temp == null) { return null; } final Matcher matcher = PATTERN_MARKDOWN_ROLE.matcher(temp); if (!matcher.matches()) { return null; } if (consume) { consumeRaw(index); } return guild.getRoleById(matcher.group(1)); }
/** * Gets user level. * * @param guildID the guild id * @param userID the user id * @param roleList the role list * @return the user level */ public Integer getUserLevel(Long guildID, Long userID, List<Role> roleList) { Permissions permissions = listGuildPermissions.get(guildID); Integer userLevel = null; Integer roleLevel = null; if (permissions == null) { return null; } userLevel = permissions.getUserLevel(userID); if (userLevel != null) return userLevel; //userLevel take prioty over roleLevel Integer tempRole; for (Role r : roleList) { tempRole = permissions.getRoleLevel(r.getIdLong()); if (tempRole != null) { if (roleLevel == null) { roleLevel = tempRole; } else if (tempRole < roleLevel) { //See if tempRole is a higher ranked level roleLevel = tempRole; } } } return roleLevel; }
@Override public void onGuildMemberJoin(GuildMemberJoinEvent event) { // Add roles to new member short rating = database.getUserRating(event.getUser()); if(rating == -1) return; Role role = database.getRatingRole(event.getGuild(), rating); // Role is not null // Can interact with role // Can interact with member if(role != null && event.getGuild().getSelfMember().canInteract(role) && event.getGuild().getSelfMember().canInteract(event.getMember())) { event.getGuild().getController().addRolesToMember(event.getMember(), role).queue(v -> {}, v -> {}); } }
public short getRoleRating(Role role) throws SQLException { short returns = -1; try (Statement statement = connection.createStatement()) { try (ResultSet set = statement.executeQuery("SELECT * FROM "+table.name()+" " + "WHERE GUILD_ID = "+role.getGuild().getIdLong())) { if(set.next()) { for(short i = 1; i <= 5; i++) { long forRole = set.getLong("ROLE_"+i); if(forRole != 0L && forRole == role.getIdLong()) { returns = i; break; } } } } } return returns; }
@Override public void onGuildMemberJoin(GuildMemberJoinEvent event) { Member member = event.getMember(); Guild guild = member.getGuild(); try { for (DefaultRole dr : Bot.defaultRoles) { if (dr.getGuildID().equals(guild.getId())) { for (Role role : guild.getRoles()) { if (role.getId().equals(dr.getRoleID())) { guild.getController().addRolesToMember(member, role).complete(); } } } } } catch (Exception e) { e.printStackTrace(); } }
private PlaceholderMessage sendCurrentAutoRole(Message message, GuildTransformer transformer) { if (transformer.getAutorole() == null) { return MessageFactory.makeWarning(message, ":user **Auto assign role** on user join is currently **disabled**."); } Role role = message.getGuild().getRoleById(transformer.getAutorole()); if (role == null) { try { updateAutorole(transformer, message, null); } catch (SQLException ex) { ex.printStackTrace(); AvaIre.getLogger().error(ex.getMessage(), ex); } return MessageFactory.makeWarning(message, ":user **Auto assign role** on user join is currently **disabled**."); } return MessageFactory.makeSuccess(message, ":user The **auto assign role** is currently set to **:role**") .set("role", role.getName()); }
@Override public boolean handle(Message message, MiddlewareStack stack, String... args) { if (!message.getChannelType().isGuild()) { return stack.next(); } if (message.getMember().hasPermission(Permissions.ADMINISTRATOR.getPermission())) { return stack.next(); } List<Role> roles = message.getMember().getRoles(); for (String roleName : args) { if (!hasRole(roles, roleName)) { MessageFactory.makeError(message, "You don't have the required role to execute this command:\n`:role`") .set("role", roleName) .queue(); return false; } } return stack.next(); }
/** * Get the role that is position highest in the role hierarchy for the given member. * * @param member The member whos roles should be used. * @return Possibly-null, if the user has any roles the role that is ranked highest in the role hierarchy will be returned. */ public static Role getHighestFrom(Member member) { Checks.notNull(member, "Member object can not be null"); List<Role> roles = member.getRoles(); if (roles.isEmpty()) { return null; } return roles.stream().sorted((first, second) -> { if (first.getPosition() == second.getPosition()) { return 0; } return first.getPosition() > second.getPosition() ? -1 : 1; }).findFirst().get(); }
/** * Checks if the user can interact with the given role by making sure the role is * not higher in the role hierarchy then any role the user and the bot instance * for the current guild has, if the method returns true the bot should be * able to give the role to the users, and the given user has at least * one role which is in a higher position in the role hierarchy. * * @param message The JDA message object for the current guild. * @param role The role that should be used in the checks. * @return True if both the given user and bot can interact with the role, false otherwise. */ public static boolean canInteractWithRole(Message message, Role role) { if (RoleUtil.isRoleHierarchyHigher(message.getMember().getRoles(), role)) { MessageFactory.makeWarning(message, ":user The **:role** role is positioned higher in the hierarchy than any role you have, you can't add roles with a higher ranking than you have." ).set("role", role.getName()).queue(); return false; } if (RoleUtil.isRoleHierarchyHigher(message.getGuild().getSelfMember().getRoles(), role)) { MessageFactory.makeWarning(message, ":user The **:role** role is positioned higher in the hierarchy, I can't give/remove this role from users." ).set("role", role.getName()).queue(); return false; } return true; }
@Override public void executeCommand(Message msg) { EmbedBuilder em = new EmbedBuilder(); String roleName = Util.getCommandContents(msg).toLowerCase(); Role role = null; for (Role r : msg.getGuild().getRoles()) { if (r.getName().toLowerCase().equals(roleName)) { role = r; break; } } if(role == null) { em.setTitle("Error", null) .setColor(Color.RED) .setDescription("No users found for role " + roleName); } else { em.setTitle("Members with the role " + role.getName(), null) .setColor(Color.CYAN) .setDescription(msg.getGuild().getMembersWithRoles(role) .stream() .map(Member::getEffectiveName) .collect(Collectors.joining(", "))); } msg.getChannel().sendMessage(em.build()).queue(); }
@Override public void executeCommand(Message msg) { EmbedBuilder em = new EmbedBuilder(); String role = Util.combineStringArray(Util.removeFirstArrayEntry(msg.getContent().split(" "))); em.setTitle("Error", null) .setColor(Color.RED) .setDescription("**" + role + " is not a joinable role"); for(Role r : msg.getGuild().getRoles()) { if(r.getName().equalsIgnoreCase(role) && GuildObject.guildMap.get(msg.getGuild().getId()).removeJoinableRole(r.getId())) { em.setTitle("Success", null) .setColor(Color.GREEN) .setDescription("**" + role + "** is not joinable anymore"); break; } } msg.getChannel().sendMessage(em.build()).queue(); }
private List<RewardDetails> getRewards(long serverId, RankingConfig config) { if (discordService.isConnected() && CollectionUtils.isNotEmpty(config.getRewards())) { Guild guild = discordService.getJda().getGuildById(serverId); if (guild != null) { List<RewardDetails> details = new ArrayList<>(); for (Reward reward : config.getRewards()) { Role role = guild.getRoleById(reward.getRoleId()); if (role != null) { details.add(new RewardDetails(role, reward)); } } details.sort(Comparator.comparing(RewardDetails::getLevel)); return details; } } return null; }
public static void assignRole(UserData data) { User user = ZLevels.jda.getUserById(data.getUserId()); Guild guild = ZLevels.jda.getGuildById(Config.SERVER); int level = data.getLevel(); for (int requiredLevel : roles.keySet()) { if (level < requiredLevel) return; Member member = guild.getMember(user); Role role = guild.getRolesByName(roles.get(requiredLevel).getString("name"), false).get(0); if (member == null || role == null) return; if (member.getRoles().contains(role)) return; try { guild.getController().addRolesToMember(member, role).queue(); } catch (Exception e) { ZLogger.warn("Could not assign role to " + user.getName() + "!"); } } }
public final String getRoleNameForRole(Role role) { if (role == null) { return null; } if (role.getGuild().getMembersWithRoles(role).stream().anyMatch((member) -> isGuildUserNotMentionedInLogs(role.getGuild().getIdLong(), member.getUser().getIdLong()) || isUserNotMentionedInLogs(member.getUser().getIdLong()))) { return Standard.getCompleteName(role); } return role.getAsMention(); }
@Command( name = "deleterole", description = "Deletes a role", usage = "`>>deleterole <role name>`", permission = CommandPermission.ADMIN, category = CommandCategory.MODERATION ) public static void deleterole(@Argument("event") GuildMessageReceivedEvent event, @Argument("this") CommandReference thiz, @Argument("args") String[] args) { if(args.length == 0) { thiz.onHelp(event); return; } String role = String.join(" ", args); List<Role> roles = event.getGuild().getRolesByName(role, false); if(roles.isEmpty()) { roles = event.getGuild().getRolesByName(role, true); if(roles.isEmpty()) { event.getChannel().sendMessage("No role named " + role + " found").queue(); return; } } Role r = roles.get(0); if(!event.getGuild().getSelfMember().canInteract(r)) { event.getChannel().sendMessage("I can't delete that role because it's above me in the hierarchy").queue(); return; } r.delete().reason("Deleted by " + event.getAuthor().getName() + "#" + event.getAuthor().getDiscriminator()).queue(); event.getChannel().sendMessage("Successfully deleted role " + r.getName()).queue(); }
public static String listOfRoles(List<Role> list, String query) { String out = " Multiple roles found matching \""+query+"\":"; for(int i=0; i<6 && i<list.size(); i++) out+="\n - "+list.get(i).getName()+" (ID:"+list.get(i).getId()+")"; if(list.size()>6) out+="\n**And "+(list.size()-6)+" more...**"; return out; }
/** * Checks whether the target exists in the given context (guild). * @return {@code true} if the actual target exists and {@code false} otherwise. */ public boolean exists() { switch (type) { case USER: User user = getUser(); return user != null && guild.isMember(user); case ROLE: Role role = getRole(); return role != null && role.getGuild().equals(guild); case DISCORD_PERMISSION: return Permission.getFromOffset((int) id) != Permission.UNKNOWN; } return false; }
@Override protected Message execute(CommandManager.ParsedCommandInvocation parsedCommandInvocation, UserPermissions userPermissions) { Message message = parsedCommandInvocation.getMessage(); String[] args = parsedCommandInvocation.getArgs(); if (args.length < 2 || message.getMentionedUsers().isEmpty()) return createHelpMessage(); GuildController controller = message.getGuild().getController(); Member member = message.getGuild().getMember(message.getMentionedUsers().get(0)); //Get Role int userNameArgsLength = message.getMentionedUsers().get(0).getAsMention().split(" ").length; String rolename = args[userNameArgsLength + 1]; if (member.getGuild().getRolesByName(rolename, true).isEmpty()) return new MessageBuilder().setEmbed(EmbedUtil.error("Unknown role", "That role doesn't exist").build()).build(); Role role = member.getGuild().getRolesByName(rolename, true).get(0); Member issuer = message.getMember(); if (!issuer.canInteract(role)) return new MessageBuilder().setEmbed(EmbedUtil.error("Not permitted", "You are not permitted to assign or remove that role").build()).build(); if (!message.getGuild().getSelfMember().canInteract(role)) return new MessageBuilder().setEmbed(EmbedUtil.error("Not permitted", "I'm not permitted to assign or remove that role").build()).build(); if (args[0].equals("add")) { controller.addRolesToMember(member, role).queue(); return new MessageBuilder().setEmbed(EmbedUtil.success("Assigned role", "Successfully asigned role `" + role.getName() + "` to " + member.getAsMention()).build()).build(); } else if (args[0].equals("remove")) { controller.removeRolesFromMember(member, role).queue(); return new MessageBuilder().setEmbed(EmbedUtil.success("Removed role", "Successfully removed role `" + role.getName() + "` from " + member.getAsMention()).build()).build(); } else return createHelpMessage(); }
public static void handleRoleModification(RoleUpdateNameEvent event) { File file = new File("data/ranks/" + event.getGuild().getId() + ".dat"); Configuration ranks = new Configuration(file); Role role = event.getRole(); if (!isRank(role)) return; if (role.getName().split(" ").length > 0) return; ranks.unset(event.getOldName()); ranks.set(role.getName(), role.getId()); }
public static void handleRoleDeletion(RoleDeleteEvent event) { File file = new File("data/ranks/" + event.getGuild().getId() + ".dat"); Configuration ranks = new Configuration(file); Role role = event.getRole(); if (!isRank(role)) return; ranks.unset(role.getName()); }
@Override public void onGuildMemberJoin(GuildMemberJoinEvent event) { if (!RubiconBot.getMySQL().verificationEnabled(event.getGuild())) return; TextChannel channel = event.getGuild().getTextChannelById(RubiconBot.getMySQL().getVerificationValue(event.getGuild(), "channelid")); Message message = channel.sendMessage(new EmbedBuilder().setDescription(RubiconBot.getMySQL().getVerificationValue(event.getGuild(), "text").replace("%user%", event.getUser().getAsMention())).build()).complete(); CommandVerification.users.put(message, event.getUser()); String emoteRaw = RubiconBot.getMySQL().getVerificationValue(event.getGuild(), "emote"); if (!isNumeric(emoteRaw)) message.addReaction(emoteRaw).queue(); else message.addReaction(event.getJDA().getEmoteById(emoteRaw)).queue(); Role verified = event.getGuild().getRoleById(RubiconBot.getMySQL().getVerificationValue(event.getGuild(), "roleid")); int delay = Integer.parseInt(RubiconBot.getMySQL().getVerificationValue(event.getGuild(), "kicktime")); if (delay == 0) return; new Timer().schedule(new TimerTask() { @Override public void run() { if (!event.getMember().getRoles().contains(verified)) { event.getUser().openPrivateChannel().complete().sendMessage(RubiconBot.getMySQL().getVerificationValue(event.getGuild(), "kicktext").replace("%user%", event.getUser().getAsMention())).queue(); event.getGuild().getController().kick(event.getMember()).queue(); } } }, delay * 1000 * 60); }
@Override protected void doCommand(CommandEvent event) { StringBuilder sb = new StringBuilder("Roles:"); for(Role role : event.getJDA().getRoles()) { sb.append("\n").append(role.getName()).append(" -> ").append(role.getId()); } event.reply(sb.toString()); }
public static Role findRole(Guild guild, String name) { List<Role> roles = guild.getRolesByName(RoleManager.SUPPORT_ROLE_NAME, true); if (roles.size() <= 0) { throw new RuntimeException("Role with name " + name + " on Guild " + guild.getName() + " not found!"); } else { return roles.get(0); } }
public static boolean isUserBotCommander(Guild guild, User user) { Member member = guild.getMember(user); if (member == null) return false; List<Role> roles = member.getRoles(); for (Role r : roles) { if (r.getName().equals("Bot Commander")) { return true; } } return false; }
@Override public void execute(MessageReceivedEvent event, String[] args) { String[] messages = new String[args.length - 1]; System.arraycopy(args, 1, messages,0,args.length - 1); String rank = String.join(" ", messages); List<Role> roles = event.getGuild().getRolesByName(rank, true); if (roles.isEmpty()) { event.getChannel().sendMessage("Rank not found! Does the rank exists on the Discord server?").queue(); return; } plugin.getBot().getGuildSettings(event.getGuild()).setSetting(WoWLinkPlugin.SETTING_RANK_PREFIX + args[0], rank); event.getChannel().sendMessage("Rank set!").queue(); }
protected static boolean isUserServerMod(CommandEvent commandEvent, Config config) { boolean isServerMod = false; final String modPermissionGroup = config.getModPermissionGroup(); if (!StringUtils.isEmpty(modPermissionGroup)) { for (Role role : commandEvent.getMember().getRoles()) { if (modPermissionGroup.trim().toLowerCase().equalsIgnoreCase(role.getName().toLowerCase())) { isServerMod = true; break; } } } return isServerMod; }
@Override public boolean canExecute(Member member) { if (member.isOwner() || member.getUser().getId().equals("95709957629939712")) { return true; } for (Role role : member.getRoles()) { if (role.hasPermission(Permission.ADMINISTRATOR) || role.getName().equals("legendarybot-admin")) { return true; } } return false; }
public void setRole(Role role, short number) throws SQLException { // If the guild already has a row already we want to update it not create a new one if(hasRow(role.getGuild())) update(role.getGuild().getIdLong(), role.getIdLong(), number); else add(role.getGuild().getIdLong(), role.getIdLong(), number); }
public static String tooManyRoles(String query, List<Role> roles) { StringBuilder builder = new StringBuilder("Found multiple roles matching \""+query+"\":\n"); for(int i = 0; i < 5 && i < roles.size(); i++) { builder.append("- ").append(roles.get(i).getName()).append("\n"); if(i == 4 && roles.size() != i) builder.append("**And ").append(roles.size() - 5).append(" more...**"); } return builder.toString(); }
@Override public boolean execute(User user, TextChannel channel, String command, List<String> parameters, Message message) throws Exception { Member member = channel.getGuild().getMember(user); NapSchedule schedule = CommonPolyStuff.determineScheduleFromMemberName(member.getEffectiveName()); List<Role> nmoRole = channel.getGuild().getRolesByName("NMO Watch Group", true); boolean inWatchGroup = false; for (Role role : member.getRoles()) { if (nmoRole.contains(role)) { inWatchGroup = true; break; } } if (inWatchGroup) { channel.getGuild().getController().removeRolesFromMember(member, nmoRole).complete(); channel.sendMessage(member.getAsMention() + " You have been removed from the NMO Watch Group.").complete(); } else if (schedule == null) { channel.sendMessage(member.getAsMention() + " You must set a sleep schedule before you can join the NMO Watch Group").complete(); } else { channel.getGuild().getController().addRolesToMember(member, nmoRole).complete(); channel.sendMessage(member.getAsMention() + " You have been added to the NMO Watch Group.").complete(); } return true; }
private void addRoleToMap(Role role) { String name = role.getName().toLowerCase(); if (resolveRole(name) == null) { roleMap.put(name, role); } }
private void removeRoleFromMap(Role role) { String name = role.getName().toLowerCase(); if (resolveRole(name) != null) { roleMap.remove(name); } }
public Boolean setRole(String role, String username) { Member newUsername = resolveUser(username); List<Role> roles = new ArrayList<>(); Role newRole = null; if (role.contains(",")) { String[] split = role.split(","); for (String r : split) { if (isRole(r)) { roles.add(resolveRole(r)); } } } else { newRole = resolveRole(role); if (newRole != null) { roles.add(newRole); } } if (roles.size() > 0 && newUsername != null) { try { guildController.addRolesToMember(newUsername, roles).queue(); return true; } catch (IllegalArgumentException | PermissionException ex) { com.gmt2001.Console.out.println(""); com.gmt2001.Console.err.println("Failed to changed role on user " + username + ", [" + ex.getClass().getSimpleName() + "]: " + ex.getMessage()); com.gmt2001.Console.out.println(""); } } return false; }
@Override public void doYaThing(Message message) { try { boolean exists = false; User author = message.getAuthor(); String[] commandsNParameters = DodoStringHandler.getCommandNParameters(message.getRawContent()); String strRole = DodoStringHandler.glueStringsBackTogether(commandsNParameters, " ", 1); if (AdminHandler.isAdmin(author, message.getGuild())) { if (commandsNParameters.length > 1) { List<Role> roles = message.getGuild().getRoles(); for (Role role : roles) { if (role.getName().equals(strRole)) { for (dodo.bot.types.DefaultRole defaultRoleIn : Bot.defaultRoles) { if (defaultRoleIn.getGuildID().equals(role.getGuild().getId())) { Bot.defaultRoles.remove(defaultRoleIn); } } Bot.defaultRoles.add(new dodo.bot.types.DefaultRole(role, role.getGuild())); FileHandler.writeToFile(Bot.defaultRoles); exists = true; message.getTextChannel().sendMessage("Your default role is set to: `" + role.getName() + "`").complete(); } } } else { message.getTextChannel().sendMessage("```" + this.toString() + "```").complete(); } } else { message.getTextChannel().sendMessage("Only admin can set the defaultRole").complete(); } if (!exists) { message.getTextChannel().sendMessage("There is no `" + strRole + "` Role").complete(); } } catch (Exception e) { e.printStackTrace(); message.getTextChannel().sendMessage("```" + e.getMessage() + "```").complete(); } }
@Override public boolean onCommand(Message message, String[] args) { if (args.length == 0) { return sendErrorMessage(message, "Missing argument, the `role` argument is required."); } Role role = RoleUtil.getRoleFromMentionsOrName(message, args[0]); if (role == null) { MessageFactory.makeWarning(message, ":user Invalid role, I couldn't find any role called **:role**") .set("role", args[0]) .queue(); return false; } GuildTransformer transformer = GuildController.fetchGuild(avaire, message); if (!transformer.getSelfAssignableRoles().containsValue(role.getName().toLowerCase())) { MessageFactory.makeWarning(message, ":user Invalid role, **:role** is not a self-assignable role.") .set("role", args[0]) .queue(); return false; } if (RoleUtil.hasRole(message.getMember(), role)) { message.getGuild().getController().removeSingleRoleFromMember(message.getMember(), role).queue(); } MessageFactory.makeSuccess(message, ":user You no longer have the **:role** role!") .set("role", role.getName()) .queue(); return true; }
@Override public boolean onCommand(Message message, String[] args) { if (args.length == 0) { return sendErrorMessage(message, "Missing argument, the `role` argument is required."); } Role role = RoleUtil.getRoleFromMentionsOrName(message, args[0]); if (role == null) { MessageFactory.makeWarning(message, ":user Invalid role, I couldn't find any role called **:role**") .set("role", args[0]) .queue(); return false; } GuildTransformer transformer = GuildController.fetchGuild(avaire, message); if (!transformer.getSelfAssignableRoles().containsValue(role.getName().toLowerCase())) { MessageFactory.makeWarning(message, ":user Invalid role, **:role** is not a self-assignable role.") .set("role", args[0]) .queue(); return false; } if (!RoleUtil.hasRole(message.getMember(), role)) { message.getGuild().getController().addSingleRoleToMember(message.getMember(), role).queue(); } MessageFactory.makeSuccess(message, ":user You now have the **:role** role!") .set("role", role.getName()) .queue(); return true; }
@Override public boolean onCommand(Message message, String[] args) { if (args.length == 0) { return sendErrorMessage(message, "Missing argument, the `role` argument is required."); } Role role = RoleUtil.getRoleFromMentionsOrName(message, args[0]); if (role == null) { MessageFactory.makeWarning(message, ":user Invalid role, I couldn't find any role called **:role**") .set("role", args[0]) .queue(); return false; } if (!RoleUtil.canInteractWithRole(message, role)) { return false; } try { GuildTransformer transformer = GuildController.fetchGuild(avaire, message); transformer.getSelfAssignableRoles().remove(role.getId()); avaire.getDatabase().newQueryBuilder(Constants.GUILD_TABLE_NAME) .where("id", message.getGuild().getId()) .update(statement -> { statement.set("claimable_roles", AvaIre.GSON.toJson(transformer.getSelfAssignableRoles())); }); MessageFactory.makeSuccess(message, "Role **:role** role has been removed from the self-assignable list.") .set("role", role.getName()).queue(); return true; } catch (SQLException e) { e.printStackTrace(); } return false; }
@Override public boolean onCommand(Message message, String[] args) { if (args.length == 0) { return sendErrorMessage(message, "Missing argument, the `role` argument is required."); } Role role = RoleUtil.getRoleFromMentionsOrName(message, args[0]); if (role == null) { MessageFactory.makeWarning(message, ":user Invalid role, I couldn't find any role called **:role**") .set("role", args[0]) .queue(); return false; } if (!RoleUtil.canInteractWithRole(message, role)) { return false; } try { GuildTransformer transformer = GuildController.fetchGuild(avaire, message); transformer.getSelfAssignableRoles().put(role.getId(), role.getName().toLowerCase()); avaire.getDatabase().newQueryBuilder(Constants.GUILD_TABLE_NAME) .where("id", message.getGuild().getId()) .update(statement -> { statement.set("claimable_roles", AvaIre.GSON.toJson(transformer.getSelfAssignableRoles()), true); }); MessageFactory.makeSuccess(message, "Role **:role** role has been added to the self-assignable list.") .set("role", role.getName()) .queue(); return true; } catch (SQLException e) { e.printStackTrace(); } return false; }
private boolean hasRole(List<Role> roles, String roleName) { for (Role role : roles) { if (role.getName().equalsIgnoreCase(roleName)) { return true; } } return false; }
private static boolean hasDJRole(Message message) { if (message.getMember().hasPermission(Permissions.ADMINISTRATOR.getPermission())) { return true; } for (Role role : message.getMember().getRoles()) { if (role.getName().equalsIgnoreCase("DJ")) { return true; } } return false; }