#topgg-api
1 messages · Page 173 of 1
is that normal to receive GET query instead of POST query when a user vote using webhook ?
i've made some tests and your system reach my endpoint using GET instead of POST, but on the website it's clearly mentioned it should be POST 🤔
We will attempt to perform a POST request to this URL when sending you webhook data.
here's two entries logs
2021-11-09T17:35:18.165042+00:00 heroku[router]: at=info method=GET path="/" host=.......wumpus.bot request_id=e5f2ba9c-3cf0-45aa-b2d7-d9e036f7677f fwd="ips" dyno=web.1 connect=0ms service=5ms status=404 bytes=383 protocol=http
2021-11-09T17:35:24.045957+00:00 heroku[router]: at=info method=GET path="/" host=.......wumpus.bot request_id=46db4d48-5dbe-4d89-9763-29c9de94efbd fwd="ips" dyno=web.1 connect=0ms service=2ms status=404 bytes=383 protocol=http
Only your website know my endpoint, then I don't really understand what's going on 🤔
Is it coming from topgg's servers?
https://docs.top.gg/resources/webhooks/#security
A short list of what would cause get requests:
- a crawler going through your domains
- you opening the link in your browser
- you sending it through discord (embedding fetches the link, refer to crawler above)
- a user accidentally visiting your voting endpoint
Top.gg does not make get requests, the only requests it makes are POST ones, so compare the ips the request came from
Howdy, my Bot is currently experiencing a "401" error when trying to use the top.gg api
Make sure to send the authorization within the header
You can find an example in the docs
Does anyone know why when i make a request to top.gg's API it gives me an error with "Authorization is an illegal HTTP header"?
probably looking for authorization not authorizations
Sorry i don't know where that s came from 
You got an error log and code snipped to be able figure it out?
haiii is there a way to get a bots info (not my bot) on https://github.com/top-gg/Java-SDK ?
DiscordBotListAPI#getBot(String id)
is your bet
An API wrapper for https://discordbots.org/api/docs that works in Java - java-sdk/DiscordBotListAPI.java at master · top-gg/java-sdk
Can I get the number of votes my bot has?
who pinged me ?
hi, how can i do to have my discordbotlist token ?
You can only generate a token if you got an approved bot on topgg
- You need an approved bot
- Look at pins
There's a reason to not receive the user tag along the user ID from the webhook query ?
sounds weird to me but ok, i'll fetch your API 😅
Hey. I wanna use the Topggpy Library but I need a dblwebhook and password...where can I get this?
leave it as dblwebhook
password is just something you set
and then make sure you have the same password set on the webhook authantication field
ah. But i tryed to upvote the Bot with this code but he print no notification for me
What are you intending to do on vote?
where can I find this?
Give vote rewards or just see who voted?
you set the password yourself
yeah
okay
the on the /webhooks page on top.gg, enter http://IPADDRESS/dblwebhook
replace ipaddress with the ip addrss of the place you want to host the bot
i dont understand...
ah i have to set the Ip adress where I host my bot?
into this link?
where are you hosting
Replit, Heroku, VPS, PC etc
vps
ah shit hahaha
that is pterodactyl
yeah sry
@rain heart the dashboard display an empty token field
Clear cache then try again
I'm trying to generate it but the XHR query always encounter an internal server error
it changes nothing
Oh known issue then
there's a way to generate it from your side and then DM me the token ?
If it doesn't work on your end, it will likely not work on my end either
I finally got it, it took so much time 😅
it doesnt work
can somebody help me
?
@tidal idol sry for ping but it seems like you know this api
@jaunty plank can help better
ok
where are you hosting your bot
There @forest trench
Why my bot's server count is zero
it is in 69 servers
from where can I get the code for that
Ok Thank You
click the link on channel topic
how can i setup a webhook?
^
?
how can i setup a webhook
im complete new
https://docs.top.gg/ will help you
it didnt
it told me to setup a webhook
i dont know how to
I dont understnad it
what is your bot id @restive otter
this
903596039917940758
though im not sure if topgg uses the client id
or diff id
But how can my bot recieve the data?
by using topgg-sdk
what programming language do you use?
node js
im not sure i understand that. ill try and inform if i have any issue
thanks
Can we check if an user has voted a server?
I was looking for server votes instead
i didnt see channel name ;d
Is there any way I can use top.gg api to show ServerCount and UserCount in my own website?
Makes more sense to just send it from your bot to your site
Any way how
make a public webserver on your bot to fetch bot stats
use js on your website to make a request to that and return the data it gets
embed it into your website
no spoonfeeding happening
K
Yes
Idk if this is the right way to post this suggestion but heres my suggestion:
Add an endpoint for editing a bots description
Motivation:
- some people have autogenerated documentation for their bots that they may want to update automatically from a CI/CD pipeline
- if the bot is open-source and has a github/gitlab/gitea repo, the repos readme on said git platform can be in synced to top.gg
Ehhh this just sounds like abuse waiting to happen, but yeah sure feel free to add a suggestion for that on https://github.com/top-gg/issues
good point I've added it as remark

