1.0.0-b • Published 3 years ago

top.gg-core v1.0.0-b

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

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
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