Class DIH4JDABuilder

java.lang.Object
xyz.dynxsty.dih4jda.DIH4JDABuilder

public class DIH4JDABuilder extends Object
Builder class used to instantiate a new DIH4JDA instance.
See Also:
  • Method Details

    • setJDA

      @Nonnull public static DIH4JDABuilder setJDA(@Nonnull net.dv8tion.jda.api.JDA instance)
      Sets the JDA instance the handler will be used for.
      Parameters:
      instance - The JDA instance.
      Returns:
      The DIH4JDABuilder for chaining convenience.
    • setCommandPackages

      @Nonnull public DIH4JDABuilder setCommandPackages(@Nonnull String... pack)
      Allows to specify package(s) that house all ApplicationCommands classes. DIH4JDA then uses the ClassWalker to "scan" for those classes.
      Parameters:
      pack - The packages.
      Returns:
      The DIH4JDABuilder for chaining convenience.
    • setExecutor

      @Nonnull public DIH4JDABuilder setExecutor(@Nonnull Executor executor)
      Allows to specify a custom Executor that will be used to execute all commands and events.
      If you have access to Java 21 it's recommended to use the Executors.newVirtualThreadPerTaskExecutor().

      Standard: ForkJoinPool.commonPool()
      Parameters:
      executor - The custom Executor.
      Returns:
      The DIH4JDABuilder for chaining convenience.
    • disableLogging

      @Nonnull @Deprecated(forRemoval=true) public DIH4JDABuilder disableLogging(@Nullable DIH4JDALogger.Type... types)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use DIH4JDALogger.disableLogging(DIH4JDALogger.Type...) instead. Will be removed in 2.0
      Sets the types of logging that should be disabled.
      Parameters:
      types - All DIH4JDALogger.Type's that should be disabled.
      Returns:
      The DIH4JDABuilder for chaining convenience.
    • disableStacktracePrinting

      @Nonnull public DIH4JDABuilder disableStacktracePrinting()
      Disables stacktrace-printing for all raised exceptions that were not caught by an DIH4JDAEventListener.
      Returns:
      The DIH4JDABuilder for chaining convenience.
    • disableAutomaticCommandRegistration

      @Nonnull public DIH4JDABuilder disableAutomaticCommandRegistration()
      Whether DIH4JDA should automatically register all interactions on each onReady event. A manual registration of all interactions can be executed using DIH4JDA.registerInteractions().
      Returns:
      The DIH4JDABuilder for chaining convenience.
    • setGlobalSmartQueue

      @Nonnull public DIH4JDABuilder setGlobalSmartQueue(boolean enable)
      NOT RECOMMENDED (unless there are some bugs)
      This will disable the GLOBAL Smart Queueing functionality. If the Global SmartQueue is disabled Global Slash/Context Commands get overridden on each DIH4JDA.registerInteractions() call, thus, making Global Commands unusable for about an hour, until they're registered again.
      By default, this also deletes unknown/unused commands. This behaviour can be disabled with disableUnknownCommandDeletion().
      Parameters:
      enable - a Boolean that is true if the SmartQueue should be enabled for global commands.
      Returns:
      The DIH4JDABuilder for chaining convenience.
    • setGuildSmartQueue

      @Nonnull public DIH4JDABuilder setGuildSmartQueue(boolean enable)
      This will disable the GUILD Smart Queueing functionality. If the Guild SmartQueue is disabled Guild Slash/Context Commands get overridden on each DIH4JDA.registerInteractions() call. It is RECOMMENDED to disable this functionality for 300+ servers to shorten the start-up time. By default, this also deletes unknown/unused commands. This behaviour can be disabled with disableUnknownCommandDeletion().
      Parameters:
      enable - a Boolean that is true if the SmartQueue should be enabled for guild commands.
      Returns:
      The DIH4JDABuilder for chaining convenience.
    • disableUnknownCommandDeletion

      @Nonnull public DIH4JDABuilder disableUnknownCommandDeletion()
      Disables the deletion of unknown/unused commands while using SmartQueue.
      Returns:
      The DIH4JDABuilder for chaining convenience.
    • disableUnregisteredCommandException

      @Nonnull public DIH4JDABuilder disableUnregisteredCommandException()
      Disables the CommandNotRegisteredException getting thrown for unregistered commands.
      Returns:
      The DIH4JDABuilder for chaining convenience.
    • build

      @Nonnull public DIH4JDA build() throws DIH4JDAException
      Returns a validated DIH4JDA instance.
      Returns:
      The built, usable DIH4JDA
      Throws:
      DIH4JDAException - If anything was wrong with your configuration.