Releases: Kaktushose/jda-commands
2.3.0-alpha.2
Overview
This is a follow-up release bringing in some bug fixes and minor changes.
1) New Features
-
Parameter names will be automatically transformed into snake_case, e.g.
int delDays
->del_days
#67 -
You can now use
EmbedDTO#injectFormat(Object...)
to format all fields of an EmbedDTO #69 -
Added
JDACommandsSlashBuilder#enableHelp(boolean)
. If set tofalse
no help commands will be auto generated. Default value istrue
, which also represents the behavior prior to this update. -
StateSection
now has methods to clear or remove entries. Furthermore you can now define a time to live:StateSection section = new StateSection(1, TimeUnit.MINUTES);
2) Changes
-
The
EmbedCache
no automatically loads all embeds when the object gets created #58. Thus:-
EmbedCache#loadEmbedsToCache()
got deprecated -
EmbedCache#loadEmbeds()
got introduced as an alternative which has the same functionality
-
-
Deleting ephemeral messages will replace the message with deleted and will remove all embeds or components instead of throwing an exception #71
3) Bug Fixes
-
Illegal values for SlashCommandData will no longer result in a crash #68
-
fixed that String arguments weren't concatenated #72
-
The type adapters for Integer and Long can now also handle floating point numbers
-
The contextual prefix is now also used in error embeds
-
fixed that Buttons didn't always have the correct order in an ActionRow
4) Internal changes
N/A
You can find the complete changelog here.
JavaDoc for the new classes is currently not available but the wiki will be updated soon:tm:
Maven
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<dependency>
<groupId>com.github.Kaktushose</groupId>
<artifactId>jda-commands</artifactId>
<version>v2.3.0-alpha.2</version>
</dependency>
Gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.Kaktushose:jda-commands:v2.3.0-alpha.2'
}
2.3.0-alpha.1
Overview
This release updates jda-commands to JDA 5 and brings in first implementations for interactions. No breaking changes were made, this is completely backwards compatible to v2.2.0!
Please note that this is the first release and will still contain some bugs
Slash Commands
This release adds support for slash commands. They will work out of the box, which means that you don't have to change your command classes to make slash commands work.
Enabling Slash Commands
In order to get started with slash commands, you need to build jda-commands a little bit different.
JDACommands.slash(jda, Main.class).startGlobal();
This will register all CommandDefinitions as global commands. Registering guild commands looks similar:
JDACommands.slash(jda, Main.class).guilds(0123456789L).startGuild();
CommandRegistrationPolicy
By calling registrationPolicy(CommandRegistrationPolicy)
you can define the operation mode of your bot. You can choose between text, slash, text and slash or migrating where the bot will inform the user that text commands aren't available anymore.
Replying
The bot will always acknowledge incoming interaction events first to prevent time outs when your response building takes longer.
The reply methods of the CommandEvent have been integrated to work with slash commands. So again, no changes needed. To send ephemeral replies there are two ways:
-
Pass it to the reply method:
event.reply("test", true);
-
Set it as default
@Command(value = "greet", ephemeral = true) public void greet(CommandEvent event) { event.reply("Hello"); }
Parameters
Slash command parameters need a name and a description when being registered. To accomplish that a new annotation has been introduced.
@Command("greet")
public void greet(CommandEvent event, @Param(name = "member", value = "The member to greet") Member member) {
event.reply("Hello %s", member.getAsMention());
}
The name can be omitted when you compile with the -parameters
flag. This will make the method parameter name readable for jda-commands at runtime.
If you also omit the description "empty description" will be used by default.
Choices
Slash command parameters can also have a limited set of choices. This was also achieved by introducing a new annotation.
@Command("food")
public void chooseFood(CommandEvent event, @Choices({"Apples", "Burger", "Pizza"}) String food) {
event.reply("You chose %s", food);
}
Buttons
Buttons are one of the new components Discord has introduced. They are arranged in so called ActionRows and can either be enabled or disabled.
Defining Buttons
Buttons are defined the same way as commands are:
@Button(label = "Click me!", style = ButtonStyle.DANGER)
public void onButton(ButtonEvent event) {
event.reply("You clicked me!");
}
Adding Buttons to Messages
Buttons have ids, by default this id is equal to the method name. However you can use your own id by passing it to the @Button
annotation.
Buttons can be added to messages by either calling event#with
or event#withButtons
with the id of the button you want to add. We will discuss the difference in a second. However, each call to a with
method will create a new ActionRow.
Have a look at this first simple example:
@Button(label = "Click me!", style = ButtonStyle.DANGER)
public void onButton(ButtonEvent event) {
event.reply("You clicked me!");
}
@Command("greet")
public void greet(CommandEvent event) {
event.withButtons("onButton").reply("Hello!");
}
Sometimes we don't want a button to be active all the time. event#withButtons
will always enable buttons but by calling event#with
you can change this behavior.
@Command("leaderboard")
public void onLeaderboard(CommandEvent event) {
event.with(Buttons.disabled("onLeft"), Buttons.enabled("onRight")).reply("Page 1");
}
Replying
You can reply to buttons exactly like you reply to commands. Alternatively you can edit the original message (the message the button is attached to) by calling event#edit
.
Additional methods are event#clearComponents
and event#editComponents
.
1) New Features
-
Slash Command and Buttons support
-
@Param
and@Choices
annotation for parameters -
compile with
-parameters
flag and jda-commands will automatically set the parameter name -
the prefix in help messages will either be the actual prefix or
/
depending on the execution context -
Automatically generated command usage in the format
prefix command <args> (optional args)
-
new class
JDAContext
as a bridge between JDA and ShardManager -
New type adapters for all channel types
-
StateSection
as a simple key value storage
2) Changes
-
commands can no longer have empty labels
-
JDACommands#getJda
andCommandDispatcher#getJda
have been deprecated. Use#getJDAContext instead
-
removed
JDACommands#getRouter
andJDACommands#setRouter
-
removed
CommandDispatcher#getRouter
andCommandDispatcher#setRouter
3) Bug Fixes
- fix Levenshtein distance calculation for multiple labels #52
4) Internal changes
-
added
isSlash
andOptionMapping
toCommandContext
-
new class
GenericEvent
as a bridge between text and interaction events -
new parser implementations for interactions
-
new data structure classes
CommandTree
andTreeNode
to generate valid slash command paths -
reply methods have been extracted to a
ReplyAction
andReplyCallback
interface with their respective implementations for text and interactions commands. -
added
toCommandData
andtoSubCommandData
methods to CommandDefinition -
new reflection class ButtonDefinition
You can find the complete changelog here.
JavaDoc for the new classes is currently not available but the wiki will be updated soon:tm:
Maven
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<dependency>
<groupId>com.github.Kaktushose</groupId>
<artifactId>jda-commands</artifactId>
<version>v2.3.0-alpha.1</version>
</dependency>
Gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.Kaktushose:jda-commands:v2.3.0-alpha.1'
}
2.2.0
🎉 2.2.0
1) New Features
- added a default error message that is sent when the command execution throws an exception:
2) Changes
-
added
FilterPosition.UNKNOWN
-
added a
position
andannotation
field to the@Component
annotation. This is needed to: -
register
TypeAdapter
,Filter
andValidator
now directly by annotating them with@Component
-
building command defintions with missing type adapters will now result in a warn message instead of not registering the command
3) Bug Fixes
- N/A
You can find the complete changelog here.
Also checkout the Wiki or the JavaDoc.
Maven
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<dependency>
<groupId>com.github.Kaktushose</groupId>
<artifactId>jda-commands</artifactId>
<version>v.2.2.0</version>
</dependency>
Gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.Kaktushose:jda-commands:v.2.2.0'
}
2.1.0
🎉 2.1.0
1) New Features
MessageSender [#40]
Added the MessageSender
interface. You can implement your own MessageSender
to change how the framework sends messages.
This might be useful to add reactions or send messages to different channels than the event channel.
-
MessageSender interface has three methods:
-
DefaultMessageSender
will simply send the message to the event channel -
use your own
MessageSender
implementation either by annotating it with@Component
or passing it to theImplementationRegistry
.
Embeds
-
added an embed and default error messages for all constraints
-
added a list of possible commands to the
Command Not Found
embed (and respectively theCommandContext#getPossibleCommands
method)
2) Changes
- the
Router
can now also be updated via theImplementationRegistry
, thus the setter and getter methods have been marked as deprecated - the
Perm
andNotPerm
annotation now accept a String array - added sub / super command information to markdown documentation generator
- updated markdown documentation style
3) Bug Fixes
- fixed a bug where the levenshtein distance calculation ignored the label case [#46]
- fixed a bug where the command router didn't find a command when the input has two or more matches
- fixed a bug where the max distance setting wasn't loaded from the properties file
- fixed a bug where custom embed factories weren't used
- fixed a bug where String arguments weren't concatenated
- fixed the Javadoc search
You can find the complete changelog here.
Also checkout the Wiki or the JavaDoc.
Maven
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<dependency>
<groupId>com.github.Kaktushose</groupId>
<artifactId>jda-commands</artifactId>
<version>v.2.1.0</version>
</dependency>
Gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.Kaktushose:jda-commands:v.2.1.0'
}
2.0.0
🎉 Version 2.0.0
JDA-Commands 2.0.0 comes in with a complete rewrite of the project. Many things have changed, so have a look at the Migration Guide for details.
❗ This is a breaking release that isn't backwards compatible with versions prior to 2.0.0 ❗
Changelog
- added new parameter validation system
- added filters and a CommandContext to the execution chain
- added cooldown system
- added support for private messages
- added support for super and sub commands
- added quote parsing
- added leventshein distance
- changed settings system and added options to store settings
- changed permissions system
- improved embed generation
- improved type adapting system
- improved event parsing system
- simplified building process and registering of modules
- bug fixes
Also checkout the Wiki or the JavaDoc.
The old version is still available at legacy/v1
Maven
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<dependency>
<groupId>com.github.Kaktushose</groupId>
<artifactId>jda-commands</artifactId>
<version>v.2.0.0</version>
</dependency>
Gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.Kaktushose:jda-commands:v.2.0.0'
}
v1.1.1
See the Wiki or the JavaDoc for details.
Changelog
- support for multiple prefixes
- option to only scan a specfifc package for commands, see
setCommandPackage(String)
for details - error message if a user is muted and attempts to execute a command
Producer
interface removed- ArgumentParser bug fixed, primitive datatypes now also work
Maven
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<dependency>
<groupId>com.github.Kaktushose</groupId>
<artifactId>jda-commands</artifactId>
<version>1.1.1</version>
</dependency>
Gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.Kaktushose:jda-commands:1.1.1'
}
1.1.0
See the Wiki or the JavaDoc for details.
Changelog
- settings refactored, each guild now has its own settings object
- removed settings file system
- ArgumentParser now supports all classes with a String constructor
- i18n support / load embeds from json
- auto generate command documentation
- help embeds now support custom help prefixes
- bug fixes regarding permissions system
Maven
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<dependency>
<groupId>com.github.Kaktushose</groupId>
<artifactId>jda-commands</artifactId>
<version>v.1.1.0</version>
</dependency>
Gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.Kaktushose:jda-commands:v.1.1.0'
}
1.0.1
See the Wiki or the JavaDoc for details.
Maven
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<dependency>
<groupId>com.github.Kaktushose</groupId>
<artifactId>jda-commands</artifactId>
<version>v.1.0.1</version>
</dependency>
Gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.Kaktushose:jda-commands:v.1.0.1'
}