Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Getting Started

Kevin edited this page Jun 7, 2024 · 2 revisions

To start using ACF Javacord, you first must create a new command manager. Depending on what kind of commands you want your bot to have - message (traditional) commands or slash commands - you create either a MessageCommandManager or SlashCommandManager. In case you would like to create both kinds of commands for your bot, instead of creating both command managers separately, you can use the convenience class JavacordCommandManager, which combines the two into one single class.

Creating a MessageCommandManager

When you want to use message commands, you must first create a CommandConfig:

public class ExampleCommandConfig implements CommandConfig {

    @NotNull
    private final List<String> commandPrefixes = new CopyOnWriteArrayList<>(new String[] {"e!"});

    @NotNull
    @Override
    public List<String> getCommandPrefixes() {
        return commandPrefixes;
    }
}

After that, you can use it to create the command manager:

DiscordApi api = [YOUR_DISCORD_API_INSTANCE];
MessageCommandManager commandManager = new JavacordOptions().configProvider(new ExampleCommandConfig()).createMessageManager(api);

Creating a SlashCommandManager

For slash commands, a CommandConfig is not needed, instead you create one directly:

DiscordApi api = [YOUR_DISCORD_API_INSTANCE];
JavacordCommandManager commandManager =  new JavacordOptions().createSlashManager(api);

Creating a JavacordCommandManager

Just like when creating a MessageCommandManager, to create a JavacordCommandManager you must also first create a CommandConfig. See above on how to make one.

Once you have, you can create the command manager:

DiscordApi api = [YOUR_DISCORD_API_INSTANCE];
JavacordCommandManager commandManager =  new JavacordOptions().configProvider(new ExampleCommandConfig()).createManager(api);