net.dv8tion.jda.api.entities.TextChannel Java Examples

The following examples show how to use net.dv8tion.jda.api.entities.TextChannel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: SkyBot   Author: DuncteBot   File: PurgeChannelCommand.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void execute(@Nonnull CommandContext ctx) {
    final List<TextChannel> channels = FinderUtil.findTextChannels(ctx.getArgsRaw(), ctx.getGuild());

    if (channels.isEmpty()) {
        this.sendUsageInstructions(ctx);
        return;
    }

    final TextChannel toPurge = channels.get(0);

    if (toPurge.equals(ctx.getChannel())) {
        sendMsg(ctx, "For security reasons you can not use this command in the channel that you want to purge");
        return;
    }

    toPurge.createCopy()
        .setPosition(toPurge.getPosition())
        .queue(
            (success) -> {
                toPurge.delete().queue();
                sendSuccess(ctx.getMessage());
            },
            (error) -> sendError(ctx.getMessage())
        );
}
 
Example #2
Source Project: lavaplayer   Author: sedmelluq   File: MusicController.java    License: Apache License 2.0 6 votes vote down vote up
@BotCommandHandler
private void deserialize(Message message, String content) throws IOException {
  outputChannel.set((TextChannel) message.getChannel());
  connectToFirstVoiceChannel(guild.getAudioManager());

  byte[] bytes = Base64.decode(content);

  MessageInput inputStream = new MessageInput(new ByteArrayInputStream(bytes));
  DecodedTrackHolder holder;

  while ((holder = manager.decodeTrack(inputStream)) != null) {
    if (holder.decodedTrack != null) {
      scheduler.addToQueue(holder.decodedTrack);
    }
  }
}
 
Example #3
Source Project: JuniperBot   Author: JuniperBot   File: MessageController.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void doForMessage(Consumer<? super Message> success, Consumer<? super Throwable> error) {
    TextChannel channel = jda.getTextChannelById(channelId);
    if (channel != null) {
        channel.retrieveMessageById(messageId).queue(
                m -> contextService.withContext(guildId, () -> {
                    if (success != null) {
                        success.accept(m);
                    }
                }),
                t -> contextService.withContext(guildId, () -> {
                    if (error != null) {
                        error.accept(t);
                    }
                }));
    }
}
 
Example #4
Source Project: MantaroBot   Author: Mantaro   File: InvestigateCmd.java    License: GNU General Public License v3.0 6 votes vote down vote up
private static void investigateChannel(GuildMessageReceivedEvent event, TextChannel channel, boolean file) {
    if (channel == null) {
        event.getChannel().sendMessage("Unknown channel").queue();
        return;
    }
    Investigation investigation = new Investigation(file);
    channel.getIterableHistory().takeAsync(200)
            .thenAccept(messages -> {
                List<InvestigatedMessage> res = investigation.get(channel);
                messages.forEach(m -> res.add(0, InvestigatedMessage.from(m)));
            })
            .thenRun(() -> investigation.result(channel.getGuild(), event))
            .exceptionally(e -> {
                e.printStackTrace();
                event.getChannel().sendMessage("Unable to execute: " + e).queue();
                return null;
            });
}
 
Example #5
Source Project: JuniperBot   Author: JuniperBot   File: SlowModeCommand.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean doCommand(GuildMessageReceivedEvent event, BotContext context, String query) {
    TextChannel channel = event.getChannel();
    if (!StringUtils.isNumeric(query)) {
        return showHelp(channel, context);
    }

    int seconds;
    try {
        seconds = Integer.parseInt(query);
    } catch (NumberFormatException e) {
        return showHelp(channel, context);
    }
    if (seconds < 0 || seconds > 120) {
        return showHelp(channel, context);
    }

    channel.sendTyping().queue();
    channel.getManager().setSlowmode(seconds).queue(e -> contextService.withContext(channel.getGuild(), () -> {
        if (seconds > 0) {
            String secPlurals = messageService.getCountPlural(seconds, "discord.plurals.second");
            messageService.onEmbedMessage(channel, "discord.command.mod.slow.enabled", seconds,
                    secPlurals);
        } else {
            messageService.onEmbedMessage(channel, "discord.command.mod.slow.disabled");
        }
    }));
    return true;
}
 
