Skip to content

Mysterypotatoguy/sdcf4j

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#sdcf4j Latest version Latest JavaDocs Latest JavaDocs

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>sdcf4j-repo</id>
  <url>http://repo.bastian-oppermann.de</url>
</repository>
...
<!-- The core module -->
<dependency>
  <groupId>de.btobastian.sdcf4j</groupId>
  <artifactId>sdcf4j-core</artifactId>
  <version>1.0.3</version>
</dependency>
<!-- The module for your prefered lib-->
<dependency>
  <groupId>de.btobastian.sdcf4j</groupId>
  <!-- Possible artifact ids: sdcf4j-javacord, sdcf4j-jda, sdcf4j-discord4j -->
  <artifactId>sdcf4j-javacord</artifactId>
  <version>1.0.3</version>
</dependency>

Support

You can find me on 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!";
}

// only Message as parameter without return type (Javacord and JDA)
@Command(aliases = {"!ping"}, description = "Pong!")
public void onCommand(Message message) {
    message.reply("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);
// JDA
CommandHandler cmdHandler = new JDAHandler(jda);
// Discord4J
CommandHandler cmdHandler = new Discord4JHandler(client);

// register the command
cmdHandler.registerCommand(new PingCommand());

About

A simple Discord command framework for Java

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%