Class JDACommands

java.lang.Object
com.github.kaktushose.jda.commands.JDACommands

public final class JDACommands extends Object

The main entry point of the JDA-Commands framework. This class includes methods to manage the overall framework while running.

Instances of this class can be created by using one of the "start" or "builder" methods.

  • Method Summary

    Modifier and Type
    Method
    Description
    static @NotNull JDACommandsBuilder
    builder(@NotNull net.dv8tion.jda.api.JDA jda, @NotNull Class<?> clazz, @NotNull String... packages)
    Create a new builder.
    static @NotNull JDACommandsBuilder
    builder(@NotNull net.dv8tion.jda.api.sharding.ShardManager shardManager, @NotNull Class<?> clazz, @NotNull String... packages)
    Create a new builder.
    @NotNull net.dv8tion.jda.api.interactions.components.buttons.Button
    getButton(@NotNull Class<?> origin, @NotNull String button)
    Gets a Button based on the method name and the given class and transforms it into a JDA Button.
    @NotNull net.dv8tion.jda.api.interactions.components.selections.SelectMenu
    getSelectMenu(@NotNull Class<?> origin, @NotNull String menu)
    Gets a StringSelectMenu or EntitySelectMenu based on the method name and the given class and transforms it into a JDA SelectMenu.
    void
    Shuts down this JDACommands instance, making it unable to receive any events from Discord.
    static @NotNull JDACommands
    start(@NotNull net.dv8tion.jda.api.JDA jda, @NotNull Class<?> clazz, @NotNull String... packages)
    Creates a new JDACommands instance and starts the frameworks, including scanning the classpath for annotated classes.
    static @NotNull JDACommands
    start(@NotNull net.dv8tion.jda.api.sharding.ShardManager shardManager, @NotNull Class<?> clazz, @NotNull String... packages)
    Creates a new JDACommands instance and starts the frameworks, including scanning the classpath for annotated classes.
    void
    Updates all slash commands that are registered with CommandScope.GUILD

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • start

      @NotNull public static @NotNull JDACommands start(@NotNull @NotNull net.dv8tion.jda.api.JDA jda, @NotNull @NotNull Class<?> clazz, @NotNull @NotNull String... packages)
      Creates a new JDACommands instance and starts the frameworks, including scanning the classpath for annotated classes. This uses reflections for some functionality.
      Parameters:
      jda - the corresponding JDA instance
      clazz - a class of the classpath to scan
      packages - package(s) to exclusively scan
      Returns:
      a new JDACommands instance
    • start

      @NotNull public static @NotNull JDACommands start(@NotNull @NotNull net.dv8tion.jda.api.sharding.ShardManager shardManager, @NotNull @NotNull Class<?> clazz, @NotNull @NotNull String... packages)
      Creates a new JDACommands instance and starts the frameworks, including scanning the classpath for annotated classes. This uses reflections for some functionality.
      Parameters:
      shardManager - the corresponding ShardManager instance
      clazz - a class of the classpath to scan
      packages - package(s) to exclusively scan
      Returns:
      a new JDACommands instance
    • builder

      @NotNull public static @NotNull JDACommandsBuilder builder(@NotNull @NotNull net.dv8tion.jda.api.JDA jda, @NotNull @NotNull Class<?> clazz, @NotNull @NotNull String... packages)
      Create a new builder.
      Parameters:
      jda - the corresponding JDA instance
      clazz - a class of the classpath to scan
      packages - package(s) to exclusively scan
      Returns:
      a new JDACommandsBuilder
    • builder

      @NotNull public static @NotNull JDACommandsBuilder builder(@NotNull @NotNull net.dv8tion.jda.api.sharding.ShardManager shardManager, @NotNull @NotNull Class<?> clazz, @NotNull @NotNull String... packages)
      Create a new builder.
      Parameters:
      shardManager - the corresponding ShardManager instance
      Returns:
      a new JDACommandsBuilder
    • shutdown

      public void shutdown()
      Shuts down this JDACommands instance, making it unable to receive any events from Discord. This will not unregister any slash commands.
    • updateGuildCommands

      public void updateGuildCommands()
      Updates all slash commands that are registered with CommandScope.GUILD
    • getButton

      @NotNull public @NotNull net.dv8tion.jda.api.interactions.components.buttons.Button getButton(@NotNull @NotNull Class<?> origin, @NotNull @NotNull String button)

      Gets a Button based on the method name and the given class and transforms it into a JDA Button.

      The button will be Runtime independent. This may be useful if you want to send a message without using the framework.

      Parameters:
      button - the name of the button in the format `FullClassNameWithPackage.method``
      Returns:
      the JDA Button
    • getSelectMenu

      @NotNull public @NotNull net.dv8tion.jda.api.interactions.components.selections.SelectMenu getSelectMenu(@NotNull @NotNull Class<?> origin, @NotNull @NotNull String menu)

      Gets a StringSelectMenu or EntitySelectMenu based on the method name and the given class and transforms it into a JDA SelectMenu.

      The select menu will be Runtime independent. This may be useful if you want to send a component without using the framework.

      Parameters:
      origin - the Class of the method
      menu - the name of the button in the format `FullClassNameWithPackage.method``
      Returns:
      the JDA SelectMenu