#topgg-api
1 messages · Page 5 of 1
You can always vote as the owner
ok yea i can vote and it works
-api
This channel is for suggestions, help, and bugs related to our official API libraries and documentation found at https://docs.top.gg/
If you need help with other development, please use development.
For support please ask in #support next time :)
But to answer your question, you would need to boost, have an approved bot on our site or become a staff member to get a role
Why does the webhook send a GET method to my webhook URL?
🤔 When you press the test button on topgg? or a real vote?
Seems to be both for me
Are you using unsupported characters?
like accented characters
in the url?
url or auth yeah
nope
"headers": {
"accept": "application/json, text/plain, */*",
"accept-encoding": "gzip",
"authorization": "REDACTED",
"cf-connecting-ip": "159.203.105.187",
"cf-ipcountry": "US",
"cf-ray": "773e0f111d97e6c4",
"cf-visitor": "{\"scheme\":\"https\"}",
"connection": "Keep-Alive",
"host": "WEBHOOK_HOST",
"user-agent": "Top.gg Webhook/1.0.0",
"x-forwarded-proto": "https",
"x-real-ip": "159.203.105.187"
}```
🤔 weird
Yeah, it also shows up as a get request, instead of post request.
the only thing I can think of is try sending your own request using something like postman and see what happens.
ok
I've never seen someone receive a get request like that.
When I try sending my own POST request, it works fine
idk why the test button aand actual votes show up at a GET request
Its so strange.
No chance its a CF setting messing it up right? 🤔
I don't think so.
Someone else might have an idea, but I dont think I've seen this before.
Alright
Internal redirection?
Or does the request hit your endpoint directly?
Hit the endpoint directly
I will test it myself in 2-3 mins to see what's goin on
Ok
Interestingly not for me tho...
{
"HTTPS":"on",
"SSL_TLS_SNI":"***",
"HTTP_ACCEPT":"application/json, text/plain, */*",
"CONTENT_TYPE":"application/json",
"HTTP_USER_AGENT":"Top.gg Webhook/1.0.0",
"CONTENT_LENGTH":"81",
"HTTP_HOST":"***",
"HTTP_CONNECTION":"close",
"SERVER_SIGNATURE":"",
"SERVER_SOFTWARE":"Apache/2.4.51",
"SERVER_NAME":"***",
"SERVER_ADDR":"192.168.*.*",
"SERVER_PORT":"443",
"REMOTE_ADDR":"159.203.105.187",
"REQUEST_SCHEME":"https",
"REMOTE_PORT":"37932",
"GATEWAY_INTERFACE":"CGI/1.1",
"SERVER_PROTOCOL":"HTTP/1.1",
"REQUEST_METHOD":"POST",
"REQUEST_TIME_FLOAT":1670090922.552303,
"REQUEST_TIME":1670090922
}```
hmm that's weird
Not for me either. Using cf workers.
That's what I'm using.
Everything else seems to work. The only issue is the METHOD
it's mainly this
hmm no full log then I guess
I would like to see the content type
is there actually any data send with the request?
I mean as GET request what is the entire request uri ?
Does it somehow include the GET parameter names and values the post request sends as body?
content type isnt included in get requests is it? 🤔
use a database and store the unix time they last voted
add +12 hours to the unix time they last voted and check if the current unix time is less
Yeah that's what I'm wondering about
When this really is the entire log, then it really is a GET request
I'm not sure if cf somehow does redirect the post request (data) to a GET request
I would like to see the request uri
or query string log
then
does anyone know how to setup topgg webhook on oracle vm
That is the entire request log
I seem to have solved the issue with the request being GET
What was it?
how can I show server counts?
You gotta report the current server count frequently to the topgg api
like this?
The server count is the body/data not the header
You're also missing the content type header
Dayumm
sorry I didn't understand what should I do exact?
Axios should have a similar syntax
You have to send the data in the body
You tried to send it as header
oh
reposting from #support
Hey! I've been building a bot using discord.py, and I used to use topgg's python API wrapper to show bot stats on the website. But that doesn't seem to work anymore, now that I've updated discordpy to 2.0
I'm extremely novice at working with APIs, and usually just work with a wrapper, are there any good and updated python API wrappers for Topgg?
What's the error you got on the library?
I dont think we knew it broke? 👀
https://github.com/top-gg/docs/blob/master/content/api/user.mdx use html page or maybe?
Top.gg documentation website. Contribute to top-gg/docs development by creating an account on GitHub.
@jaunty plank hllo sorry ping, there is
explain how dblwebhook and password?
and confuse
/dblwebhook => the endpoint for the webhook call, will be needed to be written here:
What will be written there is something like http(s)://<ip/domain>:<port>/dblwebhook
password => the password that you choose, will be needed to be written here:
@hallow atlas Make a POST request with the header and the body needed to the endpoint, see https://docs.top.gg/api/bot/#post-stats
Yes thanks
@restive otter thanks
Hey, can someone explain how that's 3 arguments?
TypeError: __init__() takes 2 positional arguments but 3 were given
@restive otter Help?
-pins
@restive otter
Hey, can someone explain how that's 3 arguments?
TypeError: __init__() takes 2 positional arguments but 3 were given
If someone votes for my bot while it is offline, how can I give them their rewards/perks once the bot is back online?
The vote event contains the user ID you can store in a database
Once your bot comes online, query the database and cache the results and you know who voted
But make sure this webhook listener doesn't go offline
Or you will most likely miss vote events
Alternatively you can also send a request to another endpoint of the topgg api getting the last 1000 users/voters iirc
Which you could also run once your bot starts for example
Does that include the time they voted?
No
You know the (current) timestamp of the vote only when receiving it as event
While event is the wrong word
It's actually a post request aka webhook
This isn't available when sending a request to the api to get the latest voters
So other than having an event listener, there is no way to when the user has voted?
Can I use await get_user_vote(userid) to check if the user has voted in the last 12h?
Like I said you get the last 1000 voters at any time per request but the api will not provide the timestamps
If you need to know when somebody voted you will have to create a webhook listener in other words a webserver listening for post requests
I don’t see after vote dms people , pins it said webhook
Hey can somebody help me with the topgg webhook? On the page I have it says "Cannot GET /dblwebhook"
Not getting any responses when testing it on topgg either
Nevermind! Got it all figured out and working! Changed stuff around and used postman til i got a response!
That’s correct, webhooks allow you to get notified whenever a user votes for your bot.
After that (in your case) you will have to simply dm the user
Hi , am trying to send a test webhook message from the site , but i keep getting errors
What errors?
on topgg?
Try logging out and back in, if that doesnt work, try again in 10-15 minutes.
i just changed browser .
and nothing , i will wait 15m and c how it goes and give you feedback
thanks for you help.
does anyone know what a snowflake type is ?
am throwing an int as a userId but am getting a 400 response
if thats the reason for the error tho
nvm, problem solved
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
In case you're still interested what it is
is the api required to update my bots server count on top.gg? i thought i read it somewhere!
It is, see https://docs.top.gg/api/bot/#post-stats
thanks!
So I was posting my bot counts to Topgg by using this api
But recently its stop updating
The api status and respond was 200 and OK
my server count was 97 but at top.gg website, its stuck at 100
why this happen?
i has regenerate token and update new token to bot and i get this
When you regenerate your token
regenerate
refresh the page
then copy
silly site bug
i try
- i regenerate 1 min ago
- i has check the api and i copy token by api
selfbot?
still getting unauthorized errors?
"brainfuck.py" "hentai.py" 💀
💀
Let me check
Bruh
Brainfuck is a code lang :))
- check on google
What about hentai.py•°•
Nsfw command :/

