Skip to content

Releases: Kaktushose/jda-commands

2.3.0-alpha.2

04 Jul 09:59
Compare
Choose a tag to compare

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 to false no help commands will be auto generated. Default value is true, 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

01 Jul 15:01
Compare
Choose a tag to compare

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 and CommandDispatcher#getJda have been deprecated. Use #getJDAContext instead

  • removed JDACommands#getRouter and JDACommands#setRouter

  • removed CommandDispatcher#getRouter and CommandDispatcher#setRouter

3) Bug Fixes

  • fix Levenshtein distance calculation for multiple labels #52

4) Internal changes

  • added isSlash and OptionMapping to CommandContext

  • new class GenericEvent as a bridge between text and interaction events

  • new parser implementations for interactions

  • new data structure classes CommandTree and TreeNode to generate valid slash command paths

  • reply methods have been extracted to a ReplyAction and ReplyCallback interface with their respective implementations for text and interactions commands.

  • added toCommandData and toSubCommandData 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

09 Feb 14:58
Compare
Choose a tag to compare

🎉 2.2.0

1) New Features

  • added a default error message that is sent when the command execution throws an exception:

image

2) Changes

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

02 Feb 22:26
Compare
Choose a tag to compare

🎉 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.

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 the CommandContext#getPossibleCommands method)

example

2) Changes

  • the Router can now also be updated via the ImplementationRegistry, thus the setter and getter methods have been marked as deprecated
  • the Perm and NotPerm 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

31 Jan 16:55
Compare
Choose a tag to compare

🎉 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

27 Mar 16:34
Compare
Choose a tag to compare

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

14 Feb 19:00
Compare
Choose a tag to compare

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

15 Nov 12:06
Compare
Choose a tag to compare

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'
}

1.0.0

23 Aug 17:39
Compare
Choose a tag to compare

See the Wiki or the JavaDoc for details.

Maven

<dependency>
  <groupId>com.github.kaktushose</groupId>
  <artifactId>jda-commands</artifactId>
  <version>1.0.0</version>
</dependency>