Giter Site home page Giter Site logo

top.gg-core's Introduction

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

    top.gg-core's People

    Contributors

    angelocore avatar

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google โค๏ธ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.