Skip to content

Command Synchronization

Miu edited this page Sep 28, 2023 · 4 revisions

Nexus simplifies and streamlines command synchronization with an easy-to-use approach. To synchronize commands, you only need to include the following line in your code:

Nexus.synchronizer.synchronize()

Error and Completion Handling

As commands can pertain to multiple servers, Nexus employs customized handling for Futures, which also encompasses error management. To handle errors effectively, incorporate .addTaskErrorListener(...) which functions similarly to .exceptionally(...). Similarly, .addTaskCompletionListener(...) resembles .thenAccept(...), yet it's focused on individual tasks. If you aim to monitor the overall completion of all tasks, utilize .addFinalTaskCompletionListener(...) instead.

An example of handling synchronization properly would be:

Nexus.synchronizer
    .synchronize()
    .addFinalCompletionListener { println("Successfully migrated all commands to Discord.") }
    .addTaskErrorListener { exception ->
        println("An error occurred while trying to migrate commands to Discord:")
        exception.printStackTrace()
    }

To gain a deeper understanding of how the synchronizer can be used for various tasks, refer to our example:

To get started with Nexus, we recommend reading the following in chronological:

  1. Installation & Preparing Nexus
  2. Designing Commands
  3. Command Interceptors
  4. Additional Features (Subcommand Router, Option Validation)
  5. Context Menus
  6. Command Synchronization

You may want to read a specific part of handling command and middleware responses:

You can also read about additional features of Nexus:

You can read about synchronizing commands to Discord:

For more additional performance:

Additional configurations:

Clone this wiki locally