Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.idea/
*.iws
*.iml
out/
.gradle/
build/
10 changes: 8 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
group 'org.discordbots'
plugins {
id 'java'
id 'net.ltgt.apt' version '0.10'
}

apply plugin: 'java'
group 'org.discordbots'

repositories {
mavenCentral()
Expand All @@ -15,4 +18,7 @@ dependencies {
compile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.11.0'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
compile group: 'com.fatboyindustrial.gson-javatime-serialisers', name: 'gson-javatime-serialisers', version: '1.1.1'

compileOnly 'org.projectlombok:lombok:1.18.2'
apt 'org.projectlombok:lombok:1.18.2'
}
Empty file modified gradlew
100644 → 100755
Empty file.
44 changes: 36 additions & 8 deletions src/main/java/org/discordbots/api/client/DiscordBotListAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,58 @@

import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CompletionStage;

public interface DiscordBotListAPI {

CompletionStage<Void> setStats(int shardId, int shardTotal, int serverCount);
CompletionStage<Void> setStats(List<Integer> shardServerCounts);

/**
* Sets the server count for your bot to display publicly.
* Provide a gap between calls or your API usage may be restricted
* @param serverCount the amount of servers your bot is in
*/
CompletionStage<Void> setStats(int serverCount);

CompletionStage<BotStats> getStats(String botId);
CompletionStage<BotStats> getStats();

/**
* If you have more than 1000 votes every month, <b>do not use this method</b>
* @return a list of users who have voted for the bot in the past 24 hours.
*/
CompletionStage<List<SimpleUser>> getVoters();

@Deprecated
CompletionStage<List<SimpleUser>> getVoters(String botId);
/**
* checks if a user has voted for the bot in the past 24 hours
* @param userId the user to see if they have voted
* @return whether the user has voted
*/
CompletionStage<Boolean> hasVoted(String userId);

CompletionStage<BotResult> getBots(Map<String, String> search, int limit, int offset);
CompletionStage<BotResult> getBots(Map<String, String> search, int limit, int offset, String sort);
CompletionStage<BotResult> getBots(Map<String, String> search, int limit, int offset, String sort, List<String> fields);

/**
* https://discordbots.org/api/docs#bots
* @return a {@link Bot} object about the current bot
*/
CompletionStage<Bot> getBot();

/**
* Returns information on the bot with the given ID.
* @return a {@link Bot} object about the given <code>botId</code>
*/
CompletionStage<Bot> getBot(String botId);

CompletionStage<User> getUser(String userId);

/**
* @return the current voting multiplier.
* Determines if it is the weekend or not.
*/
CompletionStage<VotingMultiplier> getVotingMultiplier();

class Builder {
Expand All @@ -45,11 +76,8 @@ public Builder botId(String botId) {
}

public DiscordBotListAPI build() {
if(token == null)
throw new IllegalArgumentException("The provided token cannot be null!");

if(botId == null)
throw new IllegalArgumentException("The provided bot ID cannot be null!");
Objects.requireNonNull(token, "The provided token cannot be null!");
Objects.requireNonNull(botId, "The provided bot ID cannot be null!");

return new DiscordBotListAPIImpl(token, botId);
}
Expand Down
97 changes: 2 additions & 95 deletions src/main/java/org/discordbots/api/client/entity/Bot.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.discordbots.api.client.entity;

import com.google.gson.annotations.SerializedName;
import lombok.Getter;

import java.time.OffsetDateTime;
import java.util.List;

@Getter
public class Bot {

private String id;
Expand Down Expand Up @@ -46,99 +48,4 @@ public class Bot {
private int points;

private boolean legacy;



public String getId() {
return id;
}

public String getClientId() {
return clientId;
}

public String getUsername() {
return username;
}

public String getDiscriminator() {
return discriminator;
}

public String getAvatar() {
return avatar;
}

public String getDefaultAvatar() {
return defaultAvatar;
}

public String getPrefix() {
return prefix;
}

public String getInvite() {
return invite;
}

public String getWebsite() {
return website;
}

public String getVanity() {
return vanity;
}

public String getSupport() {
return support;
}

public List<String> getTags() {
return tags;
}

public String getLongDescription() {
return longDescription;
}

public String getShortDescription() {
return shortDescription;
}

public String getBetaDescription() {
return betaDescription;
}

public boolean isCertified() {
return certified;
}

public OffsetDateTime getApprovalTime() {
return approvalTime;
}

public long getServerCount() {
return serverCount;
}

public List<String> getGuilds() {
return guilds;
}

public List<Integer> getShards() {
return shards;
}

public int getMonthlyPoints() {
return monthlyPoints;
}

public int getPoints() {
return points;
}

public boolean isLegacy() {
return legacy;
}

}
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package org.discordbots.api.client.entity;

import com.google.gson.annotations.SerializedName;
import lombok.Getter;

import java.util.Collections;
import java.util.List;

public class BotStats {

@SerializedName("server_count")
@Getter
private int serverCount;
private List<Integer> shards;

public int getServerCount() { return serverCount; }
public List<Integer> getShards() { return Collections.unmodifiableList(shards); }
}
30 changes: 7 additions & 23 deletions src/main/java/org/discordbots/api/client/entity/Result.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
package org.discordbots.api.client.entity;

import lombok.Getter;

import java.util.List;

@Getter
public class Result<T> {

private List<T> results;
private int limit, offset, count, total;



public List<T> getResults() {
return results;
}

public int getLimit() {
return limit;
}

public int getOffset() {
return offset;
}

public int getCount() {
return count;
}

public int getTotal() {
return total;
}
private int limit;
private int offset;
private int count;
private int total;

}
22 changes: 3 additions & 19 deletions src/main/java/org/discordbots/api/client/entity/SimpleUser.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
package org.discordbots.api.client.entity;

import lombok.Getter;

@Getter
public class SimpleUser {

private String id;
private String username;
private String discriminator;

private String avatar;



public String getId() {
return id;
}

public String getUsername() {
return username;
}

public String getDiscriminator() {
return discriminator;
}

public String getAvatar() {
return avatar;
}

}
36 changes: 2 additions & 34 deletions src/main/java/org/discordbots/api/client/entity/User.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.discordbots.api.client.entity;

import com.google.gson.annotations.SerializedName;
import lombok.Getter;

@Getter
public class User extends SimpleUser {

@SerializedName("defAvatar")
Expand All @@ -12,38 +14,4 @@ public class User extends SimpleUser {

private Social social;



public String getDefaultAvatar() {
return defaultAvatar;
}

public boolean isAdmin() {
return admin;
}

public boolean isMod() {
return mod;
}

public boolean isWebMod() {
return webMod;
}

public boolean isArtist() {
return artist;
}

public boolean isCertifiedDev() {
return certifiedDev;
}

public boolean isSupporter() {
return supporter;
}

public Social getSocial() {
return social;
}

}
24 changes: 2 additions & 22 deletions src/main/java/org/discordbots/api/client/entity/Vote.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.discordbots.api.client.entity;

import com.google.gson.annotations.SerializedName;
import lombok.Getter;

@Getter
public class Vote {

@SerializedName("bot")
Expand All @@ -16,26 +18,4 @@ public class Vote {
@SerializedName("isWeekend")
private boolean weekend;



public String getBotId() {
return botId;
}

public String getUserId() {
return userId;
}

public String getType() {
return type;
}

public String getQuery() {
return query;
}

public boolean isWeekend() {
return weekend;
}

}
Loading