Command Synchronization - ShindouMihou/Nexus GitHub Wiki

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: