#topgg-api
1 messages ยท Page 14 of 1
your bot can post to discord
if you setup a port for express to work on
and top.gg sends the data to your bot which your bot sends to discord
I don't think my host allows me to open extra ports
why not use the port your bot is running on
sure if you want you could dm me
Is the API down? I keep getting a 502 bad gateway
yes
One message removed from a suspended account.
@radiant pasture @silk idol i got question for both of you
||Insert a joke I just Forgot ||
Dm
Yes
Okey
don't ask to ask mf just ask???
also this is the wrong channel
i know
I thought it was general for sec
One message removed from a suspended account.
One message removed from a suspended account.
When will the website be fixed? There are commands in my bot that require voting, and my bot is not working because it cannot connect to the site.
One message removed from a suspended account.
:c
To integrate the top.gg api, should I use topgg autoposter or sdk?
I'm thinking about thanks
SDK is more affordable, thank you very much

The site has b.o again, but I wanted to add the topgg bot link to the website, confirm that this is correct please
top.gg/bot/<ID>

yes
if you regenerate your topgg api token, the old one is invalidated right?
yes
thanks
TopGGAPIError: 401 Unauthorized (You need a token for this endpoint)
Why this?
One message removed from a suspended account.
One message removed from a suspended account.
Ok
Bruh but i have changed all the paths but it doesn't fix it and the error doesn't say where it is located
One message removed from a suspended account.
One message removed from a suspended account.
Ys
One message removed from a suspended account.
nor fixed
Where do I paste my token to create a new .env file on vsc?
Inside the .env file ๐
You create the file first, not paste the token to create the file.
And how do I create the file? Sorry
Thank you @jaunty plank 
having trouble installing the python-sdk atm
installing with pip install -U topggpy seems to work but trying to install from source gets ```
Running command git clone --filter=blob:none --quiet https://github.com/top-gg/python-sdk /tmp/pip-req-build-x31mgezk
Resolved https://github.com/top-gg/python-sdk to commit 06844706605b2d368d6892933f7f1aae45be5dee
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
ร python setup.py egg_info did not run successfully.
โ exit code: 1
โฐโ> [3 lines of output]
error in topggpy setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Expected end or semicolon (after name and no valid version specifier)
https://files.pythonhosted.org/packages/18/93/1f005bbe044471a0444a82cdd7356f5120b9cf94fe2c50c0cdbf28f1258b/aiohttp-3.9.3.tar.gz
^
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
ร Encountered error while generating package metadata.
โฐโ> See above for output.
does anyone have an example webhook request for bot votes?
i was looking for an example json object ๐ฅฒ
๐
that describes the json object
ive been awake for almost 50 hours ๐ญ my brain doesnt want to understand it
{
"bot": "136583532972605440",
"user": "1213694236319416351",
"type": "upvote",
"isWeekend": true,
"query": "?hi=howareyou&someotherquery=weeee"
}
ty
Installing from the source is a bad idea because the official repository is currently broken. If you want to get the 2.0.0a version, you need to run pip install topggpy==2.0.0a0 so it installs the 2.0.0a version. Alternatively, 1.4.0 should still work just fine for d.py.
cool...good to know
Check out this issue for... well, some kind of details: https://github.com/top-gg/python-sdk/issues/75
Collecting git+https://github.com/top-gg/python-sdk/ (from -r requirements.txt (line 14)) Cloning https://github.com/top-gg/python-sdk/ to /tmp/pip-req-build-z18_guw1 Running command git clone --fi...
edit bot > webhook
Hmm
How to make an logger that logged vote in a specific channel on discord
make an api endpoint in your bot and add its url in topgg
it will then send a post request on every vote
like for example https://api.wamellow.com/v1/votes >
If I really say I didn't understand
I am beginner in these things
look at tutorials for your languages of choice on how to setup a http server to handle requests
note that you also need to host your bot on a server where you have some IP address
Hi, I'm using this curl to post bot's stats but getting 401, I tried to reset token and use new token as well
curl --location 'https://top.gg/api/bots/<bot_id_here>/stats' \
--header 'Authorization: <token_here>' \
--header 'Content-Type: application/json' \
--header 'Authentication: <token_here>' \
--data '{
"server_count": 1,
"shard_count": 1
}'```
it accepts just one header, thats Authorization
not sure if thats the cause but wont hurt to check
also, try making a request using a programming language, if that works, then its prolly your cURL syntax
not an expert on that, so you gotta check the docs
So I used this API
from discord.ext import tasks
import topgg
# This example uses tasks provided by discord.ext to create a task that posts guild count to Top.gg every 30 minutes.
dbl_token = "Top.gg token" # set this to your bot's Top.gg token
bot.topggpy = topgg.DBLClient(bot, dbl_token)
@tasks.loop(minutes=30)
async def update_stats():
"""This function runs every 30 minutes to automatically update your server count."""
try:
await bot.topggpy.post_guild_count()
print(f"Posted server count ({bot.topggpy.guild_count})")
except Exception as e:
print(f"Failed to post server count\n{e.__class__.__name__}: {e}")
update_stats.start()
It said on my end that it posted the server count, I go to the top.gg page and it hasnt updated?
By application was giving 401 that's why I'm trying curl :/
Yes it happened when my bot was posting stats to top.gg too
Looks like its working just fine for me now, it couldโve been a small hiccup in services
Still getting 401 ๐ฆ
hi
I am looking for the blockchain and web dev
plz send me DM, if anyone know well
not the right place to recruit devs
does topgg have a event listener for new votes?
how can i add server count
const nodefetch = require('node-fetch');
const body = { "server_count": client.guilds.cache.size };
nodefetch(`https://top.gg/api/bots/id/stats`, {
method: 'POST',
headers: {
"Content-Type": "application/json",
"Authorization": "token",
},
body: JSON.stringify(body),
}).catch((err) => console.error(`#${cache.index + 1} ${this.name}: ${err.stack}`));```
change token with your token and the id in the https with your bot id
Thereโs a npm package
Auto-Poster for Top.gg. Latest version: 2.0.2, last published: a month ago. Start using topgg-autoposter in your project by running npm i topgg-autoposter. There are 4 other projects in the npm registry using topgg-autoposter.
Something here to learn everything about topggpy
in python
i do understand nodejs
and i know how to do it now
thanks
oh
Does anyone know how to, got a manual, video tutorial on how to make voting restricted commands
this is how I do it:
- top.gg sends a request to https://api.wamellow.com/v1/votes (webhooks)
- I store the vote date in the database
- on commands, I check if they last voted less than 12 hours ago
Intersting. Would need a documentation tho
well, only the top.gg webhook is documented, the other stuff are things you have to find out yourself with your programing language and database
That sucks.
could I get support regarding the topggpy library here? and to get the webhook manager working? I'm not able to.
hmm how to fix toppggpy webhook error:
Error handling request
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\aiohttp\web_protocol.py", line 350, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "aiohttp\\_http_parser.pyx", line 557, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message:
Invalid method encountered:
b'\x03'
^
cgpm
same:)
administrator? really?
it's 2024 not 2004. create a non admin user for day to day work
๐ but it's windows, it doesn't matter ^-^
it DOES matter
this isn't windows xp days any more
Your user account doesn't have admin access?
I actually didn't know that people did that ๐
I put an admin password in to do admin stuff
windows can work like sudo if you have separate admin accounts and keep UAC on
this is how ms want you to work
they just default to moron mode
lol
especially in windows 11
however that default is not administrator
an admin account and administrator are different
administrator is a guessable name, makes you easier to hack
they've had the default administrator account disabled since what, vista unless you're on a domain controller
administrator always has the same UID
So administrator is effectively root? Above admin perms?
kinda yeah
I gotta learn windows still and I've been using it forever
it's root instead of making your own user account in the root or wheel group
the normal setup of windows is a user who isn't technically an admin all the time but elevates to admin via uac
which is why you can't just delete windows files
since after windows xp
basically like sudo
that's when it pops up "do you want to perform changes to your pc"
elevation
as actual administrator it may not prompt
Okay yeah I see what you mean.
https://github.com/top-gg/python-sdk/issues/72
Something similar seems to be going on.
- Which version of the package?
- Which part are you stuck on, specifically?
I figured it out, thank you!
Please don't mass ping
Can you elaborate?
You're looking for the docs? Or?
I want top.gg api
Api
We can't "give" a website.
;-;
There is a button for adding Discord bots on the website. ๐
If it is approved, you will have access to the Top.gg API.
Mine isn't getting approved
If it gets rejected, fix the cause. If you got no response, keep waiting
vps not real pc
I still wouldn't run a bot as admin
same way I wouldn't run one as root
use the permissions systems your os gives you
TopGGAPIError: 504 Gateway Timeout
at Api._request (/home/container/node_modules/@top-gg/sdk/dist/structs/Api.js:61:19)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Api.postStats (/home/container/node_modules/@top-gg/sdk/dist/structs/Api.js:86:9) {
response: {
statusCode: 504,
headers: {
date: 'Tue, 12 Mar 2024 14:56:42 GMT',
'content-type': 'text/plain; charset=UTF-8',
'content-length': '15',
connection: 'keep-alive',
'strict-transport-security': 'max-age=15552000; includeSubDomains; preload',
'x-content-type-options': 'nosniff',
'x-frame-options': 'SAMEORIGIN',
'referrer-policy': 'same-origin',
'cache-control': 'private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0',
expires: 'Thu, 01 Jan 1970 00:00:01 GMT',
server: 'cloudflare',
'cf-ray': '8634a071beaea832-SYD',
'alt-svc': 'h3=":443"; ma=86400'
},
trailers: {},
opaque: null,
body: BodyReadable {
_events: [Object],
_readableState: [ReadableState],
_read: [Function: bound resume],
_maxListeners: undefined,
_eventsCount: 3,
[Symbol(shapeMode)]: true,
[Symbol(kCapture)]: false,
[Symbol(abort)]: [Function (anonymous)],
[Symbol(kConsume)]: [Object],
[Symbol(kBody)]: null,
[Symbol(kContentType)]: 'text/plain; charset=UTF-8',
[Symbol(kReading)]: false
},
context: undefined
}
}``` anyone having the same error every now and again?
This is an error on the top.gg side, which is probably caused by a temporary API downtime
Hi
I can't post my bot's stats. I am using the Api builder from @topgg/sdk
It says I'm unauthorized
But I am using the correct token
const Topgg = require("@top-gg/sdk")
const express = require("express")
const app = express()
const webhook = new Topgg.Webhook("your webhook auth")
app.post("/dblwebhook", webhook.listener(vote => {
// vote will be your vote object, e.g
console.log(vote.user) // 395526710101278721 < user who voted\
}))
app.listen(80)
Is there any way, I can achieve this same thing without having to use webhook?
Someone tell me as beginner guider
How to make a logging system that log on specific channel when someone vote my bot
With variables of who voted, a timer when they vote again
Total vote counts
Right now for vote events you must use webhooks.
depends on a lot of things, like what lib you're using. think this would be more #development if you already have your webhook set up
why not just use topgg-autoposter 
How to create my own webhook?
You just make an API endpoint for whatever lib and language you use.
And can a moderator see your webhook link or auth?
I have no idea how to do that. Does any documentation exist about this?
Np.
Though I use js
We have some libs on the docs site that can do this.
As for doing it from scratch you can just Google webhooks for your programming language
Yeah I have no problem with how to handle that and all. I just don't know how to create my own webhook.
Will do what you said. Thanks!
Hey hey, as a question, can someone briefly explain to me the API and what you can do with it, for example?
I'm new to this API area, I always code everything myself, etc
hence the stupid question
The docs are super easy to read if you're looking to use the raw api.
Thanks
Because i'm using a library not very well known
And that module requiere the client of Eris or Djs
Not sure where to post this but, is it correct to assume bot icons aren't being shown when the bot avatar is a gif format? 
correct
I'm not using DJS
Nor Eris
It is a new library that is not very well known.
typescript huh?
Then use a direct API request, you don't need any library for that
I meant that I am using a framework library from the Discord API not very well known, but I will definitely make a post to the api
hey, I am getting started with tpogg API , how do I get the topgg API token?
got the token
instead of sending the code, I am sending the parameter values because my library might not be familiar:
header:
"Authorization": "topggapitoken"
}```
type: POST
body:
{
"server_count": 57
}
url:
```https://top.gg/api/bots/815583533308313641/stats```
property: empty
is this good?
i received
{
"message": "You are not allowed to update this bot"
}
how do I update the server count of my bot on top.gg??
Remove this colon in the link
it was in the link already
It shouldn't be there
ok I'll try
You were supposed to replace :bot_id with your bot's id, not just bot_id
That's why it's even bolded
o i get it I'll try
now it says invalid input
{"message":"Invalid input"}
@runic creek help :>
stevenclinton.#0 was successfully banned.
hi
can you help me ^
:>
what lib are you using
c!eval $httpRequest[https://top.gg/api/bots/815583533308313641/stats;POST;
{
"server_count": 57
}
;;err;
{
"Authorization": "$getVar[topggapikey]"
}
]
does there need to be anything in the object/property parameter?
i have just put
"server_count": 57
}
in the "body"
looks fine
^ that's what Im doing and it's returning "invalid input"
Yeah looks good to me too. I'm more familiar with using .NET though but I would recommend using something like postman first to test making a call to ensure it sends through all fine. Then you can craft the call in your code from there.
Maybe try a get call as well? It could help narrow down the problem area.
all requests (POST/GET) are to be https or json?
I mean if you go off the docs, it looks fine
And are you unable to use the js lib for posting stats?
when using GET, there's just no response, no error or anything
rn i am tryna post the server stats, yes
Yeah, are you able to use the autoposter lib by chance? Would make it easier as that handles the requests for you
wut is autoposter lib :
o:
i need to install it?
npm i topgg-autoposter, i need to install this?
const client = new Discord.Client() // Your discord.js or eris client (or djs ShardingManager)
const { AutoPoster } = require('topgg-autoposter')
const ap = AutoPoster('Your Top.gg Token', client)
ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
})
``` and also add this?
yes
ok ig i have done this stuff
now it will do it automatically or I have to something?
yo it worked thanks ๐ฎ
curl -X POST -H "Authorization: " -d "{\"server_count\":50}" https://top.gg/api/bots/1209874430981963846/stats
{"message":"Invalid input"}
why doesnt work?
Why did the bot stats stopped updating at 31,200 servers? Was there some change in API? It worked 4-5 days ago
O vote
Officially? No, but there is an endpoint that the site uses to get these reviews from the API
If you look carefully in the "Network" tab, you will find the appropriate API request and the endpoint in it
Hello, someone has a JavaScript Code for webhook message when a user vote ?
API not working for anyone?
working for me
Was there a change? I'm getting 400 codes now and didn't change anything
Can someone tell to me how too add bot too server
what bot
you can join their support server and they will help you out
you can also look for the bot's documents online they usually tell you how to use it
@sand spire
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 :(
read that, should help 
where is that damaged top gege python sdk
One message removed from a suspended account.
Anyone know why this stopped working? I've been getting 400 Bad Request error codes for the past week or so and didn't change anything. I verified it's passing the correct token and payload via debugging:
async def update_server_count():
guild_count = len(bot.guilds)
payload = {
'server_count': guild_count
}
headers = {
'Authorization': bot.topgg_token
}
async with aiohttp.ClientSession() as session:
async with session.post(f'https://top.gg/api/bots/{bot.user.id}/stats', data=payload, headers=headers) as resp:
if resp.status == 200:
print(f'Server count of {guild_count} posted successfully to top.gg.')
else:
print(f'Failed to post server count. Status code: {resp.status}')
Should I refresh my token?
tldr possibly just random stupid requests coming through.
Looks like you're missing a content type header
reddit bots when?
Is this correct?
headers = {
'Authorization': bot.topgg_token,
'Content-Type': 'application/json'
}
Yep
I'm still getting 400 Bad Request
I think there's an odd issue in the web api migration, are you sending shards?
does your bot.topgg_token have a Bearer prefix?
i dont know either lmao
wait yeah i think we don't
he's only sending server count from looking at his previous snippets
@muted verge try data=json.dumps(payload)
#credits
or json=payload
This worked, thanks!
โค๏ธ
credits plizz
for me also not working
the stats stopped updating randomly
this is my code
await fetch(`https://top.gg/api/bots/718493970652594217/stats`, {
method: "POST",
headers: {
"Authorization": config.topggToken,
},
body: params
});
also getting 400
trying stuff said above
Ok now getting 200
are you using js?
This will make your life easier https://www.npmjs.com/package/topgg-autoposter
Auto-Poster for Top.gg. Latest version: 2.0.2, last published: 2 months ago. Start using topgg-autoposter in your project by running npm i topgg-autoposter. There are 5 other projects in the npm registry using topgg-autoposter.
Hi, I was wondering a question, is it possible to make a /vote command which votes directly on the site without having to click on the link etc. that it is automatic and that its vote is carried out by the person who executes the command?
Nope, the user would need to go to the website to vote
ok, thanks for your answers ๐
nuh, lightweight is better
its just a single post request
and autoposter doesn't work too well for clustering in some cases
hi๏ผwhen i apply the bot token to track the server count, top.gg kept showing: http 400
You're missing required parts of posting stats.
https://docs.top.gg/docs/API/bot#post-stats
API resource for a bots or apps on a platform like Discord
Hello everyone,
Is there an API endpoint, where I could post a description of Bot?
I am aware, that I can change the Description manually on the Top.GG site.
Ping me, when answering this question
short answer, no
long answer, yes with a user account, but I doubt you are supposed to do that, so no again
yw
Dynamic/changing descriptions can be done with an iframe
iframe to a website you have, then you can update that iframe any time you want.
How do I make an event in the topgg javascript (node.js) library, that when a user has voted, it returns the userId and everything
I tried toppgg-votes but that didn't work
The closest I saw to official topgg stuff was: https://www.npmjs.com/package/topgg-autoposter
But this didn't have posting events. just to post stats to the website
Auto-Poster for Top.gg. Latest version: 2.0.2, last published: 2 months ago. Start using topgg-autoposter in your project by running npm i topgg-autoposter. There are 5 other projects in the npm registry using topgg-autoposter.
I'm not sure what this is
I think you're looking for: https://docs.top.gg/docs/Libraries/javascript#webhooks
Official Top.gg JavaScript library
Hmm, thats not official. I'm not sure who made that.
what does it mean by "auth" the url?
Looks like you're trying to use a discord URL. Top.gg webhooks are not discord webhooks.
ohh you mean topgg token
Is the only way to receive voting events with a webhook and an ePoint?
If anyone needs help with top.gg's api then this video got you covered. Helped me a lot
Quick showcase on how the top.gg API can be easily used with the help of the top.gg javascript SDK to give users a reward for voting for your bot as well as how you can easily implement the autoposter library to keep your bot stats up to date on the website.
Credits
Produced...
Glad you liked it!

