tgc

top.gg-core

A top.gg API

Showing:

Popularity

Downloads/wk

2K

GitHub Stars

8

Maintenance

Last Commit

6mos ago

Contributors

1

Package

Dependencies

5

Size (min+gzip)

230.0KB

License

Apache-2.0

Type Definitions

Tree-Shakeable

No?

Categories

Readme

NPM Banner

NPM version NPM downloads

Install

$ npm i top.gg-core

Definite

const top = require('top.gg-core');

Examples

Setup

Go to webhooks section of your bot

Click Show Token and copy paste
const topgg = new top.Client('TOP GG TOKEN');

Post Stats

topgg.post({ servers: client.guilds.cache.size }).then(console.log); //post only server count | returning: boolean

topgg.post({
    servers: client.guilds.cache.size,
    shard: {
        id: client.Shard.id,
        count: client.Shard.count
    }
}).then(console.log) //with shard info | returning: boolean

topgg.on('posted', data => {
  console.log(data);
});



Informaion

topgg.bot('id of the bot').then(res => console.log(res.username + '\n' + res)); //bot who is in top.gg information

topgg.user('id of the user').then(res => console.log(res.color)); //top.gg bot developer information | color = the main hex color who user selected

topgg.votes().then(console.log); //all votes who your bot have

topgg.isVoted('id of user').then(console.log); //if the user is voted for your bot | returning: true/false (boolean)

Vote

Setup

Go to webhooks section of your bot

On Webhook URL put your domain (example.com, example.glitch.me, example.user.repl.co) and path (/topggVote) and the result is <domain.com>/topggVote Create a password and put into Authorization
const webhook = new top.Webhook('your password');

Default Method

webhook.login('your path | on the example: /topggVote', '3000'); //you can edit the port (only numbers) NOTE: PUT .login METHOD BEFORE THE .on('vote') METHOD

webhook.on('vote', vote => {
  console.log(`User id: ${vote.user}\nAll data: ${vote}`);
});

/**
 * returning
 * {
  bot: '767341532093087755',
  user: '728512329888825396',
  type: 'test',
  query: [Object: null prototype] { test: 'data', notRandomNumber: '8' },
  isWeekend: true
}
 */

Advanced Method

const express = require('express');
const app = express();

app.post('/topggVote', webhook.advanced(), (req, res) => {
    console.log(req.vote);
});

app.listen('3000', () => {
    console.log('App listening on port 3000');
});

Full Discord.js Example

const discord = require('discord.js');
const top = require('top.gg-core');

const client = new discord.Client();
const topgg = new top.Client('TOP GG TOKEN');
const webhook = new top.Webhook('your password');

client.on('ready', () => {
  console.log('Logged');

  topgg.post({
    servers: client.guilds.cache.size
  });

  setInterval(() => {
    topgg.post({
      servers: client.guilds.cache.size
    });
  }, 3600000); //posting stats every 1h | another method: https://npmjs.com/package/top.gg-auto

});

topgg.on('posted', data => {
  console.log(data);
});

webhook.login('your path | on the example: /topggVote', '3000'); //you can edit the port (only numbers) NOTE: PUT .login METHOD BEFORE THE .on('vote') METHOD

webhook.on('vote', vote => {
  console.log(`User id: ${vote.user}\nAll data: ${vote}`);
});

client.on('message', message => {
  if (message.content.startsWith('!votes')) {

    let votes = await topgg.votes();
    
    message.channel.send(`I have ${votes} votes`);

  }
});

client.login('DISCORD BOT TOKEN');

Full Eris Example

const Eris = require('eris');

const client = new Eris("DISCORD BOT TOKEN");

client.on("ready", () => {
  console.log('Logged');

  topgg.post({
    servers: client.guilds.size
  });

  setInterval(() => {
    topgg.post({
      servers: client.guilds.size
    });
  }, 3600000); //posting stats every 1h | another method: https://npmjs.com/package/top.gg-auto

});

topgg.on('posted', data => {
  console.log(data);
});

webhook.login('your path | on the example: /topggVote', '3000'); //you can edit the port (only numbers) NOTE: PUT .login METHOD BEFORE THE .on('vote') METHOD

webhook.on('vote', vote => {
  console.log(`User id: ${vote.user}\nAll data: ${vote}`);
});

client.on("messageCreate", message => {
  if (message.content.startsWith('!votes')) {

    let votes = await topgg.votes();
    
    client.createMessage(message.channel.id, `I have ${votes} votes`);

  }
});

client.connect();

top.gg-core is not affiliated with discord bot list (top.gg)


Contact

Youtube, Discord

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100