Options
All
  • Public
  • Public/Protected
  • All
Menu

Top.gg API Client for Posting stats or Fetching data

example
const Topgg = require(`@top-gg/sdk`)

const api = new Topgg.Api('Your top.gg token')
link

Library docs

link

API Reference

Hierarchy

  • EventEmitter
    • Api

Index

Constructors

constructor

  • new Api(token: string, options?: APIOptions): Api
  • Create Top.gg API instance

    Parameters

    • token: string

      Token or options

    • options: APIOptions = {}

      API Options

    Returns Api

Methods

getBot

  • getBot(id: string): Promise<BotInfo>
  • Get bot info

    example
    await api.getBot('461521980492087297') // returns bot info
    

    Parameters

    • id: string

      Bot ID

    Returns Promise<BotInfo>

    Info for bot

getBots

  • Get a list of bots

    example
    // Finding by properties
    await api.getBots({
      search: {
        username: 'shiro',
        certifiedBot: true
        ...any other bot object properties
      }
    })
    // =>
    {
      results: [
        {
          id: '461521980492087297',
          username: 'Shiro',
          discriminator: '8764',
          lib: 'discord.js',
          ...rest of bot object
        }
        ...other shiro knockoffs B)
      ],
      limit: 10,
      offset: 0,
      count: 1,
      total: 1
    }
    // Restricting fields
    await api.getBots({
      fields: ['id', 'username']
    })
    // =>
    {
      results: [
        {
          id: '461521980492087297',
          username: 'Shiro'
        },
        {
          id: '493716749342998541',
          username: 'Mimu'
        },
        ...
      ],
      ...
    }
    

    Parameters

    Returns Promise<BotsResponse>

    Return response

getStats

  • getStats(id: string): Promise<BotStats>
  • Get a bots stats

    example
    await api.getStats('461521980492087297')
    // =>
    {
      serverCount: 28199,
      shardCount 1,
      shards: []
    }
    

    Parameters

    • id: string

      Bot ID

    Returns Promise<BotStats>

    Stats of bot requested

getUser

  • getUser(id: string): Promise<UserInfo>
  • Get user info

    example
    await api.getUser('205680187394752512')
    // =>
    user.username // Xignotic
    

    Parameters

    • id: string

      User ID

    Returns Promise<UserInfo>

    Info for user

getVotes

  • Get users who've voted

    example
    await api.getVotes()
    // =>
    [
      {
        username: 'Xignotic',
        discriminator: '0001',
        id: '205680187394752512',
        avatar: '3b9335670c7213b3a2d4e990081900c7'
      },
      {
        username: 'iara',
        discriminator: '0001',
        id: '395526710101278721',
        avatar: '3d1477390b8d7c3cec717ac5c778f5f4'
      }
      ...more
    ]
    

    Returns Promise<ShortUser[]>

    Array of users who've voted

hasVoted

  • hasVoted(id: string): Promise<boolean>
  • Get whether or not a user has voted in the last 12 hours

    example
    await api.hasVoted('205680187394752512')
    // => true/false
    

    Parameters

    • id: string

      User ID

    Returns Promise<boolean>

    Whether the user has voted in the last 12 hours

isWeekend

  • isWeekend(): Promise<boolean>
  • Whether or not the weekend multiplier is active

    example
    await api.isWeekend()
    // => true/false
    

    Returns Promise<boolean>

    Whether the multiplier is active

postStats

  • Post bot stats to Top.gg

    example
    await api.postStats({
      serverCount: 28199,
      shardCount: 1
    })
    

    Parameters

    Returns Promise<BotStats>

    Passed object

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Method

Generated using TypeDoc