📔 Command Repository
The CommandRepository is the object responsible for storing commands. It's stored by a CommandManager, and you can get
it via CommandManager#getRepository().
You can't modify the repository directly since the CommandManager returns a ReadonlyCommandRepository type, but the
hidden methods are available at the CommandManager. This is because adding, removing and updating a command needs more
logic than just modifying the repository, and the manager is responsible for coordinating this.
👷 Creation
You can create a command repository by either:
- Extending
DefaultCommandRepositoryfrom@framework(recommended). - Implementing the
CommandRepositoryinterface from@core.
- Extending DefaultCommandRepository
- Implementing CommandRepository
class MyCommandRepository extends DefaultCommandRepository {
// ...
}
const myRepository = new MyCommandRepository();
const myBot = Bot.create((bot) => ({
commands: DefaultCommandManager.create(bot, client, clientBus, { repository: myRepository }),
}));
class MyCommandRepository implements CommandRepository {
// ...
}
const myRepository = new MyCommandRepository();
const myBot = Bot.create((bot) => ({
commands: DefaultCommandManager.create(bot, client, clientBus, { repository: myRepository }),
}));