Public library to make slash & prefix commands creation for JDA API easier.
The music bot might not be working. This libary is not updated anymore. This might be a problem with Lavaplayer.
Join the Discord server for support.
If you want to bring any changes to the library you can create a fork of this branch, contact me on Discord, give good explanation of your changes and they might get added to this official branch.
- Main Class Example
- Create a slash command
- Create a prefix command
- Config File Setup
- MySQL Database
- Download
Latest Version: GitHub Release
public static void main(String[] args) throws InterruptedException, IOException {
EasyCommands easyCommands = new EasyCommands();
JDA jda = easyCommands.addExecutor( // Add your custom commands/executors here!
new HelpCmd(easyCommands),
new ExampleCmd1()...
).registerListeners( // Add your custom listeners/events here!
new ExampleListener1(),
new ExampleListener2()...
).addGatewayIntents(/*leave empty if any*/)
.addEnabledCacheFlags(/*leave empty if any*/)
.buildJDA(); // Starts the bot!
}
Example slash executor class (Implement needed functions) Includes more functions than shown in the example
public class ExampleCmd extends SlashExecutor {
@Override
public String getName() {
return "hello";
}
@Override
public String getDescription() {
return "Say Hello world!";
}
@Override
public void execute(EventData data, MySQL mySQL) {
data.reply("Hello world!", false).queue();
}
}
or check out this simple command class: NowPlayingCmd.java
You can edit the default prefix by adding one line of code to your main class. See Main class example
- Create a new Java class. Ex: PHelloCmd.java
- Extend the class with CommandExecutor. Ex:
public class HelloCmd extends PrefixExecutor
- You can now override all the necessesary functions. Ex:
getName(), getDescription(), execute()
- When you are done creating your command class, you can register it inside of your Main class. Ex:
JDA jda = easyCommands.addExecutor(new PHelloCmd()).buildJDA();
easyCommands.getPrefixCommands().setPrefix("prefix");
Simply add this line inside your Main class under EasyCommands easyCommands = new EasyCommands();
In your main class when building the JDA ->
.addExecutor(new ExampleCmd())
.addExecutor(new ExampleCmd1(), new ExampleCmd2(), new ExampleCmd3()...)
(You can also add multiple commands inside that function)
The Config file settings get generated automaticaly on creation. If you want to update the config file when a new version releases take a look at ConfigSettings
To access the config settings inside of your code you need to use a EasyCommands
instance can get the function getConfig()
public static void main(String[] args) throws InterruptedException, IOException {
EasyCommands easyCommands = new EasyCommands();
easyCommands.getConfig().get...; <------ !!!
JDA jda = easyCommands.addExecutor( // Add your custom commands/executors here!
new HelpCmd(easyCommands),
new ExampleCmd1()...
).registerListeners( // Add your custom listeners/events here!
new ExampleListener1(),
new ExampleListener2()...
).buildJDA(); // Starts the bot!
}
You need to configure the Config file correctly. See --> Config File Setup
Latest Version: GitHub Release
Make sure to replace VERSION with the latest available version above! Check JitPack for more information.
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.FrostedCA</groupId>
<artifactId>EasyCommands</artifactId>
<version>VERSION</version>
</dependency>
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.FrostedCA:EasyCommands:VERSION'
}