Search in sources :

Example 11 with OptionMapping

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

the class Play method onPerform.

@Override
public void onPerform(CommandEvent commandEvent) {
    if (!Main.getInstance().getMusicWorker().checkInteractPermission(commandEvent)) {
        return;
    }
    if (commandEvent.isSlashCommand()) {
        OptionMapping valueOption = commandEvent.getSlashCommandInteractionEvent().getOption("name");
        if (valueOption != null) {
            playSong(valueOption.getAsString(), commandEvent);
        } else {
            EmbedBuilder em = new EmbedBuilder();
            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("Usage: " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "play (Url)");
            em.setFooter(commandEvent.getGuild().getName() + " - " + Data.ADVERTISEMENT, commandEvent.getGuild().getIconUrl());
            sendMessage(em, 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
        }
    } else {
        if (commandEvent.getArguments().length < 1) {
            EmbedBuilder em = new EmbedBuilder();
            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("Usage: " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "play (Url)");
            em.setFooter(commandEvent.getGuild().getName() + " - " + Data.ADVERTISEMENT, commandEvent.getGuild().getIconUrl());
            sendMessage(em, 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
        } else {
            playSong(commandEvent.getArguments()[0], commandEvent);
        }
    }
}
Also used : OptionMapping(net.dv8tion.jda.api.interactions.commands.OptionMapping) EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder)

Example 12 with OptionMapping

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

the class Level method onPerform.

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

Example 13 with OptionMapping

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

the class Kiss method onPerform.

@Override
public void onPerform(CommandEvent commandEvent) {
    if (commandEvent.isSlashCommand()) {
        OptionMapping targetOption = commandEvent.getSlashCommandInteractionEvent().getOption("target");
        if (targetOption != null && targetOption.getAsMember() != null) {
            sendKiss(targetOption.getAsMember(), commandEvent);
        } else {
            sendMessage("No User was given to Kiss!", 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() + "kiss @user", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
            } else {
                sendKiss(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() + "kiss @user", 5, commandEvent.getTextChannel(), commandEvent.getInteractionHook());
        }
    }
}
Also used : OptionMapping(net.dv8tion.jda.api.interactions.commands.OptionMapping)

Example 14 with OptionMapping

use of net.dv8tion.jda.api.interactions.commands.OptionMapping in project MMDBot by MinecraftModDevelopment.

the class CmdHelp method execute.

/**
 * Prepare the potential scrolling buttons for a help command,
 * and send the message with the proper embeds.
 * <p>
 * See {@link #getEmbed(int)} for the implementation.
 */
public void execute(SlashCommandEvent e) {
    OptionMapping commandName = e.getOption("command");
    commands = CommandModule.getCommandClient().getCommands();
    commands.addAll(CommandModule.getCommandClient().getSlashCommands());
    updateMaximum(commands.size());
    // If no command specified, show all.
    if (commandName == null) {
        sendPaginatedMessage(e);
    } else {
        Command command = CommandModule.getCommandClient().getCommands().stream().filter(// Find the command with the matching name
        com -> com.getName().equals(commandName.getAsString())).findFirst().orElseGet(// And return it as Command.
        CmdHelp::new);
        // Build the embed that summarises the command.
        EmbedBuilder embed = new EmbedBuilder();
        embed.setAuthor(References.NAME, References.ISSUE_TRACKER, MMDBot.getJDA().getSelfUser().getAvatarUrl());
        embed.setDescription("Command help:");
        embed.addField(command.getName(), command.getHelp(), false);
        // If we have arguments defined and there's content, add it to the embed
        if (command.getArguments() != null && command.getArguments().length() > 0) {
            embed.addField("Arguments", command.getArguments(), false);
        }
        embed.setFooter(References.NAME).setTimestamp(Instant.now());
        e.replyEmbeds(embed.build()).queue();
    }
}
Also used : OptionMapping(net.dv8tion.jda.api.interactions.commands.OptionMapping) EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) Command(com.jagrosh.jdautilities.command.Command) PaginatedCommand(com.mcmoddev.mmdbot.modules.commands.community.PaginatedCommand)

Example 15 with OptionMapping

use of net.dv8tion.jda.api.interactions.commands.OptionMapping in project MMDBot by MinecraftModDevelopment.

the class CmdFabricVersion method execute.

/**
 * Execute.
 *
 * @param event The {@link CommandEvent CommandEvent} that triggered this Command.
 */
@Override
protected void execute(final SlashCommandEvent event) {
    if (!Utils.checkCommand(this, event)) {
        return;
    }
    String minecraft = MinecraftVersionHelper.getLatest();
    OptionMapping version = event.getOption("version");
    if (version != null)
        minecraft = version.getAsString();
    var yarnVersion = FabricVersionHelper.getLatestYarn(minecraft);
    if (yarnVersion == null) {
        yarnVersion = "None";
    }
    final var embed = new EmbedBuilder();
    embed.setTitle("Fabric Versions for Minecraft " + minecraft);
    embed.addField("Latest Yarn", yarnVersion, true);
    embed.addField("Latest API", FabricVersionHelper.getLatestApi(), true);
    embed.addField("Latest Loader", FabricVersionHelper.getLatestLoader(), true);
    embed.setColor(Color.WHITE);
    embed.setTimestamp(Instant.now());
    event.replyEmbeds(embed.build()).mentionRepliedUser(false).queue();
}
Also used : OptionMapping(net.dv8tion.jda.api.interactions.commands.OptionMapping) EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder)

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