jda-commands 4.0.0-beta.3 API

JDA-Commands

A declarative, annotation driven interaction framework for JDA.


Resources

This is the official documentation for jda-commands. If you are new to jda-commands (or JDA in general) you might also find the following resources helpful:

Having trouble or found a bug?

Example usage

1. Create JDACommands instance and start framework

public class Main {
    
    public static void main(String[] args) {
        JDA jda = yourJDABuilding();
        JDACommands jdaCommands = JDACommands.start(jda, Main.class);
    }
    
}

2. Create interaction class

@Interaction
public class HelloWorld { 
    
    @SlashCommand("greet") 
    public void onCommand(CommandEvent event) {
        event.reply("Hello World!");
    }
    
}

Runtime Concept

One of the core concepts in jda-commands is the so-called Runtime. It is mentioned frequently in the docs. A Runtime delegates the jda events to their corresponding EventHandlers and manages the used virtual threads.

A new Runtime is created each time a SlashCommandInteractionEvent, GenericContextInteractionEvent or CommandAutoCompleteInteractionEvent is provided by jda or if an interaction is marked as independent.

Runtimes are executed in parallel, but events are processed sequentially by each runtime. Every EventHandler called by this Runtime is executed in its own virtual thread, isolated from the runtime one.

See ExpirationStrategy for details when a Runtime will close.

event/runtime flowchart
Modules
Module
Description
The base module of jda-commands