Skip to content

Configuring extensions

Passing instances of Extension.Data

If we want to configure an extension, we can pass an instance of the extension specific implementation of Extension.Data to the JDA-Commands builder. In case of our MyExtension example, that would be:

Example

JDACommands.builder(jda, Main.class)
   .extensionData(new MyExtensionData("someValue"))
   .start();

Filtering found Extensions

Filtering extensions is crucial for resolving cycling dependencies. To filter which extensions we want to include in our application, we can utilize the JDACBuilder#filterExtensions(JDACBuilder.FilterStrategy, String...) method. You need to pass the following two parameters:

  1. JDACBuilder.FilterStrategy, which will either exclude (FilterStrategy.EXCLUDE) or include (FilterStrategy.INCLUDE) the passed extensions.
  2. String... is an enumeration of the full class names, which should be either included or excluded. The strings will be matched to the full class names of the classes extending Extension using String#startWith, thus specifying package names is possible.

Exclude default Guice Extension

JDACommands.builder(jda, Main.class)
        .filterExtensions(FilterStrategy.EXCLUDE, "com.github.kaktushose.jda.commands.guice")
        .start();