Package xyz.dynxsty.dih4jda
Class DIH4JDABuilder
java.lang.Object
xyz.dynxsty.dih4jda.DIH4JDABuilder
Builder class used to instantiate a new
DIH4JDA
instance.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Returns a validatedDIH4JDA
instance.Whether DIH4JDA should automatically register all interactions on each onReady event.disableLogging
(DIH4JDALogger.Type... types) Deprecated, for removal: This API element is subject to removal in a future version.Disables stacktrace-printing for all raised exceptions that were not caught by anDIH4JDAEventListener
.Disables the deletion of unknown/unused commands while using SmartQueue.Disables theCommandNotRegisteredException
getting thrown for unregistered commands.setCommandPackages
(String... pack) Allows to specify package(s) that house allApplicationCommand
s classes.setExecutor
(Executor executor) Allows to specify a customExecutor
that will be used to execute all commands and events.
If you have access to Java 21 it's recommended to use theExecutors.newVirtualThreadPerTaskExecutor()
.
Standard:ForkJoinPool.commonPool()
setGlobalSmartQueue
(boolean enable) NOT RECOMMENDED (unless there are some bugs)
This will disable the GLOBAL Smart Queueing functionality.setGuildSmartQueue
(boolean enable) This will disable the GUILD Smart Queueing functionality.static DIH4JDABuilder
setJDA
(net.dv8tion.jda.api.JDA instance) Sets theJDA
instance the handler will be used for.
-
Method Details
-
setJDA
Sets theJDA
instance the handler will be used for.- Parameters:
instance
- TheJDA
instance.- Returns:
- The
DIH4JDABuilder
for chaining convenience.
-
setCommandPackages
Allows to specify package(s) that house allApplicationCommand
s classes. DIH4JDA then uses theClassWalker
to "scan" for those classes.- Parameters:
pack
- The packages.- Returns:
- The
DIH4JDABuilder
for chaining convenience.
-
setExecutor
Allows to specify a customExecutor
that will be used to execute all commands and events.
If you have access to Java 21 it's recommended to use theExecutors.newVirtualThreadPerTaskExecutor()
.
Standard:ForkJoinPool.commonPool()
- Parameters:
executor
- The customExecutor
.- 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.UseDIH4JDALogger.disableLogging(DIH4JDALogger.Type...)
instead. Will be removed in 2.0Sets the types of logging that should be disabled.- Parameters:
types
- AllDIH4JDALogger.Type
's that should be disabled.- Returns:
- The
DIH4JDABuilder
for chaining convenience.
-
disableStacktracePrinting
Disables stacktrace-printing for all raised exceptions that were not caught by anDIH4JDAEventListener
.- Returns:
- The
DIH4JDABuilder
for chaining convenience.
-
disableAutomaticCommandRegistration
Whether DIH4JDA should automatically register all interactions on each onReady event. A manual registration of all interactions can be executed usingDIH4JDA.registerInteractions()
.- Returns:
- The
DIH4JDABuilder
for chaining convenience.
-
setGlobalSmartQueue
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 eachDIH4JDA.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 withdisableUnknownCommandDeletion()
.- Parameters:
enable
- aBoolean
that is true if theSmartQueue
should be enabled for global commands.- Returns:
- The
DIH4JDABuilder
for chaining convenience.
-
setGuildSmartQueue
This will disable the GUILD Smart Queueing functionality. If the Guild SmartQueue is disabled Guild Slash/Context Commands get overridden on eachDIH4JDA.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 withdisableUnknownCommandDeletion()
.- Parameters:
enable
- aBoolean
that is true if theSmartQueue
should be enabled for guild commands.- Returns:
- The
DIH4JDABuilder
for chaining convenience.
-
disableUnknownCommandDeletion
Disables the deletion of unknown/unused commands while using SmartQueue.- Returns:
- The
DIH4JDABuilder
for chaining convenience.
-
disableUnregisteredCommandException
Disables theCommandNotRegisteredException
getting thrown for unregistered commands.- Returns:
- The
DIH4JDABuilder
for chaining convenience.
-
build
Returns a validatedDIH4JDA
instance.- Returns:
- The built, usable
DIH4JDA
- Throws:
DIH4JDAException
- If anything was wrong with your configuration.
-
DIH4JDALogger.disableLogging(DIH4JDALogger.Type...)
instead.