Skip to content

A Command API Module for Discord and everything else!

Notifications You must be signed in to change notification settings

Kaioru/Instructability

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Instructability Build Status

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!

Usage

For Discord4J

As a External Module

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!

In a project

Step 1 - Adding the dependencies
Maven
<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

Step 2 - Enabling the module
IDiscordClient client = new ClientBuilder()
                .withToken(token)
                .login();

client.getModuleLoader().loadModule(new InstructabilityModule());
Step 4 - Changing the command Prefix
@Mention
client.getDispatcher().registerListener((IListener<ReadyEvent>) event -> // Ensures 'getOurUser()' is not null
        Instructables.getRegistry().setPrefix(client.getOurUser().mention() + " ")
);
Everything else
Instructables.getRegistry().setPrefix("!"); // !<command>
Instructables.getRegistry().setPrefix("bot "); // bot <command>
Step 3 - Adding commands!
Using Annotations
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

Using the Builder
Instructables.getRegistry()
        .registerCommand(new Discord4JCommandBuilder("demo")
        .build((args, event, msg) -> {
            msg.appendContent("Hello world!")
                    .build();
        }));
Using Classes
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());

Projects using Instructability

Need help?

I'm on Discord as @Kaioru, feel free to drop me a PM. I'm also on Discord4J's Discord channel.

Contribution

I'm not the best programmer out there, there will be imperfections and stuff.

So feel free to contribute and help the project out!

About

A Command API Module for Discord and everything else!

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages