Creating commands
Kordify provides a very simple API to create slash commands.
Command class
You can create command by creating a new object inheriting world.anhgelus.kordify.api.commands.Command
.
There are 3 overrides in this object.
name
variable is the name of the command. (Here we will be able to call this command with /my-name
.)
description
variable is the description of the command.
handle
is the method called when the command is used by a user. You can get every important information in event
.
Adding options
You can add options to your command using the method addOption(OptionData)
from world.anhgelus.kordify.api.commands.Command
. net.dv8tion.jda.api.interactions.commands.build.OptionData
represents an option for slash commands. It comes from JDA and you can check the documentation about OptionData
here.
Registering the command
Now we can register the command. We just have to call register()
from somewhere, so let's do this from our method start()
!