A command framework for the famous discord api for java - JDA
Using maven:
<repositories>
<repository>
<id>ivan</id>
<url>https://repo.mrivanplays.com/repository/ivan/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.mrivanplays</groupId>
<artifactId>JDCF</artifactId>
<version>VERSION</version> <!-- Replace VERSION with latest version -->
<scope>compile</scope>
</dependency>
</dependencies>
Using gradle:
repositories {
maven {
url 'https://repo.mrivanplays.com/repository/ivan'
}
}
dependencies {
implementation group: 'com.mrivanplays', name: 'JDCF', version: 'VERSION' // Replace VERSION with latest version
}
Example command:
import com.mrivanplays.jdcf.Command;
import com.mrivanplays.jdcf.CommandExecutionContext;
import com.mrivanplays.jdcf.args.CommandArguments;
import com.mrivanplays.jdcf.args.FailReason;
import com.mrivanplays.jdcf.data.CommandAliases;
import com.mrivanplays.jdcf.data.CommandDescription;
import com.mrivanplays.jdcf.data.CommandUsage;
import net.dv8tion.jda.api.Permission;
import org.jetbrains.annotations.NotNull;
// the usage and description aren't necessary if you don't enable
// the help command.
@CommandDescription("My command runs on command")
@CommandUsage("mycommandname <something>")
@CommandAliases("commandname|mcn|cn")
public class MyCommand extends Command {
@Override
public boolean execute(@NotNull CommandExecutionContext context, @NotNull CommandArguments args) {
args.nextString()
.ifPresent(argument -> context.getChannel().sendMessage(argument).queue())
.orElse(failReason -> {
if (failReason == FailReason.ARGUMENT_NOT_TYPED) {
context.getChannel().sendMessage("Specify something.").queue();
}
});
return true;
}
}
Example command manager initialization (without overriding the default settings) and command registration
public static void main(String[] args) {
JDA jda = // assuming you have set a jda instance
CommandManager commandManager = new CommandManager(jda);
commandManager.registerCommand(new MyCommand());
}
I think you can figure out the other things yourself. For any questions you can ask me on Discord showed up.
Thanks to JetBrains I am able to use their products on this project. Thank you JetBrains <3