Skip to content
This repository was archived by the owner on Jul 26, 2019. It is now read-only.

BotBlockAPI

Andre_601 edited this page Jun 27, 2019 · 6 revisions

The BotBlockAPI is the essential class for handling the information used in the RequestHandler.

The class allows you to...

  • Add Botlist sites and their API-tokens. For a list of supported sites, click here
  • Set a delay for posting the guild counts.

Create an instance

It is recommended to use the Builder to create an instance.
However, if you have knowledge of what you need to provide and what those values are for, then feel free to use this constructor:

/*
 * Sets the Map containing the sites and tokens and also the update interval.
 */
new BotBlockAPI(Map<String, String> authTokens, int updateInterval);

Builder

The Builder is an internal class that was made to provide an easy way to set up an instance of BotBlockAPI.

The code could look like this:

BotBlockAPI api = new BotBlockAPI.Builder()
    .addAuthToken("BotList1", "Token1")
    .addAuthToken("BotList2", "Token2")
    .build();

Methods

The Builder has the following methods available:

addAuthToken(String site, String token)

Required? Yes
Values: String, String

May throw:

  • NullPointerException - When either site or token are empty/null

Adds a site and the corresponding token to a Map that will be used for posting the guild counts.
If a value with the same site name is already set, it will be overriden.

You may receive the API-token from the botlist your bot is on.

You have to use this AT LEAST once!

setAuthTokens(Map<String, String> authTokens)

Required? No (If you called addAuthTokens(String, String))
Values: Map<String, String>

May throw:

  • NullPointerException - When the provided Map is empty/null

Set the Map directly with the sites and their token.
This will override the ENTIRE Map and all its previous entries!

setUpdateInterval(int updateInterval)

Required? No (Has a default value of 30)
Values: Integer

May throw:

  • IllegalArgumentException - If provided value is less than 2

Sets the delay in which the guild counts should be posted.

The delay cannot be less than 2. This is due to BotBlock's rate limit which is 1 request every 120 seconds.

build()

Required? Yes
Values: None

This will create the BotBlockAPI instance which means it should be called last.