diff --git a/typings/index.d.ts b/typings/index.d.ts index acf820f..c85cbbb 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -6,18 +6,26 @@ declare class DBLAPI extends EventEmitter { constructor(token: string, client?: object); public webhook?: DBLWebhook; - public postStats(serverCount: number, shardId?: number, shardCount?: number): Promise - public getStats(id: string): Promise - public getBot(id: string): Promise - public getUser(id: string): Promise - public getBots(query: DBLAPI.BotsQuery): Promise - public getVotes(): Promise - public hasVoted(id: string): Promise - public isWeekend(): Promise + public postStats( + serverCount: number, + shardId?: number, + shardCount?: number + ): Promise; + public getStats(id: string): Promise; + public getBot(id: string): Promise; + public getUser(id: string): Promise; + public getBots(query: DBLAPI.BotsQuery): Promise; + public getVotes(): Promise; + public hasVoted(id: string): Promise; + public isWeekend(): Promise; public token?: string; - private _request(method: string, endpoint: string, data?: object): Promise + private _request( + method: string, + endpoint: string, + data?: object + ): Promise; public on(event: 'posted', listener: () => void): this; public on(event: 'error', listener: (error: Error) => void): this; @@ -25,7 +33,7 @@ declare class DBLAPI extends EventEmitter { import { Server, ServerResponse, IncomingMessage } from 'http'; declare class DBLWebhook extends EventEmitter { - constructor(port?: number, path?: string, auth?: string, server?: Server) + constructor(port?: number, path?: string, auth?: string, server?: Server); public port: number; public path: string; @@ -36,10 +44,20 @@ declare class DBLWebhook extends EventEmitter { private _startWebhook(): void; private _attachWebhook(server: Server): void; private _handleRequest(req: IncomingMessage, res: ServerResponse): void; - private _returnResponse(res: ServerResponse, statusCode: number, data?: string): void; - - public on(event: 'ready', listener: (hostname: string, port: number, path: string) => void): this; - public on(event: 'vote', listener: (bot: string, user: string, type: string, isWeekend: boolean, query?: object) => void): this; + private _returnResponse( + res: ServerResponse, + statusCode: number, + data?: string + ): void; + + public on( + event: 'ready', + listener: (hook: DBLAPI.ReadyEventArgs) => void + ): this; + public on( + event: 'vote', + listener: (vote: DBLAPI.VoteEventArgs) => void + ): this; } declare namespace DBLAPI { @@ -49,13 +67,13 @@ declare namespace DBLAPI { webhookAuth?: string; webhookPath?: string; webhookServer?: Server; - } + }; export type BotStats = { server_count: number; shards: number[]; shard_count: number; - } + }; export type Bot = { id: number; @@ -77,7 +95,7 @@ declare namespace DBLAPI { certifiedBot: boolean; vanity?: string; points: number; - } + }; export type User = { id: number; @@ -94,7 +112,7 @@ declare namespace DBLAPI { mod: boolean; webMod: boolean; admin: boolean; - } + }; export type UserSocial = { youtube?: string; @@ -102,7 +120,7 @@ declare namespace DBLAPI { twitter?: string; instagram?: string; github?: string; - } + }; export type BotsQuery = { limit?: number; @@ -110,7 +128,7 @@ declare namespace DBLAPI { search: string; sort: string; fields?: string; - } + }; export type BotSearchResult = { results: Bot[]; @@ -118,12 +136,26 @@ declare namespace DBLAPI { offset: number; count: number; total: number; - } + }; export type Vote = { username: string; discriminator: string; id: string; avatar: string; - } + }; + + export type VoteEventArgs = { + bot: string; + user: string; + type: string; + isWeekend: boolean; + query?: object; + }; + + export type ReadyEventArgs = { + hostname: string; + port: number; + path: string; + }; }