-
Notifications
You must be signed in to change notification settings - Fork 0
BotBlockAPI
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 a the guild counts.
- Set if either a JDA or a ShardManager should be used (or none at all).
It is recommended to use the Builder to create an instance.
However, if you have knowledge of what you need to provide and what they do you can use one of the following ways to create:
/*
* Sets the Map containing the sites and tokens and also the update interval.
* JDA and ShardManager will be null and JDA requirement will be true unless
* manually changed.
*
* Possible RequestHandlers:
* - RequestHandler(BotBlockAPI botBlockAPI);
* - RequestHandler(String botId, int guilds, BotBlockAPI botBlockAPI);
* - RequestHandler(Long botId, int guilds, BotBlockAPI botBlockAPI);
*/
new BotBlockAPI(Map<String, String> authTokens, int updateInterval);
/*
* Sets the Map containing the sites and tokens, the update interval and
* the instance of JDA.
* ShardManager will be null and JDA requirement will be false unless
* manually changed.
*
* Possible RequestHandlers:
* - RequestHandler(BotBlockAPI botBlockAPI);
* - RequestHandler(JDA jda, BotBlockAPI botBlockAPI);
* - RequestHandler(String botId, int guilds, BotBlockAPI botBlockAPI);
* - RequestHandler(Long botId, int guilds, BotBlockAPI botBlockAPI);
*/
new BotBlockAPI(Map<String, String> authTokens, int updateDelay, JDA jda);
/*
* Sets the Map containing the sites and tokens, the update interval and
* the instance of ShardManager.
* JDA will be null and JDA requirement will be false unless manually changed.
*
* Possible RequestHandlers:
* - RequestHandler(BotBlockAPI botBlockAPI);
* - RequestHandler(ShardManager shardManager, BotBlockAPI botBlockAPI);
* - RequestHandler(String botId, int guilds, BotBlockAPI botBlockAPI);
* - RequestHandler(Long botId, int guilds, BotBlockAPI botBlockAPI);
*/
new BotBlockAPI(Map<String, String> authTokens, int updateDelay, ShardManager shardManager);
The Builder is an internal class that was made to provide an easy way to set up an instance of BotBlockAPI.
When calling new BotBlockAPI.Builder()
you can directly provide either a JDA or ShardManager instance. This is optional and you can set it any time with setJDA(JDA jda)
or setShardManager(ShardManager shardManager)
(This needs to be done before calling build()
).
The code could look like this:
BotBlockAPI api = new BotBlockAPI.Builder(jda)
.addAuthToken("BotList1", "Token1")
.addAuthToken("BotList2", "Token2")
.build();
The Builder has following methods available:
Adds a site and the corresponding site 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 have to use this AT LEAST once!
Set the Map directly with the sites and their token.
This will override the ENTIRE Map and all its previous entries!
Sets the delay in which the guild counts should be posted.
The time is in minutes and you need to set it to at least 1 or else it throws an IllegalArgumentException
.
The default Update delay is 30 minutes.
Disables the requirement of setting a JDA or ShardManager instance.
You can still call methods that require JDA or ShardManager when you set the corresponding instance first.
Auto-Posting won't be possible with this enabled.
Sets the JDA instance.
You can also provide it directly through Builder (new BotBlockAPI.Builder(JDA jda)
).
This will set disableJDA(boolean disable)
to false when it was enabled.
When you set a ShardManager instance, this will be ignored.
Similar properties like setJDA(JDA jda)
but for ShardManager.
This will set disableJDA(boolean disable)
to false when it was enabled.
This will create the BotBlockAPI instance which means it should be called lastly.
JavaBotBlockAPI - A continued fork of BotBlock4J for the BotBlock API