brawlstats
Version:
A simple API Wrapper for Brawl Stars
393 lines (377 loc) • 10.4 kB
TypeScript
import * as Collection from '@discordjs/collection';
import Collection__default from '@discordjs/collection';
declare const enum Brawlers {
SHELLY = "SHELLY",
COLT = "COLT",
BULL = "BULL",
BROCK = "BROCK",
RICO = "RICO",
SPIKE = "SPIKE",
BARLEY = "BARLEY",
JESSIE = "JESSIE",
NITA = "NITA",
DYNAMIKE = "DYNAMIKE",
EL_PRIMO = "EL PRIMO",
MORTIS = "MORTIS",
CROW = "CROW",
POCO = "POCO",
BO = "BO",
PIPER = "PIPER",
PAM = "PAM",
TARA = "TARA",
DARRYL = "DARRYL",
PENNY = "PENNY",
FRANK = "FRANK",
GENE = "GENE",
TICK = "TICK",
LEON = "LEON",
ROSA = "ROSA",
CARL = "CARL",
BIBI = "BIBI",
BIT8 = "8-BIT",
SANDY = "SANDY",
BEA = "BEA",
EMZ = "EMZ",
MR_P = "MR. P",
MAX = "MAX",
JACKY = "JACKY",
GALE = "GALE",
NANI = "NANI",
SPROUT = "SPROUT",
SURGE = "SURGE",
COLETTE = "COLETTE",
AMBER = "AMBER",
LOU = "LOU",
BYRON = "BYRON",
EDGAR = "EDGAR",
COLONEL_RUFFS = "COLONEL RUFFS",
STU = "STU",
BELLE = "BELLE",
SQUEAK = "SQUEAK",
GROM = "GROM",
BUZZ = "BUZZ",
GRIFF = "GRIFF",
ASH = "ASH",
MEG = "MEG",
LOLA = "LOLA",
FANG = "FANG",
EVE = "EVE"
}
declare const enum Events {
GemGrab = "GemGrab",
SoloShowdown = "SoloShowdown",
BrawlBall = "BrawlBall",
HotZone = "HotZone",
DuoShowdown = "DuoShowdown",
Knockout = "Knockout",
BigGame = "BigGame",
Duels = "Duels",
Wipeout = "Wipeout",
Payload = "Payload"
}
interface BrawlerInterface {
id: number;
name: string;
starPowers?: StarPowersEntityOrGadgetsEntity[] | null;
gadgets?: StarPowersEntityOrGadgetsEntity[] | null;
}
interface IClub {
tag: string;
name: string;
description: string;
type: string;
badgeId: number;
requiredTrophies: number;
trophies: number;
members?: MembersEntity[] | null;
}
interface MembersEntity {
tag: string;
name: string;
nameColor: string;
role: string;
trophies: number;
icon: Icon$1;
}
interface Icon$1 {
id: number;
}
interface StarPowersEntityOrGadgetsEntity {
id: number;
name: string;
}
interface ItemsEntity {
battleTime: string;
event: Event;
battle: Battle;
}
interface IEvent {
startTime: string;
endTime: string;
event: Event;
}
interface Event {
id: number;
mode?: keyof typeof Events | string;
map?: string | null;
}
interface Battle {
mode: string;
type: string;
rank?: number | null;
trophyChange?: number | null;
players?: PlayersEntityOrEntityOrTeamsEntityEntityOrStarPlayer[] | null;
result?: string | null;
duration?: number | null;
starPlayer?: PlayersEntityOrEntityOrTeamsEntityEntityOrStarPlayer1 | null;
teams?: (PlayersEntityOrEntityOrTeamsEntityEntityOrStarPlayer[] | null)[] | null;
}
interface PlayersEntityOrEntityOrTeamsEntityEntityOrStarPlayer {
tag: string;
name: string;
brawler: Brawler;
}
interface Brawler {
id: number;
name: string;
power: number;
trophies: number;
}
interface PlayersEntityOrEntityOrTeamsEntityEntityOrStarPlayer1 {
tag: string;
name: string;
brawler: Brawler;
}
declare type BrawlersType = 'SHELLY' | 'COLT' | 'BULL' | 'BROCK' | 'RICO' | 'SPIKE' | 'BARLEY' | 'JESSIE' | 'NITA' | 'DYNAMIKE' | 'EL PRIMO' | 'MORTIS' | 'CROW' | 'POCO' | 'BO' | 'PIPER' | 'PAM' | 'TARA' | 'DARRYL' | 'PENNY' | 'FRANK' | 'GENE' | 'TICK' | 'LEON' | 'ROSA' | 'CARL' | 'BIBI' | '8-BIT' | 'SANDY' | 'BEA' | 'EMZ' | 'MR. P' | 'MAX' | 'JACKY' | 'GALE' | 'NANI' | 'SPROUT' | 'SURGE' | 'COLETTE' | 'AMBER' | 'LOU' | 'BYRON' | 'EDGAR' | 'COLONEL RUFFS' | 'STU' | 'BELLE' | 'SQUEAK' | 'GROM' | 'BUZZ' | 'GRIFF' | 'ASH' | 'MEG' | 'LOLA' | 'FANG' | 'EVE';
declare class BattlelogManager {
#private;
constructor(token: string);
/**
* Get battlelog of a player from the API.
* @param tag The tag of the player.
*/
fetch(tag: string): Promise<Battlelog[]>;
/**
* Get battlelogs of multiple players from the API.
* @param tags The tag of each player.
*/
fetchMany(...tags: string[]): Promise<Battlelog[][]>;
}
interface Battlelog {
battleTime: string;
event: Event;
battle: Battle;
}
declare class Structure {
#private;
constructor(endpoint: string);
request<T>(endpoint?: string, token?: string): Promise<T>;
}
/**
* The entity which we use to construct every club entry.
*/
declare class Club extends Structure {
tag: string;
name: string;
description: string;
type: 'open' | 'closed';
badgeId: number;
requiredTrophies: number;
trophies: number;
members: MembersEntity[];
constructor(data: Omit<IClub, 'members'>);
}
declare class ClubManager {
#private;
constructor(token: string);
/**
* Get details of a club from the API.
* @async
* @param {String} tag The tag of the club.
*/
fetch(tag: string): Club | Promise<Club> | undefined;
/**
* Get details of a multiple clubs from the API.
* @async
* @param {String} tags The tag of each club.
*/
fetchMany(...tags: string[]): Promise<Club[]>;
}
/**
* The entity which we use to construct every player entry.
*/
declare class Player extends Structure {
tag: string;
name: string;
nameColor: string;
icon: Icon;
trophies: number;
highestTrophies: number;
highestPowerPlayPoints: number;
expLevel: number;
expPoints: number;
isQualifiedFromChampionshipChallenge: boolean;
trioVictories: number;
soloVictories: number;
duoVictories: number;
bestRoboRumbleTime: number;
bestTimeAsBigBrawler: number;
club: PlayerClub;
brawlers?: BrawlersEntity[] | null;
constructor(options: Omit<IPlayer, '3vs3Victories'>);
/**
* Get battlelog of the player.
*/
getBattleLog(): Promise<ItemsEntity[] | null | undefined>;
}
interface IPlayer {
tag: string;
name: string;
nameColor: string;
icon: Icon;
trophies: number;
highestTrophies: number;
highestPowerPlayPoints: number;
expLevel: number;
expPoints: number;
isQualifiedFromChampionshipChallenge: boolean;
'3vs3Victories': number;
trioVictories: number;
soloVictories: number;
duoVictories: number;
bestRoboRumbleTime: number;
bestTimeAsBigBrawler: number;
club: PlayerClub;
brawlers?: BrawlersEntity[] | null;
}
interface Icon {
id: number;
}
interface PlayerClub {
tag: string;
name: string;
}
interface BrawlersEntity {
id: number;
name: string;
power: number;
rank: number;
trophies: number;
highestTrophies: number;
gears?: (GearsEntity | null)[] | null;
starPowers?: (StarPowersEntityOrGadgetsEntity | null)[] | null;
gadgets?: StarPowersEntityOrGadgetsEntity[] | null;
}
interface GearsEntity {
id: number;
name: string;
level: number;
}
/**
* The entity which we use to construct every leaderboard entry.
*/
declare class Leaderboard extends Structure {
tag: string;
name: string;
nameColor: string;
icon: Icon$1;
trophies: number;
rank: number;
club: PlayerClub;
constructor(options: Omit<Leaderboard, 'constructor'>);
}
declare class LeaderboardManager {
#private;
constructor(token: string);
/**
* Fetch the leaderboards of a player or a club.
* @param {RestLeaderboardOptions} options Options for the leaderboards.
*/
fetch(options: RestLeaderboardOptions): Promise<Collection__default<string, Leaderboard>>;
/**
* Fetch the leaderboards of a brawler.
* @param {LeaderboardBrawlerOptions} options Options for the leaderboards.
*/
fetch(options: LeaderboardBrawlerOptions): Promise<Collection__default<string, Leaderboard>>;
}
interface LeaderboardOptions {
mode: 'players' | 'clubs' | 'brawlers';
region: string;
name?: BrawlersType;
}
interface LeaderboardBrawlerOptions {
mode: 'brawlers';
region: string;
name: BrawlersType;
}
interface RestLeaderboardOptions {
mode: 'players' | 'clubs';
region: string;
}
declare class PlayerManager {
#private;
constructor(token: string);
/**
* Get details of a player from the API.
* @param {String} tag The tag of the player.
*/
fetch(tag: string): Player | Promise<Player> | undefined;
/**
* Get details of multiple players from the API.
* @param {String} tags The tag of each player.
*/
fetchMany(...tags: string[]): Promise<Player[]>;
}
declare class RotationManager {
#private;
constructor(token: string);
/**
* Get the events rotation from the API.
* @param {RotationOptions} options The options to for data formatting.
*/
get(options?: RotationOptions): Promise<IEvent[]>;
}
/**
* The options to get a rotation.
*/
interface RotationOptions {
/**
* The timezone to recieve times in, defaults to Etc/UTC.
* @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
*/
timezone?: string;
}
declare class Client {
#private;
options: ClientOptions;
brawlers: Collection.Collection<BrawlersType | Brawlers, BrawlerInterface>;
players: PlayerManager;
clubs: ClubManager;
rotation: RotationManager;
leaderboards: LeaderboardManager;
battlelogs: BattlelogManager;
constructor(options?: ClientOptions);
}
/**
* The options to construct the Client
*/
interface ClientOptions {
/**
* The token to use for the API
* @default process.env.BRAWLSTARS_TOKEN
*/
token?: string;
cache?: CacheType;
}
interface CacheType {
player?: {
timeout: number;
};
club?: {
timeout: number;
};
}
declare function dateFromBrawlStars(value: string, timeZone: string): string;
declare function minutes(value: number): number;
declare function hours(value: number): number;
export { Battlelog, BattlelogManager, BrawlerInterface, Brawlers, BrawlersType, Client, ClientOptions, Club, ClubManager, IEvent as Event, Events, Leaderboard, LeaderboardBrawlerOptions, LeaderboardManager, LeaderboardOptions, Player, PlayerManager, RestLeaderboardOptions, RotationManager, RotationOptions, StarPowersEntityOrGadgetsEntity, dateFromBrawlStars, hours, minutes };