Giter VIP home page Giter VIP logo

botlisthandler's Introduction

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.

BotListHandler

This handler can be used in 3 ways:

  • standalone (updating the stats yourself)
  • using JDA
  • using Javacord

Getting the handler

Replace %VERSION_xyz% with the latest release tag:

  • version_core
  • version_jda
  • version_javacord

Modules

  • 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

Gradle

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%'
}

Maven

<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>

Initialization

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.

Implementation

There are 3 ways to use BotListHandler:

Standalone

botListHandler.updateAllStats(botId, serverCount);

Event based

// 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();

Automatic stats posting (recommended)

// 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();

Your own updater for automatic stats posting

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.

Currently supported bot lists

botsondiscord.xyz

discord.bots.gg

discordbotlist.com

discordbots.co

discordextremelist.xyz

discords.com

discordservices.net

top.gg

Troubleshooting

Please visit the wiki for troubleshooting steps. If the wiki doesn't contain the problem you're having, open a new issue.

botlisthandler's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar sebm253 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

botlisthandler's Issues

Javacord support

Hey uhm I wanted to ask you if this is getting Javacord support.

Javacord doesn't work

Hey, I was trying to implement this framework with Javacord but this error occurs all the time:

Caused by: java.lang.NoSuchMethodError: 'java.util.Collection org.javacord.api.DiscordApi.getServers()'
	at dev.mlnr.blh.javacord.BLHJavacordUpdater.getServerCount(BLHJavacordUpdater.java:67)
Caused by: java.lang.NoSuchMethodError: 'java.util.Collection org.javacord.api.DiscordApi.getServers()'

This is my code:

        Map<BotList, String> botLists = new EnumMap<>(BotList.class);
        botLists.put(BotList.TOP_GG, System.getenv("TopGGToken"));
        botLists.put(BotList.BOTS_ON_DISCORD, System.getenv("BotsForDiscordToken"));
        botLists.put(BotList.DBL, System.getenv("DiscordBotListToken"));


        BLHJavacordUpdater javaCordUpdater = new BLHJavacordUpdater(shardsById.values());

        new BLHBuilder(javaCordUpdater, botLists)
                .setAutoPostDelay(5, TimeUnit.MINUTES)
                .build();

ShardsById gives back a Map which contains every shard with its ID...So shardsById.values returns all Shards as a List

Is there any official fix?
Best Regards Marvin

Top.gg error 403: Denied

Hey uhm I got this problem right here: Top.gg is spraying a 403. The token is correct and my top.gg api is posting everything fine so its rn this handler: 2021-04-15 10:32:33,427 <ERROR> <OkHttp https://top.gg/... > <[]> <{}> < dev.mlnr.blh.core.api.BotListHandler> Failed to update the stats for bot list TOP_GG with code 403

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.