Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Latest commit

 

History

History
96 lines (76 loc) · 4.03 KB

README.md

File metadata and controls

96 lines (76 loc) · 4.03 KB

Tatsumaki4J CircleCI Download Codacy Badge

An asynchronous Java API wrapper around one of the most popular bots on Discord, Tatsumaki.

The API wrapper has all endpoints implemented: guilds, users and ping.

When you create the client, by default a number of fixed threads are created, specifically CPUs/CPU cores + 1. You can customise this using the client builder.

The client is designed to run for the duration of your program, keeping the thread pool alive for quick async execution. Once you are done with the client, call its close method to shutdown the executor services, which will keep your program alive. However, you must create a new instance of the client if you wish to make another API request after closing the client.

Note that I am not part of the Tatsumaki Bot development. If you have any queries about the bot or the API, please visit https://tatsumaki.xyz/

How do I get an API key

To get an API key, run the following command on Tatsumaki: t!apikey

Dependencies

This library is available on JCenter. The current release is 0.6.1

Replace {LATEST_VERSION} with the current release.

Gradle Setup

implementation 'uk.co.hassie.libraries.discord.tatsumaki4j:{LATEST_VERSION}'

Maven Setup

<dependency>
  <groupId>uk.co.hassie.libraries.discord</groupId>
  <artifactId>tatsumaki4j</artifactId>
  <version>{LATEST_VERSION}</version>
  <type>pom</type>
</dependency>

Tutorial

Creating the client

// Create the client with the default number of threads.
TatsumakiClient tatsumakiClient = new TatsumakiClient("YOUR TATSUMAKI BOT TOKEN");

// Create the client with a custom number of threads.
TatsumakiClient tatsumakiClient = new TatsumakiClient.Builder()
    .setThreadPoolSize(1)
    .setToken("YOUR TATSUMAKI BOT TOKEN")
    .build();

Retrieving user profile data

// Request for user profile data for a user.
tatsumakiClient.getUser("User ID",
    user -> {
        // Success, output some stuff.
        System.out.println("User's Rank: " + user.getRank());
        System.out.println("User's Reputation: " + user.getReputation());
    },
    // Output error message.
    Throwable::printStackTrace
}

// Do other stuff here if required while the above request
// is executed.

Endpoints

  • GET Guild Leaderboard: getGuildLeaderboard(guildId, Response<GuildLeaderboard> response, Error error)
  • GET Guild User Stats: getGuildUserStats(guildId, userId, Response<GuildUserStats> response, Error error)
  • GET Ping: getPing(Response<Ping> response, Error error)
  • GET User: getUser(Response<TatsumakiUser> response, Error error)
  • PUT Guild User Points: updateGuildUserPoints(guildId, userId, updateAction, amount, Response<GuildUserPoints> response, Error error)
  • PUT Guild User Score: updateGuildUserScore(guildId, userId, updateAction, amount, Response<GuildUserScore> response, Error error)

Closing the client

tatsumakiClient.close();

License

Copyright ©2018-2019 Hassie.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.