:))))

just to double check, you're sure you regenerated then refreshed then copied the new token?
the refresh is important
Don't use ClientSession for fetching data use session.request
It won't affect the Bot's session
Also you are using os.getenv() which sometimes returns None so make sure to load the .env in your file for that use python-dot env and then import function the function from dotenv import load_dotenv then just call it at the top of your code load_env
This will solve your whole error 99.9%
Thanks
I use it
I need to im import and run for bot token is on env
I do it 3 time befor report this
Lol is not block
Read this discord.py doc
Are you a new python dev ?
- now is work
from where I can get the topgg-auth-token? (ok got it i check pins and I get the video link but bruh I have to add my bot on topgg to get auth-token? is there any other way to get the token without this?)
There is not. Only approved bots can use the API endpoints with an authentication token.
discord.py use a own session which inherited from aiohttp.ClientSession and if you use another client session it block the current Event loop if your response was late, also ClientSession handles only 1 ClientSession response at a time so if you creating 2 or more client session there is a chance to block your event loop.
br is not block
what is this
They just mentioned how you should request without blocking your event loop
No, i was developer since 4yrs in python. With the knowledge of Django, httpx, and micropython
hmmm
- and why it block
- my bot is not block by that
If you create 2 or more client session at a time then discord.Client's session will stop and that's called code blocking
- i run muti client session at the same time and it not block
I know, i was said that because you are using topgg api, also if you use ClientSession you will get Json decode error because of your Bot's session
I mentioned above if the api respond later then it will block
If you requesting 10 times (GET) using different ClientSession and if the all responses takes 1 or 2 sec then your event loop will directly destroy
is block ? :\
Dude are you a blind?? Or what ?? I said if your response takes time then it will block it
how do i get the api token
thx
why not set time out
Sir please do not share false information. Aiohttp is not blocking
Hello it's topgg support blapi to post stats?
is server vote tracking supported? i'm yet to find anything on it
you will have to implement it yourself, check the pins of this channel for an example
Will #announcements event be held in VC?
yeah
Ok thx❤️
Hey, can someone explain how that's 3 arguments?
TypeError: __init__() takes 2 positional arguments but 3 were given
Hey, I'm not a python dev. I know python arguments can be a bit weird.
Looking around online, I got this.
https://stackoverflow.com/a/68011047
It sounds like you may need to use named arguments rather than positional arguments in your case.
Which I believe you can do.
https://topggpy.readthedocs.io/en/stable/api.html#client
I need to look into learning the basics of python, we don't really have a lot of python devs around to help here.
Hello, how can I display my monthly votes in my discord.js (please ping me)
Auto-Poster for Top.gg. Latest version: 2.0.1, last published: a year ago. Start using topgg-autoposter in your project by running npm i topgg-autoposter. There is 1 other project in the npm registry using topgg-autoposter.
how do i do that exactly i don't understand
It has examples.
const { AutoPoster } = require('topgg-autoposter')
const poster = AutoPoster('topggtoken', client) // your discord.js or eris client
^ copied from the provided example
Yes and where do I enter what I want at the end, in this case votes
Oh, sorry I misread. I'm trying to do too many things at once ^_^.
What are you trying to do? receive vote events? or just use a vote count?
just a voit count
You can use https://www.npmjs.com/package/@top-gg/sdk
with the getBot method
https://topgg.js.org/classes/api#getBot
Official Top.gg Node SDK. Latest version: 3.1.3, last published: a year ago. Start using @top-gg/sdk in your project by running npm i @top-gg/sdk. There are 7 other projects in the npm registry using @top-gg/sdk.
Botinfo returns points & monthly points which is the number of votes.
how do i use this
https://topgg.js.org/classes/api
^ example for setting up the sdk.
https://topgg.js.org/classes/api#getBot
^ example using getBot
do you have an example script where it logs into the console how many votes the bot has per month
console.log((await api.getBot('461521980492087297')).monthlyPoints)
thank you
console.log((await api.getBot('996525009403117679')).monthlyPoints)
^^^
SyntaxError: Unexpected identifier
the bot log undefined
try just this
console.log((await api.getBot('461521980492087297')))
Make sure you're updating the bot id to your own
D
yes i have update it
it doesent work
what does it log?
nothink
Is that part of your code running?
console.log((await api.getBot('996525009403117679')))
^^^
SyntaxError: Unexpected identifier
no
did you fix that?
yes
hmm, I'm not sure then.
If you fixed the async issue I don't see why it wouldn't log.
it log undefinieded
You got this error, or it logs undefined?
Or, you get an error that says cant read 'getBot' of undefined.
no this is only undefined no error
Can you show the code you've used?
Yes
Looks like you deleted the await, which is needed to resolve the promise.
It also looks like you commented out the console.log, which means it never runs.
cough token
deleted for your protection
I had the await in it, but it didn't work either
the token and the password were not the real ones
You have to resolve the promise
I provided a resource earlier for learning about promises
wait
console.log((await api.getBot('996525009403117679')).monthlyPoints)
^^^
SyntaxError: Unexpected identifier
Yep, youll need to use that in an async context
You can refer to this to learn about async and await
how?
This page teaches you about async and await
can you me make a exapmle
That page literally is covered in examples
console.log((await api.getBot('996525009403117679')).monthlyPoints)
}```
is this right?
You could do that yeah, then call the function.
how do i do that then?
You can call it like any other js function
test()
You wont be able to use it outside of that function though
do you have a example
write test()
and then
itll run this function
I dont know what else to say 
the bog log [object Promise]
Can you show the test function?
async function test() {
await api.getBot('996525009403117679').monthlyPoints
}```
and what are you logging?
[object Promise]
this itself doesnt log anything, nor will it work
I mean show the console.log
console.log((await api.getBot('996525009403117679')).monthlyPoints)
}``` if I do that he logs in the console the right baer in the text there is nothing
You're jumping ahead.
This codes only purpose is to log it.
If you want it in the text, youll be better off assigning your variable in your webhook post function.
const tbot = await api.getBot('id');
then make this function
webhook.listener(vote => { async
webhook.listener(async vote => {
finally it works, thanks to you
Just a small piece of advice, when asking for help. Tell someone when you're changing the code to something else.
Its so hard to follow what's going on when you just try stuff & I don't know it.
This was a 2 minute problem that took over an hour
hi, i am trying to get the bots stats to put it on its site and i noticed to get the data i hade to first set the servers the bot is in to top gg i did like this (the java code one) and then i tried to import the package and access them in js but it got stuck on this line (the javascript code one)
ping me when someone has an answer
You might want to delete the screenshot containing your token, and show the error(s) you get or whatever you get that is unexpected. We can't run code on your computer 
here is it but with my key sensored
soo
gave u the things u asked
You're not awaiting anything, plus it needs to be in an async context
Documentation for @top-gg/sdk
Also, you can use console log to debug your code and help us in helping you
i cant use console.log i am using react with vite
You always can
it doesnt work idk why
It will show up in your browser's console
And these frameworks most likely have an alternative to log in your terminal as well
So you can either use console log or use the alternative for the framework, though console log works
also adding await didnt change anything
You're not awaiting anything, plus it needs to be in an async context
Otherwise just make a normal GET request to the API with the Authorization header
Though do note that everyone will see your token, it's frontend
ok
ill try this first
i did this (i am new to js thats why the bot is not in js) and it gave
ReferenceError: require is not defined (site)
🤔 are you running this in nodejs?
^
require is a feature of nodejs
well its a node js project
by the package json and node modules
soo
?
bruh
when is someone answering.
ah, well youll probably need to use imports, https://www.w3schools.com/js/js_modules.asp
does getStats(...) do the request?
If so you're doing two requests at once for no reason
is this how u do it
import Topgg from '@top-gg/sdk'
cuz for me it doesnt work
says
SyntaxError: Unexpected identifier 'Topgg'
Show us how you execute your code
its the image in this but with the const top gg replaced with import Topgg from '@top-gg/sdk'
Show us how you execute your code
How do you execute this code?
In which environment do you start it?
I can't open txt files on mobile
So you're not running the code inside the nodejs environment
It won't work then
well it imports it at the end and uses its passed values in here
then what do i do
Those are nodejs modules
You're trying to run the shit as script in your site
Makes no sense and will never work
i said i am new to js so idk what really i am suppose to do
so can u give a little help
If you wanna make the request then use native JS methods like fetch
You can't import the nodejs package into your native JavaScript script
well i did try that but idk how to pass the token
ok
What u can also do is to create a nodejs project fetching that api stats from topgg and saving em in a database
Then query the database in your backend and show the stats on your website
Generally fetching the api stats on your website will get you rate limited really quick if it happens on each request
If I'm gonna spam F5 for a few seconds hundreds of requests will be made
So... you should rethink your concept probably
And go with a save method like storing the stats in your database and query this database
but i dont have a database so how am i going to do that
also is this how u fetch with the token
oops put my token
Anything is better than doing the request if somebody loads your site
for me to fetch the stats i first need to know how to fetch
brb good time for @jaunty plank to jump in
i gtg soon like in 5 mins
tbh, this is out of the scope of what I can help with tonight.
before i go this is the code for this
Yeah that's the native fetch api
thx it works now i am going to make it save the data on a db
Do i have to list my bot to the website to get the api details even if its a bot only my server uses? is there like a toggle option to now list the bot?
^ if so can i link another bot application and use my tokens on another bot?
👀 why do you need api information for a bot thats private?
We do not allow using links for other bots.
The link must be for the bot that was submitted.
it just So that i could track which users upvoted the server and award those users etc, but i thought that might of been the case, no worries 🙂
(how do i remove a pending bot that i had already submitted haha)
You can track votes without listing a bot.
Servers get webhook access, you can store webhook requests in a database to track it.
Amazing thank you, i was attempting to do it through npm package but this will work perfectly, thank you for your help!
What link do I provide for users to vote for my bot?
just got a Gateway Time-out on the api is this normal or?
it's an issue on top.ggs end, nothing u can do
It’s normal
Either use a library listed on https://docs.top.gg or make a request yourself on this endpoint https://docs.top.gg/api/bot/#individual-user-vote
Any reason why I keep getting this error when attempting to post stats?
Top.gg api error
Anyway to fix it?
Nope
?
His system can not reach the host
I can ping top.gg on the vps and it returns fine
Show me pls
No not this error
Ah
Yeah either an issue with your dns server or a firewall block connections to port 443
Hi, how can I use on_dbl_vote on discord 2.0? I tried a lot of things but nothing worked
It’s weird though because this hasn’t happened before today
It's the first time happening?
Mhm
Definitely an issue on your end
I tried many different hosts now and all without issues
IPv4 and v6
Is there a way I could possibly fix it?
Just to test add a different nameserver
sudo nano /etc/resolv.conf
Add a new nameserver below
nameserver 8.8.8.8
Mk
I want the request in real time of who voted, I can check who has voted using aiohttp, but not in real time when they click on the button
It was already set as that
Ok this is much more confusing then
😵
Add nameserver 127.0.0.53
As first line
If that still doesn't work you will probably have to check or and edit the netplan
To see what nameservers are configured in there
Mk
Maybe opendns etc
If the issue still persists get back to me tomorrow
Just ping me and I will reply asap
Good luck 
Alr thanks!
I have no idea what discord 2.0 is
are you getting an error?
I want to know if the function on_dbl_vote support dpy 2.0, if not, what I can do for this works and get in real time who voted
I dont see why it wouldnt
I lot of people are asking the same think as me here in this chat, nobody get a solution?
.
.
Did you configure your webhook on the site?
yes sir, I can get the wekbook work with the test function
but the vote function not
👀 show the code please
...
import topgg
...
class Bot(commands.Bot):
...
@commands.Cog.listener()
async def on_dbl_test(self, data):
print("voted test")
print(data)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print("voted oficial")
print(data)
...
async def on_ready(self):
self.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "pass")
self.topgg_webhook.run(5000)
await self.on_dbl_test(self)
await self.on_dbl_vote(self)
I tried to insert the topgg_webhook in setup_hook but same problem, I dont have a response from on_dbl_vote
I appreciate if someone that are using dpy 2.0 help me
First things first, do you have the web server running and publicly available via an IP - and have you written that down in the bot's settings on Top.gg correctly? Otherwise you will never receive any webhook.
Second, you're missing self as the first parameter. You might want to look at how OOP works in Python
wdym by web server?
I create an url using this "https://webhook-topgg.com", after I put the webhook url with the auth on "https://top.gg/bot/BOTID/webhooks"
I receive the webook when I click the test button and when someone vote, but I want that I bot get his ID to reward him
self.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "pass")
self.topgg_webhook.run(5000)
That runs a web server, to catch webhooks
abotu the self, I edited my post, but I already tested it and I dont get the vote from my bot
yes
So I don't understand what webhook-topgg.com has anything to do with that
You are running a web server on port 5000
That web server needs to be reachable by Top.gg, hence have a public IP that allows connections to the port 5000
And you need to write http(s)://<ip/domain>:5000/dblwebhook in the bot's webhook settings
then I dont need webhook-topgg.com? I need to use my IP
Correct, as you make the handling of posted webhooks yourself
where I put it? in my code?
self.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("https://IP:5000/dblwebhook", "pass")
The auth is what you have in "pass"
I know, but that case I was using the auth from webhook-topgg.com
The auth webhook-topgg uses is just the discord webhook auth.
Which you're not using here.
how can I get the data from on_dbl_test? I need to do something in "on_ready"? I even need it? dpy 2.0 is complicated
await self.on_dbl_test(self) i'm getting the data from my bot when I click on test, not from myself
//top-gg vote tracker
const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express()
const webhook = new Topgg.Webhook('psiIBvCxfGbSNggHJ')
app.post('/dblwebhook', webhook.listener(async vote => {
console.log(`[Vote Logs] ${vote.user} voted for ${vote.bot}`);
}));
app.listen(3000)
console.log(`[Webhook] Top.gg webhook is ready`);
this is what i have in my code rn and the webhook url i have set to http://123.123.37.107:3000/dblwebhook
but nothing is being logged into the console when i try sending a test
also the ip i need to use is my IPv4 right? i am running this locally
When I try to ping the IP I get 100% packet loss.
Top.gg won't be able to reach the IP either so it won't be able to send you any webhooks.
You can also see yourself that it will never work by going on the website yourself with another device, e.g. your phone.
If it's the IP of your computer, you need to do port forwarding. You can search on Google how to do that.
If it's the IP of a VPS, contact your VPS provider to make sure the port 3000 can be used and double check the IP, as it should be obviously be possible to ping it, even if the port 3000 is blocked.
Seeing that the IP comes from
China Unicom
I suppose that is your personal, computer, IP. Unless your VPS uses that company obviously..
Nonetheless, nothing we can do before you did both things above.
oh thats not my real ip i just gave a random one to show here
oh thanks ... let me try
Ah all right, makes sense then 
is it possible to run the webhook server on VS code
As in, running it locally?
yes I'm testing it on my local pc
Yeah, youll need to port forward though
how can I do that?
like on the top.gg page in webhook, i set the webhook url to https://my_ip:51705/dblwebhook
ah i got it
const webhook = new Topgg.Webhook(my bots topgg auth)
app.post("/dblwebhook", webhook.listener(async vote => {
console.log(vote)
}))
why this code isn't working?
app = require("express")()
and i added app.listen(3000)
where is the problem
Does
https://top.gg/api/bots/:bot_id/check
Reset every 12 hour or is it just showing total no of votes for user
It resets every 12 hours, if you want the number of votes youll want to track that yourself
Did you fill in your webhook information on your bot/servers edit page?
Thanks
yes
It will depend on your hosting method
i have vps
Just to clarify, you didn't use a discord webhook, nor a third party service(webhook-topgg for example) as the url correct?
http://yourVPSIP:port/path
alright thank you i love you
I think the default example port is set to '5000' in the py lib, and the path is '/dblwebhook'
No i just used my own domain
Is it linked to the webserver in this code?
Yes
did you set the port&path correctly?
for example.
if you have ssl, and your code is this
it would be
https://example.com/dblwebhook
It might also be
https://example.com:3000/dblwebhook
or use http.
Itll depend on your setup, ie nginx with a reverse proxy?
cloudflare might block https requests on port 3000.
Where can i see server count that i posted using api
Not this I mean where will it show up on top gg page lol
Gotcha
In here i put the url of my webhook right?
It'll be the url to your webserver
Heya! talked to my host abt this and it was fixed temporarily
Pinging top.gg on the vps returns fine but I still get these errors
I am also getting that error
If your host fixed it temporarily, the issue is probably pertaining to your host.
When you run the code from a home computer does it work?
how i can get total of votes with package (topgg/sdk something like this ....)?
For the bot or the user?
total votes of bots & total votes for user (if available!)
We do not track votes per user.
That's something you'll need to track yourself.
The votes for the bot are provided with this method on the sdk.
Documentation for @top-gg/sdk
Ok , thank u so much ❤️
To get votes i will use methon getVotes()?
@jaunty plank
method*
Get votes will get all users who voted within the past 12 hours.
Am i the only one who somehow cant install topgg-autoposter? Like everytime i install it and start the bot the log says that this module is missing and when i check if its there its somehow gone. Any ideas how to fix this?
where is the bot running?
on your pc?
Server
It wont even start on local
So i didnt bother to try there
Are you getting any warnings/errors during install?
No
I'd add it directly to the package.json and do npm i
npm i installs everything in the package.json dependencies
Did that and nothing
If you install another library and use it does it also not install?
Like express or something
No it does install, i have topgg already installed but the autposter is somehow buggy or something.
I already contacted the support of the hosting to try to help me with resolving this issue
A simple API wrapper for top.gg written in Python. Contribute to top-gg/python-sdk development by creating an account on GitHub.
how do you specify port in this example shown
That is the endpoint, not where it starts
https://github.com/top-gg/python-sdk/blob/master/examples/discordpy_example/__main__.py#L52 that is where you specify the port
oh
thanks

import discord
from discord.ext import commands
import asyncio
import topgg
@topgg.endpoint("/dblwebhook", topgg.WebhookType.BOT)
async def on_bot_vote(vote_data: topgg.BotVoteData, client: commands.Bot):
if vote_data.type == "test":
print(f"Received a test vote by:\n{vote_data.user}")
else:
print(f"Received a vote by:\n{vote_data.user}")
user = await client.fetch_user(vote_data.user)
await user.send("Thanks for voting for our bot on top.gg!")
@topgg.endpoint("/dslwebhook", topgg.WebhookType.GUILD)
async def on_guild_vote(vote_data: topgg.GuildVoteData, client: commands.Bot):
if vote_data.type == "test":
print(f"Received a test vote by:\n{vote_data.user}")
else:
print(f"Received a vote by:\n{vote_data.user}")
user = await client.fetch_user(vote_data.user)
guild: discord.Guild = await client.fetch_guild(vote_data.guild)
await user.send(f"Thanks for voting for {guild.name} on top.gg!")
class Topgg(commands.Cog):
def __init__(self, client: commands.Bot):
self.client = client
self.webhook_manager = topgg.WebhookManager().set_data(self.client).endpoint(on_bot_vote).endpoint(on_guild_vote)
@commands.Cog.listener()
async def on_ready(self):
if not self.webhook_manager.is_running:
await self.webhook_manager.start(port=5000)
def setup(client):
client.add_cog(Topgg(client))
print("Topgg cog loaded")
this should work right
im still waiting for my bot to get accepted so i cant test
i tried doing a post request using https://reqbin.com/
didnt seem to work
im using https://railway.app to host my bot btw
i did add port as a variable
Like it gets timed out
Is it just a connection error?
Are you sure you're using the correct url?
what is the webhook authorisation
If you're running that code from your computer, have you setup port forwarding correctly and given the right IP in the bot's settings on Top.gg?
A password that will be sent in the request along with the other data to your server so that you can be sure the voting data is coming from Top.gg and not some random user doing requests.
https://top.gg/api/bots/1041382394378338374/check?userId=748878236896854126
?? is there anything i have done wrong here, it doesnt seem to be working
Define
it doesnt seem to be working
Saying "it's not working" is not helpful at all, you can provide error codes etc.
Also share code as well
is the top.gg api broken?
im providing a valid user id but it gives an error of not found
in
let user = await api.getUser(userid)```
@top-gg/sdk btw
what are you trying to do?
im tryna get user info bro 😭
no you need to add and then subtract then multiply by 57
w h a t
yeah im a js pro
🗿 ..
you use swift, smh
where do you put the authorixation code in a link?
i have this, https://top.gg/api/bots/1041382394378338374/check?userId=748878236896854126 but idk where the code goes
wdym?
.
its giving me {"error":"Unauthorized"}
i have but it doesnt show were to but the thing
no
Hello @restive otter
Hello @vapid tulip
Hello
is the top.gg api broken?
im providing a valid user id but it gives an error of not found
in
let user = await api.getUser(userid)```
@top-gg/sdk btw
repost
they don't even know it
i dont understand it lol, thats why im here
what programming language do you usually use?
wait nvm im stupid i found it
lmao ok
Check your token that you assigned to the sdk
/leaderboard
do i need to own a domain to set up a webhook?
no
just a public ip and a web server
what does that mean
im not good with domain/ip stuff
It might help to read a few things so you understand them.
All a domain does is refer to an ip(super simplified)
So for example
https://google.com/
Might turn into
https://2.2.2.2/
Imo, a good 10-15 minutes of research on how http and domains work will make the process of implementing webhooks way faster.
thank you!
Is there any way to post the status of the bot without using the package?
You can use the api directly.
Post stats uses the body for that information.
I dont think it supports url parameters.
I'm confused...
because using the package, the status only updates when the bot restarts, at least for me that's how it is
I was having this issue the other day (connect EHOSTUNREACH 2606:4700::6810:ae38:443). I use the topgg-autoposter library. It was happening even when restarting the server, but now it is working fine. Any help?
Yes
const ap = AutoPoster(process.env.topggtoken, client)
ap.on('posted', () => {
console.log('[AUTOPOSTER] Posted Stats to Top.gg!')
})
@lament pawn
And for example two-three days ago worked, now not
already done that.
Mine only syncs when the bot restarts, do you know how to solve it?
Now it works, try to post inside GuildCreate event
Is there an endpoint to get all bots of an user?
Is the api down? I am getting a Gateway time-out
yes
...
Hi
No
Documentation of the endpoints and other resources are at https://docs.top.gg
@restive otter hello my brother
Having 504 error
Wait some time, should resolve by itself
Hello, I got this in the conole
TopGGAPIError: 504 Gateway Time-out
look above
it’s a issue with top.gg should fix itself
Ah sorry, seems to fine now
Thanks
I need to get information about those who vote for the server (not a bot)
i use topggpy
Hello, how do I use the api to find out when the user voted on my server?
By using webhooks, checkout the pinned messages in this channel
...
the topgg api for what it is
How can we check if the user voted for our bot in past time ?
Dude I'm also getting this same error when I tried to fetch the user votes but I found no such data category exists 🥲
you need to pass an auth token while making requests to the api
Here's what I tried !
Note : I've assigned my top.gg bot token to the variable self.tgt
When I was trying to get the value of "voted" variable I wad getting an error so took complete data as an output which was something like {"error" : Forbidden}
Please do tell my what's the mistake in this code
async def check(self,ctx, user: discord.Member):
async with aiohttp.ClientSession() as s:
async with s.get(f'https://top.gg/api/bots/751100444188737617/check?userId={user.id}', headers={'Authorization': self.tgt}) as r:
data = await r.json()
await ctx.send(pain)
if data['voted'] == 1:
return "True"
else:
return "False"
https://top.gg/api/bots/botid/stats?server_count=servercount is this http correct?
i dont understand
the bot only return {"error":"Required parameter server_count or shards missing"}
i used post
You need to pass the parameters in the body as JSON
Not sure what method you use to post but with fetch a basic example would be:
fetch("URL", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "TOKEN",
},
body: JSON.stringify({
"server_count": 1337
}),
});
ohhhh okay
Using ?x=y and &x=y are so called query parameters and more used for GET requests 
Hey, i need a api key for my bot please, how to get one?
if your bot is approved it can be found on your bots edit page, in the webhook section.
Okok, thx ^^
How do I get the webhook and authorization from a server? I want the bot to get information when x user votes on the server
when I open the "webhook" tab in the dashboard, it only shows empty fields
I am unable get notification via webhook in discord.
you cannot use discord webhooks as you've been told already
See the pinned messages
ok it’s not discord webhook
http://<your ip or domain>:<port>/dblwebhook
Not necessarily /dblwebhook either
I just have it set for me just keep thing organize
It will connect Discord?
@restive otter
Yup
You're using js?
Python
Okay wait
Eh wait this could give you a better description i guess
https://docs.top.gg/libraries/python/
which id?
where did you saw that?
-topggid
💀 oh the user id
the token is the webhook one i guess
You can get it on your bot's page when clicking "Edit" and going into the webhook section
Ok
getting error
Without code, can't help
w8 i am giving
Have you actually defined bot
It is supposed to be your bot instance in your code
Such as when you do in your bot's file
bot = commands.Bot(command_prefix="$", intents=discord.Intents.default())
https://discordpy.readthedocs.io/en/stable/ext/commands/commands.html
yup
wait
Why bot = bot = ... and is it in the same file
still getting same error
^
i solved
it
and it is in
same file
Then I recommend to reorder your imports and where you have them located
As said, I recommend to reorder them
You never have a random import in the middle of your file
Imports go at the top of your file
ok
Still getting
Same error
Thought you solved it..?
Regenerate your Top.gg token on your bot's page, then refresh the page and then copy the token.
Make sure to refresh the page between regenerating the token and copying it.
Ok
problem sloved thank you!
how much time did it take
to update on top.gg
profile
Approximately 30 minutes 
ok
how could i make vote only command?
By doing something like
check_voted = await bot.topggpy.get_user_vote(USER_ID)
if check_voted:
print("User voted")
else:
print("User not voted")
Reading documentation will help you find other things you may need in the future https://topggpy.readthedocs.io/en/stable/api.html#topgg.DBLClient.get_user_vote
Yeah
what should i paste in USERID
Nothing static
You will need to have there the ID of the user you want to check if they have voted
ok
is i have to use @bot.event?
I don't know, depends where you want to check if a user voted
ok
If you want to check if a user voted for the bot in an event, it will be in the event's function
If you want to check if a user voted for the bot in a command, it will be in the command's function
If you want to check if a user voted for the bot in a task, it will be in the task's function
etc.
Then you will need to add the code in your command's function
which one
Every command you want to have the user to vote to use it?
like this?
Why an event?
You just said you wanted in commands
yes
Then write it in your command, not in a new event that will never get fired
yeah
like this....
Try it and see
error
Your bot object doesn't have the topggpy attribute, as the error says
so what i have to do now
Define the topggpy attribute for your bot's object
how
Have you learned Python already?
yes
Have you learned about classes
yes
Then you know how to fix it 
ok i understand
-topggkey
-topggapi
wow f
man how do you get your api key
so can you check if someone has voted
You can get it on your bot's page when clicking "Edit" and going into the webhook section

Is the api closed?
No, try again later
How can I make servers appear like that?
I mean like this (the servers appearing right there)
post the server count to the topgg api
how
Thanks
But I mean how can I make this appear in my bot's
yes you need to post your bots server count for that to appear
I saw the docs but still I don't understand how can I post it
by sending a post request to the linked endpoint, click the link and read it
there also some libraries that could make it simpler for you
what language are you using?
javascript
Alright, so I could make like a replit and make that code run?
probably?
I made it like this:
const client = new Discord.Client() // Your discord.js or eris client (or djs ShardingManager)
const { AutoPoster } = require('topgg-autoposter')
const ap = AutoPoster(process.env.token, client)
ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
})```
But it returns that Discord is not defined
Import it or use your current client object
It clearly says that it's your discord.js client definition, so you know what it should be
Never existed, don't rely on AI as source of information
does the DBLClient class close itself after sending out the request, because I don't see the coro being used afterwards ... ?
asking for the API library in py
Hello i have question i want add code to my bot if anyone vote the bot send dm thank to user is there package or smt do like that
depends on language you're using
you can either use the request api:
https://top.gg/api/bots/<botID>/check?userId=<userID>
or use socket (webhook), which is recommended for your use case, you can find package in pins if there is one
socket? why would you need socket for that
meant the webhook thing
For their use case only webhooks make sense
How do I setup Fibo? I cannot find webhooks at all on Top gg
Fibo?
Fibobot
Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Discord Support Server" button on the bot's page of the bot you need support for. If there isn't a button that says "Discord Support Server" or nothing else mentioned about a support server, the server invite is invalid or you were banned from the bot's support server, then we can't help you. Sorry :(
Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Discord Support Server" button on the bot's page of the bot you need support for. If there isn't a button that says "Discord Support Server" or nothing else mentioned about a support server, the server invite is invalid or you were banned from the bot's support server, then we can't help you. Sorry :(
Hello, how to get Total vote and Vote Strike ? in user
you need to track that yourself, Check the pins
hi, is there any way of getting reviews/the amount of stars of a bot?
not an official way, but, everything's possible 😏
yes scrape your bots page
POST https://api.top.gg/graphql gives reviews (look up in network log for more info 🤓)
and an easy way to get your bot probably banned for scraping top.gg ez
also undocumented endpoints = probably no Support
well it wouldn't necessarily be detectable but yeah
Reccomending it is probably not a good idea though
then make an public endpoint lols
Reviews probably will never be a public endpoint.
Since rewarding/incentivising users reviews is against our policies and most people would use it to give rewards its probably not a good idea
then just give devs the total ⭐ of the bot itself?
That's something that I'd like to see added yeah.
or like some sort of widget to embed on a website that shows the total stars
like trustpilots
i am getting 401 error when posting stats
const token = process.env.topgg as string
AutoPoster(token, bot)
.on('posted', () => {
console.log('Posted stats to Top.gg!')
})```
Why does the topgg api ratelimits too fast?
I've vote only cmds. After every restart in 1h only it ratelimits
Top gg should increase ratelimit time
you should use webhooks then https://docs.top.gg/resources/webhooks/
How do I do that
Use it?*
read the docs
click the link
Why not <Api>.hasVoted(user id)
SuS
?
Topgg should increase ratelimit duration.
no
webhooks exist for this reason
no
use webhooks and dont abuse api
simple
How to setup webhook.*

how to get list of who voted for my bot or server? in python
https://docs.top.gg/api/bot/#last-1000-votes closest you can get
Not always but sometimes while posting bot status to top.gg I get this error.
I got this from console:
response: {
status: 504,
statusText: 'Gateway Time-out',
headers: AxiosHeaders { ... },
.....
}
An issue on top.ggs end
nothing u can do bout it
No need to copy paste what other users send, thanks
Thanks for letting me know. I thought my client face some issues sometimes.
5xx errors are server errors you can't do much about as a user/client other than trying again later
Hm okay. Thanks 👍
Anybody else having issue sending stats through the API?
Confirmed the API token we are using is valid.
Error suggests API token is not valid.
Reset the token, refresh the page and then copy it
I figured that at first, and have reset the token and confirmed the new token is being used, still getting the same message
Error still says the token is invalid
have you refreshed the page after regenerating the token? as regenerating the token will not display the correct one until the site was refreshed
Owo hunt
Please keep any owo commands to #commands - This is the third time you've done it outside 
how to get topgg token
Hello I was wondering if someone could help me and explain how to set up a webhook in my python bot to receive a user id of anyone who votes for my bot
answered you in #support 
check the pins of this channel, there's also a link to the documentation for each language specific API wrapper library
Hello! My bot has a vote based command, meaning the user can't use it unless they vote but it seems like most of the time the API is returning 504 Gateway error which is causing trouble for my bot, why is it? am I hitting rate limit?
no, as I said it’s an issue on top.ggs end
@restive otter sorry for pinging you here, but if it's not on their end then what's the issue?
there’s nothing you can do about it
except trying again
I mean what is the actual issue and why is this happening?
A gateway timeout, as it says
but there’s nothing you can do sadly
I see :/
yeah
It usually is
😁
I didn't had an anticrash and my bot was crashing over and over
fun
catch the error
yeah added it
the thing is I coded this bot just for fun, so my codebase is hella messy and the bot skyrocketed out of nowhere. Now I need to rewrite the whole thing if I wanna fix it
have to use webhooks if you wanna know that
how to make topgg show the right number of bot servers
youll need to post your bot's server count to topgg using our api or one of our libraries
do i need top token?
Youll need a topgg token, which can be found on your bots edit page in the webhook section.
it can take 30 minutes to update
what can make number right in the website if i can add any numbers i want
users see your real server count when inviting your bot.
if we catch you posting incorrect counts we will ask you to fix it or you may be banned from our site.
how will bot know exact number of my bot count?
how will your bot? or us?
how will the user who add my bot see its server count
alright
its on the page users invite your bot on
just noticed it
Why not, why can't. How to?
Oki
- rate limit is 429
now that my bot is approved i need to reward my users who votes the bot
does api generate any event when user votes the bot?
https://docs.top.gg/resources/webhooks/
you can use webhooks, which will send a post request to your web server when someone votes
i dont really have any web server
then make one
i dont have any platform to host it
im hardly getting by by hosting bot on free vps service
guess i dont have any choices then
getting events in api itself sure sounds nice tho
The api is just an api.
It can't provide events like a websocket does.
The way an api like topgg provides events is webhooks. Which is pretty standard.
nvm
alr
I am getting this error when using the topgg-autoposter package. It does not happen every time, but it is fairly common. Any help or idea of what's causing the issue?
Hey, I wonder if our ipv6 connections just are a bit unreliable?
We did have a partial outage yesterday, but you've been having this issue enough that I don't think it's related to outages.
The only time this seems to happen is on ipv6.
My host believes it’s their IPv6. I am waiting on an update/a response back but for now they’re waiting to hear back from their ISPs NOC they said
Would there be any example implementations of it?
yes, i believe so
I havent found any
Could you show me?
Okay so I found the code but I dont understand what "route" is like is it the "Webhook URL" posted on your Top.gg bot?
Cause I used that in the code and im not receiving anything
Or maybe I am and I cant see it I dont know
I think most likely none of this is running at all and im doing something super wrong
hello i use topgg autoposter to post stats on bot but it only show one cluster information (i use discord-hybrid-sharding npm for shard staff)
is there any way to fix this ?
isnt there any way to get when user voted the bot in c# library without using webhooks?
To update the statistics of the bot I only use the same method of server_count?
what part are you unsure about?
just webhooks in general?
I cant figure out how to properly implement it at all and it just seems hopeless at this point
The webhook to discord thing you made is very impressive btw