Typescript Wrapper¶
Danger
This is subject to change. The Typescript wrapper will receive an update with a lot of breaking changes soon.
Dependency installation¶
To use this wrapper in your JavaScript/TypeScript app, you can add it via the npm registry.
npm i globaltags.ts
bun i globaltags.ts
pnpm add globaltags.ts
yarn add globaltags.ts
Imports¶
After adding the dependency you can import the actual API class like this:
import { GlobalTagAPI } from "globaltags.ts";
const { GlobalTagAPI } = require('globaltags.ts');
Usage¶
To use the wrapper you only need to instantiate a new GlobalTagAPI
object. You can then use GlobalTagAPI#fetchPlayer
to fetch player data and receive an instance of the Player
class.
const api = new GlobalTagAPI(); // (1)
// Get a player instance from a specific player uuid
const player = await api.fetchPlayer('<UUID>', { token: '<YOUR API KEY>' }).catch(() => null);
if(!player) return;
// You can now interact with the player data.
console.log(player.tag || 'No Tag'); // (2)
player.setTag('The new tag :o', { token: 'current auth token' }); // (3)
player.appealBan('I want to apologize', { token: 'token' }); // (4)
- If you want to use a custom instance of the api you need to pass an options object
- Log the player's current tag if it exists.
- Update the player's tag IF you have the admin permission to do so.
- Appeal your ban if you were banned by an administrator.
Contributing¶
If you find any bugs or have feature ideas feel free to create an issue.