Search in sources :

Example 1 with CommandEvent

use of com.freya02.botcommands.api.prefixed.CommandEvent in project BotCommands by freya022.

the class MessageComponents method execute.

@JDATextCommand(name = "components")
public void execute(CommandEvent event) {
    final ActionRow firstRow = ActionRow.of(Components.selectionMenu(SELECTION_HANDLER_NAME).addOption("Option 1", "Value 1").addOption("Option 2", "Value 2").addOption("Option 3", "Value 3").setPlaceholder("Select a value").build());
    final ActionRow secondRow = ActionRow.of(Components.primaryButton(BUTTON_HANDLER_NAME).build("Primary button (persistent, no group)"));
    event.getMessage().reply("Components !").setActionRows(firstRow, secondRow).queue();
}
Also used : ActionRow(net.dv8tion.jda.api.interactions.components.ActionRow) JDATextCommand(com.freya02.botcommands.api.prefixed.annotations.JDATextCommand)

Example 2 with CommandEvent

use of com.freya02.botcommands.api.prefixed.CommandEvent in project BotCommands by freya022.

the class EnableInfoCommand method execute.

@JDATextCommand(name = "enableinfocommand", description = "Enables the /info command")
public void execute(CommandEvent event) {
    if (event.getMember().canInteract(event.getGuild().getSelfMember())) {
        final BasicSettingsProvider settingsProvider = (BasicSettingsProvider) event.getContext().getSettingsProvider();
        if (settingsProvider == null) {
            event.indicateError("No settings provider has been set").queue();
            return;
        }
        settingsProvider.addCommand(event.getGuild(), "info");
        event.reactSuccess().queue();
    } else {
        event.indicateError("You cannot do this").queue();
    }
}
Also used : BasicSettingsProvider(com.freya02.bot.wiki.slash.BasicSettingsProvider) JDATextCommand(com.freya02.botcommands.api.prefixed.annotations.JDATextCommand)

Aggregations

JDATextCommand (com.freya02.botcommands.api.prefixed.annotations.JDATextCommand)2 BasicSettingsProvider (com.freya02.bot.wiki.slash.BasicSettingsProvider)1 ActionRow (net.dv8tion.jda.api.interactions.components.ActionRow)1