you made it?
Yessir
YOU BETTER DO MORE
maybe like how to make your bot page better with like markdown or html
More is coming
I just gotta stop being lazy and get to work
feel you
stop lying
where can I host a mini webhook server for free to listen to votes?
You canโt get in without a token
Where do I enter the token?
@icy aurora
You cant in web
hello I'd like to know why I'm getting this "Error: 401 Unauthorized (You need a token for this endpoint)" error, because I'm using this tokenI'd like to know why I'm getting this "Error: 401 Unauthorized (You need a token for this endpoint)" error, because I'm using this token
Try regenerating it
Webhook authorization is something you make.
Since you're the one that has the http server you can make it whatever you want.
For example I could just start hitting keys on my keyboard.
dnjsaiodjnsadnkoas
^ valid auth
wait what how is that possible
The auth is for you, or the library you use to validate the incoming request is actually coming from Top.gg
If only you know it no one can submit fake requests.
How to i get my API Key?
Thanks
Then how do I do that?
The request isn't working. Url is valid
How do I get one then??
Pretty sure you find that on your bot's edit page
Or use this
Thats just to fill in your own webhook url.
This is for another library, but it covers what a webhook actually is and how they work.
https://top-gg.gitbook.io/top.gg-voting-node-sdk/faq/what-are-webhooks
isn't it possible to test vote for topggpy lib?
Like it doesn't it load in the on_dbl_vote event?
I'm trying to send message whenever someone votes, using my main bot but the event on_dbl_vote is not getting called when i send test vote
is this the right url to post the bots server count? https://top.gg/api/bots/BotID/stats
it used to work but since like 2 weeks it just doesn't anymore
Use top.gg autoposter. Can't remember the exact name but something like that. Here is a video tutorial: https://www.youtube.com/watch?v=wqlU2KOxQws&t=65s
Quick showcase on how the top.gg API can be easily used with the help of the top.gg javascript SDK to give users a reward for voting for your bot as well as how you can easily implement the autoposter library to keep your bot stats up to date on the website.
Credits
Produced...
...
Hey, does anybody knows why my response returns into false?
in my topGG code:
function topGG(serverCount) {
fetch("https://top.gg/api/bots/1193672589428654120/stats", {
method: "POST",
headers: {
Authorization: "token",
},
body: {
server_count: serverCount
}
}).then(response => {
response.json()
console.log(response.ok)
})
}
module.exports = {topGG}```
In bot.js
```js
setInterval(() => {
topGG(client.guilds.cache.size)
}, 30000)```
Are votes from app owners no longer sent to the webhook? I voted with my own account and nothing happened, but when I told someone to vote they received it
Auto-Poster for Top.gg. Latest version: 2.0.2, last published: 2 months ago. Start using topgg-autoposter in your project by running npm i topgg-autoposter. There are 4 other projects in the npm registry using topgg-autoposter.
Mine still working
I'm using JS not TS
that is in js
that package is written in ts but works ts and js
~~Hello, I'm trying to reward a user when they vote, but my bot isn't receiving the vote POST requests. Whether a user votes or I use the "send test" function, my bot isn't receiving them. Here is my code and config:
const { Webhook } = require("@top-gg/sdk");
const express = require("express");
const app = express();
const webhook = new Webhook("my-auth");
const PORT = 3000;
app.post("/dblwebhook", webhook.listener(vote => {
console.log("vote received:", vote);
rewardVote(vote.user);
}));
app.listen(PORT);
console.info(`Connected to TopGG (port ${PORT})`);
Then in the webhook config, I have:
- Webhook URL:
http://[host ip]:3000/dblwebhook - Authorization:
my-auth~~
Edit: got it fixed, my code was correct, but I needed to unblock the port on my VPS's firewall
I did the same and when I hit send test it doesn't send anything, it doesn't work, why?
Why does server 1 appear?
You didnโt post your stats
what do you mean
https://topggpy.readthedocs.io/en/stable/webhooks.html#helper-methods
If you're using v1.4.0, it does.
If you're attempting to use v2.0.0a, refer to this example: https://github.com/Top-gg-Community/python-sdk/tree/master/examples/discordpy_example
A simple API wrapper for top.gg written in Python. Contribute to Top-gg-Community/python-sdk development by creating an account on GitHub.
Make sure the webhook manager is running properly and top.gg's access to it is not hindered.
No, the webhook manager in this case is an alias for a webserver. In other words, a server running on your machine that accepts HTTP requests.
Top.gg does not support Discord webhooks.
alright, thanks
no
you got code the webhook or use https://webhook-topgg.com/
Simplifying top.gg webhooks for all users, allowing non-developers and developers to use webhooks for their bot and server without confusing configuration.
any other way instead of webhook? bc if i'm running multiple bots on different ips is there an event any other than webhook that i can get?
^ @lusty tundra
Traceback (most recent call last):
File "/home/container/bot.py", line 2973, in <module>
bot.topggpy = topgg.DBLClient(bot, dbl_token)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/container/.local/lib/python3.12/site-packages/topgg/client.py", line 98, in init
self.http = HTTPClient(token, loop=self.loop, session=kwargs.get("session"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/container/.local/lib/python3.12/site-packages/topgg/http.py", line 84, in init
self.session = kwargs.get("session") or aiohttp.ClientSession(loop=self.loop)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/container/.local/lib/python3.12/site-packages/aiohttp/client.py", line 279, in init
loop = get_running_loop(loop)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/container/.local/lib/python3.12/site-packages/aiohttp/helpers.py", line 301, in get_running_loop
if not loop.is_running():
^^^^^^^^^^^^^^^
File "/home/container/.local/lib/python3.12/site-packages/discord/client.py", line 140, in getattr
raise AttributeError(msg)
AttributeError: loop attribute cannot be accessed in non-async contexts. Consider using either an asynchronous main function and passing it to asyncio.run or using asynchronous initialisation hooks such as Client.setup_hook
Idk python very well, i just pulled it from topgg documentation
so what now
follow https://docs.top.gg
When do vows reset?
@long canopy read this ๐
they gave me example
error which came
Top.gg Python library
A simple API wrapper for top.gg written in Python. Contribute to Top-gg-Community/python-sdk development by creating an account on GitHub.
reading the documentation will help
Hey is there a way in python where I can give rewards based on if a person has voted or not?
API/ Documentation in Python
or something
I want the same thing lol
What does this mean?
you are not unauthorized to use the api
You need a token
Is the token from the bot or somewhere on the website?
๐ซถ
Have the votes been reset? If yes, when?
Votes reset the first day of every votes
I meant the applications
Where do you get your bot topgg token? in the webhooks?
It looks like this is wrong in the docs ๐ I when use parameters ?source=command on my vote URL I get an object response on the query property and not a string:
{
user: '491002268401926145',
type: 'upvote',
query: { source: 'command' },
isWeekend: true,
bot: '675996677366218774'
}
Which is very nice ngl but the docs need updating because they say it's a string
https://docs.top.gg/docs/Resources/webhooks#bot-webhooks
Webhook integration for receiving vote data
I have a bug when i want to add Background Image in my bot page...
-bgimage
@still roost
The bot page background link is currently broken. We suggest you use CSS for the time being!
Add the following code to your bot description:
body {
background: url(INSERT_LINK_HERE);
}
</style>
oki thanks
language is python
i was using this
everything works
even post shard and server count func
the hting is on_dbl_vote isn't being called
not in cog or in main file
am setting dblclient in OnReady event
but thats not the issue i blieve
hope somone can help thanks
nope
i tried with send Test button and also tried real voting too
but none
no error or print
dblclient = topgg.DBLClient(bot, topgg_token)
this how i am setting it
we need webhook?
Yeah, you need a webhook not a discord webhook.
Hi, How do I send message whenever someone votes? I am using Python discord.py. I have made my own webhook using FastAPI which returns status code 200.
If your webhook works, you just need to send the dm.
https://discordpy.readthedocs.io/en/stable/faq.html#how-do-i-send-a-dm
How to get the user cooldown on voting?
Thats something you should track on your side. store the timestamp when they vote in your database, then 12 hours from then is the cooldown
Hi Can Any One Help Get My Bot Server Amount In Discord.py Also Did Not Understand Docs And Example If Possible Pls Send Code Or Yt Video
Using topggpy?
but the event doesn't get triggered
So the webhook you made doesn't work?
Did you fill in your url and auth on top.gg? Not a discord webhook.
Yeah
I return a response with status code 200
I think the webhook works fine but I didn't do the code of topggpy correctly
You mean i'll need to dm in webhook's code?
I am hosting server and bot differnetly
I'm really confused on what your issue actually is.
Is the webhook not working?
Or is the dm not working?
We can't fix the DM issue until the webhook works, but it sounds like your webhook doesn't work.
I'm not really certain which issue it is
How do I make sure if my webhook works fine?
like do you have any page that shows the response from my server?
You'd just want to print a response when you get a vote.
in my webhook?
Yeah it does print
So, you're receiving webhooks?
Yes
Then you just need to add your bot to your webhook code, and just send a DM in the event. Or send a message in the channel you want. Or both
So you mean I'll send DM in the code of my webhook and not where my main source code is right?
yeah, you can always use ipc to forward the request to your "main" bot progran, but thats a pain. It should just be easier to add a very basic bot to the endpoint you want.
And just send a DM via that.
It shouldnt need any commands or anything, just log in to the bot and send DMs.
You'll likely want to disable all intents too.
so what's the use of topggpy?
Topggpy has a webhook server, its not a discord library, its just for receiving webhooks. The only feature other than receiving webhooks is for accessing the Topgg API.
oh, so the only way to send message is doing it in the webhook server?
So, the webhook server can be put inside your main bot code, or in the sharding manager(or first shard).
That way your bot and webhook server are the same process.
That's the most common way people handle it.
Or it can be on its own process with a small instance the bot to send DMs.
Or it can be on its own process and you can use IPC to send it to the bot(but that's kinda silly imo).
There's no real right way to handle it, it's however you feel the most comfortable.
Alright, thanks.
Hi
Hey
Is there a top gg Js api
whenever installing topggpy, it messes with pycord to cause AttributeError: module 'discord' has no attribute 'AutoShardedBot' error. This issue only occured after installing topggpy. Does it not support pycord?
is there a way to poststats just by an api endpoint? do we need to use a package?
Please ping me if you respond
Of course you can with a simple post request. The package simply automates it
Everything is in the documentation
Hii
Can you provide a link. I can't seem to find it in the docs.
Thanks so much!
how do i get a user from top.gg's internal user id's?
for example, my user id is 318453143476371456 but in the topgg url bar its 7901547614833410048 on my profile
sending a request to /api/users/:userid only accepts discord id's
๐ why do you need to get /api/users/:topggID ?
even our webhooks just send the Discord ID.
I don't think any of our public api endpoints uses or provides a Top.gg ID.
I wanna get the discord user from a user providing the profile link of topgg
Like a "who is" but based on topgg profile URL
Wouldn't it be easier to just have them mention the user in the command or provide the Discord ID?
then just use the API endpoint?
(and other way around where my whois shows the topgg profile)
I dont think we have any public API endpoints for what you're looking for.
Sad, thank you tho
I got a question regarding the api. Is it possible to get the upvote cooldown time of a voter?
Thats something you would want to store yourself. Its not provided by the API.
whats an api
omfg
what is it
Think of it as a connection
It helps to communicate between two applications
if i send test webhook on my vps, i get
7|Robloxbot | File "/usr/local/lib/python3.10/dist-packages/aiohttp/web_protocol.py", line 332, in data_received
7|Robloxbot | messages, upgraded, tail = self._request_parser.feed_data(data)
7|Robloxbot | File "aiohttp/_http_parser.pyx", line 551, in aiohttp._http_parser.HttpParser.feed_data
7|Robloxbot | aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'Invalid method encountered'"```
Cant seem to get it to work, can't see test vote, let alone real vote.
..
na it does not
it kinda hard too understand
What's hard to understand from the docs?
mh, even with different wrapper I get this
I'm not a py dev, but that reads like an error is happening with a request you're sending.
Ie after the webhook is already handled, something in your event is throwing the error. Are you possibly sending a request to an API or something that could be causing this?
I get this, when i use the "test webhook'" function on topgg.
I got this when i used the example from the lib.
There could be multiple causes for this error. I just rewrote the webserver with fastapi, lets see how it goes
might found out why
How can I test voting hehooks locally?
You canโt
send a dummy request through postman or something
{
"bot": "6916266261969696969",
"user": "584309117380853770",
"type": "upvote",
"isWeekend": false
}
Use something like this
hi can any send me the code for servers in python
i kinda did not understand the docs or example
They meant localhost type
postman can be used to send requests locally for testing
Can
no one will give you code, we dont spoonfeed here
i would suggest using this wrapper https://github.com/nexy7574/top.py/tree/2.0.0a/toppy, much better than the "official" one.
Which file should I look into
probably should not be used anymore lol
works fine, achieved because the person doesnt work on discord bot anymore
I only had to patch one minor thing
At this point just make a Rest Request
well, the thing is, the main author used [] and not .get and isWeekend would error on test hook
other then that, it works fine
you could fork and upload your changes, that would be nice for the other guy here
Hello, can someone who understands this issue help? The user votes once, but receives more than one message.
But it didn't work before, how can I do that?
I buy the webhook from this site https://webhook-topgg.com/ and write the token to topgg.
Simplifying top.gg webhooks for all users, allowing non-developers and developers to use webhooks for their bot and server without confusing configuration.
that's a known issue
@dry maple wanna check my code? see if you can find where its coming from?
I'm guessing I'm just taking too long to respond now, so Top.gg sends the response right away.
I can take a look sure
It's going to sit like that for awhile if I don't have someone else handle it.
Going to make a new GitHub repo rq
Am i doing something wrong?
const TopggAPIWebhook = new Topgg.Webhook(config.TopggToken)
api.post('/dblwebhook', TopggAPIWebhook.listener(vote => {
const Embed = new EmbedBuilder()
.setTitle(`<@${vote.user}> Just voted for RoSearcher!`)
const Channel = client.channels.fetch("1207774395268079657")
if (Channel) {
Channel.send({ embeds: [Embed] })
}
}))
fetch is a promise. It needs to be awaited
whooo[s
It should be cached, you can use get if you're caching channels.
the code should work though right?
Ok i've done that but the message aint sending
const TopggAPIWebhook = new Topgg.Webhook(config.TopggToken)
api.post('/dblwebhook', TopggAPIWebhook.listener(async vote => {
const Embed = new EmbedBuilder()
.setTitle(`<@${vote.user}> Just voted for RoSearcher!`)
const Channel = await client.channels.cache.get("1207774395268079657")
if (Channel) {
Channel.send({ embeds: [Embed] })
}
}))
not fully?
i have used them in a way with the webhook site
Ah, I mean use them use them
no
Did you setup your webhook url? not a discord url, not a url from a webhook site.
Do you mind if i send a request to that url?
yah np
Alright, gotta swap to my other OS, brb
I think you put your Top.gg token as the webhook auth, are you sure thats what you want to use as your authorization?
yes
Did you fill it in here?
sometimes it will
I'd double check your auth is set correctly.
console.log(config.TopggToken)
Make sure its the exact same thing filled in the authorization.
Ok for some reason its now showing this
Oh wait
I think ik what i did wrong
i accidently set it to the token
Yeah ๐
lol
mb
np ^-^
Ok for some reason its returning undefined no matter what
Log vote, see what it is
is your auth using something thats an accented or weird character?
IIRC it only accepts some characters
No
I would say it but yk
thats not a good idea
tbh, I'm unsure
could it be bc its a test?
do you want me to try a real vote?
plz
Voted
Hi, how can I make my own vote tracker? Using pycord (python).
When a user vote for my bot i want it to print in console, "{userid} has voted for example bot!", maybe using bot.event to check?
If this is possible. What do I need to import/install?
One message removed from a suspended account.
Top.gg Python library
anyone got like a full example for autopost? (discord.py)
anyone know why i get this error often :
TopGGAPIError: 429 Too Many Requests
at Api._request (/home/container/node_modules/@top-gg/sdk/dist/structs/Api.js:61:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Api.postStats (/home/container/node_modules/@top-gg/sdk/dist/structs/Api.js:86:9) {
response: {
statusCode: 429,
headers: {},
trailers: {},
opaque: null,
body: BodyReadable {
_readableState: [ReadableState],
_read: [Function: bound resume],
_events: [Object: null prototype],
_eventsCount: 3,
_maxListeners: undefined,
[Symbol(kCapture)]: false,
[Symbol(abort)]: [Function (anonymous)],
[Symbol(kConsume)]: [Object],
[Symbol(kBody)]: null,
[Symbol(kContentType)]: 'application/json',
[Symbol(kReading)]: false
},
context: undefined
}
}```
it obviously sais you exceeded a rate limit
You need post every 30 minutes
is there a way to get a webhook when someone writes a review for your bot? No, right?
No, there is no such webhook
There is also no documented endpoint in the API when it comes to reviews
Hey, whenever someone votes on my bot on Top.gg, it does not send a POST request to the webhook i provided. Am i doing something wrong?
I've tried clicking the "Send Test" button in the settings, which successfully sends a request and i process it correctly on my end. It's just when someone votes that nothing happens. Help please!
My code:
const express = require('express');
const app = express();
const port = 8000;
app.use(express.json());
app.post('/topgg-vote', async(req, res) => {
console.log('Received a vote from top.gg:', req.body);
const userID = req.body.user
// Here you can add your logic to respond to the vote, e.g., sending a message to a Discord channel
const channelId = 'CHANNEL_ID';
const channel = client.channels.cache.get(channelId);
if (channel) {
channel.send('Thank you for voting, <@' + userID + '>! ``+10,000 โ``');
}
await mongoose.connect(PSWRD, {
keepAlive: true,
});
let user = require("./schemas/user-schema.js");
let user1 = await user.findOne({_id : userID});
user1.bal += 10000
user1.timesVoted += 1
await user1.save().catch(e => console.log(e));
res.sendStatus(200); // Respond to Top.gg to acknowledge receipt of the vote
});
app.listen(port, () => {
console.log(`Server listening at URL:${port}`);
console.log('Server online!');
});
Hey!
Does the Webhook URL require SSL when we are doing post request?
Cause for the moment it looks like we are not getting any information
Even if the express server it's set
But when i'm doing with http:// i get This page isnโt working
http://<SERVER_IP>:port/dblwebhook
that should work if im not wrong
I think it also work with url, right?
yea
5xx is usually your fault if you run a webserver
im using this
https://www.npmjs.com/package/topgg-autoposter
Auto-Poster for Top.gg. Latest version: 2.0.2, last published: 3 months ago. Start using topgg-autoposter in your project by running npm i topgg-autoposter. There are 4 other projects in the npm registry using topgg-autoposter.
@unique cedar
use this
๐
import topgg
import sys
# Top.gg Stats Poster
TOPGG_TOKEN = os.getenv("TOPGG_TOKEN")
if not TOPGG_TOKEN:
print("Error: TOPGG_TOKEN not found in .env file.")
sys.exit(1)
def on_autopost_success():
print("TopGG Stats succesfully posted.")
def on_autopost_error(exception: Exception):
print("Failed to post:", exception, file=sys.stderr)
async def post_stats():
try:
wrapper = topgg.StatsWrapper(bot, TOPGG_TOKEN)
await wrapper.post_stats()
except Exception as e:
on_autopost_error(e)
else:
on_autopost_success()
def stats(client: discord.Client = topgg.data(discord.Client)):
return topgg.StatsWrapper(guild_count=len(client.guilds))
@bot.event
async def on_ready():
await post_stats()
File "c:\Users\Max\Documents\Programmieren\Discord-Bots\Aktive Bots\Vysion\main.py", line 67, in <module>
def stats(client: discord.Client = topgg.data(discord.Client)):
^^^^^^^^^^
AttributeError: module 'topgg' has no attribute 'data'
A simple API wrapper for top.gg written in Python. Contribute to Top-gg-Community/python-sdk development by creating an account on GitHub.
Hey, I have a question. Does the Send Test button in webhooks actually send any data? Maybe dummy data?
wdym?
yes, it basically send the data as if you voted it
Ok, thanks!
what
nvm
no tell me
i thought you were building roverification bot
hell no my bot does the right things
guys..whats the best verification bot out der??
API resource for a bots or apps on a platform like Discord
In post, what type of content i need to send?
form type or params or json?
or something else
?
JSON Body
Hey, is it normal that votes take a very long time to process? I've voted for my bot about 15 minutes ago, and the vote count still hasn't gone up, nor have I received a webhook about it.
Have you received test votes on your webhook?
Honestly, I'm unsure. I think I've been receiving both but it's very inconsistent, so right now I'm trying to figure out if Cloudflare is the cause.
Well, I've found out that it was indeed counting all votes, even test ones. Turns out printing the incoming webhooks was inconsistent than writing to a file.
Though, at least without the Cloudflare proxy, which I'd really like to use but unsure whether it's a good idea to rely that it will be immediately forwarding all data.
Can anybody provide any input on that? It's really necessary to hide myself from the public internet, but there's also no guarantee that Cloudflare will deliver every data immediately.
Well, I think I've found out that Cloudflare only caches GET, but POST is always immediately forwarded to origin. I didn't find a mention of it in the official Cloudflare docs, so can anyone comment on this and hopefully give me some reassurance?
Can someone explain to me how this package works?
https://www.npmjs.com/package/topgg-autoposter
Auto-Poster for Top.gg. Latest version: 2.0.2, last published: 3 months ago. Start using topgg-autoposter in your project by running npm i topgg-autoposter. There are 4 other projects in the npm registry using topgg-autoposter.
@leaden kestrel
Yeah, webhook-topgg(my webhook service) is behind cloudflares proxy.
it has no issues
Alright, thank you!
Each npm package has a link to its source code on github. How this package works is not very complicated
Alr
Why do i keep getting ratelimited?
toppy.errors.Ratelimited: Ratelimited by the internal ratelimiter - Retry after 1438.078099s
second time i saw it happend
is fetching bot info really that ratelimited or something else wrong?
on vote I fetch /bots/MYBOT, to get the stats. I dont really have many votes yet, so idk. Seems pretty weird to me
Why do you need to fetch bot info every vote? ๐
Thats not really how its intended to be used, its more of a "once a day" type of endpoint
so i should store monthly and total votes myself?
or is there another endpoint?
thats how jt currently looks
Assuming you just want to send a message with the number of votes I would fetch the endpoint when the bot starts, and every hour or day.
Then just increment the count in a variable.
i guess storing myself is the way than
It should just be 5-6 extra lines of code, super simple.
ye ik but i was being lazy about it

and I assume if i get ratelimited on that endpoint, the check endpoint is also affected?
Thats probably the main reason you're being ratelimited tbh
but that would be kinda silly how the check endpoint is heavily ratelimited
Imo, the check endpoint is rarely useful for anything but just checking if a webhook didn't get received.
If you need it for checking if people can use a command you'll get ratelimited pretty much instantly unless you have a ton of caching, even then I've seen bots still get ratelimited.
Thats a very odd design choice then. It sounds for me that the endpoint is made for that in mind but it seems not when the ratelimit is so heavy lmao.
I guess, i will also check it via db then
i still dont get it, are the docs outdated?
how come i get ratelimited when i wont send 60 req in a min
One bot has one webhook, this is true because there is only a webhook responsible for votes. By hosting several bots on one VPS, you can create several such webhooks (on different ports) or use the same webhook and check in the webhook code which bot this vote applies to
A webhook is nothing more than a web server that accepts requests. I don't completely understand what you mean by "multiple webhooks" since there is only one webhook on top.gg responsible for receiving requests when someone votes for your bot
People are voting for my bot but my webhook doesnt send any message
You can forward webhooks.
So you can have one receive and forward it to as many webhooks as you want.
What does your webhook code look like?
i use https://webhook-topgg.com/ for webhook notify
Simplifying top.gg webhooks for all users, allowing non-developers and developers to use webhooks for their bot and server without confusing configuration.
That's unrelated to this channel. Webhook-topgg is my site, and it's unofficial, if you want to DM me I can look into it when I have time.
I'm out of town for the next 12 hours or so, so it'll probably be tomorrow before I can help.
ohh i didnt know its unoffical
We will likely never support it.
Webhook forwarding is pretty normal, you can manage things like handling retries yourself for each webhook server.
I'm new to topgg, is it possible to make automatic rewards for voting?
yes
Can you give me the link to the api docs?
Webhook integration for receiving vote data
thanks
How can I make a topgg voter in python can someone help me
you can't vote bot mate
wdym with that?
You can even make a bot to auto vote on topgg. But I think it's against topgg's rules
Yo when you say "topgg voter" what are you looking to do? Like vote rewards?
nah automatic vote for a bot every 12 hours
100% against our rules. Instant ban

He probably wants to make a reward for voting
That if someone votes my bot should send a vote message in a channel but I don't know how to do it
If you want to give rewards for voting you can use the official api https://topggpy.readthedocs.io/en/stable/
Thanks
ahh
Use webhook for this https://topggpy.readthedocs.io/en/stable/webhooks.html
But how would you find out?
So
import discord
from discord.ext import commands
import topgg
from aiohttp import web
import os
class VoteListener(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.dbl_auth = os.getenv("TOPGG_TOKEN", "")
self.webserver = web.Application()
self.webserver.router.add_post("/dbl", self.handle_vote)
self.bot.loop.create_task(self.start_webserver())
async def start_webserver(self):
runner = web.AppRunner(self.webserver)
await runner.setup()
site = web.TCPSite(runner, "0.0.0.0", 5000)
await site.start()
print("Webhook server started on port 5000")
async def handle_vote(self, request):
auth = request.headers.get("Authorization", "")
if auth == self.dbl_auth:
data = await request.json()
user_id = data.get("user")
if user_id:
embed = discord.Embed(title=f"<@{user_id}> Just voted for RoSearcher!")
channel = self.bot.get_channel(1207774395268079657)
if channel:
await channel.send(embed=embed)
return web.Response(status=200, text="OK")
return web.Response(status=401, text="Authorization failed")
async def setup(bot):
await bot.add_cog(VoteListener(bot))
Configure the webhook link in https://top.gg/bot/:id/webhooks
*instant ban if we find out
aaaa So could there be bots that grew up using bots to vote?
Of course :))
haha
depends on the bot
what is the name of the bot?
botted votes are not allowed. they impact the site and are unfair to everyone else.
theres no such thing as a "legit" discord bot net
One message removed from a suspended account.
I doubt it would be a good idea to joke about this. Someone might take this seriously
i saw karuta bot, ig 1m vote
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
@scarlet cobalt
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
You Shouldn't Do This
Only if its unmodified couse it would be consider clone if it did
My bot started with bdfd and is developing with bdfd
There is no clone or copy of my bot, it is one and the same.
I hope you don't do anything to my bot, I worked hard to get it approved. @silk idol
not really by job and i dont have that much freetime to check
wth is bdfd
I'm Berk, and I upload videos about original Bot Designer For Discord / BDFD / DBD codes.
You can join my Discord server to get exclusive BDFD codes & APIs!
https://dsc.gg/codes
https://files.sky.h4ck.me/files/6d3862e0-a81c-4116-a089-69d5f8da98e7.png
How many perms do you want? Floxy: not much
i see
Adminsator is the same thing as all the rest
yea lol
bro at this point just use administrator
real
yep
One message removed from a suspended account.
FS better frfr
discord object
fetch snowflake by passing ID
huh
for example
Using rust's rocket and it needs the API body to be statically typed
know nothin bout rust
Otherwise it rejects the request
but i can show a discord.py example
guild = ctx.guild
channel_id = int(input("Enter Channel ID: "))
channel = guild.fetch_channel(channel_id))
like dis
it is a string
can you help me out, the bot doesn't post stats to the api
async def update_top_gg(self):
top_gg_token = os.getenv('TOP_GG_TOKEN')
if top_gg_token:
url = 'https://top.gg/api/bots/{bot_id}/stats'.format(bot_id=self.bot.user.id)
headers = {'Authorization': top_gg_token, 'Content-Type': 'application/json'}
payload = {
'server_count': len(self.bot.guilds),
}
await self.post_update(url, headers, payload)```
why is this not working
In what way is it not working?
It wasnโt doing anything when I sent test
Anyway I just had to send message so itโs figured out
User key not found in vote data
Did the user key been removed? if yes then whats the latest ?
how tto make it sao whyen soimeone votes iit sends thru embed in that channel
this might still be viable
import express, { Request, Response } from 'express';
const app = express();
const voteAuth = process.env.VOTE_AUTH_TOKEN || '';
app.post('/vote/topgg', (req: Request, res: Response) => {
const authHeader = req.header('Authorization');
if (authHeader !== voteAuth) {
console.log('Unauthorized vote request');
return res.status(401).end();
}
const { user } = req.body;
if (!user) {
console.log('Invalid vote request: User ID is required');
return res.status(400).json({ error: 'User ID is required' });
}
console.log(`Received vote from user: ${user} on top.gg`);
res.status(200).end();
});
then just configure the url for votes
Does someone face the same issue, topgg api send me the same information 2 times, but not always
Like someone voted now and the top.gg send me the same information 2 times
like the person voted 2 times
no
Is it possible to view analytics like count of invite button press ..etc from my bot?
https://top.gg/bot/:YOURBOTID/analytics?tab=invites
Just a heads up, that only shows someone clicking invite on Top.gg, it doesnt confirm they actually invited the bot
oh i didn't know that, thanks
Its any way to post on api the real number of all shards from my bot
Note, tell them what language you are using
Js
discord.js?
Yes
Do we have a example of a manual way to post stats like that message #topgg-api message
You will have to broadcast to all shards for their guild size then post the result of that to top.gg api as of my latest knowledge
Ok
discord.js offers an easy way to do this
https://discord.js.org/docs/packages/discord.js/14.15.3/ShardClientUtil:Class#fetchClientValues
im receiving webhooks with user set to null or missing, anyone else?
consistantly?
is the entire thing empty or just user?
{"avatar": "a_5532c6414c70765a28cf9448c117205f", "id": "189759562910400512", "username": "brain"}
this is what i received, but the docs say:
https://docs.top.gg/docs/Resources/webhooks#bot-webhooks
it should be user
Webhook integration for receiving vote data
wtf avatar? ๐
yeah ikr
did veld change things? ๐
idk
let me just check im not routing the wrong lists webhook to the wrong route
hmmm
i know what the problem is, i think, brb
yeah, another list is delivering its webhook to my top.gg endpoint, my page edit didnt save there when told to :/
// Auto poster for top.gg
AutoPoster(topggApiKey, client)
.on("posted", () => {
console.log("Posted stats to top.gg!");
})
.on("vote", (vote) => {
console.log(${vote.user} just voted!);
handleVoteReward(vote, client); // Call the function from votereward.js
});
could you help me fixing the issue when someone vote it seem the code does nothing
Where did you get that code? ๐
I'm guessing AI
The autoposter has nothing to do with voting events.
https://www.npmjs.com/package/topgg-autoposter
Auto-Poster for Top.gg. Latest version: 2.0.2, last published: 4 months ago. Start using topgg-autoposter in your project by running npm i topgg-autoposter. There are 4 other projects in the npm registry using topgg-autoposter.
You might be looking for: https://topgg.js.org/#md:webhook-server
Documentation for @top-gg/sdk
yep ai
hey Woo really want to know to know when someone has voted the bot
Did you look at this?
discord node.js ?
Hi, can someone please help me with the py-sdk?
I have the webhook manager in a cog and I start the webhook in the cog_load function with .run(port_number).
Then I run await webhookmanager.stop() in the cog_unload function. But, the problem seems to be that the session does not get closed properly because I get an error saying that the address and port is in use.
I even tried to access the webserver property and call shutdown() but that still does not solve the problem. It means I have to restart my whole bot in order to unbind from the port but it seems reasonable to expect the .close() function to do it which does not work. It runs but it does not unbind to the port. Any help would be greatly appreciated.
Hi. Sorry for pinging. Would you be able to help me with this ^? It seems like you would based on your previous messages.
๐ dumb question, but what is a cog?
Not a py dev, so I dont know, but why would you be stopping it?
A cog is like a modular section of your code. So, you can edit your code and reload the cog without having to restart the whole bot.
It looks like the method you want to use is close
https://topggpy.readthedocs.io/en/stable/webhooks.html#topgg.WebhookManager.close
I know.
I am using it.
But, when reload my cog, the webhook manager gets restarted.
That throws an error because when I ran webhook.close() it did not properly unbind the session from the port.
class Voting(commands.Cog):
def __init__(self, bot):
self.topgg_webhook = WebhookManager(bot).dbl_webhook(auth_key=TOPGG_AUTH_KEY)
self.topgg_dbl_client = DBLClient(bot, TOPGG_CLIENT_TOKEN)
# bot.topgg_webhook.webserver.router.add_post(path="/dbl", handler=self.on_dbl_vote)
# bot.topgg_webhook.
self.bot = bot
def cog_load(self):
self.topgg_webhook.run(5000)
async def cog_unload(self):
await self.topgg_webhook.close()
await self.topgg_webhook.webserver.shutdown()
print("webserver shutdown")```
So, the webhook has been closed, then when the cog loads again, it throws an error saying the ip:port is in use. Does that make more sense?
It just seems like the close method is not properly shutting down the session. even if I access the webserver and call shutdown(seems overkill) it still does not work. So, instead of just reloading this individual cog, I have to restart my whole bot in order to unbind the ip:port.
It just runs the stop method https://topggpy.readthedocs.io/en/stable/_modules/topgg/webhook.html#WebhookManager.close
๐ I'm not sure what part of that method would cause the issue.
So, you know when you call run you specify a port?
That makes the webserver bind to that port.
I want stop() to unbind from the port. That is what I'd expect it to do but that does not happen.
Because, when I do run() again, after calling close(), it says the port is still bound to.
Cogs are awesome, btw. It's a pity I could not find them in the js sdks for discord. I even considered making my own cogs lib. They are that cool.
I dont know how aiohttp works, but it sounds like it doesn't work the way you want it to for whatever reason.
I would expect it to release the port when its stop method is called.
Exactly, that is why I am here. I don't normally ask for help
.
Okay, thanks for your help. I'll just leave it bound for now and I'll just restart my whole bot if it becomes thaty necessary.
If you track down why aiohttp isnt releasing the port you should make a pull request. Thats definatly something we would want fixed
Yeah, I do suspect that it might be an issue with the SDK. I'll go check out the source code for a bit. I'll make an issue or PR if I do find a problem.
There is an __app property in the webhook manager and it does not get stopped in the close() method. Only the _webserver gets stopped. I am not sure if the __app prop is supposed to get stopped but it does seem like a possibility.
That might be the issue, I'll dig a little deeper.
Here, https://docs.aiohttp.org/en/stable/web_reference.html#aiohttp.web.Application.shutdown.
The Application object has a shutdown method but it does not get called in the WebhookManager.close() method.
Sorry to ask this but is there someone I can speak to about this? Perhaps someone that maintains the py sdk?
You can just make a PR request on our github or @untold sparrow can redirect you to whoever is our py dev(i forget :D)
Yes, please. Because, I'd rather get some feedback instead of make a fool out of myself in case I am just making a stupid mistake somewhere.

in the meantime https://topggpy.readthedocs.io/en/stable/webhooks.html?highlight=webserver#topgg.WebhookManager.webserver
You can access the web.application.shutdown method yourself.
Should be enough to get it working until close() is properly working
Cc @woven coral above 
Yeah, I had to reset my bot and it seems to work properly now. So, I probably ended up getting a runaway session that stayed bound to the port when I reloaded the cog. So, the webhook manager got deleted but the webserver from the previous one was still active. Sorry for the trouble and thanks a ton for your help.
On your bots edit page click "webhooks"
Thanks
// app.js
document.addEventListener("DOMContentLoaded", () => {
const BOT_ID = "BOT_ID"; // Reemplaza con el ID de tu bot
const API_KEY = "TU_API_KEY_AQUI"; // Reemplaza con tu API Key de top.gg
// Verificaciรณn inicial
console.log("Iniciando la solicitud de estadรญsticas del bot...");
// Fetch bot stats (server count)
fetch(`https://top.gg/api/bots/${BOT_ID}/stats`, {
headers: {
Authorization: API_KEY
}
})
.then(response => {
console.log("Bot stats response status:", response.status);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => {
console.log("Bot stats data:", data);
document.getElementById("server-count").textContent = data.server_count || "Not Found";
})
.catch(error => console.error("Error fetching bot stats:", error));
// Fetch bot votes
fetch(`https://top.gg/api/bots/${BOT_ID}`, {
headers: {
Authorization: API_KEY
}
})
.then(response => {
console.log("Bot votes response status:", response.status);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => {
console.log("Bot votes data:", data);
document.getElementById("vote-count").textContent = data.points || "Not Found";
})
.catch(error => console.error("Error fetching bot votes:", error));
});```
Are you looking for the servers correctly?
Because only the votes appear but the servers tell me the variable that I have configured Not Found
@rough crater
my PR cant even get accepted and now you're asking me for this ๐ญ
soo from my understanding, https://github.com/null8626/python-sdk/commit/f80bd29fb4bc6430d3cddb0e2497f4e0a17112ed
One question, for the votes can I get the name of the last person who voted for the bot? and can I get the last server anyway?
And how are reviews handled in the API?
@signal hawk
No need to ping a CM
You can fetch the last 1k https://docs.top.gg/docs/API/bot#last-1000-votes
API resource for a bots or apps on a platform like Discord
Iโm not sure if this is in order though - Iโd recommend using a vote webhook and storing the votes in your own database and fetching when needed
Bro you be the lead on the python lib
You referring to the cpp PR?
both
@signal hawk
One message removed from a suspended account.
One message removed from a suspended account.
Small bots not showing servers and shards?
The rest if it gives me data
Or are the servers it shows inviting the bot from top.gg?
@jaunty plank
Bot owners have to post their server/shard count
they dont have to, so it can be 0
or just not exist
How do I publish them on the web?
you're trying to show your server/shard counts?
API resource for a bots or apps on a platform like Discord
Yes
This is the docs for posting stats
But he doesn't find anything.
The problem is that it does not show the bot servers in top.gg
topgg gives me cloudflare "you have been blocked" response when posting stats.
Should I appeal this or am i doing something wrong
URL: https://top.gg/api/bots/BOT_ID/stats
Method: POST
Payload:
{
"server_count": 3730,
"shard_list": [0, 1, 2, 3]
}```
Yes im providing a token and yes its valid
You are rate limited by cloudflare
how, when i make no requests
this is the first request i made since idk how many months
Do you fetch votes from the api by any chance
Hey
Hllo
its me
auth or token?
The auth is something you make
The token is on your bots edit page in the webhook section
im following the top.gg api
whichever auth it asks for
The api requires a token, its on your bots edit page in the webhook section
async with aiohttp.ClientSession() as session:
headers = {
"Authorization": token}
data = {
'server_count': server_count,
'shard_count': shard_count
}
async with session.post(f'https://top.gg/api/bots/:botid:/stats',
headers=headers,data=data) as resp:
content = await resp.json()
print(content)
This is our request, but it returns: {'message': 'Invalid input'}
It was on purpose,details are hidden.
We are aware of that.Is the request good besides that?
no need to be sassy
you would be surprised the number of people who make that mistake
Also, assuming server_count and shard_count are both numbers then yes it looks correct
Ok,sorry for that.
I believe you.
Do you know maybe why are we getting {'message': 'Invalid input'} with the above request?
Is there any part of the request that looks suspicious to you,which is the reason for the 'Invalid input' message?
you're missing the content type header
Do json=data instead of data=data if you want to send dict/JSON data.
Alternatively, what Woo said. Add 'Content-Type': 'application/json' to your headers.
can someone give me an example of the vote data that is sent to the url?
this webhook i mean
{
"bot": "",
"user": "",
"type": "vote",
"isWeekend": "false",
"query": "test=true"
}```
is this the correct data that is sent to the webhook url?
and im assuming, remove query if it's not a test?
query is the query string on the url when they vote.
ohh




