Skip to content
This repository was archived by the owner on Dec 31, 2018. It is now read-only.

BenjaminUrquhart/DiscordBansAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 

Repository files navigation

###########################################################################

DiscordList (and therefore DBans) no longer exists. This wrapper is defunct

###########################################################################

DiscordBansAPI

Java library to interface with the Discord Bans API

An example program is shown in src/net/dbans/test

How to use

  1. Add the latest jarfile release to your buildpath

  2. Import the API with import net.dbans.*;

  3. Create an API object

DiscordBanAPI api = new DiscordBanAPI("your token here");
//If you want to catch exceptions...
DiscordBanAPI api = new DiscordBanAPI("your token here", true);
  1. Make calls
//Single user checking
//Returns null for all exceptions except for NumberFormatException, throws IllegalArgumentException in that case
//Throws all exceptions if verbosity is enabled
String id = "user id here";
UserInfo info = api.checkUser(id);
//Bulk checking
List<String> ids = /*List of user IDs*/;
List<UserInfo> list = api.checkUsers(ids);

Note: if an exception is thrown the methods will return null unless verbosity is enabled, then an exception will be thrown instead

You can see if a user is banned using UserInfo#isBanned():

if(info.isBanned()){ //returns true/false
  //do stuff
}

Getting user ID:

System.out.println(info.getUserId());

If you want to know why a user is banned:

if(info.isBanned()){
  System.out.println(info.getReason()); //If the user isn't banned, this will throw an IllegalStateException
}

Geting proof URL:

if(info.isBanned()){
  System.out.println(info.getProof()); //If the user isn't banned, this will throw an IllegalStateException
}

Getting case ID:

if(info.isBanned()){
  System.out.println(info.getCaseId()); //If the user isn't banned, this will throw an IllegalStateException
}

Getting Direct URLs to Proofs:

if(info.isBanned()){
  String[] urls = info.getDirectProofUrls();
  for(String url: urls){
    System.out.println(url);
  }
}

Standalone Client

Executing the jarfile in a terminal window will give you a small interactive client.

java -jar path/to/jarfile.jar <token>

This is mainly for checking your token's validity. Just enter a user ID at the prompt to see the results.

Multiple users can be checked by inputting a comma-separated string of user ids. Example: 123456789123456789,98765432109876543210

About

Java Library to interface with the Discord Bans API

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages