https://github.com/jdiscordbots/command-framework
A command system for JDA that allows to treat slash and text commands the same
https://github.com/jdiscordbots/command-framework
command-framework command-system discord-bot discord-jda discord-slash-commands jda library slash-commands
Last synced: 7 days ago
JSON representation
A command system for JDA that allows to treat slash and text commands the same
- Host: GitHub
- URL: https://github.com/jdiscordbots/command-framework
- Owner: JDiscordBots
- License: mit
- Created: 2020-06-02T18:37:24.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-08T21:10:00.000Z (about 2 years ago)
- Last Synced: 2025-07-24T08:42:40.388Z (11 months ago)
- Topics: command-framework, command-system, discord-bot, discord-jda, discord-slash-commands, jda, library, slash-commands
- Language: Java
- Homepage:
- Size: 133 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# Command Framework
A command system for JDA that allows to treat slash and text commands the same
## Usage
1. Add Command-Framework to the dependencies section of your `pom.xml` (replace VERSION with [](https://maven-badges.herokuapp.com/maven-central/io.github.jdiscordbots/command-framework)):
```xml
io.github.jdiscordbots
command-framework
VERSION
compile
```
2. Create an instance of `CommandFramework`
3. Set prefix, owners etc.
4. Build the command listener using `CommandFramework#build()` and add it to your JDA(Builder) instance as an event listener
5. Create command classes which are annotated by `@Command("commandname")` and implement the `ICommand` interface
6. See how it works perfectly
### Working example:
Main:
```java
public class Main {
public static void main(String[] args) throws LoginException {
final JDABuilder builder = JDABuilder.createDefault("your token");
final CommandFramework framework = new CommandFramework() // Step 1
/* Step 2 */
.setMentionPrefix(true) // Allow mention prefix, Default: true
.setPrefix("prefix") // Default: !
.setOwners("owner1", "optional owner 2", "...", "optional owner n"); // Set owners for permissions system, Default: {}
builder.addEventListeners(framework.build()).build(); // Step 3
}
}
```
Example command:
```java
import io.github.jdiscordbots.command_framework.command.*;
@Command({"example", "examplealias"}) // Step 4
public class Example implements ICommand {
@Override
public void action(CommandEvent event) {
event.getChannel().sendMessage("Example command reply").queue();
}
@Override
public String help() {
return "Example command";
}
}
```
Example permission restricted command:
```java
import io.github.jdiscordbots.command_framework.command.*;
import net.dv8tion.jda.api.Permission;
@Command({"permissionexample", "permissionexamplealias"}) // Step 4
public class PermissionExample implements ICommand {
@Override
public void action(CommandEvent event) {
event.getChannel().sendMessage("Permission example command reply").queue();
}
@Override
public boolean allowExecute(CommandEvent event) {
return event.getMember().hasPermission(Permission.MANAGE_PERMISSIONS); // Allow use of command only to members with manage permissions permission
}
@Override
public String help() {
return "Permission example command";
}
}
```
### Docs
You can take a look at the JavaDoc at [javadoc.io](https://javadoc.io/doc/io.github.jdiscordbots/command-framework/latest/index.html).