https://github.com/cristian-sknz/jda-commands
An experimental project to create JDA commands using annotations
https://github.com/cristian-sknz/jda-commands
discord-bot java jda-discord jda-utilities
Last synced: 2 months ago
JSON representation
An experimental project to create JDA commands using annotations
- Host: GitHub
- URL: https://github.com/cristian-sknz/jda-commands
- Owner: Cristian-Sknz
- License: agpl-3.0
- Created: 2021-07-01T21:29:36.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-12-06T23:13:14.000Z (over 3 years ago)
- Last Synced: 2025-01-22T20:35:30.110Z (4 months ago)
- Topics: discord-bot, java, jda-discord, jda-utilities
- Language: Java
- Homepage:
- Size: 128 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JDA-Commands
An experimental project to create JDA commands using annotations## Readme!
This project is completely experimental, it's an attempt to merge
"commands common" to slash commands. To make this more interesting,
decide to make annotations interact fully with the commands.I'll leave examples below if you want to understand how it works.
If you support this idea and want some features and other changes, don't hesitate to make issues and pull requests!## Examples
Commands are made in slash command format,
after being slashed, they are converted to "common commands".
### Start JDA Application
```java
public static void main(String[] args) {
JDABuilder builder = JDABuilder.createDefault("BOT_TOKEN");
JDACommands commands = new JDACommands(guild -> "+");
builder.addEventListeners(commands);
commands.register(HelloCommand.class);
JDA jda = builder.build();commands.publishCommands(jda.updateCommands());
}
```You can use a database to set the prefix for each guild:
```java
PrefixConfiguration prefix = (guild) -> {
GuildRepository repository = Util.getRepository();
GuildDatabase guildDatabase = repository.getByGuildId(guild.getIdLong());
return guildDatabase.getPrefix();
};JDACommands commands = new JDACommands(prefix);
```### Hello World
Here is an example of a simple command, a Hello World!
```java
import ...@CommandController(name = "hello", description = "Say hello to the world, say hello to someone")
public class HelloCommand {@CommandExecutor(options = {
@CommandOption(type = OptionType.STRING,
name = "name",
description = "Enter someone's name!",
isRequired = true
)})
public void execute(CommandReply commandReply, @CommandParameter("name") String name){
commandReply.replyFormat("Hello World! Have a nice day %s!", name).queue();
}
```
#### Output
- Slash Command
![]()
- Common Command
![]()