src/main/java/me/evyn/bot/commands/fun/Say.java
@Override
    public void run(MessageReceivedEvent event, String prefix, boolean embed, String[] args) {

        User botUser = event.getJDA().getSelfUser();

        // If message is not ran in guild, send error and return
        if (!event.isFromType(ChannelType.TEXT)) {
            EmbedBuilder eb = EmbedCreator.newErrorEmbedMessage(botUser,
                    "This command can only be ran in servers.");

            event.getChannel()
                    .sendMessage(eb.build())
                    .queue();
            return;
        }

        Member botMember = event.getGuild().getSelfMember();

        // check if bot has Manage Messages permissions
        if (botMember.hasPermission(Permission.MESSAGE_MANAGE)) {

            if (args.length > 0) {
                StringBuilder sb = new StringBuilder();

                // delete all occurrences of "@" and append arguments together
                Arrays.stream(args)
                        .forEach(arg -> {
                            arg = arg.replace("@", "");
                            sb.append(arg).append(" ");
                        });

                // send cleaned command arguments
                event.getChannel()
                        .sendMessage(sb.toString())
                        .queue();

                // delete original message
                event.getMessage()
                        .delete()
                        .queue();
            } else {
                // no command arguments present
                if (embed) {
                    EmbedBuilder eb = EmbedCreator.newErrorEmbedMessage(botUser, "Missing message. " +
                            "Try running `" + prefix + "usage say` for proper command usage.");

                    event.getChannel()
                            .sendMessage(eb.build())
                            .queue();
                    return;
                } else {
                    event.getChannel()
                            .sendMessage("ERROR: Missing message. " + "\n"
                                    + "Try running `" + prefix + "usage say` for proper command usage.")
                            .queue();
                    return;
                }

            }
        } else {
            // bot is missing manage messages
            if (embed) {
                EmbedBuilder eb = EmbedCreator.newErrorEmbedMessage(botUser, "The bot is missing the " +
                        "`Manage Messages` permission.");
                event.getChannel()
                        .sendMessage(eb.build())
                        .queue();
                return;
            } else {
                event.getChannel()
                        .sendMessage("ERROR: The bot is missing the `Manage Messages` permission.")
                        .queue();
            }
        }
    }
/**
     * If command is ran in guild, clean any mentions in command arguments and send cleaned content. Then delete
     * the original message
     * @param event Discord API message event
     * @param prefix Specific guild bot prefix
     * @param embed Guild embed setting
     * @param args Command arguments
     */
If command is ran in guild, clean any mentions in command arguments and send cleaned content. Then delete
the original message
@param event Discord API message event
@param prefix Specific guild bot prefix
@param embed Guild embed setting
@param args Command arguments
If command is ran in guild clean any mentions in command arguments and send cleaned content . Then delete the original message @param event Discord API message event @param prefix Specific guild bot prefix @param embed Guild embed setting @param args Command arguments
@Override
    public void run(MessageReceivedEvent event, String prefix, boolean embed, String[] args) {
        User botUser = event.getJDA().getSelfUser();
        if (!event.isFromType(ChannelType.TEXT)) {
            EmbedBuilder eb = EmbedCreator.newErrorEmbedMessage(botUser,
                    "This command can only be ran in servers.");
            event.getChannel()
                    .sendMessage(eb.build())
                    .queue();
            return;
        }
        Member botMember = event.getGuild().getSelfMember();
        if (botMember.hasPermission(Permission.MESSAGE_MANAGE)) {
            if (args.length > 0) {
                StringBuilder sb = new StringBuilder();
                Arrays.stream(args)
                        .forEach(arg -> {
                            arg = arg.replace("@", "");
                            sb.append(arg).append(" ");
                        });
                event.getChannel()
                        .sendMessage(sb.toString())
                        .queue();
                event.getMessage()
                        .delete()
                        .queue();
            } else {
                if (embed) {
                    EmbedBuilder eb = EmbedCreator.newErrorEmbedMessage(botUser, "Missing message. " +
                            "Try running `" + prefix + "usage say` for proper command usage.");
                    event.getChannel()
                            .sendMessage(eb.build())
                            .queue();
                    return;
                } else {
                    event.getChannel()
                            .sendMessage("ERROR: Missing message. " + "\n"
                                    + "Try running `" + prefix + "usage say` for proper command usage.")
                            .queue();
                    return;
                }
            }
        } else {
            if (embed) {
                EmbedBuilder eb = EmbedCreator.newErrorEmbedMessage(botUser, "The bot is missing the " +
                        "`Manage Messages` permission.");
                event.getChannel()
                        .sendMessage(eb.build())
                        .queue();
                return;
            } else {
                event.getChannel()
                        .sendMessage("ERROR: The bot is missing the `Manage Messages` permission.")
                        .queue();
            }
        }
    }
@ Override public void run ( MessageReceivedEvent event , String prefix , boolean embed , String [ ] args ) { User botUser = event . getJDA ( ) . getSelfUser ( ) ; if ( ! event . isFromType ( ChannelType . TEXT ) ) { EmbedBuilder eb = EmbedCreator . newErrorEmbedMessage ( botUser , "This command can only be ran in servers." ) ; event . getChannel ( ) . sendMessage ( eb . build ( ) ) . queue ( ) ; return ; } Member botMember = event . getGuild ( ) . getSelfMember ( ) ; if ( botMember . hasPermission ( Permission . MESSAGE_MANAGE ) ) { if ( args . length > 0 ) { StringBuilder sb = new StringBuilder ( ) ; Arrays . stream ( args ) . forEach ( arg -> { arg = arg . replace ( "@" , "" ) ; sb . append ( arg ) . append ( " " ) ; } ) ; event . getChannel ( ) . sendMessage ( sb . toString ( ) ) . queue ( ) ; event . getMessage ( ) . delete ( ) . queue ( ) ; } else { if ( embed ) { EmbedBuilder eb = EmbedCreator . newErrorEmbedMessage ( botUser , "Missing message. " + "Try running `" + prefix + "usage say` for proper command usage." ) ; event . getChannel ( ) . sendMessage ( eb . build ( ) ) . queue ( ) ; return ; } else { event . getChannel ( ) . sendMessage ( "ERROR: Missing message. " + "\n" + "Try running `" + prefix + "usage say` for proper command usage." ) . queue ( ) ; return ; } } } else { if ( embed ) { EmbedBuilder eb = EmbedCreator . newErrorEmbedMessage ( botUser , "The bot is missing the " + "`Manage Messages` permission." ) ; event . getChannel ( ) . sendMessage ( eb . build ( ) ) . queue ( ) ; return ; } else { event . getChannel ( ) . sendMessage ( "ERROR: The bot is missing the `Manage Messages` permission." ) . queue ( ) ; } } }
If command is ran in guild, clean any mentions in command arguments and send cleaned content.
If command is ran in guild clean any mentions in command arguments and send cleaned content .
// If message is not ran in guild, send error and return // check if bot has Manage Messages permissions // delete all occurrences of "@" and append arguments together // send cleaned command arguments // delete original message // no command arguments present // bot is missing manage messages