DServices4J is the official Java library for the Discordservices.net API.
It supports all GET and POST APIs of the site.
You can use the latest version (displayed) above by using either Maven or Gradle for your project.
Alternatively can you also download the individual jar-files from the GitHub releases.
Please replace {version}
with the above displayed version:
repositories{
maven{ url = 'https://repo.codemc.io/repository/maven-public' }
}
dependencies{
implementation 'net.discordservices:dservices4j:{version}'
}
Please replace {version}
with the above displayed version:
<repositories>
<repository>
<id>codemc</id>
<url>https://repo.codemc.io/repository/maven-public</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.discordservices</groupId>
<artifactId>dservices4j</artifactId>
<version>{version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
The DServices4J class is the main class for everything.
It is used to set the API token and to access the various API endpoints.
To get an instance of it, just do this:
String token = /* Your Discord Services API token */
String id = /* The ID of your Bot */
DServices4J instance = new DServices4J().Builder()
.setToken(token)
.setId(id)
.build();
DServices4J has a Commands
class to set the commands of your bot and posting them to the corresponding API.
To get an instance, first create a DServices4J instance and then use the getCommands()
method.
// instance is our DServices4J class.
Commands commands = instance.getCommands();
The Stats
class is the main class to post your bot's statistic with.
As of now does the class offer postStats(long)
for Guilds and a single shard and postStats(long, long)
for Guilds with multiple shards.
To get an instance, first create a DServices4J instance and the use the getStats()
method.
// instance is our DServices4J class.
Stats stats = instance.getStats();
The News
class is used to post announcements about your bot.
These announcements can be both normal or error/issue ones.
To get an instance, first create a DServices4J instance and the use the getNews()
method.
// instance is our DServices4J class.
News news = instance.getNews();