topgg.post({servers: client.guilds.cache.size}).then(console.log);//post only server count | returning: booleantopgg.post({servers: client.guilds.cache.size,shard: {id: client.Shard.id,count: client.Shard.count}}).then(console.log)//with shard info | returning: booleantopgg.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 informationtopgg.user('id of the user').then(res=>console.log(res.color));//top.gg bot developer information | color = the main hex color who user selectedtopgg.votes().then(console.log);//all votes who your bot havetopgg.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
constwebhook=newtop.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') METHODwebhook.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
constexpress=require('express');constapp=express();app.post('/topggVote',webhook.advanced(),(req,res)=>{console.log(req.vote);});app.listen('3000',()=>{console.log('App listening on port 3000');});
constdiscord=require('discord.js');consttop=require('top.gg-core');constclient=newdiscord.Client();consttopgg=newtop.Client('TOP GG TOKEN');constwebhook=newtop.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') METHODwebhook.on('vote',vote=>{console.log(`User id: ${vote.user}\nAll data: ${vote}`);});client.on('message',message=>{if(message.content.startsWith('!votes')){letvotes=awaittopgg.votes();message.channel.send(`I have ${votes} votes`);}});client.login('DISCORD BOT TOKEN');
constEris=require('eris');constclient=newEris("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') METHODwebhook.on('vote',vote=>{console.log(`User id: ${vote.user}\nAll data: ${vote}`);});client.on("messageCreate",message=>{if(message.content.startsWith('!votes')){letvotes=awaittopgg.votes();client.createMessage(message.channel.id,`I have ${votes} votes`);}});client.connect();