Overview
Botrino comes with a library that allows to easily create application commands and listeners for Discord interactions. Discord recently added Application Commands as a native way to implement commands within Discord, as well as Message Components to allow for more specific and intuitive interactions with the bot.
#
PreambleAlthough it is designed to be an extension of the Botrino framework, this library is completely decoupled from the framework itself. As such, it is possible to add this library to your project even if you aren't using the framework. The only difference is that you won't benefit from the automatic registration of commands, but you will be able to use all features.
#
Features- Straightforward annotation-based command declaration, with full support for slash commands with subcommands/subcommand groups and context menu commands
- Automatic deployment of commands into the Discord application, with ability to choose whether to deploy them globally or in a specific guild during development
- Inject command options into fields using annotations to conveniently access the values
- Handle component interactions either by treating them as regular commands or by awaiting them in order to continue the execution of a parent command
- Automatic ACK of interaction events, configurable on a per-command basis
- Define privileges for each command with your own rules
- Cooldown per user
- Centralized error handling
- Pre-process interaction events by filtering them or adapting the locale to the target user
- Utilities such as pagination system using buttons
#
Quick startPrerequisites
JDK 11 or newer is required. You can download the OpenJDK here.
You have two ways to start a project. Choose only one of the two options.
#
Option 1: Using Botrino frameworkInitialize your project by following the steps in the Getting Started page.
tip
If you decide to use the Maven archetype, the library will be already added, so you won't need to follow the next steps! Otherwise, continue reading.
Add the following dependency in your project. Replace [VERSION] with the latest version as shown here:
- Maven
- Gradle
Add
requires botrino.interaction
in yourmodule-info.java
. You can actually removerequires botrino.api
sincebotrino.interaction
is already requiring it transitively.Add the following line in the end of your
config.json
:
You are now ready to add commands to your application, they will be registered automatically! You can jump directly to the Creating your first commands section.
#
Option 2: Using the library aloneAdd the following dependency in your project. Replace [VERSION] with the latest version as shown here:
- Maven
- Gradle
Create a main method with these few lines of code:
#
Creating your first commands#
A basic ping command#
A command with options#
A command with subcommands and subcommand groups#
A command using component interactions#
A command using a pagination system based on componentstip
All of these features (and more !) are fully documented in the next pages.