Class JDACommands
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 TypeMethodDescriptionstatic JDACBuilderCreate a new builder.static JDACBuilderbuilder(ShardManager shardManager) Create a new builder.Gets anEmbedbased on the given name.getSelectMenu(Class<?> origin, String menu) Gets aStringMenuorEntityMenubased on the method name and the given class and transforms it into a JDASelectMenu.Gets theJDACIntrospectioninstance with scopeJDACScope.INITIALIZED.<T> Tproperty(JDACProperty<T> property) Gets the value of a property.voidshutdown()Shuts down this JDACommands instance, making it unable to receive any events from Discord.static JDACommandsCreates a new JDACommands instance and starts the frameworks, including scanning the classpath for annotated classes.static JDACommandsstart(ShardManager shardManager) Creates a new JDACommands instance and starts the frameworks, including scanning the classpath for annotated classes.voidUpdates all slash commands that are registered withCommandScope.GUILDvoidupdateGuildCommands(Collection<Guild> guilds) Updates all slash commands that are registered withCommandScope.GUILDfor the givenGuilds.
-
Method Details
-
start
Creates a new JDACommands instance and starts the frameworks, including scanning the classpath for annotated classes. This uses reflections for some functionality.
If any exception while configuration/start of JDA-Commands is thrown, the JDA instance if shutdown per default. This can be configured by setting
JDACBuilder.shutdownJDA(boolean)tofalse.- Parameters:
jda- the correspondingJDAinstance- Returns:
- a new JDACommands instance
-
start
Creates a new JDACommands instance and starts the frameworks, including scanning the classpath for annotated classes. This uses reflections for some functionality.
If any exception while configuration/start of JDA-Commands is thrown, the JDA instance if shutdown per default. This can be configured by setting
JDACBuilder.shutdownJDA(boolean)tofalse.- Parameters:
shardManager- the correspondingShardManagerinstance- Returns:
- a new JDACommands instance
-
builder
Create a new builder.- Parameters:
jda- the correspondingJDAinstance- Returns:
- a new
JDACBuilder
-
builder
Create a new builder.- Parameters:
shardManager- the correspondingShardManagerinstance- Returns:
- a new
JDACBuilder
-
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.
If
JDACBuilder.shutdownJDA(boolean)is set to `true``, the underlyingJDAorShardManagerinstance will be shutdown too. -
updateGuildCommands
public void updateGuildCommands()Updates all slash commands that are registered withCommandScope.GUILD -
updateGuildCommands
Updates all slash commands that are registered withCommandScope.GUILDfor the givenGuilds.- Parameters:
guilds- aCollectionof guilds to update.
-
getButton
Gets a
Buttonbased on the method name and the given class and transforms it into a JDAButton.The button will be
Runtimeindependent. 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
Gets a
StringMenuorEntityMenubased on the method name and the given class and transforms it into a JDASelectMenu.The select menu will be
Runtimeindependent. This may be useful if you want to send a component without using the framework.- Parameters:
origin- theClassof the methodmenu- the name of the button in the format `FullClassNameWithPackage.method``- Returns:
- the JDA
SelectMenu
-
embed
Gets an
Embedbased on the given name.Use
findEmbed(String)if you cannot ensure that theEmbedexists.- Parameters:
name- the name of theEmbed- Returns:
- the
Embed - Throws:
IllegalArgumentException- if noEmbedwith the given name exists in the configured data sources
-
findEmbed
Gets an
Embedbased on the given name and wraps it in anOptional.Use this instead of
embed(String)if you cannot ensure that theEmbedexists. -
introspection
Gets theJDACIntrospectioninstance with scopeJDACScope.INITIALIZED.- Returns:
- the
JDACIntrospectioninstance
-
property
Gets the value of a property.
This is a shortcut for
JDACommands#introscpection#get- Type Parameters:
T- the type of property- Parameters:
property- theJDACPropertydescription- Returns:
- T
-