A modular Discord bot.
This respository contains the core modules of Baymax.
Baymax Core is available on my Maven.
repositories {
maven {
name "shadowfacts"
"url "http://mvn.rx14.co.uk/shadowfacts/
}
}
dependencies {
compile "net.shadowfacts:Baymax:1.0.0"
}
Create a class that extends net.shadowfacts.baymax.module.base.Module
. Create a no-args constructor that calls the super constructor with the name of the module. Override configure
to configure your module and override init
to run code during Baymax's initialization phase. All classes extending Module
will be registered automatically.
In your resources, include a file called NAME-reference.conf
which is the TypeSafe config file for your module where NAME
is the name you passed into the Module
constructor.
The init
method is called during Baymax's initialization phase when all the modules are being configured and set up. Use this to register commands and event handlers.
Note: Modules are initialized before the JDA instance is created. Register a handler for ReadyEvent
if you need to run code after the JDA is initialized.
Commands are registered through the CommandManager
using CommandManager.register
. register
takes three argument: the name of the command, the usage string of the command (for use by the help
command), and the function to call when the command is run by a user.
See the ping module and its command for a simple example of a command.
Event handlers are registered using Listener.INSTANCE.register
which accepts two parameters: the class of the event and a function that consumes that event.
See the temperature module for a simple example of an event handler.