#topgg-api
1 messages · Page 164 of 1
https://i.woo.pics/6aab31b77f.webp
green arrow is the url http://YOURPUBLICIP:3000/dblwebhook
purple is the auth you put here in your code const webhook = new Topgg.Webhook("your webhook auth")
ok i did it
make sure to save then test, if it doesnt log anything first time restart your code.
it should log something like
355427757376667659
in the console of the running program
uh im not getting anything
did you try restarting the code
ah
do you mind dming me exactly what you put at the green arrow?
One message removed from a suspended account.
Is this for a bot or a server?
I'm using this method to post stats.
const Topgg = require(`@top-gg/sdk`);
const api = new Topgg.Api('xxx');
api.postStats({
lib: 'discord.js'
});
but it is not posting the libraries but it is posting other guildscounts etcs
how to post lib with that method?
You can't
#topgg-api message
So you mean I can only send lib via autoposter?
Oh you can't post lib. lib is deprecated.
is there any way to track what the response from a webhook webserver is when using the test button on a bot's dashboard
some other lists send the request from the browser so you can use devtools to see exactly what is being sent and what the response is
in the case of top.gg, repeatedly redeploying my entire bot just to check this stuff when something in my code doesnt work is inconvenient at best
I’m having a problem with setting up the vote tracker in my server, when I put the topgg link and authentication code in the webhook section, when I click send test it says something went wrong
It's either a problem on top.gg's end or on votetracker.xyz's end. I'd suggest contacting votetracker.xyz's devs to make sure you have everything set up correctly and they don't have any issues on their end and then coming back here for further support if needed.
It's a top.gg issue
Oh
any fix or known issue?
Make sure the webhook URL is valid, or its an issue with top.gg
Hmm mist be a topgg issue
work with webhooks
- get the user id from the voter through the webhook requests
- fetch the user
- check if user can me messaged
- send vote message
done
Why it doesn't work? It's the tenth time i post this
//------------Top.gg------------
const Topgg = require('@top-gg/sdk')
const express = require('express');
const app = express();
const webhook = new Topgg.Webhook(" ")
app.post('/dblwebhook', webhook.listener(vote => {
console.log("Porco dio")
bot.channels.cache.get("860843237022498856").send(`${vote.user}`)
}))
bot
Voting doesn't work until your bot gets approved
but it was approved long ago