Example #6
Source Project: JuniperBot   Author: JuniperBot   File: CheckOwnerQueueListener.java    License: GNU General Public License v3.0 6 votes vote down vote up
@RabbitListener(queues = RabbitConfiguration.QUEUE_CHECK_OWNER_REQUEST)
public boolean isAdministrator(CheckOwnerRequest request) {
    Guild guild = null;
    switch (request.getType()) {
        case TEXT:
            TextChannel textChannel = discordService.getTextChannelById(request.getChannelId());
            if (textChannel != null) {
                guild = textChannel.getGuild();
            }
            break;
        case VOICE:
            VoiceChannel voiceChannel = discordService.getVoiceChannelById(request.getChannelId());
            if (voiceChannel != null) {
                guild = voiceChannel.getGuild();
            }
            break;
    }
    if (guild == null) {
        return true;
    }
    Member member = guild.getMemberById(request.getUserId());
    if (member == null) {
        return false;
    }
    return member.isOwner() || member.hasPermission(Permission.ADMINISTRATOR);
}
 
Example #7
Source Project: JuniperBot   Author: JuniperBot   File: HistoryServiceImpl.java    License: GNU General Public License v3.0 6 votes vote down vote up
private StringEncryptor getEncryptor(TextChannel channel, String iv) {
    StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
    encryptor.setAlgorithm("PBEWithHMACSHA512AndAES_256");
    encryptor.setPassword(String.format("%s:%s", channel.getGuild().getId(), channel.getId()));
    encryptor.setIvGenerator(new StringFixedIvGenerator(iv));
    return encryptor;
}
 
Example #8
Source Project: SkyBot   Author: DuncteBot   File: SettingsBase.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@Nullable
protected TextChannel findTextChannel(@Nonnull CommandContext ctx) {
    final List<TextChannel> foundChannels = FinderUtil.findTextChannels(ctx.getArgsRaw(), ctx.getGuild());

    if (foundChannels.isEmpty()) {
        return null;
    }

    return foundChannels.stream()
        .filter(TextChannel::canTalk)
        .findFirst()
        .orElse(null);
}
 
Example #9
Source Project: SkyBot   Author: DuncteBot   File: SettingsCommand.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void execute(@Nonnull CommandContext ctx) {
    final DunctebotGuild guild = ctx.getGuild();
    final GuildSettings settings = guild.getSettings();
    final TextChannel logChan = AirUtils.getLogChannel(settings.getLogChannel(), guild);
    final TextChannel welcomeLeaveChannel = AirUtils.getLogChannel(settings.getWelcomeLeaveChannel(), guild);
    final Role autoRole = guild.getRoleById(settings.getAutoroleRole());
    final Role muteRole = guild.getRoleById(settings.getMuteRoleId());

    final EmbedBuilder message = EmbedUtils.embedMessage("Here are the settings from this guild.\n" +
        "**Show join/leave messages:** " + toEmoji(settings.isEnableJoinMessage()) + "\n" +
        "**Swearword filter:** " + toEmoji(settings.isEnableSwearFilter()) + "\n" +
        "**Announce next track:** " + toEmoji(settings.isAnnounceTracks()) + "\n" +
        "**Auto de-hoist:** " + toEmoji(settings.isAutoDeHoist()) + "\n" +
        "**Filter Discord invites:** " + toEmoji(settings.isFilterInvites()) + "\n" +
        "**Spamfilter:** " + toEmoji(settings.isEnableSpamFilter()) + "\n" +
        "**Kick Mode:** " + (settings.getKickState() ? "Kick Members" : "Mute members") + "\n" +

        "**MuteRole:** " + (settings.getMuteRoleId() <= 0
        ? "Not Set" : (muteRole == null ? "Not set" : muteRole.getAsMention())) + "\n" +

        "**Join message:** " + settings.getCustomJoinMessage() + "\n" +
        "**Leave message:** " + settings.getCustomLeaveMessage() + "\n" +

        "**AutoRole:** " + (settings.getAutoroleRole() <= 0
        ? "Not Set" : (autoRole == null ? "Not Set" : autoRole.getAsMention())) + "\n" +

        "**Current prefix:** " + settings.getCustomPrefix() + "\n" +
        "**Modlog Channel:** " + (logChan == null ? "Not set" : logChan.getAsMention()) + "\n" +
        "**Welcome/Leave channel:** " + (welcomeLeaveChannel == null ? "Not set" : welcomeLeaveChannel.getAsMention()) + "\n" +
        "**Embed color code:** " + guild.getHexColor()
    );

    sendEmbed(ctx.getEvent(), message);
}
 
