#topgg-api
1 messages ยท Page 131 of 1
wait so my Webhook URL cant be the same as the port?
the url is
http://youip:yourport/yourpath
the port needs to be the same between the url and the code
ok
Hi ! Im using https://www.npmjs.com/package/dblapi.js but I have seen this package is actually deprecated. Is there any thing to change in my code for using https://npmjs.com/@top-gg/sdk ?
Error: listen EACCES: permission denied http://myip:1250/webhook
just make it 3943 or something
wdym
home
Congratz
you're banned for an hour now
Read the full docs before using the top.gg api
not just jump into it
oh gosh I'm stupid
For some reason even tho my vote logger is correct it doesn't work
did you add the webhook url to your webhook settings on your bot page?
Everything works except the vote thingy like my vote client doesn't log
dbl.webhook.on('vote', async vote => {
console.log(vote)
const userID = vote.user;
if(channelForWebhooks) await channelForWebhooks.send(`User with ID \`${userID}\` just voted!`);
})
Yes, http://IP:PORT/dblwebhookIPs
I replaced port and ip with the port and ip
wrong
Then?
Ok
this is the proper usage
Omg works
@rain heart how do I make a webhook to post it like not my bot but a webhook poster it
Post*
@rain heart like I make a webhooke for a channel and using the webhook token when someone votes the webhook sends user has voted
Webhook*
you can make a request to that webhook then
Ok
if you're referring to a discord webhook
Also can I make this a name instead of id like username#0000
if(channelForWebhooks) await channelForWebhooks.send(`User with ID \`${userID}\` just voted!`);
you need to query the user's full name through the library you're using then
I don't know how to do that
@rain heart no no I mean I don't know how to refer to the webhook
Can't really help with making that unfortunately, as i dont code in js
oh ok
Can I do this?
if(channelForWebhooks) await channelForWebhooks.send(`User with ID \`<@${userID}>\` just voted!`);
So that instead of mention it comes as tag
I don't understand
The total votes that my bot is querying from the api is not accounting for double votes of weekends. (In top.gg it's 55 votes but when querying it's 40 only) is there a way to correctly count the weekend votes too?
(I'm using discord.py btw)
it is accounting that
No, I want the vote log to say Chill#9999 has voted
Not id
You need to get the tag from the user through your bot library
through discordjs presumably
${message.author.tag}
how can I fix this?
Log in
okat thx
Hi hi, I am completely lost on how to get a webhook for vote messages, I have to code I just need to know how to make a webhook lol
Node JS
you can use https://npmjs.com/@top-gg/sdk
lol tnx
Setup a webhook
Library probably has support for this. Which language?
A simple API wrapper for top.gg written in Python. Contribute to top-gg/python-sdk development by creating an account on GitHub.
HTTP requests were borked on 3.9 last I checked, but webserver stuff should work fine ig
yeah i saw that, but still aint sure on how to setup a webhook
when you come to the site
Just set the webhook port, auth and path properly
And pass the URL as http://yourip:yourport/yourpath in the URL field on the website
Hey, I am trying to setup webhook in node-sdk
Do I need to run webhook server separately?
your path in the sense?
webhook path. It's /dblwebhook by default. Take a look at the docs.
ok ok ok @green roost thanks let me give it a shot
I'm asking that do I need to run the webhook server separately?
Like a server.js file cuz "Webhook server" is shown differently in docs
Sure you could do that
How do you do this? combined in 1 file ?
I tread on dangerous ground and do this manually lol
It's unsupported tho, so don't do it unless you know what you're doing, I just don't like extra deps.
Have you set up the web app to listen for the webhook post?
There's a pretty complete example in the docs I sent
I am thinking about that.. but how would I handle the vote event?
Like I want to send message in channel
This is also covered in the docs, except it logs to console. Just change that to redirect to a channel
This is also covered in the docs
Where? Couldn't find it
I have the code to make the webhook running but whenever I try to connect I get "Cannot GET /dblwebhook" any ideas?
^
you can't make get requests to it
Click the test button?
Oki, what is suppose to happen? lol
your webhook should get a request then upon testing
How do I know if it did?
again, if you received a request
if you didn't, it most likely didn't work or it is not working
Yep didn't work hmmm
Dosn't it have my ip thoe...
I won't do anything with it, don't worries
though if you don't feel comfortable, just test it yourself using something like postman to make your own test-request
const Topgg = require('@top-gg/sdk')
const app = express() // Your express app
const webhook = new Topgg.Webhook(Password is here) // add your top.gg webhook authorization (not bot token)
console.log("ONLINE");
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
console.log("Connected");
// req.vote is your vote object e.g
console.log(req.vote.user) // 221221226561929217
}) // attach the middleware
app.listen(3000) // your port``` This is code right?
Yes
Hey, I want to test events on webhook on my local system.. how can I do that?
I mean what to enter in Webhook URL so that it'll send post req on my pc's webhook
if your webhook is running on your pc, you need to portforward
ah... can you explain please? ๐
I cannot assist you with how to portforward, you will need to look up a few tutorials on how you can get started
Could you host the webhook of something like heroku?
yeah, you need to use the heroku project url iirc
for the webhook
This is my secondary router
Do I need to do this on my main router too?
how do i set that up
Portforwarding is going to be useless if it isn't your main router
in the sense of if you connected it to another router
is it tcp & udp?
just use all protocol
Basically no need to portforward on secondary router?
No, portforwarding is not going to work if your secondary router is just connected to your main router
you need to open external ports
"outside" ports
Is that on the bot webpage?
Wait there is a special section for them lol
It asks for Internal IP.. will port forwarding work for that particular IP?
https://prnt.sc/xrfhq9
for that particular internal ip (internal ip of the pc the webhook is running on)
yes
There's a problem
my pc is connected to secondary router.. with ip : 192.168.1.1 and main router has ip 192.168.0.1
so it's not allowing port forwarding on my pc's ip address 192.168.1.103 cuz it's different network segment ๐
that is what i was referring to
portforwarding isn't going to do anything if the port is not opened on your main router
F
now either I have to disable DHCP server on 2nd router and make some changes to make sure every system has ip from main router and all are on same network segment
or I test this on my laptop cuz code will run on VPS anyays ๐
which one sounds good?
test the webhook on your vps
It'll work but I need multiple tests cuz I want role and message for upvote user on upvote
So I need to test those things.. I can't do it on VPS cuz it'll be tedious to modify code on VPS
I'll figure it out, thanks for the help :)
I made voting required command to my bot. When I test the webhook. Everything worked correctly. But when I do the voting required command in my bot nothing happened and this error has found in the console.
at IncomingMessage.<anonymous> (/home/runner/TopggWebhooks/node_modules/dblapi.js/src/index.js:118:25)
at IncomingMessage.emit (events.js:327:22)
at IncomingMessage.EventEmitter.emit (domain.js:483:12)
at endReadableNT (_stream_readable.js:1220:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:270) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:270) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
This is the message event code.
```javascript
client.on('message', message => {
if(message.content.startsWith('!ping')){
dbl.hasVoted(message.author.id).then(c => {
if (c){
message.channel.send(`Pong ${client.ws.ping}ms`)
} else {
message.channel.send(`You haven't voted me on top.gg!`)
}
})
}
})```
Any help would be highly appreciated
@wanton cliff
Regen ur token and try
as seen by the 401
Or ur missing authorisation
though they're using the library, so probably not that
I'll try regen. token
I can't find what the url is for the heroku server
I'm still getting that error
When I test the webhook. It works good
When test the webhook 726481895961002065 has voted me!
I tried. But no
im suuuuuuuuper confused lol
wait
@rain heart
i have this defined in my code
dblpy = dbl.DBLClient(client, gg_token, autopost=True, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
wait sorry again, what is my webhook?
really sorry, just new to this, would be nice if you could help me thru, really
Authorization
the key that authorizes your webhook
the Authorization field
would be in your case password
your webhook url
the one you just posted
just replace myip with the ip the webhook is hosted on, for example a vps
or where your bot is hosted on
self hosted referring to what? hosted on your own pc?
yes
yeah
So
It's working when testing
But it's not working when doing a command
just that error
because it is not authorized
again make sure the token is correct
let it print out etc
It's working when testing. That means token is correct
It's just that error
thats not webhook related according to the error message
Also when test top.gg send a webhook to my discord server channel. But it won't work when doing a command
Yeah
That's why I want to know what is that error and how can I fix that?
I can send the sample code to the bot. I made a new code for testing.
token is stored in the config.json
const Discord = require('discord.js');
const client = new Discord.Client();
const config = require('./config.json')
const DBL = require('dblapi.js');
const dbl = new DBL(config.token, { webhookPort: 5000, webhookAuth: config.dblauth });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', (vote) => {
console.log(`${vote.user} has voted me!`);
const webhook = new Discord.WebhookClient('804254555314585641', '1B9V4yc-V9UgQeDHUa2i_RvApSCpZ_wlnCvJkrrRHIsEaxJnYSBY7smK6dPdoFdeGHDD');
webhook.send(`${vote.user} has voted me!`)
});
client.once('ready', () => {
console.log('Bot is online!')
});
client.on('message', message => {
if(message.content.startsWith('!ping')){
dbl.hasVoted(message.author.id).then(c => {
if (c){
message.channel.send(`Pong! ${client.ws.ping}`)
} else {
message.channel.send(`You haven't voted me on top.gg!`)
}
})
}
})
client.login(config.token);```
This is the sample code
TOP.GG API ONLY!!!
ANY OFF-TOPIC CONVERSATION WILL BE DELETED AND MUTED
This channel is only for SUGGESTIONS/HELP/BUGS to do with OFFICIAL API LIBRARIES and API DOCS found at: https://top.gg/api/docs
shiv needs to re-learn the commands 
127.etc is local host right?
yes
Is there a way to get who voted without webhook?
This is my webhook code
Sample one
if you only want to check if the user voted only when for example a !vote command is run, yes
if you want live updates, webhook
Could you link me to the information on this pls
Any answer for my question?
const Topgg = require('@top-gg/sdk')
const api = new Topgg.Api('Your top.gg token')
setInterval(() => {
api.postStats({
serverCount: client.guilds.cache.size,
})
}, 180000) // post every 30 minutes```
is not it right?
it is right
Tnx <3 Keep up the good work!
can't 100%help you with it, i dont work with js
:/
ahhhh how do i find my vps's ip? ๐
oh nvm
TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["authorization"] Hmmm
Now it works ok...
ok i have another question
how do i use this without cogs
@commands.Cog.listener()
async def on_dbl_vote(self, data):
"""An event that is called whenever someone votes for the bot on top.gg."""
print("Received an upvote:", "\n", data, sep="")
use either event or listen deco
Sometimes the website shows that my bot is in 2 servers
This usually fixes after I restart my bot
This usually happens when it passes 100
Happened last time too
@vital anvil Broken?
import dbl
import discord
from discord.ext import commands
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = ('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6Ijc4OTkxMTYzMzMyMDM0NMCIsImJvdCI6dHJ1ZSwiaWF0IjoxNjA5Njk0MDg1fQ.ntaEtGOqIVSV6WkKLksZWhAjYV6bQa5m-fN7apNkGh0') # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes
async def on_guild_post():
print("Server count posted successfully")
def setup(bot):
bot.add_cog(TopGG(bot))
```This is the cog I use.
The top.gg token?
Oh whoops
where do i do that whoops
thx
Well still the bug happens from time to time
sorry was in online class, no :(
ok
leme see...
k im here
what should the internal and external ports be
waid
OOO
i was using the wrrong thing
sec
leme find my router
this site lists and explains port forwarding for most routers.
https://portforward.com/
oki il @ you when ive done it
(node:39) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 posted listeners added to [DJSPoster]. Use emitter.setMaxListeners() to increase limit
I got this error
you're using too many event listeners
-api
TOP.GG API ONLY!!!
ANY OFF-TOPIC CONVERSATION WILL BE DELETED AND MUTED
This channel is only for SUGGESTIONS/HELP/BUGS to do with OFFICIAL API LIBRARIES and API DOCS found at: https://top.gg/api/docs
lol saw it
-api
Still a tad confused on how to set up a webhook to be notified of votes. Here's what i have:
const DBL = require('dblapi.js');
const dbl = new DBL(process.env.TOPGG_TOKEN, { webhookPort: 4000, webhookAuth: 'test' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
However, the test button doesn't work at all (nothing comes out in console). What am I doing wrong?
corrected image*
(a ping with response would be great)
0.0.0.0 isnt a public ip, use the public ip
also dblapi.js is deprecated
what is the public ip
repl
you wont have one, youll need to use your repl url
okay
also repl expects you to use 8080 as your port. iirc
so it should be the replurl + :8080?
your code needs to be 8080 webhookPort: 4000 should be 8080
then your url will be
yourreplurl/dblwebhook
someone who speaks spanish ?, help me to use the API
how do i get a weebhock? Password
you create that yourself
Ok, I will try everything it says, any error I come to warn
How is it achieved? I want to make my bot notify when they vote for it
sorry if misunderstood, i'm using translator
How?
how to create webhook in mobile?
Use Google
ok, I created.
i created a webhook, how to make the bot send "DynamicFighter#0001 has just Voted" in that channel?
Use the weebhock
I recommend you watch a video
How do I get the password for the weebhock? @slim storm
Srry for ping

It's actually not.
What i mean is, In top.gg website, my bot's total votes in January are 59,
But when i query it from the api and find it's total length it's 43
My discord account password?
That I remember I have not provided any password
Aaaa
xD
Password random?

A question
I saw a video on how to do the vote but he gets a panel, which panel is it?
Yes something like that
what you see in the photo

What kind of menu is it?
@slim storm

No
It's from a video xD
But how do you access that?
That does not appear to me as panel D:
I use a host not my PC
Not a VPS
Used glitch
But I reached the deadline xD
Okay
But my question is:
How do i get to pa
That appears in the photo
Yes
Okay
I just need the token and right?
The other is optional
Leave try, but I don't know how to know if it works xD
Orita all my friends are you asleep
xD orita
I use a translator
D:
Ok
pass me the weebhock part?
@slim storm
To send a message to a discord weebhock

dbl.weebhock //etc xD```
For me to send a
To send a message to the weebhock created in a channel
Yed
Yes*

