Instructability is a Commands API primarily written for Discord4J. Although, there will be future support for other Discord Bot libraries.
Psst.. I've been working on another Command API for discord.. Check it out here
Instructability's development is currently on hold. check out another Command Framework, Discordinator for more developments!
Simply add the instructability-discord4j.jar
file downloaded from the Releases Page to the modules directory of your Discord4J bot, along with your other external Instructability modules.
And viola! Everything is now done and working!
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.Kaioru</groupId>
<artifactId>instructability</artifactId>
<version>@VERSION@</version>
</dependency>
Where @VERSION@ is the version you wish to use of Instructability.
Further instructions on this step can be found on JitPack
IDiscordClient client = new ClientBuilder()
.withToken(token)
.login();
client.getModuleLoader().loadModule(new InstructabilityModule());
client.getDispatcher().registerListener((IListener<ReadyEvent>) event -> // Ensures 'getOurUser()' is not null
Instructables.getRegistry().setPrefix(client.getOurUser().mention() + " ")
);
Instructables.getRegistry().setPrefix("!"); // !<command>
Instructables.getRegistry().setPrefix("bot "); // bot <command>
public class AnnotationCommands {
@Discord4JAnnotatedCommand(
name = "demo",
desc = "This is a demo!"
)
public void cmdDemo(LinkedList<String> args, MessageReceivedEvent event, MessageBuilder msg) throws Exception {
msg.appendContent("Hello world!")
.build();
}
}
public class AnnotatedMiddlewareCommand extends Discord4JCommand {
@Override
public String getName() {
return "annotated";
}
@Override
public String getDesc() {
return Defaults.DESCRIPTION;
}
@Override
public void execute(LinkedList<String> args, MessageReceivedEvent event, MessageBuilder msg) throws Exception {}
}
AnnotatedMiddlewareCommand cmd = new AnnotatedMiddlewareCommand();
cmd.registerCommands(new AnnotationCommands());
Instructables.getRegistry().registerCommand(cmd);
It is currently not possible to add Annotated commands directly to the CommandRegistry. It will be fixed in the next update
Instructables.getRegistry()
.registerCommand(new Discord4JCommandBuilder("demo")
.build((args, event, msg) -> {
msg.appendContent("Hello world!")
.build();
}));
public class DemoCommand extends Discord4JCommand {
@Override
public String getName() {
return "demo";
}
@Override
public String getDesc() {
return Defaults.DESCRIPTION;
}
@Override
public void execute(LinkedList<String> args, MessageReceivedEvent event, MessageBuilder msg) throws Exception {
msg.appendContent("Hello world!")
.build();
}
}
Instructables.getRegistry().registerCommand(new DemoCommand());
- ExtendedInstructs - Only supports Discord4J
- InstructPermissions - Only supports Discord4J, not up-to-date
I'm on Discord as @Kaioru, feel free to drop me a PM. I'm also on Discord4J's Discord channel.
I'm not the best programmer out there, there will be imperfections and stuff.
So feel free to contribute and help the project out!