Example #10
Source Project: SkyBot   Author: DuncteBot   File: SetLogChannelCommand.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void execute(@Nonnull CommandContext ctx) {
    if (ctx.getArgs().isEmpty()) {
        this.sendUsageInstructions(ctx);
        return;
    }

    final String in = ctx.getArgsJoined();

    if ("null".equalsIgnoreCase(in) || "none".equalsIgnoreCase(in) ||
        "off".equalsIgnoreCase(in) || "disable".equalsIgnoreCase(in)) {
        ctx.getGuild().setSettings(ctx.getGuildSettings().setLogChannel(0L));
        sendMsg(ctx.getEvent(), "Logging has been turned off");
        return;
    }

    final TextChannel channel = findTextChannel(ctx);

    if (channel == null) {
        sendMsg(ctx.getEvent(), "I could not found a text channel for your query.\n" +
            "Make sure that it's a valid channel that I can speak in");
        return;
    }

    ctx.getGuild().setSettings(ctx.getGuildSettings().setLogChannel(channel.getIdLong()));
    sendMsg(ctx.getEvent(), "The new log channel has been set to " + channel.getAsMention());
}
 
Example #11
Source Project: SkyBot   Author: DuncteBot   File: CleanupCommand.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
private void removeMessage(TextChannel channel, CompletableFuture<Message> hack) {
    try {
        final Message hacked = hack.get();

        if (hacked != null) {
            channel.deleteMessageById(hacked.getIdLong()).queue();
        }
    }
    catch (InterruptedException | ExecutionException e) {
        e.printStackTrace();
    }
}
 
Example #12
Source Project: JDA   Author: DV8FromTheWorld   File: WebhookManagerImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
@CheckReturnValue
public WebhookManagerImpl setChannel(@Nonnull TextChannel channel)
{
    Checks.notNull(channel, "Channel");
    Checks.check(channel.getGuild().equals(getGuild()), "Channel is not from the same guild");
    this.channel = channel.getId();
    set |= CHANNEL;
    return this;
}
 
Example #13
Source Project: SkyBot   Author: DuncteBot   File: ImageCommandBase.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public void handleBasicImage(GuildMessageReceivedEvent event, byte[] image) {
    final TextChannel channel = event.getChannel();

    if (event.getGuild().getSelfMember().hasPermission(channel, Permission.MESSAGE_ATTACH_FILES)) {
        channel.sendFile(image, getFileName()).queue();
    } else {
        sendMsg(channel, "I need permission to upload files in order for this command to work.");
    }
}
 
Example #14
Source Project: SkyBot   Author: DuncteBot   File: CommandManager.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public void dispatchCommand(@Nonnull ICommand cmd, String invoke, List<String> args, GuildMessageReceivedEvent event) {
    this.commandThread.submit(() -> {
        MDC.put("command.invoke", invoke);
        MDC.put("command.args", args.toString());
        MDC.put("user.tag", event.getAuthor().getAsTag());
        MDC.put("user.id", event.getAuthor().getId());
        MDC.put("guild", event.getGuild().toString());
        setJDAContext(event.getJDA());

        final TextChannel channel = event.getChannel();

        if (!channel.canTalk()) {
            return;
        }

        // Suppress errors from when we can't type in the channel
        channel.sendTyping().queue(null, (t) -> {});

        try {
            if (!cmd.isCustom()) {
                runNormalCommand(cmd, invoke, args, event);
            } else {
                runCustomCommand(cmd, invoke, args, event);
            }
        }
        catch (Throwable ex) {
            Sentry.capture(ex);
            ex.printStackTrace();
            sendMsg(event, "Something went wrong whilst executing the command, my developers have been informed of this\n" + ex.getMessage());
        }
    });
}
 