Yes
I just need to make him send a message to the weebhock who creates in a channel
example: 588911640624496673 You voted for me
xd
I already have that :p
Wait
I think what I want to do is in the docs
does not say
What I'm looking for is to send a message to the webhook that I did
I don't know what the image is
It does not appear in my bot
I mean this
No me aparece asรญ
F translate
;-;
XD
Wait
Already
It doesn't appear like that to me
Nothing like that appears to me
:'(
Ok
:0
I did not know that the other things appeared
Leave try to see if it works
The moment of the truth
: '(
It does not work
he does not command or say anything
Yes
how to make the bot send "DynamicFighter#0001 has voted in top.gg" in my webhook created channel
const DBL = require('dblapi.js');
const dbl = new DBL(process.env.TOPGG_TOKEN, { webhookPort: 8080, webhookAuth: '********' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});```
โฌ๏ธ โฌ๏ธ โฌ๏ธ โฌ๏ธ โฌ๏ธ
I'm new to webhooks :c
does 10 characters enough?
I'll wait for you here xD
then how to log the votes of a bot in a channel?
ohh ok

repl.ir URLs proxy to port 8080 internally
Allowed port for requests is 443 aka HTTPS
host webhook on port 8080, send requests to 443
The URL needs to be with just the domain
As you're probably aware, HTTPS is port 443. That's where you actually send the requests. So, just the repl.co domain without port is what you need
Do not worry
BUT you HOST the webhook on port 8080
const DBL = require('dblapi.js');
const dbl = new DBL(process.env.TOPGG_TOKEN, { webhookPort: 8080, webhookAuth: '********' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});```
So is that okay?
pins
Ok
tomorrow I see all that, which is when I have the pc
@slim storm thanks for your help
I'm going to sleep
1sec
port is 3000 for my webhook
and it still works
ยฏ\_(ใ)_/ยฏ
yup
Im using the domain
yup
but it should work with repl.username.repl.co too
ok now im confusion 
idk what you mean by protocol lol
repl.co/dblwebhook but yeah
o
Port 8080
i do
https
only https
It didn't work for me, it threw an 404 error
Not sure how to do a post request (discord.py)
Hello
aiohttp
You could use dblpy
yes i am using dblpy
i just removed the webhook part for now because i dont need on_dbl_vote func rn
i just need to post the top.gg votes to my statistics command
Anyone help with webhook bot
@sullen nymph no I'm using get_bot_upvotes()
please any information about this err
(node:41) UnhandledPromiseRejectionWarning: Top.GG API Error: 502 Bad Gateway
This error appeared in the console to me without reason
anyone will answer please ping me
what are you trying to do
I didn't do anything and this error appeared in the console
(node:41) UnhandledPromiseRejectionWarning: Top.GG API Error: 502 Bad Gateway
at Api._request (/node_modules/@top-gg/sdk/dist/structs/Api.js:74:19)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Api.postStats (/node_modules/@top-gg/sdk/dist/structs/Api.js:94:9)
(node:41) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
this error
https://top.gg/api/docs @restive otter
There is a fork of dblapi.js named "top.gg" and it isnt archived, am I able to use it instead of @top-gg/sdk?
https://www.npmjs.com/package/top.gg I'm talking about this
Am I able to use it instead of @top-gg/sdk?
tias
What
Try it and see
._.
That lib you linked to is unofficial, you can try it just don't expect much useful support.
yes... but it hasn't been updated in a year
It's officially unofficial
hi how can i authorized my token
ah ok
how can i do it i cant understand
i translate for turkish
but i cant understand this again
just like you need to use a token for your bot, you need to use a token for top.gg api
the top.gg api token can be found here https://top.gg/api/docs#mybots
it needs to be sent in the
Authorization header
oh you here too!
it needs to be sent in every api request in the Authorization header, or it needs to be in the initialization line of the library you use.
okeyy ty
yea why wouldnt I lmao
How to use the new api?
theres a new api?
for autoposting, you could just set an interval
Can I get it to notify when someone votes for my bot?
how?
what language
D.js
https://github.com/top-gg/node-sdk official library supports that. Check its docs (README.md)
And to notify in a channel?
it is up to you
you can use send function of discord.js or just use discord's webhook
ok
Thank you
Do you know why he doesn't send the message?
@willow spindle
const webhook = new Discord.WebhookClient("**************", "*******************************")
webhook.send(`El usuario con la ID ${req.vote.user} ha votado por mi :D`)```
Already served
Can you do a checkvote with @ top-gg / sdk?
how do I get the servers where my bot is on the page to appear? Like the print below
??
what language are you using?
why does that make a difference
I'm saying that I have the same question, how do I show the total servers on my topgg page
what language are you using
you cant make a bot in css?
ok wait a sec
Question: Is there a wait to check if my bot is blacklisted on the API?
you'll get a non-200 http code
<style>
.entity-header__image {
border-radius: 50% !important;
animation: float 5s ease-in-out infinite;
}
@keyframes float {
0% {
box-shadow: 0 5px 15px 0px rgba(0, 0, 0, 0.6);
-webkit-transform: translatey(0px);
transform: translatey(0px);
}
50% {
box-shadow: 0 25px 15px 0px rgba(0, 0, 0, 0.2);
-webkit-transform: translatey(-15px);
transform: translatey(-15px);
}
100% {
box-shadow: 0 5px 15px 0px rgba(0, 0, 0, 0.6);
-webkit-transform: translatey(0px);
transform: translatey(0px);
}
}
.entity-content__divider {
display: none;
}
</style>
i just have that
and the description itself
Because we are trying to post stats and don't get a error but the stats don't get update with the JS package.
how exactly is that code for your discord bot?
Is this normal that the stats are not updating?
oh you mean my bots code?
yeah
ah nevermind that takes a lot of work
thanks anyway
Is it just me or have people got way lazier since i last talked here
nah it doesnt
you code in js?
so can you say how do I share my data with the api?

You need to write code to send HTTP requests to the api
also yeah dice is incorrect*
use @top-gg/sdk
sad
i'll search thanks guys
if I put just that
const AutoPoster = require('topgg-autoposter')
const ap = AutoPoster('topggtoken', client)
it will start posting?
lmao
why did you delete your message?
**<style>
.entity-header__image {
border-radius: 50% !important;
animation: float 5s ease-in-out infinite;
}
@keyframes float {
0% {
box-shadow: 0 5px 15px 0px rgba(0, 0, 0, 0.6);
-webkit-transform: translatey(0px);
transform: translatey(0px);
}
50% {
box-shadow: 0 25px 15px 0px rgba(0, 0, 0, 0.2);
-webkit-transform: translatey(-15px);
transform: translatey(-15px);
}
100% {
box-shadow: 0 5px 15px 0px rgba(0, 0, 0, 0.6);
-webkit-transform: translatey(0px);
transform: translatey(0px);
}
}
.entity-content__divider {
display: none;
}
</style>**
||ooof||
if you want to set up a on vote event, do you need to port forward?
you need to use webhooks, thus port forwarding
import dbl
import discord
from discord.ext import commands
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = ('Yeah I will not put it here lol') # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes
async def on_guild_post():
print("Server count posted successfully")
def setup(bot):
bot.add_cog(TopGG(bot))
Sometimes my bot shows 2 servers
When I'm not in 2 servers.
bug?
have u checked the docs
Yeah
have u added the package?
mhm
try again
try again?
yeah
try what again
hi my bot got approved a few minutes ago so I decided to look at the API on the site and use webhooks but don't know exactly how to do it. It is written not to be afraid to write here, that's why I'm here :D
I pasted the webhook link from discord on the page where it was indicated
You cannot use discord webhooks for that
{'error': 'Unauthorized'} on vote check
Token invalid prob
but browser works fine?
You can check if someone voted through your browser?
How to check if a user has upvoted
Thanks
And how do i get how many servers my bot is in on my page (Im guessing im going to need to setup a webhook)
How do top.gg webhooks work and what can they be used for?
is it possible to send notifications on discord from top.gg in the form of a webhook?
Webhooks are used to receive bite events mostly.
They're required once you pass like 1k monthly votes
And yes you can send notifs in discord webhooks with simple redirection.
Using a library of your choice, set up a web server on your computer to receive the webhook requests, and upon receiving the request, format and send via discord webhook.
@rain heart Can't understand ๐ฆ
didn't work.
Then you're not ready to do this yet
the webhook auth is set by you
is there any blog post for this?
Hi, I'm also trying to post my bot's server count (in python). This is the code for the cog I use: https://mystb.in/ApparentlyHouseholdsUniform.python
I load the cog with client.load_extension('cogs.top_gg') before I run the bot. the cog is in ./cogs/top_gg.py relative to the script where I run the bot.
I'm not getting any errors, but also no update. The top_gg token is correct, I have printed it in the cog to double check before.
This is pretty much the example code in the API documentation > pyton library
you are saying you are not getting the update that the server count has been succesfully updated?
yea manual approach worked for me
so id suggest you do it manually for now using a discord.ext.tasks
yep, thanks, will try that
wlcm.๐
the cog has to be TopGG in order to work?
How do I make sure a person's vote was in the last 12h? (Using api not webhook)
Don't have to, I am using Dblpy in my existing EventLoops Cog and it works perfectly fine.
Although the docs did made me wonder if it has to be like that LOL
async def on_dbl_vote(self, data):
search = self.db.search(self.query.user == data['user'])
if not (search):
self.db.insert({'user': data['user'], 'votes': 1})
else:
search = search[0]
votes = search['votes']
self.db.update({'votes': votes + 1}, self.query.user == data['user'])
print(data)
``` I believe this doesn't work.
Should I, like, add Cog.listener decorator?
Mhm
I have the same sorta question, I have this code:
@commands.Cog.listener()
async def on_dbl_vote(data):
print(data)
print(data.isWeekend)
print(data.bot)
print(data.user)
await db.query(
f'''
UPDATE users
SET votecount = votecount + 1
WHERE id = {data.user}
''')
But it did not fire when I voted (not even print(data)) I think I am forgetting to config something on top.gg but I don't know how/where to do it :/
Unrelated but important: be careful using format strings like that as queries. Image what happens if data.user is "1; drop table users;"
instead, use substitution characters provided by the module you use (mysql = %s, postgres = ?)
look up the documentation how to execute queries with data
ok thx
Is it possible to setup the webhook for when people vote for your bot on heroku? I know we need a webhook port and stuff, I've looked at the docs and everything but i cant seem to find anything on this.
I mean, that's not how you work with dicts? 
still doesnt work with decorator lol
does it work only with a webhook?
Ye, how is top.gg supposed to notify you
Wait, how do I set up a webhook?
not sure if creating a webhook in my server will be enough
Is there a way to get the number of times someone has voted?
No, only through tracking it yourself on webhooks
Damn so is there no way to make it so a user can only claim a vote reward if they have voted again without a webhook?
I guess I could go through the last 100 votes count that and match against a number
@rustic stirrup I am trying to use a database, postgre and elephantSQL as the host, it works well for me
anyway I have a question: I have this code
from discord.ext import commands, tasks
import dbl
import libs.database as db
import os
KEY = os.getenv('TOPGG_TOKEN')
class TopGG(commands.Cog):
"""
This example uses tasks provided by discord.ext to create a task that posts guild count to top.gg every 30 minutes.
"""
def __init__(self, bot):
self.bot = bot
self.token = KEY # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
self.update_stats.start()
def cog_unload(self):
self.update_stats.cancel()
@tasks.loop(minutes=30)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count."""
await self.bot.wait_until_ready()
try:
server_count = len(self.bot.guilds)
await self.dblpy.post_guild_count(server_count)
print('Posted server count ({})'.format(server_count))
except Exception as e:
print('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
@commands.Cog.listener()
async def on_dbl_vote(self,data):
print(data)
print(data.isWeekend)
print(data.bot)
print(data.user)
await db.query(
f'''
UPDATE users
SET votecount = votecount + 1
WHERE id = {data.user.id}
''')
@commands.Cog.listener()
async def on_dbl_test(self,data):
print(data)
def setup(bot):
bot.add_cog(TopGG(bot))
I dont really know what the issue is, I think I am not filling out self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000) correctly but idk how to fix it, what config do I need to do on https://top.gg/bot/798634937606864937/webhooks
@versed storm its been quite a while, If there is someone/role I am supposed to ping I am sry
ping me when someone sees this
Can someone help me link my bot to a webhook so it can display how many servers it is in?
Hey, I have my bot on 2 servers and when I for example write command or click emoji on one i want to give myself a role on another. How can I do this with discord.py?
i have like
member = ctx.author
role = discord.utils.get(a.roles, name='role')
await discord.Member.add_roles(member, role)
and i want instead of adding role to myself on this server i want to add it on another one
Use #development for this.
So I have got my bot on Top.gg and have installed the package with cmd prompt. Where would I put this code in order to make it work?
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})```
Ping me when you have an answer.
What is the folder called?
huh?
in node_modules?
Oh crap.
@top-gg/sdk
read the docs of this package
Ok.
const client = Discord.Client() // Your discord.js client
const Topgg = require('@top-gg/sdk')
const api = new Topgg.Api('Your top.gg token')
setInterval(() => {
api.postStats({
serverCount: client.guilds.cache.size,
shardId: client.shard.ids[0], // if you're sharding
shardCount: client.options.shardCount
})
}, 1800000) // post every 30 minutes```
Is it this one?
Or the other code?
@willow spindle
But where do I put this code?
do you actually know how to code
Not this type of coding.
I've never seen this before.
Can you please just tell me where I should put it?
I'm sorry if I'm stupid.
No there is no one specific to ping, I can't help you with the API, I Don't use it. And I don't know python. Just be patient.
And/or ask again.
ok, ima work on it later,I have more important stuff to do
Ironically, so did I which is why it took hours for me to even respond 
lol
Ok, I'm using python to develop a bot that receives a vote. However, the docs just cover bot voting. And the webhook for on_dbl_vote returns bot_id and user_id... but not server_id..
My bot is to get dbl votes on servers not bots so how would I do this?
@sullen nymphi was told you'd be able to help me
can you please let me know ASAP? I want to finish this before top.gg reset votes
oh my nick 
lol
also, is it possible to get all the votes of a certian user?
How do i fix this
this is impossible because votes are done by users not by an entire server.
Anybody know the problem with this code?
I'm trying to get the API to work.
I can't.
what's your error?
no i mean. The object returns bot_id and user_id.... is there any way for it to return server_id for votes done on servers?
What do you mean "votes done on servers"

then you remove that line of code
the server votes?
Only that line?
oh and shardCount
Oh.
Ok.
I did that.
But.
Let me try it again.
Maybe I forgot to install the package.
To my hosting service.
You can only fetch for the server that you have the token of.
So if you have a token for that server it's assumed that you know the server ID of the server you have the token of

or more so, recieve webhook events from
but?
you'd still get this thing?
That's completely irrelevant to server ID
also, is it possible to get all the votes of a certian user voting for a server
that's to make sure that the request is from topgg
what's the webhook data for server requests then
I'm testing the bot again.
was confused on your question
no it's fine... i'm confused so it affects my questions too
found 1 low severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
/home/container/bot.js:17
const client = Discord.Client() // Your discord.js client
^
ReferenceError: Discord is not defined
at Object.<anonymous> (/home/container/bot.js:17:16)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:941:32)
at Function.Module._load (internal/modules/cjs/loader.js:782:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
container@pterodactyl~ Server marked as offline...
[Pterodactyl Daemon]: ---------- Detected server process in a crashed state! ----------
[Pterodactyl Daemon]: Exit code: 1
[Pterodactyl Daemon]: Out of memory: false
[Pterodactyl Daemon]: Aborting automatic restart, last crash occurred less than 60 seconds ago.```
@dense grail
This is what I get.
This is my code.
again, this is unrelated to #topgg-api
You defined discord js as DiscordJS
@surreal kernel i think it's guild, user, type, isWeekend
but I honestly don't know, I haven't tested the webhooks
but you get it from the event on_dbl_vote?
@restive otter No, here you decided to define the lib as DiscordJS, so you have to use that.
Please go to #development. Your question is not related to the API.
when the webhook fires ye
it's on your server's page
i have to add the bot to the server that's on topgg but i haven't yet
can i still make a fake webhook or do i have to add server first
you shouldn't have to add a bot to a server thats on top.gg?
it's just a webhook
bots aren't related to server votes ??
what
you have to add the bot "DSL" to a server that's listed on top.gg
then you should be able to mess around with webhooks
remember to open your ports
webhooks including fake webhooks?
and what ports
sorry but i'm just really confused as to how this all works
Yes, you can test webhooks via the server edit page on top.gg
in order for a webhook event to fire, your program application must have a port open that you're listening to for the top.gg webhook to like, send a post req to you
@dense grail what port should i open? and what type of url should I use for webhook?
I also voted on the server but nothing happened... no errors or anything through webhook
@dense grail
ping me please since i have to sleep now
You didnt need to mention them 4 times 
your dbl token is wrong
Is there a way to store all my bot reviews and send then on my server channel?
I suggest using webhooks for that
How?
Read the docs
does anyone know how to get the code from my command. For ex I have a command ping and want to get it's code and send it?
@wraith skiff if you're using Node.js then use child_process and execute the bash command cat <path to command>
also this channel is for top.gg api help, not for bot coding help
Try to find a module that can be used to execute bash commands
Or view file contents
In Node.js it's child_process, in Python I don't know though
ok thanks
subprocess module is probably what you want
or for discord bots with async asyncio's subprocess system
oh thats complex
I mean if you just wanna ping an ip
yes #development for that
no ones answering there
Are you using the java-sdk?
yh
Best is to do it through webhooks then https://github.com/Hopefuls/topggwebhooks4j
Java Webhook Library for Top.gg. Contribute to Hopefuls/topggwebhooks4j development by creating an account on GitHub.
ok
i am asking if a member votes my server can @wild lantern (webhook) send a message like {user} just voted the server!
you need a webhook for that like xiuh said
ok i got it now what next?
next is make a webhook by yourself ๐ธ
i did it
wait! i think you cant do it
Not a Discord webhook
then?
You need a physical machine that listens to HTTP requests
bc you dont have the acces to the site
Not with the servers part
i dont know how to do this
you know better than me
is it necessary even if i'm not notifying anybody and just want to handle new votes?
Well, how do you plan on handling votes without a machine that runs 24/7?
webhook is part of the api kinda
i mean, isn't listening to api with some async magic enough?
no, webhooks is the easiest way
yea, it's just a basic server with a route for the webhook
k, are there any guides?
the current js lib is pinned.
https://github.com/pydanny/webhooks i found something
why not just use either a webserver or dblpy for this
a webhook is a webserver
i recognise that shiv
yes I do too
no
Hey i have voting credit how can i transfer them to my account
You can redeem them on the first of Feb (tomorrow)
Idk, it's weirdly confusing for me, but until then I have a new approach that should work
Thx lmfao
I'm using replit
im trying to use the top.gg api and when i try to use dbl.webhook.on it just says TypeError: Cannot read property 'on' of undefined
note: i have dbl and DBL both setup
so for that lib you need to initialize with the webhook data
const dbl = new DBL(yourDBLTokenHere, { webhookPort: yourport, webhookAuth: 'yourpassword' });
i did
it includes webhook port and auth?
right, so that doesn't initialize the webhook at all
port can be any available port, password you make.
5000 is fine
and password is anything?
yeah, any string
i typically just smash on the keyboard for a bit
dsajIND9AD9uasjdoijAD9pas43jADPsad
ez
haha
you can use the autoposter
https://npmjs.com/package/topgg-autoposter
npm i topgg-autoposter
const AutoPoster = require('topgg-autoposter')
const poster = AutoPoster('topggtoken', client) // your djs client/shardingmanager or eris client
thats it?
yep, the new lib handles everything for posting server counts.
i just have to put it in my index.js file, ok...thanks!
yeah, just make sure its after client is initialized.
yes
it will show the change on the website immediately or after some time?
so that i can check if i did it correctly or not
it works but now doesnt detect votes at all
not even a message in console
dbl.webhook.on('vote', vote => {
//my code
});
can take some time.
so it doesnt work? or it does work?
so did you fill in the url and auth on your bots edit page on the webhook section?





