-
Notifications
You must be signed in to change notification settings - Fork 1
Getting Started
Dynxsty edited this page Nov 13, 2022
·
1 revision
This version of DIH4JDA must be used with the following version of JDA: net.dv8tion:JDA:5.0.0-alpha.22
DIH4JDA itself is distributed through Maven Central:
<dependency>
<groupId>xyz.dynxsty</groupId>
<artifactId>dih4jda</artifactId>
<version>1.6</version>
</dependency>dependencies {
[...]
implementation("xyz.dynxsty:dih4jda:1.6")
}Creating a new DIH4JDA instance is fairly easy:
DIH4JDA dih4jda = DIH4JDABuilder
.setJDA(jda) // Your JDA instance
.build();Now, you get to decide how you want your commands to be registered:
To manually register commands, use the following methods, AFTER you've .build(); your DIH4JDA instance, like that:
DIH4JDA dih4jda = DIH4JDABuilder
.setJDA(jda) // Your JDA instance
.build();
dih4jda.addSlashCommands(new PingCommand(), new HelloWorldCommand());
dih4jda.addContextMenus(new PingUserContext(), new HelloWorldMessageContext());Alternatively, you can specify packages on the DIH4JDABuilder instance which will be scanned for all classes that extend one of the following classes:
SlashCommandContextCommand.UserContextCommand.Message
DIH4JDA dih4jda = DIH4JDABuilder
.setJDA(jda) // Your JDA instance
.setCommandPackages("xyz.dynxsty.bot.commands") // OPTIONAL: The package(s) that contains all your commands
.build();Upon calling .build();, the bot will register all commands that are in the specified package(s).