Yes, that is against the api guidelines
what is the rate limit for updating bot guild and member count
What is the API to look at the number of servers in which the bot was added from TOP.GG
wont it be easier to just save your bots server/user count in a database, you can run it in a loop and keep updating the counts every few minutes
and inside of your website you can just fetch the information from the database
would be simpler and faster then using top.gg api
A separately-excited d.c. motor is rated at 8 kW, 230 V, 1200 rpm is supplied with power from a 6-pulse three-phase fully-controlled bridge rectifier. The armature circuit resistance is 0.50 Ω and the machine constant is 1.5 V.s/rad. The motor is assumed to operate in continuous current mode, calculate for firing angles of α = 0 ̊ and α = 30 ̊, (a) the motor speed in rpm, (b) the power factor, and (c) the efficiency of the system. Neglect any losses in the converter circuit and assume that the load torque remains constant for each case.

Neglect any losses
You're about to be neglected
😔
at IncomingMessage.<anonymous> (/home/runner/Clash-Chest/node_modules/dblapi.js/src/index.js:118:25)
at IncomingMessage.emit (events.js:326:22)
at IncomingMessage.EventEmitter.emit (domain.js:483:12)
at endReadableNT (_stream_readable.js:1241:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:277) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
``` why??
its only with dblapi.js
and, this is top.gg topic, right?
ok, thanks for letting me know
Guys! is it possible to have vote command ?
Eg: .vote should direct vote on the top.gg page
🥲
I was hoping to have a command for that - would make life easier
Abuse ? How so ?
Hmmm! That's a valid point
help?
I dont think dblapi.js still works
Try using https://www.npmjs.com/package/@top-gg/sdk
It's going to be the url to your webhook listener you make in code.
The exact format depends on your hosting service
?
sorry but i didn't understand properly
I host it in replit
Your webhook url will be
Your replit url with the path you set in code
You define that in code
ok
worked
thx
but how can i send a message to dms?
vote.user.send doesn't work
ok
app.post('/vote', webhook.listener(vote => {
(async() => {
if(await vote.isWeekend()) {
console.log("is weekend")
} else {
console.log("it is not weekend")
}
})();
}))
it throw vote.isWeekend is not a function
That is still a function you're using
Not a variable
isWeekend is a variable on the vote object
still dont get how to do it
i dont understand where should I add .isWeekend()
i have already understood that
but how can I check if is weekend or not?
I again note towards your vote object having variables, one being user in the docs as an example
Perhaps that might be the same thing for isWeekend???
so vote.isWeekend ?
Try it
ok it now works
but it only shows "it is not weekend"
even tho is weekend
@rain heart do u know why?
Can't help otherwise
Test votes might display something different
Try an actual vote
how to get the voter's tag?
not the id
fetch it using your bot library
Nope
You can only use the top.gg bot
Mr @jaunty plank can confirm
yeah, only @wild lantern
Yep thought so
Hey is this abandoned https://github.com/top-gg/go-sdk ?
hasnt been updated in over a year and it seems to be very poorly documented for go
not abandoned, just nobody willing to maintain it
C:\Users\yigit\OneDrive\Masaüstü\Oyun\Botlar\Elzem destek\Deneme\node_modules\dblapi.js\src\index.js:118
const err = new Error(`${res.statusCode} ${res.statusMessage}`);
^
Error: 401 Unauthorized
at IncomingMessage.<anonymous> (C:\Users\yigit\OneDrive\Masaüstü\Oyun\Botlar\Elzem destek\Deneme\node_modules\dblapi.js\src\index.js:118:25)
at IncomingMessage.emit (node:events:406:35)
at endReadableNT (node:internal/streams/readable:1331:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
I get this error,
have you provided your api token
yes
dblapi.js is outdated, try using https://www.npmjs.com/package/@top-gg/sdk instead
can you give an example command
You can read the docs at https://topgg.js.org
const topgg = require("@top-gg/sdk");
const topggClient = new topgg.Api("TOPGG_TOKEN_HERE");
await topggClient.postStats({ serverCount: /*Server Count Here*/ });
okey
dblapi
This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.
If you need help with development about your bot or development in general, feel free to use #development.
For API for server votes, what is the checkId?
is it py (f'https://top.gg/api/servers/{serverid}/check?userId={userid}', headers={'Authorization' : os.getenv('TOPGGTOKEN')})
Servers does not have an api
@rain heart why I can't use a numerical ip
http://
Add it before your ip
Not https....it is http
Np
Get what?
I mean I have a voting system
In which my bot if recives vote it does stuff with user
And dms the x user
But it didn't work
@jagged nimbus
I tried top.gg api buy got an error of 34 lines so now I don't use it 😂
🥲
let votes = await axios.get("https://top.gg/api/bots/" + client.user.id + "/votes", { headers: { 'Authorization': config.topgg.token } });
cannot read property of Id undefined
@jagged nimbus
Hmm
I really don't have any clue on it
I haven't touched any part of top.gg api
But I think someone else has
@rain heart can you help him
hello there im using this webhook example
import topgg
# This example uses topggpy's webhook system.
# The port must be a number between 1024 and 49151.
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password")
bot.topgg_webhook.run(5000) # this method can be awaited as well
@bot.event
async def on_dbl_vote(data):
"""An event that is called whenever someone votes for the bot on Top.gg."""
if data["type"] == "test":
# this is roughly equivalent to
# return await on_dbl_test(data) in this case
return bot.dispatch('dbl_test', data)
print(f"Received a vote:\n{data}")
@bot.event
async def on_dbl_test(data):
"""An event that is called whenever someone tests the webhook system for your bot on Top.gg."""
print(f"Received a test vote:\n{data}")
I've put my webhook url instead of /dblwebhook and webhook auth in pass it isnt working any help?
it isnt sending any msg in logs
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("webhook_url", "webhook_auth")
client.topgg_webhook.run(5000) # this method can be awaited as well
@client.event
async def on_dbl_vote(data):
"""An event that is called whenever someone votes for the bot on Top.gg."""
if data["type"] == "test":
# this is roughly equivalent to
# return await on_dbl_test(data) in this case
return client.dispatch('dbl_test', data)
chan = client.get_channel(890317446605582386)
await chan.send(f"Received a vote:\n{data}")
@client.event
async def on_dbl_test(data):
"""An event that is called whenever someone tests the webhook system for your bot on Top.gg."""
chan = client.get_channel(890317446605582386)
await chan.send(f"Received a test vote:\n{data}")```
this is what im doing
Help
Do you plan on using webhooks or the api, the webhook is recommended
webhook
this is a good example
np
none
it's bare express and such
oh
there is
uh
also just realised its using an old version of the lib

