Package group.worldstandard.pudel.api.interaction


package group.worldstandard.pudel.api.interaction
Discord interaction handling API (slash commands, buttons, modals, etc.).

This package provides interfaces for registering and managing Discord interactions. Interactions are the modern way to create Discord bot features, including slash commands, context menus, buttons, select menus, modals, and autocomplete.

Key Components:

Slash Command Example:

public class PingCommand implements SlashCommandHandler {
    @Override
    public String getName() { return "ping"; }

    @Override
    public String getDescription() { return "Check bot latency"; }

    @Override
    public void handle(SlashCommandInteractionEvent event) {
        long ping = event.getJDA().getGatewayPing();
        event.reply("Pong! " + ping + "ms").queue();
    }
}

// Register in your plugin:
@OnEnable
public void onEnable(PluginContext context) {
    InteractionManager manager = context.getInteractionManager();
    manager.registerSlashCommand("my-plugin", new PingCommand());
    manager.syncCommands();
}

Button Handler Example:

public class ConfirmButton implements ButtonHandler {
    @Override
    public String getIdPrefix() { return "confirm"; }

    @Override
    public void handle(ButtonInteractionEvent event) {
        event.reply("Confirmed!").queue();
    }
}
Since:
2.3.0