Search in sources :

Example 66 with OptionMapping

use of net.dv8tion.jda.api.interactions.commands.OptionMapping in project Ree6 by Ree6-Applications.

the class Slap method onPerform.

@Override
public void onPerform(CommandEvent commandEvent) {
    if (commandEvent.isSlashCommand()) {
        OptionMapping targetOption = commandEvent.getSlashCommandInteractionEvent().getOption("target");
        if (targetOption != null && targetOption.getAsMember() != null) {
            sendSlap(targetOption.getAsMember(), commandEvent);
        } else {
            sendMessage("No User was given to Slap!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
        }
    } else {
        if (commandEvent.getArguments().length == 1) {
            if (commandEvent.getMessage().getMentionedMembers().isEmpty()) {
                sendMessage("No User mentioned!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
                sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "slap @user", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
            } else {
                sendSlap(commandEvent.getMessage().getMentionedMembers().get(0), commandEvent);
            }
        } else {
            sendMessage("Not enough Arguments!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
            sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "slap @user", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
        }
    }
}
Also used : OptionMapping(net.dv8tion.jda.api.interactions.commands.OptionMapping)

Example 67 with OptionMapping

use of net.dv8tion.jda.api.interactions.commands.OptionMapping in project Ree6 by Ree6-Applications.

the class Hug method onPerform.

@Override
public void onPerform(CommandEvent commandEvent) {
    if (commandEvent.isSlashCommand()) {
        OptionMapping targetOption = commandEvent.getSlashCommandInteractionEvent().getOption("target");
        if (targetOption != null && targetOption.getAsMember() != null) {
            sendHug(targetOption.getAsMember(), commandEvent);
        } else {
            sendMessage("No User was given to Hug!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
        }
    } else {
        if (commandEvent.getArguments().length == 1) {
            if (commandEvent.getMessage().getMentionedMembers().isEmpty()) {
                sendMessage("No User mentioned!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
                sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "hug @user", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
            } else {
                sendHug(commandEvent.getMessage().getMentionedMembers().get(0), commandEvent);
            }
        } else {
            sendMessage("Not enough Arguments!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
            sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "hug @user", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
        }
    }
}
Also used : OptionMapping(net.dv8tion.jda.api.interactions.commands.OptionMapping)

Example 68 with OptionMapping

use of net.dv8tion.jda.api.interactions.commands.OptionMapping in project Ree6 by Ree6-Applications.

the class Ban method onPerform.

@Override
public void onPerform(CommandEvent commandEvent) {
    if (commandEvent.getMember().hasPermission(Permission.ADMINISTRATOR)) {
        if (commandEvent.isSlashCommand()) {
            OptionMapping targetOption = commandEvent.getSlashCommandInteractionEvent().getOption("target");
            OptionMapping reasonOption = commandEvent.getSlashCommandInteractionEvent().getOption("reason");
            if (targetOption != null) {
                if (reasonOption != null) {
                    banMember(targetOption.getAsMember(), reasonOption.getAsString(), commandEvent);
                } else {
                    banMember(targetOption.getAsMember(), null, commandEvent);
                }
            } else {
                sendMessage("No User was given to Ban!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
            }
        } else {
            if (commandEvent.getArguments().length > 0) {
                if (commandEvent.getMessage().getMentionedMembers().isEmpty()) {
                    sendMessage("No User mentioned!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
                    sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "ban @user", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
                } else {
                    if (commandEvent.getArguments().length == 1) {
                        banMember(commandEvent.getMessage().getMentionedMembers().get(0), null, commandEvent);
                    } else {
                        StringBuilder reason = new StringBuilder();
                        for (int i = 1; i < commandEvent.getArguments().length; i++) {
                            reason.append(commandEvent.getArguments()[i]).append(" ");
                        }
                        banMember(commandEvent.getMessage().getMentionedMembers().get(0), reason.toString(), commandEvent);
                    }
                }
            } else {
                sendMessage("Not enough Arguments!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
                sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "ban @user [reason]", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
            }
        }
    } else {
        sendMessage("You don't have the Permission for this Command!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
    }
    deleteMessage(commandEvent.getMessage(), commandEvent.getInteractionHook());
}
Also used : OptionMapping(net.dv8tion.jda.api.interactions.commands.OptionMapping)

Example 69 with OptionMapping

use of net.dv8tion.jda.api.interactions.commands.OptionMapping in project Ree6 by Ree6-Applications.

the class Clear method onPerform.

@Override
public void onPerform(CommandEvent commandEvent) {
    if (commandEvent.getMember().hasPermission(Permission.ADMINISTRATOR)) {
        if (commandEvent.isSlashCommand()) {
            OptionMapping amountOption = commandEvent.getSlashCommandInteractionEvent().getOption("amount");
            if (amountOption != null) {
                deleteMessages(commandEvent, (int) amountOption.getAsDouble());
            }
        } else {
            if (commandEvent.getArguments().length == 1) {
                try {
                    int amount = Integer.parseInt(commandEvent.getArguments()[0]);
                    if (amount <= 100 && amount >= 2) {
                        deleteMessages(commandEvent, amount);
                    } else {
                        sendMessage(commandEvent.getArguments()[0] + " isn't between 2 and 100 !", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
                        sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "clear 2-100", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
                    }
                } catch (Exception ex) {
                    sendMessage(commandEvent.getArguments()[0] + " isn't a number!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
                    sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "clear 2-100", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
                }
            } else {
                sendMessage("Not enough Arguments!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
                sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "clear 2-100", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
            }
        }
    } else {
        sendMessage("You don't have the Permission for this Command!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
    }
}
Also used : OptionMapping(net.dv8tion.jda.api.interactions.commands.OptionMapping)

Example 70 with OptionMapping

use of net.dv8tion.jda.api.interactions.commands.OptionMapping in project Ree6 by Ree6-Applications.

the class Twitter method onPerform.

@Override
public void onPerform(CommandEvent commandEvent) {
    if (commandEvent.isSlashCommand()) {
        OptionMapping targetOption = commandEvent.getSlashCommandInteractionEvent().getOption("target");
        OptionMapping contentOption = commandEvent.getSlashCommandInteractionEvent().getOption("content");
        if (targetOption != null && contentOption != null) {
            sendTwitterTweet(targetOption.getAsMember(), contentOption.getAsString(), commandEvent);
        } else {
            if (targetOption == null)
                sendMessage("No User was given to use for the Tweet!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
            if (contentOption == null)
                sendMessage("No Tweet Content was given!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
        }
    } else {
        if (commandEvent.getArguments().length >= 2) {
            if (commandEvent.getMessage().getMentionedMembers().isEmpty()) {
                sendMessage("No User given!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
            } else {
                StringBuilder stringBuilder = new StringBuilder();
                for (int i = 1; i < commandEvent.getArguments().length; i++) {
                    stringBuilder.append(commandEvent.getArguments()[i]).append(" ");
                }
                sendTwitterTweet(commandEvent.getMessage().getMentionedMembers().get(0), stringBuilder.toString(), commandEvent);
            }
        } else {
            sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "twitter @User Yourtexthere", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
        }
    }
}
Also used : OptionMapping(net.dv8tion.jda.api.interactions.commands.OptionMapping)

Aggregations

OptionMapping (net.dv8tion.jda.api.interactions.commands.OptionMapping)133 CommandException (uwu.narumi.tama.command.CommandException)44 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)12 Member (net.dv8tion.jda.api.entities.Member)8 TextChannel (net.dv8tion.jda.api.entities.TextChannel)8 Guild (net.dv8tion.jda.api.entities.Guild)5 Meeting (de.lightbolt.meeting.systems.meeting.model.Meeting)4 User (net.dv8tion.jda.api.entities.User)4 SlashCommandInteractionEvent (net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent)4 Message (net.dv8tion.jda.api.entities.Message)3 JamSubmissionRepository (net.javadiscord.javabot.systems.jam.dao.JamSubmissionRepository)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 Bean (at.xirado.bean.Bean)2 SlashCommand (at.xirado.bean.command.SlashCommand)2 SlashCommandContext (at.xirado.bean.command.SlashCommandContext)2 EmbedUtil (at.xirado.bean.misc.EmbedUtil)2 ApplicationOptionData (com.freya02.botcommands.internal.ApplicationOptionData)2 EventWaiter (com.jagrosh.jdautilities.commons.waiter.EventWaiter)2 AudioPlayer (com.sedmelluq.discord.lavaplayer.player.AudioPlayer)2