Search in sources :

Example 6 with OptionMapping

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

the class Mute method onPerform.

@Override
public void onPerform(CommandEvent commandEvent) {
    if (commandEvent.getMember().hasPermission(Permission.ADMINISTRATOR)) {
        if (!Main.getInstance().getSqlConnector().getSqlWorker().isMuteSetup(commandEvent.getGuild().getId())) {
            sendMessage("Mute Role hasn't been set!\nTo set it up type " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "setup mute @MuteRole !", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
            return;
        }
        if (commandEvent.isSlashCommand()) {
            OptionMapping targetOption = commandEvent.getSlashCommandInteractionEvent().getOption("target");
            if (targetOption != null) {
                muteMember(targetOption.getAsMember(), commandEvent);
            } else {
                sendMessage("No User was given to Mute!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
            }
        } else {
            if (commandEvent.getArguments().length == 1) {
                if (commandEvent.getMessage().getMentionedUsers().isEmpty()) {
                    sendMessage("No User mentioned!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
                    sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "mute @user", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
                } else {
                    muteMember(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() + "mute @user", 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 7 with OptionMapping

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

the class Volume method onPerform.

@Override
public void onPerform(CommandEvent commandEvent) {
    if (!Main.getInstance().getMusicWorker().isConnected(commandEvent.getGuild())) {
        sendMessage("Im not connected to any Channel, so there is nothing to set the volume for!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
    }
    if (!Main.getInstance().getMusicWorker().checkInteractPermission(commandEvent)) {
        return;
    }
    EmbedBuilder em = new EmbedBuilder();
    if (commandEvent.isSlashCommand()) {
        OptionMapping volumeOption = commandEvent.getSlashCommandInteractionEvent().getOption("amount");
        if (volumeOption != null) {
            int volume = (int) volumeOption.getAsDouble();
            Main.getInstance().getMusicWorker().getGuildAudioPlayer(commandEvent.getGuild()).player.setVolume(volume);
            em.setAuthor(BotInfo.botInstance.getSelfUser().getName(), Data.WEBSITE, BotInfo.botInstance.getSelfUser().getAvatarUrl());
            em.setTitle("Music Player!");
            em.setThumbnail(BotInfo.botInstance.getSelfUser().getAvatarUrl());
            em.setColor(Color.GREEN);
            em.setDescription("The Volume has been set to " + volume);
        } else {
            em.setAuthor(BotInfo.botInstance.getSelfUser().getName(), Data.WEBSITE, BotInfo.botInstance.getSelfUser().getAvatarUrl());
            em.setTitle("Music Player!");
            em.setThumbnail(BotInfo.botInstance.getSelfUser().getAvatarUrl());
            em.setColor(Color.RED);
            em.setDescription("No Volume was given.");
        }
    } else {
        if (commandEvent.getArguments().length == 1) {
            int vol;
            try {
                vol = Integer.parseInt(commandEvent.getArguments()[0]);
            } catch (Exception e) {
                vol = 50;
            }
            Main.getInstance().getMusicWorker().getGuildAudioPlayer(commandEvent.getGuild()).player.setVolume(vol);
            em.setAuthor(BotInfo.botInstance.getSelfUser().getName(), Data.WEBSITE, BotInfo.botInstance.getSelfUser().getAvatarUrl());
            em.setTitle("Music Player!");
            em.setThumbnail(BotInfo.botInstance.getSelfUser().getAvatarUrl());
            em.setColor(Color.GREEN);
            em.setDescription("The Volume has been set to " + vol);
        } else {
            em.setAuthor(BotInfo.botInstance.getSelfUser().getName(), Data.WEBSITE, BotInfo.botInstance.getSelfUser().getAvatarUrl());
            em.setTitle("Music Player!");
            em.setThumbnail(BotInfo.botInstance.getSelfUser().getAvatarUrl());
            em.setColor(Color.GREEN);
            em.setDescription("Type " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "volume [voulume]");
        }
    }
    em.setFooter(commandEvent.getGuild().getName() + " - " + Data.ADVERTISEMENT, commandEvent.getGuild().getIconUrl());
    sendMessage(em, 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
}
Also used : OptionMapping(net.dv8tion.jda.api.interactions.commands.OptionMapping) EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder)

Example 8 with OptionMapping

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

the class Kick method onPerform.

@Override
public void onPerform(CommandEvent commandEvent) {
    if (commandEvent.getMember().hasPermission(Permission.ADMINISTRATOR)) {
        if (commandEvent.isSlashCommand()) {
            OptionMapping targetOption = commandEvent.getSlashCommandInteractionEvent().getOption("target");
            if (targetOption != null) {
                kickMember(targetOption.getAsMember(), commandEvent);
            } else {
                sendMessage("No User was given to Kick!", 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() + "kick @user", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
                } else {
                    kickMember(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() + "kick @user", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
            }
        }
    } else {
        sendMessage("You dont 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 9 with OptionMapping

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

the class Prefix method onPerform.

@Override
public void onPerform(CommandEvent commandEvent) {
    if (commandEvent.getMember().hasPermission(Permission.ADMINISTRATOR) && commandEvent.getMember().hasPermission(Permission.MANAGE_SERVER)) {
        if (commandEvent.isSlashCommand()) {
            OptionMapping prefixOption = commandEvent.getSlashCommandInteractionEvent().getOption("new-prefix");
            if (prefixOption != null) {
                Main.getInstance().getSqlConnector().getSqlWorker().setSetting(commandEvent.getGuild().getId(), "chatprefix", prefixOption.getAsString());
                sendMessage("Your new Prefix has been set to: " + prefixOption.getAsString(), 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
            } else {
                sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "prefix PREFIX", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
            }
        } else {
            if (commandEvent.getArguments().length != 1) {
                sendMessage((commandEvent.getArguments().length < 1 ? "Not enough" : "Too many") + " Arguments!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
                sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "prefix PREFIX", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
            } else {
                Main.getInstance().getSqlConnector().getSqlWorker().setSetting(commandEvent.getGuild().getId(), "chatprefix", commandEvent.getArguments()[0]);
                sendMessage("Your new Prefix has been set to: " + commandEvent.getArguments()[0], 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 10 with OptionMapping

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

the class Unban method onPerform.

@Override
public void onPerform(CommandEvent commandEvent) {
    if (commandEvent.getMember().hasPermission(Permission.ADMINISTRATOR)) {
        if (commandEvent.isSlashCommand()) {
            OptionMapping targetOption = commandEvent.getSlashCommandInteractionEvent().getOption("id");
            if (targetOption != null) {
                commandEvent.getGuild().unban(targetOption.getAsString()).queue();
                sendMessage("User <@" + targetOption.getAsString() + "> has been unbanned!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
            } else {
                sendMessage("No User was given to Unban!", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
            }
        } else {
            if (commandEvent.getArguments().length == 1) {
                String userId = commandEvent.getArguments()[0];
                commandEvent.getGuild().unban(userId).queue();
                sendMessage("User <@" + userId + "> has been unbanned!", 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() + "unban @user", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
            }
        }
    } else {
        sendMessage("You dont 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)

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