Skip to content
This repository has been archived by the owner on Oct 3, 2021. It is now read-only.

Getting Started

Reperak edited this page Jul 4, 2021 · 1 revision

This guide assumes you're using IntelliJ IDEA, and are familiar with Java and JVM configuration.

JDK

If you don't have Java 16 already, download the corresponding JDK. Use the free AdoptOpenJDK binaries.

Building

./gradlew shadowJar on UNIX-like systems (e.g. Linux, macOS, *BSD)
gradlew.bat shadowJar on Windows

Refactoring

Chances are, you don't want to keep our package name. A good IDE will have refactoring support.

Refactor the following:

Test to make sure it builds correctly.

Configuring

When running your Initium-based bot, it checks for a file named "config.toml" in the current working directory. Copy the TOML below and put it into a new file with that name.

prefix = "%"
token = "TOKEN"

Running

For maximum performance, run the bot with a command like the following:
java -Xmx1024m -Xms1024m -jar initium-all.jar

Your First Command

Creating

In the command package, create a new class in one of the categories and make it extend Command
In IntelliJ IDEA, press Ctrl + O, and override the execute and getDescription methods.

In getDescription, return what you'd like the help command to display for your command.
In execute, enter the following:

messageReceivedEvent.getChannel().sendMessage("Hello, world!").queue();

These aren't the only methods you can override. There's quite a few other ways you can customize your command.

Registering

Return to the main class. In the method registerCommands, enter the following:

COMMANDS.put("mycommand", new MyCommand());

Tweak it for your own command, of course.
The string will be what triggers it, so if your prefix is '%', you'd type "%mycommand".

You're all done! Fire up your bot to test it out.

Clone this wiki locally