its not using the latest top.gg node sdk
server pfp*
thanks
npnp
@dapper copper heya can you help me
with this
Set a token
already
Is that token valid? Try regenerating
did you figure it out?
h
Try
require("dotenv").config();
Ok
I've been looking in the documentation admittedly, not very hard but similar to how you can vote on a bot and you get rewards from that bot, can you vote on a server and the bot gives you rewards for it?
you will have to use webhooks on the servers end, top.gg/servers does not have an api
only webhook support

Chrome user 😔
What is the difference between monthlyPoints and points ?
One is monthly, the other is total
They're votes
I'll let you figure out which is which
How to check if an user upvoted any listed server
ummmmmmm hi
So i use the topgg webhook manager (i want to detect votes)
What do i put in here?
here is the code:
bot.topggwebhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook","pass")
bot.topggwebhook.run(5000)
@bot.event
async def on_dbl_vote(data):
"""An event that is called whenever someone votes for the bot on Top.gg."""
print(f"Received a vote:\n{data}") ```
Where are you hosting it on? Generally http://HOST_IP:5000/dblwebhook as the URL and pass as the auth should do
okk
how i add vote log?
whats the plan
add vote rewards?
see who votes?
Vote Logs/Rewards
If you want to add vote rewards:
Visit https://docs.top.gg and find the needed library, or just the documentation on webhooks if your library isn't there.
If you just want to see WHO votes:
Visit https://webhook-topgg.com and follow the instructions to setup vote webooks!
brave is faster
Heyy
how do i add a user to my bot like here
You can't post the number of users on top.gg
Only the servers
Nah it should also support sharding stats
nope, its the auth to the webhook you made in code.
how to get it?
this?
yep
thanks
in which events am I supposed to put this? 'cuz I want to DM the user and I have to use the client inside an event
can I use my discord client inside this? or will it be undefined?
sure, depends on you to do that though
this will works?
cannot try, already voted for my bot
use the test button on the page you added the auth on
ah yeah
and here I have to put a webhook URL (provided by Discord) ?
nope, thats the webhook url to your webhook listener(the one in the code in this screenshot)
"/dblwebhook" ?
thats just the path, the whole url will be something like http://yourip:80/dblwebhook
and how do you get URL?
itll be something like http://yourip:80/dblwebhook
it depends on your hosting method and whatnot
You are the one who has to make it.
It's not something you can just get, the code cannot tell you it, nor can I.
The answer depends on your hosting.
I just have to replace yourip by my host IP?
yeah, or if its hosted somewhere without a public ip youll need to use your project url + path
If its a Discord bot hosting company using Pterodactyl then remember to include the port number
I'll try, thanks for explication
it doesn't works, it log nothing and don't DM me
uh, does /dbltoken need to be the URL that I put in Top.gg? ._.
you mean /dblwebhook
yeah
@rain heart ^
your or the other one?
well :80 is unnecessary
as http is port 80 by default so if your webserver is 80, you wont need to provide that on the url
ok but which URL I have to use so? your or the other one?
They're no different
can i use connect.sid to use the api from the bot or it's not allowed?
hey ive getting an error and help
Hi
ok... so I entered the url in the field so what I have to do.. for getting who voted? using python
this doesn't work (I didn't receive a DM from my bot
ok ty
Try console logging rather than dming for now while you get the webhook setup
it doesn't log anything ._.
What are you using to host? Vps?
yes
Do you have any firewalls blocking port 80?
don't think so
how can I check?
What operating system is your vps?
Hébergement de serveurs VPS avec des performances maximales à bas prix situé en France. Stockage NVMe & SSD dernière génération, Anti-DDOS et Assistance de proximité 7j/7.
GP-2
all informations about my VPS
any idea?
Doesn't really lower the possible number of operating systems
so, where's the issue? ._.
Well, firewalls depend on your operating system, not sure what OS your vps is using so I can't help you check if your firewall is blocking it.
Debian 11
Iirc debian uses iptables by default
"iptables -L"
so, where's the issue? ._.
Does it return anything blocking ports?
So it's not the firewall. Try using a diffrent port like 3000 just incase
You'll need to update the url on topgg and your code
http://VPS-IP:3000/dblwebhook ?
Yep
and app.listen(3000) ?
Yep
still nothing
I'd suggest adding this to your code
app.get('/test', (req, res) => res.send('Hello World!'));
then visit http://VPS-IP:3000/test in your browser then.
I have to replace /test to something or not?
its just a test, if you want it to be something other then test thats fine, but /test should work no problem
I'll try
Cannot GET /dblwebhook
http://VPS-IP:3000/test not http://VPS-IP:3000/dblwebhook
ah shit
yes there is Hello World!
do you have any non unicode characters in your authorization?
such as ü or anything like that?
but it's normal that he display Cannot GET /dblwebhook no?
nope
yeah /dblwebhook is a post, it cannot be used in a browser
are you sure your auth(on topgg) and auth you put in code is exactly the same?
yep
I'd suggest trying to simulate the request topgg is sending with postman or something else tbh
You can't access it on your browser, that's called a get request
A post request sends data
ok but the main issue?
What host
GP-2
no firewall issues(we added a get request and it functioned)
Kernel: Linux
OS: Debian 11
And what exactly does not work
^
Use reqbin and try making a request yourself
Otherwise give me the URL and I'll try it myself
auth too?
Yeah just change it to something different
@hushed path whats your current up to date code handling the webhooks
should I send it in a codeblock?
nah thats fine
can i get the number of votes with a command ? js
https://docs.top.gg/api/bot/#find-one-bot
will return a bot structure: https://docs.top.gg/api/bot/#bot-structure
which contains the total number of votes the bot has
any idea about the issue?
const url = https://top.gg/api/bots/617806421551087699/stats; // api endpoint
fetch(url, { method: "GET", headers: { Authorization: config.auth }})
.then((res) => res.text())
.then((json) => {
console.log(json)
votes = JSON.parse(json).points;
console.log(votes + " votes")
})
json = {"shards":[]}
From the docs, I can see there is isWeekend field, but it doesn't appear in my webbook ?

How to keep vote logs
how do i authorize myself for accessing topgg api? (python)
edit: getting the thing in chrome returns the expected results but using it in python code returns {'error': 'Unauthorized'}
nvm
update?
Start the webhook
like this?
will it works if I start it on my PC? and not on my host?
It has to be on your host
because otherwise it cannot be accessed from an external ip
done
the one that I sent in DM
just /dblwebhook instead of config.DBLWebhook ?
app.post('/dblwebhook', etc
?
done
Yup works now
set that as your webhook url and the auth etc
then try testing/an actual vote
like that?
no
change it back to /dblwebhook
your config.DBLWebhook seems either invalid or malformed
what does that config section look like
so I directly pass the URL and not export it from the config?
what does that section on your config look like
sent in DM
Yeah thats not what that parameter is for
it is the path, the path after http://yourip:port/THISHEREISTHEPATH
so entirely change it to /dblwebhook
{
"DBLWebhook": "/dblwebhook"
}
?
yes
so this doesn't change @rain heart?
@still niche
This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.
If you need help with development about your bot or development in general, feel free to use #development.
now it doesn't change yeah
I change this to "/dblwebhook" too?
3000 to 80
no
just remove :3000
http:// is port 80 by default
unless your server actually has a webserver running already
then you need to use 3000
if I put app.listen(3000); I have to put 3000 in the URL?
what will change if I put 3000 or 80?
nothing, just literally changes the port
you know if
someone votes for my bot
then claims their reward
they're able to claim the award like 12 hours straight
how do i like
prevent this
Youll need to track if someone has claimed their reward in your database
if they have, dont give it again.
i reset the database every 12 hours right
no, the way I would personally do it is save the time they claimed the reward in a database, then only if its been 12 hours from the saved time then give the reward
or even better give the reward on the webhook event
webhook event?
https://docs.top.gg/resources/webhooks/
when someone votes for your bot the webhook is sent to you, and you can give the event then
yeah but i don't have a url to be sent to..? i'm running my bot locally
then the above method is what I would personally do
this one
ok
Can I have this express pls
Hey, is there a way to "shutdown" a webhook listener that received a POST request with an invalid Authorization header? I'm using the official JavaScript library
so you want to disable the webhook whenever a bad request is sent? just for that single request? or for all requests going forward? or just for a period of time?
For all requests going forward for that specific webhook listener, until a guild owner re-configures the authorization code through a command (this part I can handle)
Just not sure how do I disable the webhook listener
so, you are making a webhook listener for every guild?
probably better to make one, and just disable it via an ID.
kind of a #development question anyway.
Mhm I've just realized this might be a bad idea
So if someone were to maliciously send a request with an invalid authorization header it would disable the webhook even though the actual authorization value hasn't changed and is correct
hey is it possible that when someone vote the bot it give him voter role automatically and after 24 it removes it till the time he votes back
hmm
What did you set on top.gg
0.0.0.0 is incorrect
0.0.0.0 means "being able to connect from anywhere
You need to portforward port 3000 and then use your public ip
Hey I wanna embed my bot's information embed like servers,votes etc, but its showing rate limited
then you didn't properly made sure you're following our ratelimit guidelines
feel free to read over https://docs.top.gg/resources/ratelimits/
I've never worked with API and I'm honestly a little lost but I'd love for a server count to show on my bots page, I've had a look at the API documentation but I'm not sure how to implement it into my code (js btw). Would anyone be able to assist or guide me in the right direction of how I should use the server_count field?
https://docs.top.gg/libraries/javascript/#posting-bot-stats
has a copy paste example for js
Thank you so much <33
Only approved bots get an api key, but it can be found on an approved bots edit page in the webhook section
Did you provide a topgg token?
If so try regenerating it and using the new one
Weird bug that's recently been happening
already tried it
okey wait
Are you using a topgg library? Or doing it yourself?
i did it 3 times and it works now
Op
Okay ^_^
Normally it's just once and it fixes, I'll keep this in mind for others
OSError: [Errno 10048] error while attempting to bind on address ('0.0.0.0', 2911): only one usage of each socket address (protocol/network address/port) is normally permitted```
getting this error ... while using webhook thing for getting voting events
You've had something else running on port 2911, use another port
how to check which port I can use hmm
literally put any port
ty
I am confused so please tell me.... that we have to create a webhook and then put it's url in this field right? or something else
probably good to look into this
ty
topggpy has an autopost feature that can automatically post your bot's server count at a certain interval
Refer to https://topggpy.readthedocs.io/en/latest/api/autopost.html for further details
ohh Thank you buddy
Replace mybotid in the URL with your bot's ID
Yes i did
Return home and make sure you are logged in with the right account
Ok
Forgor to tell you that I switch the v1 to /stable, so /latest is the pre-release or were you aware of that already? Cuz I don't think the old docs had /api/autopost.html
@full temple so yeah if you go by that docs, make sure to install topggpy with pip install topggpy -U --pre or its equivalent
Oh right 
whats the problem?
You’re using an outdated library
Check the docs to get the latest library which interact with the topgg API
As the one you have doesn’t work anymore
.
How to code a discord bot?
This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.
If you need help with development about your bot or development in general, feel free to use #development.
What happened to the 'isWeekend' parameter
does double votes on weekends not count anymore?
it does, however isWeekend wont show in test votes.
Oh
I have some issue installing topggpy (from git)
As topggpy new implementation (supporting for discord.py and other forks etc). They required aiohttp 3.8.0 or above to work. Forks & discord.py requires aiohttp 3.6.0 or above and below 3.8.0 to work. PIP stuck in installing aiohttp requirements.
i tried forking it and edit the requirements
it says that Cannot import "Handler" from "aiohttp.typedefs"
ping me when someone replies thx
@restive otter 
Oop, actually that import should be TYPE_CHECKING guarded, will take a look when I got home
ok?
@iron viper mind trying git+https://github.com/top-gg/python-sdk@3042f40a9fea4f3d0065d4ab8a00492cfc7e716e#egg=topggpy?
In the meantime, I need to test if it's compatible with all the versions specified
ok later
Hello there,
I wanna ask that what does topgg-autoposter & topgg-api do?
(assume that I've a zero knowledge of it)
Former is official the latter isn't
What is included in that info? only servercount or something else like usercount?
oki thanks!
one more thing I wanna ask is that .. Can I get message in a specific channel(inside support server) if someone voted or reviewed my bot?
Look at this ...
How?
with topgg-api or autoposter?
oki
is that the thing I'm looking for right?
oki thanks!
yes is compatible now
well but it seems like is no longer receiving?
@topgg.endpoint("/dbl", topgg.WebhookType.BOT, 'lwkz1234')
def dbl_vote(self, data: topgg.types.BotVoteData, client: discord.Client=topgg.data(discord.Client)):
if data["type"] == 'test':
self.bot.dispatch("dbl_test", data)
return
self.dispatch("dbl_vote", data)``` code btw
Soz just woke up, how did you register the endpoint?
in a subclass of commands.AutoShardedBot
hello, random q, is it possible to do bot.top.gg run at the same time as bot.run()?
Can you show me the code doe?
Btw, since you got access to the bot already, you don't really need topgg.data, it's there for those of you who like functional approach
Kinda irrelevant to it not being called but are you sure AutoShardedBot have bot attribute?
using the topggpy when I do py dbl = topgg.DBLClient(bot, os.environ["DBL_TOKEN"])
I get an error saying
Traceback (most recent call last):
File "/home/shahriyardx/Projects/customcommands/venv/lib/python3.8/site-packages/nextcord/client.py", line 351, in _run_event
await coro(*args, **kwargs)
File "bot.py", line 144, in on_ready
self.load_extension(cog)
File "/home/shahriyardx/Projects/customcommands/venv/lib/python3.8/site-packages/nextcord/ext/commands/bot.py", line 733, in load_extension
self._load_from_module_spec(spec, name)
File "/home/shahriyardx/Projects/customcommands/venv/lib/python3.8/site-packages/nextcord/ext/commands/bot.py", line 678, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
nextcord.ext.commands.errors.ExtensionFailed: Extension 'cogs.admin.topgg' raised an error: TypeError: __init__() takes 2 positional arguments but 3 were given
@restive otter
bot.topggpy = topgg.DBLClient(bot, dbl_token)
what are you trying to use it for
uh wdym. py class Bot(commands.AutoShardedBot): def __init__(self): # some variables
also might be a compatability issues as you are using Nextcord
i'm presuming so
@sullen nymph @restive otter can you confirm?
i'm guessing thats the issue as it says supporting discord.py on the readme, not nextcord
all forks of discord.py has the same requirements
Are you using the pre-release?
nextcord doesn't work with all discord.py features
@restive otter so how can i fix my issue... basically the webhook doesn't work....
for example, from discord import Webhook works but from nextcord import Webhook doesn't
No, I mean, you're calling self.bot, if self were an instance of AutoShardedBot, you might run into errors
oh right..
I was asking how you register the endpoint, you defined the endpoint but I don't see you register it
self.webhook_menager = topgg.WebhookManager().set_data(self).endpoint(self.dbl_vote)
self.loop.run_until_complete(self.webhook_menager.start(10000))```
menager?
doesn't matter as it is a variable name lol
V1 doesn't yeah. Just to let people know too, there's a pre-release which should work on any Discord API wrapper which can be installed with pip install topggpy -U --pre or its equivalent and the docs of which can be found at https://topggpy.rtfd.io/en/latest
Gtg btw, I'll be back in a few hours
ok?
Few things you can try doe:
- make the callback static method, perhaps what you register is the unbounded one, i.e., doesn't have self injected. But that should've thrown an error
- Build the endpoint with WebhookManager.endpoint() instead of topgg.endpoint() and finally call add_to_manager()
ok
@jaunty plank this is the issue i mentioned a while back - the bot just full on stops posting entirely every few days
stopped yesteday morning
First try just restarting the bot. If that works it might be a lib issue?
If that doesn't work try getting your auth again and restarting
That usually works
its just the fact that it also likes to crash my bot every few times
The autoposter lib?
yeah
it seems to be every 3-4 days unless i have restarted the bot to fix an issue etc
Add a try / catch
Actually
no
that should be built into the lib

If in doubt
just make your own autoposter
not hard
just make a POST request every 5-10 minutes
It gives me an unauthorised and server error most times
I can just do a tasks loop
async function postStats() {
return axios.post('https://top.gg/api/bot/id/stats', json, headers).catch(_ => { //Handle error
})
}
setInterval(postStats, 600000)
then just
handle the errors
I use Python
uh so for
python on_dbl_vote
when i placed that event in my main.py file
suddenly "bot" doesn't work anymore.
i had a look and it was Too many redirects
ow sorry
Can someone ban this bot?
Yeah
Hi, is there a way to get previous stats of a bot from this api ? Or do I have to use the Bdl-statistics one ?
I want to generate the canvas of servers evolution
use that bot in #commands
you can get a graph of growth
Yeah but thats not my question
Ik that the bot generates it, but what i want to know is, can I from the apis provided ?
View the historical performance of up to 30050 bots listed on Discord Bot List (top.gg). Updates hourly.
Yeah i saw that
But the previous route returns tons of data
There is no way to get previous data with the top gg api ? With a datetime parameter
Couldnt find it in the doc but maybe I missed it
how to get topgg token
Read pins
ok sory
nope
not in the current version at least
there is a limit parameter
ok ty for the infos
this much bad
top.gg system
regenerated token like 10 times
but still same errors
@subtle pulsar
show your code
wait
const Discord = require('discord.js');
const client = new Discord.Client() // Your discord.js client or any othe
const express = require('express')
const app = express()
const port = 8080
app.get('/', (req, res) => {
res.send('Server Online!')
})
app.listen(port, () => {
console.log(`Posting`)
})
const { AutoPoster } = require('topgg-autoposter')
AutoPoster(process.env.TOP, client)
.on('posted', () => {
console.log('Posted stats to Top.gg!')
})
client.login(process.env.TOKEN)
this works for my other bot
?
try using dotenv
not working
i tried without env too
but still
this works fine for my other bot
is the bot already approved?
btw just a note dblapi.js is deprecated
NO THAT is i was testing
just help me
this is api error
because this works fine for my other bot
@slow sonnet
also refresh data not working
and logout also not working
sed lyf
its not
you're seemingly the only one with the issue
and you need to read the errror
i got it
Thx 
can i post the coding language in the website?
wdym
how to post the Library i used in the bot page
what do you mean by "Post the library"
Library is deprecated
use dotenv and also you can use process.env.DISCORD_TOKEN instead
the discord.js lib automatically uses that if you just do client.login()
don't need to pass anything to the function
Hey !
I have a question where can i get my Webhooks token of top.gg
because i don't see it for vote
How to do that ?
Your birth date Could be anything really
But i send it where ?
You set the auth there to whatever you want, and every time Top.gg sends you a request, it'll have that auth you set in the Authorization field in headers
I still don't understand but no big deal I'll see if I get there
Top.gg code?

Is that link to the docs?
The pre-release yeah
Oh okay, and what version is the pre-release? 2.0.0a ? Like if I want to use pycord for my discord.py fork would I use that version?
Yeah it's 2.0.0a0, next pre-release will be after PR #68 I guess
Oh okay
There are some snippets in the docs and also examples in the repo. If you have any doubts you can ask me here
okay, thanks

how i get the token topgg api?
thanks
i tried using the auto post feature with the topgg python wrapper but i got topgg.errors.Unauthorized: Unauthorized (status code: 401)
the token is valid
Try regenerating the token first
How to set a webhook? For voting
Not sure why I get this error
Traceback (most recent call last):
File "main.py", line 5, in <module>
import topgg
ModuleNotFoundError: No module named 'topgg'
const express = require('express')
const { Webhook } = require('@top-gg/sdk')
const wh = new Webhook('Top.gg API token')
const app = express()
app.post('/webhook', wh.listener((vote) => {
console.log(vote.user) // 172075838806818817
}))
app.listen(80)
because you have no module named topgg
That's the problem
It's already installed
pip install topggpy
Yeah
if you have multiple python versions
make sure ur using the right version
might not have installed the library into the one you wanted
I have 1.7.3
that sounds like discord.py
It was already installed
not the actual python version
Python 3.8.12
~/AntiScammer$ pip install topggpy
Requirement already satisfied: topggpy in /opt/virtualenvs/python3/lib/python3.8/site-packages (1.4.0)
Requirement already satisfied: discord.py in /opt/virtualenvs/python3/lib/python3.8/site-packages (from topggpy) (1.7.3)
Requirement already satisfied: aiohttp<3.8.0,>=3.6.0 in /opt/virtualenvs/python3/lib/python3.8/site-packages (from discord.py->topggpy) (3.7.4.post0)
Requirement already satisfied: yarl<2.0,>=1.0 in /opt/virtualenvs/python3/lib/python3.8/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py->topggpy) (1.7.2)
Requirement already satisfied: multidict<7.0,>=4.5 in /opt/virtualenvs/python3/lib/python3.8/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py->topggpy) (5.2.0)
Requirement already satisfied: async-timeout<4.0,>=3.0 in /opt/virtualenvs/python3/lib/python3.8/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py->topggpy) (3.0.1)
Requirement already satisfied: chardet<5.0,>=2.0 in /opt/virtualenvs/python3/lib/python3.8/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py->topggpy) (4.0.0)
Requirement already satisfied: typing-extensions>=3.6.5 in /opt/virtualenvs/python3/lib/python3.8/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py->topggpy) (3.10.0.2)
Requirement already satisfied: attrs>=17.3.0 in /opt/virtualenvs/python3/lib/python3.8/site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py->topggpy) (21.2.0)
Requirement already satisfied: idna>=2.0 in /opt/virtualenvs/python3/lib/python3.8/site-packages (from yarl<2.0,>=1.0->aiohttp<3.8.0,>=3.6.0->discord.py->topggpy) (3.3)
WARNING: You are using pip version 21.2.dev0; however, version 21.3.1 is available.
You should consider upgrading via the '/opt/virtualenvs/python3/bin/python3 -m pip install --upgrade pip' command.
hmm
When I wake up I saw that my bot was offline and when I started the bot again it said that there was no module named topgg
Replit
I'll just stick with replit as I know it the most.
Donno why, My project is on always active mode, But it takes for ever to load up if i am checking up on the website. Whenever I check out to see what's wrong, I find nothing. So i just rerun the server.but i get the error saying (packages aren't found), i have reinstall packages each time? know y?
try pip3
pip3 install topggpy
I already found another way
alr
you set the password
looks good?
also you cannot use webhooks whe nyour bot is not approved
is there a way to get a user tag from someone who votes
i can get user id but i dont have permissions to fetch the user
with top.gg's api, no
you'll have to look for alternatives that provide user data with the id
just trying to do a giveaway type deal, but i cant message the user to tell them they've won without their tag 🙃
Your users are required to be in the server to participate, no?
you can just mention them using <@id>
can i get guild info from top.gg though
it's gonna be across multiple servers

