Top-gg-Community / java-sdk

An API wrapper for https://top.gg/api/docs that works in Java
Apache License 2.0
36 stars 22 forks source link

Your API is broken. #9

Open superSebi opened 4 years ago

superSebi commented 4 years ago

Expected Behavior That your api is working.

Observed Behavior Instead your API is returning this:

org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
at org.json.JSONTokener.syntaxError(JSONTokener.java:507)
at org.json.JSONObject.(JSONObject.java:222)
at org.json.JSONObject.(JSONObject.java:406)
at org.discordbots.api.client.impl.DiscordBotListAPII

Code:

public void onReady(@NotNull ReadyEvent event) {

    DiscordBotListAPI api = new DiscordBotListAPI.Builder()
            .token("Here stands the token 👍 ")
            .botId("493066387183632387")
            .build();
    new Timer().schedule(new TimerTask() {

        @Override
        public void run() {
            //event.getJDA().getPresence().setGame(null);
            new Thread(() -> {
                    for (Member m : Objects.requireNonNull(Main.shardMan.getGuildById("504609411243704365")).getMembers()) {
                        api.hasVoted(m.getId()).whenComplete((hasVoted, e) -> {
                            if (hasVoted) {
                                if (!m.getRoles().contains(Objects.requireNonNull(Main.shardMan.getGuildById("504609411243704365")).getRoleById("610402330315325472"))) {
                                    String votes = "Herbert cant load any data";

                                    Objects.requireNonNull(Objects.requireNonNull(Main.shardMan.getGuildById("504609411243704365")).getTextChannelById("504609411243704365")).sendMessage(new EmbedBuilder()
                                            .setColor(Color.cyan)
                                            .setDescription(m.getAsMention() + " voted the **" + votes + "th** for me :heart:")

             .build()).queue();
                                }
                            }
                        });
                    }