Sdcf4j
A simple Discord command framework for Java
Install / Use
/learn @Bastian/Sdcf4jREADME
⚠️ DEPRECATION WARNING ⚠️
This project is no longer actively maintained.
⚠️ DEPRECATION WARNING ⚠️
sdcf4j
Sdcf4j is a simple Discord command framework for Java, supporting Javacord, JDA and Discord4J. It helps you creating commands within seconds in a clean and simple way.
A ping command is as easy as this:
@Command(aliases = "ping", description = "Pong!")
public String onPingCommand() {
return "Pong!";
}
Maven
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
...
<!-- The core module -->
<dependency>
<groupId>de.btobastian.sdcf4j</groupId>
<artifactId>sdcf4j-core</artifactId>
<version>%version%</version>
</dependency>
<!-- The module for your preferred lib -->
<dependency>
<groupId>de.btobastian.sdcf4j</groupId>
<!-- Possible artifact ids: sdcf4j-javacord, sdcf4j-jda3, sdcf4j-discord4j -->
<artifactId>sdcf4j-javacord</artifactId>
<version>%version%</version>
</dependency>
Make sure to replace %version% with the latest version number, e.g. v1.0.0 (don't use this one!).
Latest version: <a href="#"><img src="https://shields.javacord.org/github/release/BtoBastian/sdcf4j.svg?colorB=brightgreen&label=Version" alt="Latest version"></a>
Support
You can find me in one of these servers/channels. Feel free to contact me if you need help. :)
Download
For those of you how don't use maven: Jenkins
Thanks to ketrwu (https://github.com/KennethWussmann).
Javadocs
The javadocs can be found here: JavaDocs
Thanks to ketrwu, too.
Tutorial
Take a look at the wiki for a detailed description on how to use the library.
Examples
Ping command:
public class PingCommand implements CommandExecutor {
@Command(aliases = {"!ping"}, description = "Pong!")
public String onCommand(String command, String[] args) {
return "Pong!";
}
}
Parameters are completely dynamic, so all of this examples would work:
// no parameters (Javacord, JDA and Discord4J)
@Command(aliases = {"!ping"}, description = "Pong!")
public String onCommand() {
return "Pong!";
}
// DiscordAPI and Message as parameter (Javacord)
@Command(aliases = {"!ping"}, description = "Pong!")
public String onCommand(DiscordApi api, Message message) {
return "Pong!";
}
// no private messages and async (Javacord and JDA)
@Command(aliases = {"!channelInfo", "!ci"}, description = "Pong!", async = true, privateMessages = false)
public String onCommand(Channel channel) {
return "You are in channel #" + channel.getName() + " with id " + channel.getId();
}
Register a CommandExecutor
// Javacord
CommandHandler cmdHandler = new JavacordHandler(api);
// JDA3
CommandHandler cmdHandler = new JDA3Handler(jda);
// Discord4J
CommandHandler cmdHandler = new Discord4JHandler(client);
// register the command
cmdHandler.registerCommand(new PingCommand());
Related Skills
node-connect
335.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
82.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
335.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
82.5kCommit, push, and open a PR
