Search in sources :

Example 6 with Command

use of com.jagrosh.jdautilities.command.Command in project GeyserDiscordBot by GeyserMC.

the class HelpCommand method execute.

@Override
protected void execute(CommandEvent event) {
    EmbedBuilder helpEmbed = new EmbedBuilder().setColor(BotColors.SUCCESS.getColor()).setTitle("Geyser Bot Help");
    for (Command command : GeyserBot.COMMANDS.stream().sorted(Comparator.comparing(Command::getName)).collect(Collectors.toList())) {
        if (!command.isHidden()) {
            helpEmbed.addField("`" + PropertiesManager.getPrefix() + command.getName() + (command.getArguments() != null ? " " + command.getArguments() : "") + "`", command.getHelp(), true);
        }
    }
    helpEmbed.addField("`" + PropertiesManager.getPrefix() + "tag <name>`", "Display a tag for the given name", true);
    event.getMessage().replyEmbeds(helpEmbed.build()).queue();
}
Also used : EmbedBuilder(net.dv8tion.jda.api.EmbedBuilder) Command(com.jagrosh.jdautilities.command.Command)

Example 7 with Command

use of com.jagrosh.jdautilities.command.Command in project MMDBot by MinecraftModDevelopment.

the class CmdAddTrick method execute.

@Override
protected void execute(final SlashCommandEvent event) {
    if (!Utils.checkCommand(this, event)) {
        return;
    }
    if (!event.isFromGuild()) {
        event.deferReply(true).setContent("This command only works in a guild!").queue();
        return;
    }
    if (!Utils.memberHasRole(event.getMember(), MMDBot.getConfig().getRole("bot_maintainer"))) {
        event.deferReply(true).setContent("Only Bot Maintainers can use this command.").queue();
        return;
    }
    Trick trick = trickType.createFromCommand(event);
    Optional<Trick> originalTrick = Tricks.getTricks().stream().filter(t -> t.getNames().stream().anyMatch(n -> trick.getNames().contains(n))).findAny();
    originalTrick.ifPresentOrElse(original -> {
        Tricks.replaceTrick(original, trick);
        event.reply("Updated trick!").mentionRepliedUser(false).setEphemeral(true).queue();
    }, () -> {
        Tricks.addTrick(trick);
        event.reply("Added trick!").mentionRepliedUser(false).setEphemeral(true).queue();
    });
}
Also used : GistUtils(com.mcmoddev.mmdbot.gist.GistUtils) Command(com.jagrosh.jdautilities.command.Command) Utils(com.mcmoddev.mmdbot.utilities.Utils) IOException(java.io.IOException) CommandEvent(com.jagrosh.jdautilities.command.CommandEvent) Trick(com.mcmoddev.mmdbot.utilities.tricks.Trick) SlashCommandEvent(com.jagrosh.jdautilities.command.SlashCommandEvent) MMDBot(com.mcmoddev.mmdbot.MMDBot) Objects(java.util.Objects) ExecutionException(java.util.concurrent.ExecutionException) SlashCommand(com.jagrosh.jdautilities.command.SlashCommand) Tricks(com.mcmoddev.mmdbot.utilities.tricks.Tricks) ScriptTrick(com.mcmoddev.mmdbot.utilities.tricks.ScriptTrick) Optional(java.util.Optional) Trick(com.mcmoddev.mmdbot.utilities.tricks.Trick) ScriptTrick(com.mcmoddev.mmdbot.utilities.tricks.ScriptTrick)

Example 8 with Command

use of com.jagrosh.jdautilities.command.Command in project Vinny by kikkia.

the class AliasUtils method confirmValidCommandName.

public static boolean confirmValidCommandName(String commandName) {
    List<Command> validCommands = ShardingManager.getInstance().getCommandClientImpl().getCommands();
    Map<String, Integer> commandIndex;
    Command command = validCommands.stream().filter((cmd) -> cmd.isCommandFor(commandName)).findAny().orElse(null);
    // TODO: Maybe log stats about what command aliases use
    return command != null;
}
Also used : Command(com.jagrosh.jdautilities.command.Command)

Aggregations

Command (com.jagrosh.jdautilities.command.Command)8 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)5 SlashCommand (com.jagrosh.jdautilities.command.SlashCommand)3 CommandEvent (com.jagrosh.jdautilities.command.CommandEvent)2 PaginatedCommand (com.mcmoddev.mmdbot.modules.commands.community.PaginatedCommand)2 IOException (java.io.IOException)2 SwearHandler (org.geysermc.discordbot.listeners.SwearHandler)2 CommandClientBuilder (com.jagrosh.jdautilities.command.CommandClientBuilder)1 SlashCommandEvent (com.jagrosh.jdautilities.command.SlashCommandEvent)1 EventWaiter (com.jagrosh.jdautilities.commons.waiter.EventWaiter)1 MMDBot (com.mcmoddev.mmdbot.MMDBot)1 GistUtils (com.mcmoddev.mmdbot.gist.GistUtils)1 Utils (com.mcmoddev.mmdbot.utilities.Utils)1 ScriptTrick (com.mcmoddev.mmdbot.utilities.tricks.ScriptTrick)1 Trick (com.mcmoddev.mmdbot.utilities.tricks.Trick)1 Tricks (com.mcmoddev.mmdbot.utilities.tricks.Tricks)1 FileInputStream (java.io.FileInputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1