API

DiscordBridge has an API which can be used to create custom Discord commands. These command work by a user typing (prefix)cmd <name> <args> in a server channel, and DiscordBridge will if a command is registered to "name", and if one is, it will run the CommandHandler for it (which will be given info such as UUID of the person who ran the command, if they have linked their discord & mc accounts). To use the API, you'll have import the DiscordBridge jar with whatever you are using to compile your plugin (do not bundle it with DiscordBridge). This step will vary widely, so I'd recommend you look up the specific steps for what you are using. Next, you should import:
import com.PintTheDragon.DiscordBridge.API.API;
import com.PintTheDragon.DiscordBridge.API.CommandHandler;
import com.PintTheDragon.DiscordBridge.JoinAction;


Creating a Command

To create a command, you must first create your CommandHandler. The CommandHandler is an interface and it's function void runCommand(String channelID, String authorID, boolean isAdmin, String authorUUID, String[] args) will be run when your command is called. A CommandHandler that does nothing looks like:
new CommandHandler() {
    @Override
    public void runCommand(String channelID, String authorID, boolean isAdmin, String authorUUID, String[] args) {

    }
}

Simply put whatever code you want to run inside of the function. Note that if you would like to use authorUUID, please make sure to check if it is null. It will be null if the user has not linked their discord & mc accounts). If you would like to add a response to the command, you can use void sendMessage(String channelID, String message) or void sendMessage(String message) (if you want to send the message to the server's default channel, which is not recommended for responding to commands). Next, you will want to register your command. All you have to do is run boolean addCommand(String name, CommandHandler handler) (which will return true if the command was successfully registered). Here is an example:

addCommand("spawn", SpawnHandler);

And when someone runs (prefix)cmd spawn, SpawnHandler will be run.

Join Actions

DiscordBridge uses something called JoinActions to run things on a player join (such as warping them to spawn). If you want to make a command that requires you to interact with the player who ran a command, I recommend you use Join Actions. First, you need to create your Join Action. Because of the way Join Actions function, you will need to create your own class implementing Join Action. Here's an example of what that looks like:

public class ActionSpawn implements JoinAction {

   @Override
   public void doAction(Player p, String data) {
      p.teleport(Bukkit.getServer().getWorlds().get(0).getSpawnLocation());
      p.performCommand("spawn");
   }

}

This is the Join Action that will be called for the (prefix)spawn command. Player p is the player your Join Action will be running on, and String data is a piece of arbitrary data that you set when you create the Join Action. This data could contain the command to run in a Join Action that runs a command on spawn, or the coordinates in a Join Action that teleports the player on spawn. This value doesn't have to be used, of course, and your Join Action can run a specific command. It's all up to how you need to use them. Once you have a Join Action created, you need to add it to the player with: void addAction(String UUID, JoinAction a) or void addAction(String UUID, JoinAction a, String data) (if you intend to use the data). Here's an example of that:

API.addAction(authorUUID, new ActionSpawn());

Now, the next time the player joins, the ActionSpawn Join Action will be run on them (or it will be run immediately if they are already online).

Join Actions in a Custom Command

Now that we have gone over how to create Custom Commands and use Join Actions, we'll want to put them together. Below, I have created an example of a simple spawn command:

API.addCommand("spawn", new CommandHandler() {
    @Override
    public void runCommand(String channelID, String authorID, boolean isAdmin, String authorUUID, String[] args) {
        API.addAction(authorUUID, new ActionSpawn());
        API.sendMessage("Sending to spawn.");
    }
});

That's it! If you have any questions, PLEASE let me know! I hope you enjoyed my tutorial on how to use the Developer API!