Top.gg provides the query parameter, which is linked to your vote page
https://top.gg/bot/yourbotid/vote?allofthisisquery
so you could use that to pass the guild id and user id to then get both on the vote request
it's presence intents i need for user
hmmm i just thought, i could copy the user ids to another bot under 100 servers and get their usernames right
probably yeah
presence intents is the right one to apply for though?
Discord might not like that though
Do you need a privileged intent for user tags even?
i figure ill apply for that and hopefully get it before the end of December so i dont have to worry about it
to fetch the user tags from id
because top.gg doesnt give you the tags
not through the webhook itself, but if you do have the ip https://docs.top.gg/api/user/
you could then fetch that user after they've won the giveaway
ID* not ip
oh nice, so you can do it. Thanks!
issue is, it might not be up-to-date
yup, it returns 404 for my user id

🛡️ 🎧
Hey can anyone tell , how can i make vote reminder system in my bot?
Is there something related to this in the api?
how to thread message move to other channel or thread??
- Wrong channel
- Don’t spam it in literally every channel??
Quick question for you lot, i would like to rewards my players with an in game currency for voting for the bot on top.gg, how would can i tell my bot when a player votes to give the player that reward? So like on vote, gather the users id…
i have, just not sure where to start to be perfectly honest
https://docs.top.gg/resources/webhooks/
Or the page for the language you use
thank you!
What
I want to upload the server count
Ah, the print a webhook bit was confusing lol
How can I see my bot's votes by topgg/sdk
Just see them? Or an event when someone votes
https://topgg.js.org/classes/api.html#getvotes
Gets the last 1000 votes in the month.
https://topgg.js.org/classes/webhook.html
Event for votes
How we can send voters name using webhook?
usernames aren't send over webhook
but user ids are
so you should get the users name from the userid
Is there a python library for topgg api?
Thanks
Ty
hi
I mean userid
const topgg = require("@top-gg/sdk")
const topg = await new topg.Api(process.env.topt)
var voted = await topgg.hasVoted(message.author.id)
if(voted == "true") return message.reply("already voted")
Why does this not work
const topgg = require("@top-gg/sdk")
const topg = await new topg.Api(process.env.topt)
and then your hasVoted line
var voted = await topgg.hasVoted(message.author.id)
But I want my bot to say "already voted" if the user(message.author) is already voted
Sure thing
but your code is wrong
Look at how you defined the variables
why are you trying to use topg on a const called topg
@rain heart
why are you using hasVoted on a variable that is not the api instance
@rain heart I didn't understand
@rain heart can u give example for how I do it
const topg = await new topgg.Api(process.env.topt)
@rain heart ok ty
@rain heart lmfao
That's what I have lol
thanks but still that dosent work
ok
no problemo
Um do server votes have an api?
Nope
how do i get the token
read pins btw
read pins
not your discord token
where is the api token then
@rain heart what can u do with Vote Credits?
-credits
Auction Credits
What are they?
- If enough people vote for your bot or server per month, you have the ability to get credits that you can then use for auctions.
- Don’t know what auctions is? See here for how to apply.
- These auction credits can be used to pay for any winning bids you may make
- You CANNOT “withdraw” them for real money
How does the System Work?
- Each month, bot monthly votes reset
- If you get 100 votes on your bot in the month, you can redeem $15 worth of voting credits (can’t redeem till you actually get 101 votes)
- Any vote after 100 will be worth $1 per 1000 votes (or $.001 per 1 vote)
How Can I Redeem Them?
- At the end of the month, you will be eligible to redeem your credits (you redeem them on your bot or server's
Votespage on your bot’s dashboard). You will have 30 days to redeem them before they expire. - After you redeem them, you have 31 days to use them before they expire (so you can technically stack 2 months worth)
**How can I Use them to Pay? **
- When you pay for your winning bid, you have the option to use your credits
- If your winning bid cost is more than the amount of credits you have, make sure to apply the credits first and then pay the rest with the supported payment providers
A more simplified, less detailed version can be found in #580510490074152961 after you get auctions access and any questions can be asked in #auctions-general.
How do i set up the API to detect the votes for my bot?
To have your bot's server count displayed on Top.gg, please read the documentation on server/shard posting.
internal/modules/cjs/loader.js:1102
throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/container/node_modules/node-fetch/src/index.js
require() of ES modules is not supported.
require() of /home/container/node_modules/node-fetch/src/index.js from /home/container/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename /home/container/node_modules/node-fetch/src/index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/container/node_modules/node-fetch/package.json.
at new NodeError (internal/errors.js:322:7)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1102:13)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (/home/container/index.js:3:15)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32) {
code: 'ERR_REQUIRE_ESM'
}
container@pterodactyl~ Server marked as offline...
const express = require('express')
const Topgg = require('@top-gg/sdk')
const fetch = require('node-fetch')
const app = express()
const webhook = new Topgg.Webhook('Me Key')
app.post('/vote', webhook.listener(vote => {
console.log("User with id - " + vote.user + " Voted!")
let value = JSON.stringify({
embeds: [
{
title: "New Vote!",
description: `<@${vote.user}> Just Voted For Vern!!`,
color: "8388736"
}
]
})
fetch("My Discord Webhook :D", {
method: 'POST',
headers: {
'Content-type': 'application/json',
},
body: value
}).catch(e => console.log('Error occured while posting webhook : ' + e))
}))
app.listen(2245)
console.log('Your app is ready to log votes :D')
node-fetch requires ESM in 3.x, try downgrade to 2.x
Or
const fetch = (...args) => import("node-fetch").then(r => r.fetch(...args));
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "my_token")
bot.topgg_webhook.run(5000)
@bot.event
async def on_dbl_test(data):
print(data)
i'm sending a test request to my bot and it's receiving it properly "POST /dblwebhook HTTP/1.1" 200, the problem is that the on_dbl_test is not being called at all, am i doing something wrong
It's on_dbl_vote, you gotta dispatch dbl_test yourself
Check the type field to tell whether or not it's a test
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "my_token")
bot.topgg_webhook.run(5000)
@bot.event
async def on_dbl_vote(data):
if data["type"] == "test":
return bot.dispatch('dbl_test', data)
print("test")
like this? it still doesn't do anything
print is unreachable
remove return
Err, if you wanna print that inside on_dbl_vote, you might as well just remove the dispatch
i tried both but it's still not doing anything after sending a test
How does it look like now?
the same as this but without the return bot.dispatch line
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "my_token")
bot.topgg_webhook.run(5000)
@bot.event
async def on_dbl_vote(data):
if data["type"] == "test":
print("test")
Where did you get the access log?
well the bot is hosted on repl, so the repl console
try printing data
tried already, still doesn't print anything
Heads up
this also works
const { default: fetch } = require('node-fetch')
-servercount
mod only commmand
ok sorry



