JDA-Commands¶
A declarative, annotation driven interaction framework for JDA. Our 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:
@Interaction
public class CookieClicker {
private int counter;//(1)!
@SlashCommand(value = "cookie clicker", desc = "Play cookie clicker")
public void onClicker(CommandEvent event) {
event.with().components("onCookie").reply("You've got %s cookie(s)!", counter);
}
@Button(value = "Collect", emoji = "🍪", style = ButtonStyle.SUCCESS)
public void onCookie(ComponentEvent event) {
event.reply("You've got %s cookie(s)!", ++counter);//(2)!
}
}
- Yes, that's right! We can store the
counter
as a class variable. JDA-Commands will create a new instance ofCookieClicker
for every command execution, so you don't need to worry about state. You can read more about it here. - This will edit the original message and will also keep the
🍪 Collect
button attached. You can find find more about building replies here.
Adding to your Project¶
Additional Resources¶
You might also find the following resources helpful:
Having trouble or found a bug?
- Check out the Examples
- Join the Discord Server
- Or open an Issue