Example #15
Source Project: lavaplayer   Author: sedmelluq   File: Main.java    License: Apache License 2.0 5 votes vote down vote up
private void loadAndPlay(final TextChannel channel, final String trackUrl) {
  GuildMusicManager musicManager = getGuildAudioPlayer(channel.getGuild());

  playerManager.loadItemOrdered(musicManager, trackUrl, new AudioLoadResultHandler() {
    @Override
    public void trackLoaded(AudioTrack track) {
      channel.sendMessage("Adding to queue " + track.getInfo().title).queue();

      play(channel.getGuild(), musicManager, track);
    }

    @Override
    public void playlistLoaded(AudioPlaylist playlist) {
      AudioTrack firstTrack = playlist.getSelectedTrack();

      if (firstTrack == null) {
        firstTrack = playlist.getTracks().get(0);
      }

      channel.sendMessage("Adding to queue " + firstTrack.getInfo().title + " (first track of playlist " + playlist.getName() + ")").queue();

      play(channel.getGuild(), musicManager, firstTrack);
    }

    @Override
    public void noMatches() {
      channel.sendMessage("Nothing found by " + trackUrl).queue();
    }

    @Override
    public void loadFailed(FriendlyException exception) {
      channel.sendMessage("Could not play: " + exception.getMessage()).queue();
    }
  });
}
 
Example #16
Source Project: SkyBot   Author: DuncteBot   File: JSONMessageErrorsHelper.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public static void sendErrorJSON(Message message, Throwable error, final boolean print, ObjectMapper mapper) {
    if (print) {
        logger.error(error.getLocalizedMessage(), error);
    }

    //Makes no difference if we use sendError or check here both perm types
    if (message.getChannelType() == ChannelType.TEXT) {
        final TextChannel channel = message.getTextChannel();
        if (!channel.getGuild().getSelfMember().hasPermission(channel, Permission.MESSAGE_READ,
            Permission.MESSAGE_WRITE, Permission.MESSAGE_ATTACH_FILES, Permission.MESSAGE_ADD_REACTION)) {
            return;
        }
    }

    message.addReaction(MessageUtils.getErrorReaction()).queue(null, (ignored) -> {});

    try {
        message.getChannel()
            .sendFile(
                mapper.writerWithDefaultPrettyPrinter()
                    .writeValueAsBytes(EarthUtils.throwableToJSONObject(error, mapper)),
                "error.json"
            ).embed(
            defaultEmbed().setTitle("We got an error!")
                .setDescription(String.format("Error type: %s",
                    error.getClass().getSimpleName())).build()
        ).queue();
    }
    catch (JsonProcessingException e) {
        sendMsg(message.getTextChannel(), "Error while sending file: " + e);
    }
}
 
Example #17
Source Project: JDA   Author: DV8FromTheWorld   File: GuildManagerImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
@CheckReturnValue
public GuildManagerImpl setSystemChannel(TextChannel systemChannel)
{
    Checks.check(systemChannel == null || systemChannel.getGuild().equals(getGuild()), "Channel must be from the same guild");
    this.systemChannel = systemChannel == null ? null : systemChannel.getId();
    set |= SYSTEM_CHANNEL;
    return this;
}
 
