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();
}
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();
});
}
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;
}
Aggregations