Skip to content

Kaktushose/jda-commands

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JDA-Version Generic badge Java CI Codacy Badge Codacy Badge license-shield

JDA-Commands

A lightweight, easy-to-use command framework for building Discord bots with JDA with full support for interactions. JDA-Commands goal is to remove any boilerplate code, so you can focus solely on the business logic of your bot - writing bots has never been easier!

Version Guide

jda-commands JDA Text Commands Interactions
4.0.0-beta.3 5
3.0.0 5
2.2.0 4

Features

  • Simple and intuitive syntax following an annotation-driven and declarative style

  • Built-in support for slash commands, components, context menus and modals

  • Automatic and customizable type adapting and constraint validation of parameters

  • Expandable executing chain (Middleware API)

  • Multithreaded event handling using VirtualThreads


The following example will demonstrate how easy it is not only to write commands, but also to integrate components with them:

@Interaction
public class CookieClicker {

    private int count;

    @SlashCommand(value = "cookie clicker", desc = "Play cookie clicker")
    public void onClicker(CommandEvent event) {
        event.with().components("onCookie", "onReset").reply("You've got %s cookie(s)!", count);
    }

    @Button(value = "Collect", emoji = "🍪", style = ButtonStyle.SUCCESS)
    public void onCookie(ComponentEvent event) {
        count++;
        event.reply("You've got %s cookie(s)!", count);
    }

    @Button(value = "Reset", emoji = "🔄", style = ButtonStyle.DANGER)
    public void onReset(ComponentEvent event) {
        count = 0;
        event.reply("You've got %s cookie(s)!", count);
    }
}

Finally, start the framework by calling:

JDACommands.start(jda, Main.class);

If you want to learn more, check out the Wiki or the Javadoc.

Download

You can download the latest version here.

Maven

<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>
<dependency>
    <groupId>com.github.kaktushose</groupId>
    <artifactId>jda-commands</artifactId>
    <version>VERSION</version>
</dependency>

Gradle

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
dependencies {
    implementation 'com.github.kaktushose:jda-commands:VERSION'
}

Contributing

If you think that something is missing, and you want to add it yourself, feel free to open a pull request. Please try to keep your code quality as good as mine and stick to the core concepts of this framework. Also consider opening an issue first, so we can discuss if your changes fit to the framework.

Special thanks to all contributors, especially to @Goldmensch and @lus <3

Contributors Display