BotListHandler has been discontinued as of September 2nd, 2023. I lost interest in Java a long time ago and somewhat recently, in bot lists as well.
This handler can be used in 3 ways:
- standalone (updating the stats yourself)
- using JDA
- using Javacord
Replace %VERSION_xyz%
with the latest release tag:
- core: the core module of the handler, required and bundled with every module (however it's recommended to declare the dependency separately for independent updates)
- jda: the jda module of the handler, use this if you intend to get the data from a JDA bot
- javacord: the javacord module of the handler, use this if you intend to get the data from a Javacord bot
repositories {
mavenCentral()
}
dependencies {
// required (bundled with every module, see the Modules section)
implementation group: 'dev.mlnr', name: 'BotListHandler-core', version: '%VERSION_core%'
// optional
implementation group: 'dev.mlnr', name: 'BotListHandler-jda', version: '%VERSION_jda%'
implementation group: 'dev.mlnr', name: 'BotListHandler-javacord', version: '%VERSION_javacord%'
}
<dependencies>
<!--required (bundled with every module, see the Modules section)-->
<dependency>
<groupId>dev.mlnr</groupId>
<artifactId>BotListHandler-core</artifactId>
<version>%VERSION_core%</version>
</dependency>
<!--optional-->
<dependency>
<groupId>dev.mlnr</groupId>
<artifactId>BotListHandler-jda</artifactId>
<version>%VERSION_jda%</version>
</dependency>
<dependency>
<groupId>dev.mlnr</groupId>
<artifactId>BotListHandler-javacord</artifactId>
<version>%VERSION_javacord%</version>
</dependency>
</dependencies>
Using the addBotList
method:
BotListHandler botListHandler = new BLHBuilder().addBotList(BotList.TOP_GG, "top_gg_token")
.addBotList(BotList.DSERVICES, "dservices_token")
.build();
Using the constructor:
Map<BotList, String> botLists = new EnumMap<>(BotList.class);
botLists.put(BotList.DBL, "dbl_token");
botLists.put(BotList.DEL, "del_token");
BotListHandler botListHandler = new BLHBuilder(botLists).build();
Using the setBotLists
method:
Map<BotList, String> botLists = new EnumMap<>(BotList.class);
botLists.put(BotList.DISCORDS, "discords_token");
botLists.put(BotList.DBOTS_GG, "dbots_gg_token");
BotListHandler botListHandler = new BLHBuilder().setBotLists(botLists).build();
You can store the BotListHandler
instance to add bot lists or hotswap invalid tokens at runtime.
There are 3 ways to use BotListHandler:
botListHandler.updateAllStats(botId, serverCount);
// JDA
BLHJDAListener jdaListener = new BLHJDAListener(botListHandler);
JDA jda = JDABuilder.create("token", intents)
.addEventListeners(jdaListener)
.build();
jda.awaitReady(); // optional, but if you want to update the stats after a ReadyEvent, it's required
// Javacord
BLHJavacordListener javacordListener = new BLHJavacordListener(botListHandler);
new DiscordApiBuilder().setToken(token)
.addListener(javacordListener)
.login();
// JDA - supports sharding
JDA jda = JDABuilder.create("token", intents)
.build();
jda.awaitReady(); // optional
BLHJDAUpdater jdaUpdater = new BLHJDAUpdater(jda);
BotListHandler botListHandler = new BLHBuilder(jdaUpdater, botLists)
.setAutoPostDelay(10, TimeUnit.MINUTES).build();
// Javacord - supports sharding. async approach - call join() after login() to block
new DiscordApiBuilder().setToken(token)
.login()
.thenAccept(discordApi -> {
BLHJavacordUpdater javacordUpdater = new BLHJavacordUpdater(discordApi);
new BLHBuilder(javacordUpdater, botLists)
.setAutoPostDelay(3, TimeUnit.MINUTES).build();
});
// your own updater
MyUpdater myUpdater = new MyUpdater(); // this class has to implement IBLHUpdater
BotListHandler botListHandler = new BLHBuilder(myUpdater, botLists)
.setAutoPostDelay(1, TimeUnit.HOURS).build();
Creating your own updater for automatic stats posting is simple. All you have to do is to have your updater class implement IBLHUpdater
and then provide values in the overriden methods.
Please visit the wiki for troubleshooting steps. If the wiki doesn't contain the problem you're having, open a new issue.