Example #18
Source Project: JDA   Author: DV8FromTheWorld   File: MessageReactionBulkRemoveHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Long handleInternally(DataObject content)
{
    final long messageId = content.getLong("message_id");
    final long channelId = content.getLong("channel_id");
    JDAImpl jda = getJDA();
    TextChannel channel = jda.getTextChannelById(channelId);
    if (channel == null)
    {
        jda.getEventCache().cache(EventCache.Type.CHANNEL, channelId, responseNumber, allContent, this::handle);
        EventCache.LOG.debug("Received a reaction for a channel that JDA does not currently have cached channel_id: {} message_id: {}", channelId, messageId);
        return null;
    }

    switch (channel.getType())
    {
        case TEXT:
           jda.handleEvent(
               new GuildMessageReactionRemoveAllEvent(
                   jda, responseNumber,
                   messageId, channel));
           break;
        case GROUP:
            WebSocketClient.LOG.error("Received a reaction bulk delete for a group which should not be possible");
            return null;
    }

    jda.handleEvent(
        new MessageReactionRemoveAllEvent(
            jda, responseNumber,
            messageId, channel));
    return null;
}
 
Example #19
Source Project: JuniperBot   Author: JuniperBot   File: MafiaInstance.java    License: GNU General Public License v3.0 5 votes vote down vote up
public MafiaInstance(@NonNull TextChannel channel, Locale locale, String prefix) {
    this.jda = channel.getJDA();
    this.channelId = channel.getIdLong();
    this.guildId = channel.getGuild().getIdLong();
    this.locale = locale;
    this.prefix = prefix;
    tick();
}
 
Example #20
Source Project: JuniperBot   Author: JuniperBot   File: ChoiceStateHandler.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected void outPlayer(MafiaInstance instance, MafiaPlayer player) {
    player.out();
    TextChannel goonChannel = instance.getGoonChannel();
    if (player.getRole() == MafiaRole.GOON && goonChannel != null) {
        Member member = player.getMember();
        if (member != null) {
            PermissionOverride override = goonChannel.getPermissionOverride(player.getMember());
            override.delete().queue();
        }
    }
}
 
Example #21
Source Project: JuniperBot   Author: JuniperBot   File: ChoiceStateHandler.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void unpinMessage(MafiaInstance instance) {
    String messageId = (String) instance.removeAttribute(ATTR_MESSAGE_ID + instance.getState().name());
    if (messageId == null) {
        return;
    }
    TextChannel channel = instance.getState() == MafiaState.DAY ? instance.getChannel() : instance.getGoonChannel();
    if (channel != null && channel.getGuild().getSelfMember().hasPermission(channel, Permission.MESSAGE_MANAGE)) {
        channel.unpinMessageById(messageId).queue();
    }
}
 
Example #22
Source Project: JuniperBot   Author: JuniperBot   File: MafiaService.java    License: GNU General Public License v3.0 5 votes vote down vote up
public boolean start(User user, TextChannel guild) {
    if (instances.containsKey(guild.getIdLong())) {
        return false;
    }
    MafiaInstance instance = getInstance(guild);
    return !choosingHandler.onStart(user, instance);
}
 
Example #23
Source Project: JuniperBot   Author: JuniperBot   File: MafiaService.java    License: GNU General Public License v3.0 5 votes vote down vote up
public boolean stop(Member requestedBy, TextChannel channel) {
    MafiaInstance instance = getRelatedInstance(channel.getIdLong());
    if (instance == null || !(instance.getState().equals(MafiaState.CHOOSING)
            || instance.isPlayer(requestedBy)
            || moderationService.isModerator(requestedBy))) {
        return false;
    }
    stop(instance);
    return true;
}
 
Example #24
Source Project: JuniperBot   Author: JuniperBot   File: MafiaService.java    License: GNU General Public License v3.0 5 votes vote down vote up
public boolean done(User user, TextChannel guild) {
    MafiaInstance instance = getRelatedInstance(guild.getIdLong());
    if (instance == null || !instance.isPlayer(user)) {
        return false;
    }
    if (instance.done(user)) {
        stop(instance);
    }
    return true;
}
 
