You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Andrew Lalis edited this page Nov 13, 2021
·
1 revision
Commands are defined in YAML files located in src/main/resources/commands. The data in these files are transformed into an array of CommandConfig objects using JSON deserialization. These commands are then used in SlashCommandListener#registerSlashCommands to register all slash commands.
Each command MUST define a handler property whose value is the fully-qualified class name of a class implementing SlashCommandHandler. When registering commands, the bot will look for such a class, and attempt to create a new instance of it using a no-args constructor. Therefore, make sure your handler class has a no-args constructor.
Privileges
To specify that a command should only be allowed to be executed by certain people, you can specify a list of privileges. For example:
- name: jam-admindescription: Administrator actions for configuring the Java Jam.handler: com.javadiscord.javabot2.jam.JamAdminCommandHandlerenabledByDefault: falseprivileges:
- type: ROLEid: jam.adminRoleId
- type: USERid: 235439851263098880
In this example, we define that the jam-admin command is first of all, not enabled by default, and also we say that anyone from the jam.adminRoleId role (as found using Bot.config.getJam().getAdminRoleId()). Additionally, we also say that the user whose id is 235439851263098880 is allowed to use this command. See BotConfig#resolve(String) for more information about how role names are resolved at runtime.