Someone can help?
hot to check top user vote
try insert app.listen(8080)
ok
Somebody help me
I can't test the webhook on the Top.gg website
he says:
Something went wrong An error has occurred while processing your request. I've already tried to refresh the page, but the issue remains, and nothing appears in the Chrome DevTools console other than:
508.bd0bd31c78a77c9d609f.js:1 POST https://top.gg/api/client/webhooks/testGuild 403
like this
//------------Top.gg------------
const Topgg = require('@top-gg/sdk')
const express = require('express');
const app = express();
app.listen(8080)
const webhook = new Topgg.Webhook(" ")
app.post('/dblwebhook', webhook.listener(vote => {
console.log("Porco dio")
bot.channels.cache.get("860843237022498856").send(`${vote.user}`)
}))
yes
but i'm also having problems with the webhooks issue, so it might not work anyway
somebody help me
how do I make when someone vote the bot and sends message to the channel thanks for voting (user)
server webhook or bot?
bot
youll need to use a webhook
https://docs.top.gg/resources/webhooks/
theres also libraries that can help on the left side.
ah ty
ty
Does server webhook work fine line bot webhook or is it buggy?
Could someone give me an API, so when someone votes for the bot it delivers a Reward?
I use aoi.js
hey anyone can help me with if someone voted my bot on top.gg so it will get posted in my discord server and they will get rewards plss tell me how to make this 😦
my bot is in python by the way
Is there an api url for getting bot ratings?
nope.
this one
yep
how do you stop a command from working unless they have voted?
You can have your code send a GET request to top.gg's api, and execute the command if they have voted. Documentation here: https://docs.top.gg/api/bot/#individual-user-vote
Sa
i'm still new to site request, can you help me out haha?
Probably not, unless you're writing in lua. Is there a specific part of requesting that you don't understand?
ok so im going back to the autoposter for topgg
for python i need to pass in the token for my bot
is there a way i can give the servercount
and not have give topgg my bot token lol
a couple things, i generally restrict commands with permissions and im not sure how to restrict it through a site request haha
i use javascript btw
In the case of this GET request, the value will be a value in a json-formatted string. In the case of lua, there is a built-in way to decode JSON into a lua table, so you would replace
if member:hasPermission("Permission") then
--do the mario
end
with
if result.voted == 1 then
--do the mario
end
This is because the response to the vote check api is formatted as
{
"voted": 1
}
or
{
"voted": 0
}
Not sure if that helps though, I have no experience at all with javascript.
it doesn't much but i appriciate it still haha
Wdym? Top.gg never requires the Discord token if that's what you mean
You can see the topggpy code for yourself if you are concerned it does something shady
How to get guild token?
this is my first time hearing this term
It need here :(
Hi ! Since few month i have to improvise with my bot to send correctly votes webhook to my channel by getting the username in the user file because the API return 404 for existing user.
When the API will be updated to avoid workaround and 404 errors ?
ye
Hello ? topggpy
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password") what do I put in dblwebhook and password?
It can be anything, the path needs to start with a slash though
Path to where?
Can anyone specify an example?
WIth that bit of code, say the public IP you host the webserver on was 123.123.123.123. Then, say, you run the webserver with the <WebhookManager>.run method on port 5000: bot.topgg_webhook.run(5000). The URL you're gonna put on the site is http://123.123.123.123:5000/dblwebhook and the authorization you're gonna put on the site is password.
Is that the webhook
?
Anyway you don't get it
you put it
both there and
Here
(The area I marked red)
Oh
That's a good question
mhm
You see
First you should get about 10 lemons
Cut them in half
Squeeze them in a glass
Drink it
Go in coma for half a day
Then go to https://topggjs.rtfd.io/en and read the docs
May some pls tell me what to do here ?
# This example uses topggpy's webhook system.
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password")
# The port must be a number between 1024 and 49151.
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}")
Any ideas? I randomly get this error:
Anyone?
any chegg free bot here?
any way to check if an user has voted and they did it only once so they cant get vote rewards several times after voting?
all data it sends is only 0/1 and no vote timestamp
i mean i can store cmd usage timestamp
but if ill do that, user can run cmd after an hour after they voted and the next vote will work only in an hour
You will have to that via webhooks
why
it just times out, maybe a firewall issue, need to try more
Did you try this?
Make sure to open port 80 in the firewall, on ubuntu it's sudo ufw allow 80
dont want to use 80 for that
and i finallt made it so nvm
it worked and failed at the same time
you can just choose another port
ik, got it already, i also add \tcp after the port in ufw
how do i get the API key?
Ignore them
?
See pins
its up and works, but when i test it, i dont seem to receive any requests tho
brb lemme report you
console is emptty
You’re sure you entered your public IP and port correctly and the firewall doesn’t block your specified TCP port?
it works fine if i try to do a GET request
it says cannot GET /link
so POST should be fine
i tried axios and no errors
Did you send the GET request from an external source too or internally?
on POST
external
Hmm okay maybe topgg still has issues with their test feature
You may check the pins and announcements
It should of course but I’m not up to date
Lots of users had issues with it
Make sure to hit the save button before hitting test
my friend voted after i saved and nothing logged
even with ufw disabled
Hmm weird tho, the code is accurate?
Port 80 isn’t used by another service already?
no
Is your endpoint a server, your home etc. static/dynamic IP?
Hmm okay then I would guess the issue is caused by topgg
You could ask in support if there’s still an issue with receiving webhook requests
Oh how can it timeout
Hmm you may need to google that.
Haven’t ever seen that
You can try to use an online debug tool to send post requests to any endpoint you enter to test and check if the issue persists on your side
Unfortunately there aren’t much more tips coming into my mind atm
What did you set as your webhook url @warm hornet
ok it doesnt timeout using a debugger
Also, top gg sends post requests not get
i know
Hmm it’s getting weirder 
Yeah probably
i do get everything besides topgg
do it just doesnt send snything
wait
i literally had to add http:// before my vpses ip to make it work?
lol without specifying the protocol the link isn’t valid 
At least it doesn’t seems to work in the scripts of topgg
like the webhook works for you when you dont use the sdk?
yes
did you set the auth on the site correctly?
yes
const webhook = new Topgg.Webhook("your webhook auth")
the auth here, and the auth section in the webhooks section needs to be the same.
https://i.woo.pics/5b1cfb4386.webp
hmm
ok
wait
its notthe same then
i used token
ah yeah, tokens used for accessing the api, not webhooks
the auth can just be a random string of characters.
its the most logical place for it.
it does say its for the api
Token
You will need a token to perform certain actions with the API such as posting your bot's server count and checking who has upvoted your bot.API documentation can be found here
no problem
for python, what will be the code to get requests from topgg if user has voted?
vote_check = requests.get(f"https://top.gg/api/bots/872356887193071677/check?userId={ctx.author.id}")
how do i give the authorization aliases?
this printed <request 401> something like this....
You can pass a dict which contains the authorization to the headers kwarg. Anyway, don't use requests as it's blocking (assuming you're gonna use it on your bot)
im not able to understand how to get the authorizatoin....
what do i put in the dict?
headers = {"authorization": TOPGG_TOKEN}
requests.get(..., headers=headers)

Again though, you generally don't want to have a blocking code in your async app. So consider migrating to an async lib such as aiohttp
Can I fill discord webhook url in url section for voting webhooks?
im using discord.py, how do i get user id of someone who voted on my bot
hey did u find out what to do
const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express() // Your express app
const webhook = new Topgg.Webhook('<my password here>')
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
// req.vote is your vote object e.g
console.log(req.vote.user) // 121919449996460033
}) // attach the middleware
app.listen(4002)
what am i doing wrong?
it logs nothing
Can I remove them from my console? I'm using python 3.9.5.
Without digging through topggpy code, not really
webhook middleware has been deprecated
use listener
ok ty
Accept my bot pls
wait for the queue lol, also ot
Mmm
No
what should i put in authorization at https://top.gg/bot/:my-bot-id/webhooks
whatever u put in Authorization field
any password
It's not necessary required but yes, a phrase you can use as auth (password)
You can also restrict the access to your endpoint for the topgg API source IP only
hi
i have a problem
I had my bot send a message whenever someone casts a vote in a text channel on my server, but now it keeps sending messages over and over again. My friend cast ONE vote and sent the message 5 times, i had to restart the bot to stop. What can it be?
this is my code
const topggSDK = require('@top-gg/sdk')
const express = require('express');
const app = express();
const webhook = new topggSDK.Webhook(process.env.topggPassword)
app.post('/topgg-upvote', webhook.listener(vote => {
client.channels.cache.get("871494278856192000").send(":tada: Oba! O usuário <@!" + vote.user + "> votou em mim pelo Top.gg! Obrigado! ;)")
console.log(vote)
}))
app.listen(8000)```
sorry, i speak portuguese
to solve this error, I imagine that it is necessary to answer the request with a status of 200, but how do I do this?
mention me when you answer, please
What's your @top-gg/sdk package version
Huh
now another problem: it returns unauthorized (it is necessary to inform the token) and I informed it.
const { AutoPoster } = require('topgg-autoposter')
AutoPoster(`${process.env.topggToken}`, client)
.on('posted', () => {
console.log('Posted stats to Top.gg!')
})```
My choice?
Yup
hey how can we choose a random member who reacted to a message in a guild by specifying these [reaction emoji] message-id, channel-id, guild-id using eval?
please move to #development
sorry my bad wrong channel
1|mg | TopGGAPIError: 504 Gateway Time-out
1|mg | at Api._request (/home/jnsp/minigames/node_modules/@top-gg/sdk/dist/structs/Api.js:76:19)
1|mg | at runMicrotasks (<anonymous>)
1|mg | at processTicksAndRejections (internal/process/task_queues.js:95:5)
1|mg | at async Api.postStats (/home/jnsp/minigames/node_modules/@top-gg/sdk/dist/structs/Api.js:99:9) {
1|mg | response: Response {
1|mg | size: 0,
1|mg | timeout: 0,
1|mg | [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
1|mg | [Symbol(Response internals)]: {
1|mg | url: 'https://top.gg/api//bots/stats',
1|mg | status: 504,
1|mg | statusText: 'Gateway Time-out',
1|mg | headers: [Headers],
1|mg | counter: 0
1|mg | }
1|mg | }
1|mg | }
this is currently spamming my pm2 logs lol
since now its possible to add discord bots within the discord app, top.gg should make a search system in this server which can search bots and send their invite link
(if u open bot invite link from discord it opens it within discordapp)
how to i fix this error: TopGGAPIError: 401 Unauthorized (You need a token for this endpoint)
const { AutoPoster } = require('topgg-autoposter')
AutoPoster(process.env.topggToken, client)
.on('posted', () => {
console.log('Posted stats to Top.gg!')
})```
Umm, I am a beginner and I can't seen to find yourbotid to put in https://top.gg/bot/:yourbotid/webhooks . I tried adding bot token and id from copying id by developer mode but it's showing 404 error page
any help ?
bot needs to be approved first
Well so I can't have it for my bot? any other way ?
I want to have a vote role reward system and the other bots available don't suit my taste and so I took up the challenge
...that sounds like you'd be looking for server votes instead
Yeah I am creating a bot which tracks server votes
But i would need the api to confirm if the user voted or not
So how can I get that, also is there any other way ?
Umm, is there a guide/docs for this ?
It would be really helpful if you could send it
Hi I used bots/bot:id/stats to get my bot stats but it doesn’t show my total votes per month
What is the url to fetch to get total bot votes?
Ohh i got a bit gist of it from help in #development , still I'm confused about this your webhook auth, where to get this ? (by creating a new webhoook and connecting with bot ?)
I guess we have to use this, right ? ```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\
// You can also throw an error to the listener callback in order to resend the webhook after a few seconds
}))
app.listen(80)
remove the stats part
Ah Alr sorry and thx
So i found this in docs,
// URL = http://your.server.ip:80/dblwebhook
// Authorization: webhookauth123```
How to get `your server ip` ?
thats where your webhook is hosted on
https://discord.com/api/webhooks/channel_id/token like this is the webhook I created , where channel_id and token have values, should I just copy paste it (is it where it is hosted) ?
I'm hosting my bot on replit, do I have to get something from there ?
you cannot use discord webhooks for your webhook
also, your bot has to be approved first before being able to use webhooks
So I can't have something that is able to track server votes in m server without approval?
oh server votes
you said bot
refer to the docs for the server schematics stuff: https://docs.top.gg
I thought I have to track server votes using bot
Already read it 5 times😅
https://topggjs.readthedocs.io/en/latest/Webhook.html
also read this too
and this I took from docs
umm, help ?
I checked the pins of channel too 
how to i fix this error: log TopGGAPIError: 401 Unauthorized (You need a token for this endpoint) at Api._request (/home/runner/junibot/node_modules/@top-gg/sdk/dist/structs/Api.js:76:19) at processTicksAndRejections (internal/process/task_queues.js:97:5) at async Api.postStats (/home/runner/junibot/node_modules/@top-gg/sdk/dist/structs/Api.js:99:9) { response: Response { size: 0, timeout: 0, [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null }, [Symbol(Response internals)]: { url: 'https://top.gg/api//bots/stats', status: 401, statusText: 'Unauthorized', headers: [Headers], counter: 0 } } }
this is my code
const topggAutoposter = require('topgg-autoposter')
topggAutoposter.AutoPoster('***********************.**************************.*****************************************', client)
.on('posted', () => {
console.log('Posted stats to Top.gg!')
})
***********************.**************************.***************************************** is my authorization token
Where did you get your token from?
Make sure it's valid and from the Webhooks tab of your bot page
from here
Try regen and updating your code
Why i cant post my shard_count
Probably cause your bot isn’t on any shards 🤷♂️
Meaning?
is it possible to check the via discord bot if users is ready to vote again using top.gg api?
like a boolean request
I'd suggest using the vote webhook to store the voter ID and timestamp in your database instead of hitting the API repeatedly. That avoids getting rate limited.
okay thank you for the docs!
someone help me?
Error loading botmisc.toppy
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 606, in _load_from_module_spec
spec.loader.exec_module(lib)
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/runner/Main-perseus/botmisc/toppy.py", line 5, in <module>
class topp(commands.Cog, name='topp'):
File "/home/runner/Main-perseus/botmisc/toppy.py", line 25, in topp
update_stats.start(self)
NameError: name 'self' is not defined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "main.py", line 80, in <module>
bot.load_extension(extension)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 678, in load_extension
self._load_from_module_spec(spec, name)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 609, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'botmisc.toppy' raised an error: NameError: name 'self' is not defined
Using cogs...
read the error
self isnt defined
class topp(commands.Cog, name='topp'):
def __init__(self, bot):
self.bot = bot
self.token = ''
self.dblpy = dbl.DBLbot(self.bot, self.token)
self.update_stats.start()
``` it is ig...
code```py
@tasks.loop(minutes=30)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count."""
await self.bot.wait_until_ready()
try:
server_count = len(self.bot.guilds)
await self.dblpy.post_guild_count(server_count)
print('Posted server count ({})'.format(server_count))
except Exception as e:
print('Failed to post server count\n{}: {}'.format(type(e).name, e))
update_stats.start(self)
I have this cog (https://mystb.in/AlthoughTransparencyAffordable.python) and its getting loaded and everything but the top.gg thing somehow doesnt work:
I filled out the webhook tab in my bot settings and tested it, but somehow i wasnt getting a test vote.
May some pls tell me what to do here ?
# This example uses topggpy's webhook system.
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password")
# The port must be a number between 1024 and 49151.
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}")
How should the path loook like?
node v16.6.1 isn't supported by topgg api?
theres no reason it wouldnt be supported.
the api is just an api, has nothing to do with your node version.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Ok thanks
h
Does the webhook url has to be on port 5000?
Since my bot server's ip is donator2.sweplox.cloud:1111 and not donator2.sweplox.cloud:5000
top.gg-api = not pog
lol 😆
^^^ pls 🥺
how can i send a webhook after someone has voted to my server?
The discord id or is there a separate bot id
Oh ok
So
280094303429197844 for example
{"error":"Unauthorized"} :(
Do I need a api key?
yes
Where do I get it?
See the pinned docs:
To access our API you need to authorize yourself, this can be done by using your discord bot list token. Your token can be obtained from your bot page settings under Webhooks (https://top.gg/bot/:yourbotid/webhooks replacing :yourbotid with the ID of your bot).
Oh nvm it was deleted
How should the webhook path look like ? For topggpy
Idk but I guess https://top.gg/api/bots/ur_bot_id/check?token=ur_token
they meant webhook not that
it can be anything, /path_here
Anything? So it doesn’t need my ip in the url?
Of course, the IP or DNS to your endpoint.
How would topgg know it's address if you don't provide it?
But the path the webhook service (webserver) is waiting for POST requests can be anything you like.
It isn't a physical path so it can be anything as long as it's a valid URI.
What is ErrorCode "EAI_AGAIN"?
Can someone help me? i always get the ECONNRESET error now after ive workaround the EAI_AGAIN error
Idk tbh can u show an example?
Hi
There’s no example.
The code snippets in the docs are providing a name example.
It doesn’t matter which name it gets as long as you tell your listener to watch this path.
Alr
just
what language
Hi guyz i am new to discord
401 Unauthorized Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: {
body: PassThrough {
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 4,
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: true,
[Symbol(kCapture)]: false,
[Symbol(kTransformState)]: [Object]
},
disturbed: true,
error: null
},
[Symbol(Response internals)]: {
url: 'https://top.gg/api/bots/489076647727857685/check?userId=436184825423069194',
status: 401,
statusText: 'Unauthorized',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: 0
}
}
``` why I'm getting this when I'm trying to check vote, when I open the url in my browser it works fine
you are not providing a token
I am
then its not a valid token
.set("Authorization", this.client.config.dbl);
I just copied from topgg
and did that
and if it needs token why it is opening in browser without need of token
you can try for yourself https://top.gg/api/bots/489076647727857685/check?userId=436184825423069194
you are logged in on the website
👀
oh
hm
I copied the token again and pasting it to the method directly
oh nvm sorry, I wasn't passing the headers to the method
ah
I wrote some code to get information from the top.gg website, since there is no api for getting ratings (that I know of). It works by looking for a JSON value with all of the bot's information, including votes, rating, individual ratings, and a bit more information unavailable in the current api. Unfortunately, it looks like they recently added DDoS protection, meaning GET requests to the actual website only show Cloudflare's redirect page. Is there another way I can retrieve this information? Are there plans to add a new api for this?
did you set the webhook auth too?
Yes this time I did
http://myip:port/dbl
Like that^^
When I search it up it’s shows refused to connect
-servercount
To have your bot's server count displayed on Top.gg, please read the documentation on server/shard posting.
Ok thank u
Public, otherwise how will the top.gg server know where to send the webhook to?
Ye I’m using my public one and I’m getting no response
lol
how can i get my bots vote count? python
Request :
Wish topgg had an option : in the bot page , u can enter a discord webhook url, and whenever someone votes , it sends a message to that webhook
Would be a awesome feature which would help pretty much all the developers
also, it wouldnt help all developers
what if developers wanted to reward their users when they vote but they cant because the webhook is a discord webhook
Ok that’s different case and sorry for saying “help all developers” but would be a rly nice feature to have , not like majority of bots on topgg give readers
Rewards
Sorry if that offended u just wanted to suggest
yeah but you can do other things to make it work with discord webhooks
Ye I am currently using request and web server etc
But just wanted to suggest that idea , but seems like it got turned down , thx tho
Hi
I’m tryna check if a user has voted in the last 12 hours
But whenever I vote and check it shows as False
It won't be official, but I'm working on it. It's still very early days(it's not even on its own domain yet) but it does work if you want to try it.
How can I see total votes of my bot without going on site? (I mean by executing a command)
discord.js btw
Total votes for the month?
It's in the bot structure.
https://docs.top.gg/api/bot/#bot-structure
yes ty
https://topgg.js.org/classes/api.html#getbot
^if you are using the sdk
Documentation for @top-gg/sdk
Ok
Also how many users will getVotes() will fetch?
Alright
Will it show me in a embed?
Or only console?
neither, its a object response
Oh alright
well, correction, its an promise response. that promise resolves to an array of short users
oh cool
Also i have a doubt how to give double rewards on weekend? Do I need to multiply the amount by using isWeekend()?
yeah
let amount = 500;
let weekend = await api.isWeekend();
if(weekend) {
amount *= 2
}```
probably easier to use a tenory
let amount = isWeekend() ? amount : amount * 2;
maybe cleaner to even just one line it if you prefer.
const amount = isWeekend() ? 500 : 1000;
Oh cool ty
op its a promise, youll still need to await isWeekend()
umm how can i use await without async function tho. I mean how can we use async in the webhook code?
async => {}
or if you dont want to
.then() works on promises
Oh alright
Ooh where can I go to try it? If it’s not a problem asking
I'll dm you the information when I get back to my computer.
Maybe 5‐20 minutes
Alr thx 🙏
hey it is not sending me getBot(client.user.id in an embed even though i have created a embed
It sent [object object]
getbot doesnt send an embed
its an object
you need to get the data from that object and put it in an embed
how
well what are you trying to get? votes?
yes
getBot(client.user.id).points iirc
Oh lemme try it
or well, .points on the object
refer to the docs and what it returns
ok
you need to create that embed completely yourself, getBot provides a Bot object you can use to get the data
i created embed
this is the result lol https://gyazo.com/543d78149a4b914c3560b32a56240c19
Oh
so i should use getBot(client.user.id).monthlyPoints right
again refer to the docs for the library you're using
oh ok
I've a problem, I want to setup vote rewards for my bot but idk y top.gg sends the webhook 3-5 times
you need to send a 200 response to the webhook
okay thanks
hey, how do i get started using the api and discord.py?
i want my bot to send a message in a certian channel when someone votes
hello, can anyone tell me how to use api.
I want the user Id who votes and want to display the no. of servers on the main page of top.gg
how can I authorize my bot to see this
Is there a way to send vote webhooks to localhost servers?
I mean, yes but probably would require port forwarding and some other stuff to be done first
Are points the vote count?
Yes
feel like they should be renamed ngl
nvm i managed to know how
how do i add auth to https://top.gg/api/bots/814580247973986314/votes
ill be using
const { topggcountapi } = await fetch(`https://top.gg/api/bots/814580247973986314/votes`)
.then(response => response.json());
to get count of votes
Just add the Authorization header https://docs.top.gg/api/@reference/#authentication
also, if you are just looking for vote count.
https://docs.top.gg/api/bot/#find-one-bot
gives
https://docs.top.gg/api/bot/#bot-structure
@restive otter did you set the webhook auth?
also whats your hosting location?
replit/heroku/glitch/vps/home?
you need an auth too
U there?
Okay
let me know if you need more help
can someone help me with why i keep getting the "An error has occurred while processing your request" message when i'm trying to test the top gg vote webhook?
for servers?
test button seems to not be working for servers.
yes its for a server
oh does it not work for servers
huh
youll need to use your own testing methods for testing webhooks.
such as remote postman requests
I’m always getting an error saying port in use
it should be
http://your-public-ip:8000/dblwebhook
and you should port forward
Ye it’s like that sorry
/ ~> :
Still no response
Meaning?
Port forward?
Wait
I see that’s my mistake
@restive otter ty
fuck lol
you need to use @top.gg/sdk or some webserver
when someone votes you'll receive their ID, just save it in an array or database so you can check it later
free for?
I'll not give any code
basically what you wanna do is:
user voted -> save ID to array
then when the command is executed:
user uses command -> is ID in array?
if yes -> execute command
if not -> show error message
or as fake said, use the api to manually retrieve data from top.gg
just be careful not to spam requests to top.gg
Best to save voters locally than hit the API. Hitting the API isn't scalable.
Guys what is better GTX or RTX?
#general is better.
I am setting up express app to get webhooks, but req.body is giving me undefined
are you using @top-gg/sdk package ?
np
bot.dblpy = dbl.DBLBot(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.dblpy.post_guild_count()
print(f'Posted server count ({bot.dblpy.guild_count})')
except Exception as e:
print('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
update_stats.start()
Error
Traceback (most recent call last):
File "main.py", line 100, in <module>
bot.dblpy = dbl.DBLBot(bot, dbl_token)
AttributeError: module 'dbl' has no attribute 'DBLBot'
solution ?
lol
rtfd
P.S. dblpy is outdated, refer to topggpy
and it's DBLClient, not DBLBot
alr
Yes it's monthlyPoints
Hey, so, i'm trying to use the library @top-gg/sdk but it doesn't seem to work.
This is my code:
import { Webhook } from "@top-gg/sdk"
import express from "express"
const app = express()
const webhook = new Webhook("lolitotop");
app.post("/dblwebhook", webhook.listener(vote => console.log(vote.user)));
app.listen(4433, () => console.log("Listening to the server"));
The authentication matches, the url i'm using on the dashboard is: http://my_ip:4433/dblwebhook. When I press the Test button, nothing happens on my code.
it will
but you first need to know if the server can receive the requests
like, is port 4433 open?
and if you use top-gg/sdk why do you use express?
I'm just following the example that they gave, in the example they used express
Yep
example where?
An official module for interacting with the Top.gg API - node-sdk/Webhook.ts at master · top-gg/node-sdk
ah, didn't notice it
anyway, make sure your port is open
and the address is right
The port is open, when I make a get request to localhost:4433/ in insomnia it returns what I said to
So i guess the problem is the address
thats not how port forwarding works but okay
topgg webhooks cant reach local host right?
correct
it needs to be publicly reachable from an external source
which can be allowed through portforwarding for example
i see
is it recommended?
Portforwarding is required when hosting your webhook service on your local computer
if you're hosting it on a host provider like a vps, that port is very likely already open and you wont need to do stuff regarding portforwarding
unless you're using a firewall on that vps, then you need to open your desired port
yea, thats the problem, im currently self hosting
Yeah portforwarding is required, unless you're able to tunnel that port to another server
which is very complicated and more difficult than portforwarding
is there any risk of port forwarding?
portforwarding is essentially allowing a single port to be accessed from external sources, so there are some risks of course
I'd suggest reading through that
ah, alright thanks!
"This allows you (or someone else) to access something on your computer from the internet. " 😳
in regards of that specific service you're portforwarding for
To make vote messages in my server, do I need to set up port and network stuff? Or can I just download topggpy, write some code and done?
not your whole computer of course
oh ok
as long as topgg can reach one of your ports, you're good.
Ok, I am hoping so. Networking is not one of my strong points. I'm going to try to do it now so I may post some (probably a lot) of questions here
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password")
With this bit of code - where do I find my password to connect to my bot on top.gg? And also - do I need to change the /dblwebhook or can that stay the same?
webhook
for which, /dblwebhook or password?
The token goes where password is
ok right, I tried that, what goes in /dblwebhook though?
const Top = require('@top-gg/sdk');
const express = require('express');
module.exports = client => {
this.top_gg = null;
if (process.env.TOP_GG) {
const app = express();
this.top_gg = {
api: new Top.Api(process.env.TOP_GG),
webhook: new Top.Webhook('Demon*****')
};
app.post('/dblwebhook', this.top_gg.webhook.middleware(), (req, res) => {
client.emit('userVoted', req, res);
if (res && res.status(200)) {
res.send('OK');
}
});
app.listen(1200, () => {
console.log('[dbl] Connected!');
});
} else {
// Do nothing..
}
function _post() {
const serverCount = client.guilds.cache.size;
this.dbl ? this.dbl.post() : null;
this.top_gg ? this.top_gg.api.postStats({ serverCount }) : null;
}
function init(loop) {
if (loop) {
this._post();
setInterval(() => this._post(), 1800000);
} else {
this._post();
}
return;
}
_post();
};
Why its doesn't working
Nothing. You leave it like that
It isn't working when I do a test webhook - any suggestions? The password is now the token
why do you have an else {}

How have you set the url on your top.gg dash?
I haven't set any url?
For nothing
You have to set the url the payload will be sent to
Ok, is there a cost to this?
So http://YOUR_IP:PORT/dblwebhook
Wherever you're hosting your bot
So the IP of my device? I am not good with networking, not one of my strongest points
Where are you hosting your bot?
I am hosting my bot on a VPS, but I am testing this on my DevBot - which is hosted on my laptop
It has to be your VPS's IP then once you're hosting there. If you're testing for now in a local environment then you'll need to use the IP address of your local machine.
Yes I understand that, I am only testing for the time being. Sorry for me being unhelpful here but how do I actually find the IP I need to use?
I found my IP
But getting this error now:
ValueError: path should be started with / or be empty
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("http://IP:5000/dblwebhook", "TOKEN")
remove everything but the /dblwebhook part
and token is not supposed to be your top.gg token
that is something you define yourself
like a password
why do I need to remove everything but the dblwebhook part, the other people told me to do that?
I have done
Don't touch the code except for what Hope said
so this is where I get the token right?
this is what I have
oh wait
like this?
yep
ok, how long does it take for a test to come through?
few seconds
ok because nothing came through
are you trying it when hosting it locally?
yes, just for testing purposes
wont work, unless you port forward just like Hope said
don't think anyone mentioned port forwarding?
so would this work if I put it in the VPS though?
yea, it should
ok, and just change the IPs etc
yea
it didn't work 😦
no errors given
wait I might know why
I don't know why - it just doesn't work 😦
anyone have any suggestions? Pretty sure I have done everything as everyone said
did you add the event which triggers when the test button is clicked?
This?
@client.event
async def on_dbl_test(data):
print(f"Received a test: \n {data}")
how to get api token
yep
@client.event
async def on_dbl_vote(data):
if data["type"] == "test":
return client.dispatch('dbl_test', data)
print(f"Received a vote: \n {data}")
@client.event
async def on_dbl_test(data):
print(f"Received a test: \n {data}")
This is the whole code for top.gg excluding the webhook 2 lines of code
Yeah I got all that
guess I will have to give up cos it not working damm
is the ip of your vps correct?
as far as I am aware, yes
ok
wait
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("/dblwebhook", "password")
``` im pretty sure you have something like this in your editor, now change the password field in that with a actual password that you know.
and use that to add it to the authorization field on your bot page
as far as i know, no
ok will try now
yeah that doesn't work either 😦
This is what I have: (the password is changed by the way):
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("/dblwebhook", "morgan5556")
did you click the save button?
yes lol

do your website still working with dblapi.js ?
or just http requests only
just asking
Recommended packages are in the pins here.
Or you can use http requests.
As per the docs.
yeah i see
Can you receive webhooks for when a server is voted for?
hello, is there any available documentation on how one could get information when there bot has been voted for? thanks
thanks
@jolly hornet ^^
as default ?
All of this api request is monthly upvotes?
//For user to check their upvotes
axios.defaults.headers.common['Authorization'] = process.env.TOPGG;
try {
const topggvotes = await axios.get(`https://top.gg/api/bots/814580247973986314/check?userId=${msg.author.id}`);
console.log("[Top.GG] " + msg.author.username + " | Total Vote: " + topggvotes.data.voted);
if (topggvotes.data.voted === 0 || topggvotes.data.voted === null) {
topggvotedcount = "N/A"
}else {
topggvotedcount = topggvotes.data.voted;
}
} catch (error) {
console.error(error);
}
//for top.gg prunebot total vote checking
axios.defaults.headers.common['Authorization'] = process.env.TOPGG;
try {
const topggcountapi = await axios.get('https://top.gg/api/bots/814580247973986314/votes');
if (!topggcountapi.data.length) {
topggcount = "N/A"
}else {
topggcount = topggcountapi.data.length;
}
} catch (error) {
console.error(error);
}
code works https://github.com/top-gg/python-sdk but the bot goes down after hours due to the error saying topgg module not found
A simple API wrapper for top.gg written in Python. Contribute to top-gg/python-sdk development by creating an account on GitHub.
Put your Heroku link in webhook URL section and you're done
exactly for example my app name is test
test
yea so should it be https://test.herokuapp.com
How would i be able to show my bot's server count?
hey there
so I am facing an issue with getting test votes
idk what to fill where
what should I put here?
what host are u using
like do u have a vps
do u have ngrok or any other tunneling service
what should i fill here idk
i have it downloaded, it isnt on rn
run it and then put the url into the box
what does it show
ok
idk
im using py
@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."""
print(f"Received a test vote:\n{data}")```
@client.event
async def on_dbl_vote(data):
"""An event that is called whenever someone votes for the bot on Top.gg."""
user = data['user']
embed = discord.Embed(description="New Vote! Voter: {}".format(user), color = discord.Color.gold())
channel = client.get_channel(859397571226370068)
await channel.send(embed=embed)
await user.send("Thanks for voting me on top.gg!")```
@shut flume
any idea?
of whats wrong
my top.gg token is right
and so is the pass
wdym
ig ill host it somehwere like glitch.com
wai
i need webhooks
and i want it to send msg to a discord channel
for taht i need webhooks
exactly
thats y
how else will i do
I host it on CDH
Chaotic desiny hosting
idk bout that
idk anything bout webhooks
:(
oof
*dies instantly *
hey did this work? can u help me with this if it did?
i cant seem to figure out how to use the api lol
doesnt work
lol yea
didnt :(
i mean there's no error in the code
but
it didnt
exactly
idk how to use webhooks
FetchError: invalid json response body at https://top.gg/api/bots/594189989143904264 reason: Unexpected token < in JSON at position 0
just using a GET method (and yes authorization was provided)
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', url=URL('https://top.gg/api/bots/723726581864071178/check?userId=843503225030049812')
this too
yes
but it also depends on your code
Like you have to do test.herokuapp.com/topgg if you're listening to the route
i mean it seems like everything bricked in the past 15 mins, cuz the code worked perfectly for weeks, until it didnt.
Who will dm me if my bot gets accepted
@celest pier
idk how you were trying to do it but it works for me. (It returns this ) ```json
{
"voted": 0
}
Thxxd
fetch("https://top.gg/api/bots/594189989143904264", {
method: "GET",
headers: {
Authorization: `${ConfigFile.top_gg}`,
},
})
.then((res) => res.json())
.then((json) => {
// ...
async with aiohttp.ClientSession() as s:
async with s.get(f'https://top.gg/api/bots/723726581864071178/check?userId={user_id}', headers={'Authorization': TOP_GG_TOKEN}) as r:
vote = await r.json()
if vote['voted'] == 1:
return True
else:
return False
authorization
What's this Discord api ?
what
it doesnt matter
i have cap A in both, the've worked for weeks/months
bricked about an hour or so ago
i changed nothing
can you do me a favour and send a content-type header with it
Also dosen't change anything
I get the first half
but can you explain why you're using aiohttp and not fetch in the last half ?
oh nvm It's python
they are two different languages, two different projects
actually this vote error is persistent on every single project ive checked.
at least 4
the api seems to just be dying in general
yea i found the issue
<title>Access denied | top.gg used Cloudflare to restrict access</title>
👍 nice job
<p>The owner of this website (top.gg) has banned you temporarily from accessing this website.</p>
nice.

Try regenerating the token
we did
thats not gonna change anything
Well, for my bot i regenerated the token. still having this issue
Your bot / ip sent waaaaay toooooo many requests
i setted up a webhook and copy pasted the url in my bot webhook colum
but test not coming
im just going to limit the update rate on the site
not the posting
the others
Like getting voted users
to like an hour
Probably a good idea.
So if someone is spam refreshing our website it'll ratelimit us
i setted up a webhook and copy pasted the url in my bot webhook colum
nice, makes sense actually.
when i try test its not working
your website ?
wait wasn't it a bot ?
our websites are connected to our bots
pls help anyine
is your url public ?
like no firewall or something ?
webhook url ?
Then it's possible
Like someone does ddos on your site and the whole thing go brrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
yes
alright, thanks
i created an intergration on a channel and copy pasted its url on the site
but not working
i think yes it is
Do you know how long the temp ip ban is
nope
try asking in #support
the timeout seems to be 30m
@smoky marten
for tempban
wait a minute
ok
I have a question
Actually I have lots of questions
Are you not setting up a webhook ?
What integration ?
You mean a Discord webhook ?
Are you trying to put a discord webhook for a top.gg webhook ?
i need to setup vote logs that's it
but i don't have much idea
okay
can u help me ? sir
I am thinking about how should I explain this
Okay
you know what
If you want a simple vote tracker there are bots for it
hmm ok thanks i will check that out
Like I did a simple search and this came out https://top.gg/bot/479688142908162059
(Not my bot so can't assure security)
Ok..
I am using the code in the example
code works https://github.com/top-gg/python-sdk but the bot goes down after hours due to the error saying topgg module not found
A simple API wrapper for top.gg written in Python. Contribute to top-gg/python-sdk development by creating an account on GitHub.
i'm getting unauthorized error
That's bad
??
oh
im just trying any number at the moment
i use client.guild.cache.size
ty btw
now im getting bad request 🤦♂️
body : {
"server_count" : 100
}```
what's wrong with this
im getting bad request
No idea
who is this ?
scam ?
ok i tried everything
why im getting bad request ?????
It’s still NOT a valid JSON formatted body
{ "server_count": 99 }
body: { "server_count": 99 }
🤦♂️
that's why im here
i told you i used that. now im using json
and don't blame me i was trying
still getting bad request
Yes, now look on to your screenshot
seRver not sever
And stop use spaces behind property names, that’s no coding style that’s just nonsense
👍
i just sent the token wait
i didn't code for a year
maybe i cant find the wrong thing here
It expect a content type set to JSON and there’s another typo.
body not boday
still not working
Last typo I’m helping out with.
Anyway the content type needs to be application/json
You haven’t added that to the header
i will wait
Just give it try to stringify the body again, I might have been wrong on that one, can't test it atm
didn't work
fetch("https://top.gg/api/bots/<bot_id>/stats", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": <dbl_token> }, body: JSON.stringify({ "server_count": 50 }) });```