Example #25
Source Project: JuniperBot   Author: JuniperBot   File: IndividualHandler.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onStart(User user, MafiaInstance instance) {
    MafiaPlayer individual = instance.getPlayerByRole(individualRole);
    if (individual == null) {
        return getNextHandler().onStart(user, instance);
    }
    MafiaState oldState = instance.updateState(state);
    StringBuilder messageBuilder = new StringBuilder();
    if (oldState.getTransitionEnd() != null) {
        messageBuilder.append(messageService.getMessage(oldState.getTransitionEnd())).append(" ");
    }
    if (state.getTransitionStart() != null) {
        messageBuilder.append(messageService.getMessage(state.getTransitionStart()));
    }
    if (messageBuilder.length() > 0) {
        EmbedBuilder builder = getBaseEmbed();
        builder.setDescription(messageBuilder.toString());

        TextChannel channel = instance.getChannel();
        if (channel == null) {
            return true; // end for non existent channel instantly
        }
        channel.sendMessage(builder.build()).queue();
    }
    if (!sendChoiceMessage(instance, individualRole.getChoiceMessage())) {
        instance.setEndReason(messageService.getMessage("mafia.end.reason.couldNotDM",
                individual.getName()));
        return true;
    }
    return scheduleEnd(instance, INDIVIDUAL_DELAY);
}
 
Example #26
Source Project: JDA   Author: DV8FromTheWorld   File: GenericGuildMessageReactionEvent.java    License: Apache License 2.0 5 votes vote down vote up
public GenericGuildMessageReactionEvent(@Nonnull JDA api, long responseNumber, @Nullable Member user, @Nonnull MessageReaction reaction, long userId)
{
    super(api, responseNumber, reaction.getMessageIdLong(), (TextChannel) reaction.getChannel());
    this.issuer = user;
    this.reaction = reaction;
    this.userId = userId;
}
 
Example #27
Source Project: lavaplayer   Author: sedmelluq   File: MusicController.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void sendMessage(String message) {
  TextChannel channel = outputChannel.get();

  if (channel != null) {
    channel.sendMessage(message).queue();
  }
}
 
Example #28
Source Project: lavaplayer   Author: sedmelluq   File: MusicController.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void sendMessage(String message, Consumer<Message> success, Consumer<Throwable> failure) {
  TextChannel channel = outputChannel.get();

  if (channel != null) {
    channel.sendMessage(message).queue(success, failure);
  }
}
 
Example #29
Source Project: JDA   Author: DV8FromTheWorld   File: GenericTextChannelUpdateEvent.java    License: Apache License 2.0 5 votes vote down vote up
public GenericTextChannelUpdateEvent(
    @Nonnull JDA api, long responseNumber, @Nonnull TextChannel channel,
    @Nullable T previous, @Nullable T next, @Nonnull String identifier)
{
    super(api, responseNumber, channel);
    this.previous = previous;
    this.next = next;
    this.identifier = identifier;
}
 
Example #30
Source Project: JuniperBot   Author: JuniperBot   File: WebHookServiceImpl.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean updateWebHook(long id, long guildId, String channelId, String name, String iconUrl) {
    if (discordService.isConnected(guildId)) {
        Guild guild = discordService.getShardManager().getGuildById(guildId);
        if (guild != null && channelId != null) {
            Webhook webhook = getWebHook(id, guild);
            if (webhook != null) {
                checkWebhookChannel(webhook, channelId);
                return true;
            }
            TextChannel channel = guild.getTextChannelById(channelId);
            if (channel != null && guild.getSelfMember().hasPermission(channel, Permission.MANAGE_WEBHOOKS)) {
                channel.createWebhook(CommonUtils.trimTo(name, 2, 32))
                        .setAvatar(DiscordUtils.createIcon(iconUrl))
                        .queue(e -> {
                            checkWebhookChannel(e, channelId);
                            WebHook webHook = repository.findById(id).orElse(null);
                            if (webHook != null) {
                                webHook.setHookId(e.getIdLong());
                                webHook.setToken(e.getToken());
                                repository.save(webHook);
                            }
                        });
                webHooks.invalidate(guild);
            }
            return true;
        }
    }
    return false;
}