#topgg-api
1 messages · Page 10 of 1
you can do that by creating express server in your vps/bot then your bot will gonna send vote message wherever you want
or use https://webhook-topgg.com for ease
Simplifying top.gg webhooks for all users, allowing non-developers and developers to use webhooks for their bot and server without confusing configuration.
you cannot receive review notifications however

hi
Soon i gonna code public npm package for this vote thing completely
you save me
Hey ! I tryed to add the topgg libs in my discord.py bot.
I tried 2 way to do (The github example and another from ||chatGPT 😓 ||). But one give this error :
Traceback (most recent call last):
File "C:\Users\noanh\OneDrive\Documents\Github\Altium\main.py", line 36, in <module>
dblclient = topgg.DBLClient("TOKEN").set_data(client)
^^^^^^^
TypeError: DBLClient.__init__() missing 1 required positional argument: 'token'
And the other said "there is no asynchronous loop"
Here's my actual code :
intents = discord.Intents.all()
client = Altium(intents=intents)
dblclient = topgg.DBLClient("TOKEN").set_data(client)
```this one give me the error ine the top
Mention me for infos
have you look at this yet? https://pypi.org/project/topggpy/
there example code in there
Yes I tried this one
But it doesn't work for me
I'm assuming "token" just to hide your real token? or did you not put your token in there?
It's to hide it
also your code does not look similar to this(what I circled in red is where the token should be):
but im also not a pro at this so only guessing
My_Guild = discord.Object(id=Guild)
class Altium(commands.Bot):
def __init__(self, *, intents: discord.Intents):
super().__init__(command_prefix=Prefix, intents=intents)
async def setup_hook(self):
for filename in os.listdir('cogs'):
if filename.endswith('.py'):
await client.load_extension(f'cogs.{filename[:-3]}')
for filename in os.listdir('event'):
if filename.endswith('.py'):
await client.load_extension(f'event.{filename[:-3]}')
for filename in os.listdir('tasks'):
if filename.endswith('.py'):
await client.load_extension(f'tasks.{filename[:-3]}')
intents = discord.Intents.all()
client = Altium(intents=intents)
dblclient = topgg.DBLClient(dblToken, client)
client.run(Token)
This is my code
I put the dblClient into my main.py
And I got this error :
Traceback (most recent call last):
File "C:\Users\noanh\OneDrive\Documents\Github\Altium\main.py", line 36, in <module>
dblclient = topgg.DBLClient(client, dblToken)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\noanh\AppData\Roaming\Python\Python311\site-packages\topgg\client.py", line 98, in __init__
self.http = HTTPClient(token, loop=self.loop, session=kwargs.get("session"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\noanh\AppData\Roaming\Python\Python311\site-packages\topgg\http.py", line 84, in __init__
self.session = kwargs.get("session") or aiohttp.ClientSession(loop=self.loop)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\noanh\AppData\Roaming\Python\Python311\site-packages\aiohttp\client.py", line 228, in __init__
loop = get_running_loop(loop)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\noanh\AppData\Roaming\Python\Python311\site-packages\aiohttp\helpers.py", line 289, in get_running_loop
if not loop.is_running():
^^^^^^^^^^^^^^^
File "C:\Users\noanh\AppData\Roaming\Python\Python311\site-packages\discord\client.py", line 108, in __getattr__
raise AttributeError(msg)
AttributeError: loop attribute cannot be accessed in non-async contexts. Consider using either an asynchronous main function and passing it to asyncio.run or using asynchronous initialisation hooks such as Client.setup_hook
@dire pecan this is what my code look like right now:
the logger stuff put info in a file for logs but is not needed
I did this : https://mystb.in/WhetherYeastPan. No error showing up, but when I upvote the bot, nothing happend
oh did not know you were trying to add a vote thing and not a server count
my bad maybe 😅
On the page you added your webhook url there's a test button
Nope, there are third party tools that you can use; then pull data from the message they send. but its not ideal
hey, so i got a positive post but it doesnt seem to update on the site
how long does it usualy take?
Where are the top.gg api docs
Ty
I don't see a java vote event/webhook thing. 
I dont think the library has one, however all a webhook is is a web request. It should be extremely simple to do
I have this code for topggpy and I am not getting anything on test votes or user votes.
# bot stuff
# Installed topggpy
import topgg
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("/dblwebhook", "(retracted)")
# The port must be a number between 1024 and 49151.
client.topgg_webhook.run(25509) # Pterodactyl server port
@client.event
async def on_dbl_vote(data):
print(data)
user_id = data['user']
guild_id = data['guild']
role_id = # Retracted # Replace with the ID of the role to give
guild = client.get_guild(int(guild_id))
user = guild.get_member(int(user_id))
role = guild.get_role(role_id)
if guild is not None and user is not None and role is not None:
await user.add_roles(role)
await user.send(f"Thank you for voting! You received the {role.name} role.")
I am using Pterodactyl as my host, and idk what to set as my the Webhook URL on the bot's webhook top.gg page, aka what to post to. This is what I currently have it set to (domain retracted): http://hosting.example.com/dblwebhook. I assume this is wrong.
Please ping on response
Itll be the IP to your server.
pterodactyl has different ways of handling it; some hosts provide a domain like you show, some use a dedicated ip, some use a shared ip.
If you're unsure its generally better to contact your host.
Ok, so what would be the correct URL if it was the server's IP?
http://SERVERIP:PORT/PATH
http://SERVERIP:25509/dblwebhook in the code example you provided
oh ok
make sure not to add https:// just http://
https requires a domain
are you on a shared IP?
no
its a domain
not an ip
the HOSTNAME in the network tab shows a url
the network tab ^
i updated the webhook url on the top.gg page to this and it still doens't work
http://hosting.example.com:25509/dblwebhook
👀 it might be https since its a domain
Anyone that can help me?
Yoo
How do I receive the name of those who voted for my bot, given that the hosting where I host my bot does not have a fixed ip?
using webhooks, that is your only way
can I check every time a user runs a command which requires a vote, the api? or is it more practical to store the user who voted for 12h and check everytime he runs a command once every 12h
It's a good idea to cache the result of whether the user has voted or not, and delete the cached entry after 12 hours, that way you can avoid getting ratelimited from the Top.gg API
okay
Invalid vote webhook request. Missing userId.
Is this normal for the webhook test or should it provide a userid?
how frequently do I need to post bot serverstats to the api?
every hour is probably the best
this is fine right?
module.exports = (botID, serverCount) => {
const token = process.env.TOPGGTOKEN;
const data = {
server_count: serverCount,
};
axios
.post(`https://top.gg/api/bots/${botID}/stats`, data, {
headers: {
Authorization: token,
},
})
.then(() => {
console.log('Stats updated successfully');
})
.catch((error) => {
console.error('Failed to update stats:', error.message);
});
};
cron.schedule('0 0 * * *', () => {
bot.logger.log(`Updating TopGG Servercount: ${bot.guilds.cache.size}`);
updateStats(bot.user.id, bot.guilds.cache.size);
});
hello, i have a error but i don't understand can you help me?
.....
hey, so i got a positive to my POST request but it doesn't seem to update on the site
You're using async methods outside of async contexts
"""dbl_token = "MYTOKEN" # set this to your bot's Top.gg token
client.topggpy = topgg.DBLClient(client, dbl_token)"""```
Double check the number you're posting by logging it to console.
this is a async function Nevertheless
so how should i do it? ?
i posted my servercount and got this as a response.
👀 Not the response, the number you're sending
Correct me if I'm wrong, but its not about the function, its about the context.
its 170
and you've validated that is what you're sending?
thats what it sends if i console.log the same thing. but idk if this has anything to do with it but i also cant edit the bot manualy, it doesnt let me save.
sorry but i don't enderstand
👀 I wish I could explain better, but I don't use python.
It can go into the setup hook(discordpy docs cover this) or inside another async context.
iirc discordpy provides async decorators
Should be through the edit button
i cant save tho
Can you drop your bot id in here
You don't know anyone who knows python and uses the topGG api?
738057910923296839
probably background URL
Yeah that's the bug woo was referring to, that doesn't work atm
So just empty that field
ok works thanks ❤️
Just to clarify, this error is an asyncio error. its not specific to the topgg library you're using,
anyone who knows asyncio can help give, most people in the discordpy support server should be able to help
Or looking into setup hook, or any discordpy decorators.
can you invite me to discord.py please?
I dont have it, iirc its on the docs
ok
So js can't be added to the description?
How do I make my navbar respond on mobile devices💀
You can use js in iframes, but no you can't use any js at all in your description otherwise
I'm using the topgg-autoposter (with sharding) but for some reason it only posts updates to the topgg-api when I start the bot. I don't have any errors logged and haven't made any changes to its implementation in my bot recently. Has anyone else run into this issue or know of a solution?
why aint this updating the details on my botpage?
module.exports = async (botID, serverCount) => {
const token = process.env.TOPGGTOKEN;
const data = {
server_count: serverCount,
};
axios
.post(`https://top.gg/api/bots/${botID}/stats`, data, {
headers: {
Authorization: token,
},
})
.then(() => {
console.log('Stats updated successfully');
})
.catch((error) => {
console.error('Failed to update stats:', error.message);
});
};
I only see the "prefix"-detail on my botpage
Provide a content-type of JSON too
axios
.post(`https://top.gg/api/bots/${botID}/stats`, data, {
headers: {
Authorization: token,
'content-type': 'application/json',
},
})
.then(() => {
console.log('Stats updated successfully');
})
.catch((error) => {
console.error('Failed to update stats:', error.message);
});
are you sure the token is there & it's correct?
just console.log it to make sure it exists
you can also do a quick test and do
curl https://top.gg/api/bots/123 -H "Authorization: abc"```
and replace abc with your token
it should say "Not found"
{"error":"Not Found"}
than your token is correct
console.log the env variable to makes ure its there and defined
the token is valid
hm
well you can also be doubly sure and use the official top.gg sdk
Official Top.gg Node SDK. Latest version: 3.1.5, last published: 2 months ago. Start using @top-gg/sdk in your project by running npm i @top-gg/sdk. There are 9 other projects in the npm registry using @top-gg/sdk.
easier that way
how often does it update the stats?
topgg-autoposter?
yes
it defaults to every 30 mins which is the suggested interval
okay I will try that then
and If I want to post the stats exactly at xx:30 and xx:00
omg I am just dumb..... I was testing this stuff out on my test bot and i used bot.user.id in the link to post the stats to.. no wonder it was giving me "access denied" LMFAO
does the server count update automatically after posting server count on my bot?
Should be, plus minus some time for caching
Do i need a webhook setup to run the example wehbook code on the python documentation? https://docs.top.gg/libraries/python/
Or can I run the code without a webhook setup?
👀 what do you mean 'do you need a webhook'?
You cannot use a discord webhook here if thats what you mean
No i mean any webhooks, there's a webhook url field on my bot's settings
You'll need a webhook url yes, one that points to the webserver you create in the example.
Okay okay but that webhook url isn't necessarily connected to the one on the sample code right?
where can I get started on adding a webhook on my bot (4th point of top pin)
This library does that
import topgg
# 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}")
@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}")
bot.topgg_webhook.run(5000)
starts a webserver on port 5000
ohh then will it also provide a url?
Nothing "provides" a url.
A url just points to a location on the internet. In this case the url will depend on things like where you host your bot, if you are using a domain or direct ip, things like that.
It might help to take some time to look into what a url is, and how web requests/web servers work.
well regardless, I tried the code on my bot, but it's not receiving the test vote
Did you fill in the url and auth on your bots edit page in the webhook section?
yes
Not with a discord url
yep, its a ngrok url generated from a flask app
the flask app nor ngrok is connected to my bot in any way
You'd probably have to reach out to ngrok support to verify that is setup correctly before I can really offer much more support.
I have no way of validating/helping with ngrok setups
Alright, anyway, does it need to be connected to my bot for the code above and the test vote to work?
I dont believe so
I mean as long as the 'bot' argument is filled
topgg.WebhookManager(bot)
yeah i thought so, it's weird that it's not receiving the test votes
oops wrong channel
hello, just verified my bot today, implemented a reward-system for voting on top GG, and got this now
what could be happening?
what URL are you accessing
and what are you using to access the site, based on the IP there it seems to be a datacenter IP
making requisitions from this URL:
https://top.gg/api/bots/:bot_id/votes
Oh then you did actually get cloudflare ratelimited
Did you try to fetch that endpoint too many times?
yes
@lean cliff
this is my dev, he'll know better how to explain things
Hello @rain heart , I'm responsible for the futverse bot, I recently had problems with rate limit and I wanted to see if there is the possibility of increasing the number of requests per hour of /votes.
we have an entertainment bot that really demands votes request, due to the vote-rewards system we implemented today
we need to fix this asap because we already announced this system to our playerbase and we're being questioned by our community
No
Consider using webhooks if you have a larger volume on votes than said endpoint can handle on ratelimits
There are a lot of benefits on using webhooks than the /votes endpoint too: first of all not having to keep ratelimits in mind as top.gg is the one making requests to that, aswell as having every vote rather than the last 1000 ones
The only requirement is to keep track of the votes on your end
How can I be making the connection with the webhook?
There's docs regarding webhooks: https://docs.top.gg
Some libraries have support for these too
what values do i get in the webhook?
these?
{
"username": "Xetera",
"id": "140862798832861184",
"avatar": "a_1241439d430def25c100dd28add2d42f"
}
or a list?
avatar and username is not provided in our webhooks. If you need avatar and username you'll need to fetch that data from discord.
Here's the body of webhooks: https://docs.top.gg/resources/webhooks/#schema
so come like this?
{
"id": "140862798832861184"
}
{
"bot": string,
"user": string,
"type": "upvote" || "test",
"isWeekend": boolean,
"query": string
}
"user" contains the users ID
thanks
is there any way to test if the data is being sent?
doing a test every 12 hours complicates :/
there’s a test button on your bot page
like the webhook one
Using the test button on that same page you set the webhook in
is it possible to get vote notifications without using webhook
Top.gg only provides events through webhooks, we don't offer any alternatives natively.
I mean, you can disable it by editing the setting on top.gg to go to another url? or invalidate the auth?
You can make a discord channel and check for messages in in.Because then you didn't need a Webserver
Somewhere in the pinned messages is a DC webhook
There you can enter your top.gg webhook and your discord webhook you can even customize the text
Like so
And then you can check for messages in the channel
Ooh that’s smart thanks
also there’s a bot does this without coding web server part as well
is there a total server votes option?
There's no API for top.gg/servers
yea, i was just asking cause im using webhook-topgg from the pinned messages and it has a server total votes option so i wanted to ask.
Might be tracked by the bot/website itself
I see, thank you for answering!
yep, it is
I haven’t used the api for a while now, anyway to see if a new core happened and get the user id from it?
core?
Sorry for not responding I was outside doing some work, yes core
what is a core?
Main element in a thing you know
For here it’s the api core
ok, what relation does that have with a user id
I don’t really get what you mean by what I’m saying above that I want to fetch the user id when he votes using the core api for topgg
you can also use the API to check if someone has voted in the last 12 hours: https://docs.top.gg/api/bot/#individual-user-vote
Alright thanks
Hello everyone, I've been exploring the Top.gg API and noticed there are two variables 'points' and 'monthlyPoints' associated with a bot. 'Points' seems to be the total number of upvotes a bot has ever received, and 'monthlyPoints' is apparently the number of upvotes a bot has received in the current month.
I'm curious, does anyone know the exact process of how these points are accumulated?
Any information or insights would be greatly appreciated. Thanks in advance! https://uploadi.ng/85cd2LH8
👀 how they are accumulated?
When someone votes each go up by 1.
monthly points resets at the end of the month.
Ah ok thx
TopGGAPIError: 401 Unauthorized (You need a token for this endpoint)
it updates still this error
randomly half of the time
please look into this
Your token is invalid then, press regenerate, refresh the page, then use that token
The first part of the token is always the same
No it updates time to time
its correct how else would that happen then?
just randomly this error
@rain heart yes bro what is it's use?
and wait for someone else who can help

Can't you tell me?
Just type it in short
I am quick learner so I'll understand
Yeh randi ka baccha bkl gyab ho gya
-m @errant canopy no need to be rude towards moderators because of that, thank you | 3 weeks
.piyush_xd#0 was successfully muted
One message removed from a suspended account.
is it ok to temporary put false server count. it will be a lower server count then what the current bot count is because i will be using a test bot that separe from the main bot.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
it for testing because I was trying it on the main bot but I crash it and it was down for a little bit as I was restoring it. so i don't want my main bot to go down again so i was thinking about using my test bot
One message removed from a suspended account.
One message removed from a suspended account.
I'm just going to take the risk. I'm tired of wait for a reply from staff
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
true
One message removed from a suspended account.
i guess
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
i mean it only going to be temporary and when I'm done testing I'm going to re enable the main bot stats so it will go back
he dnd tho
One message removed from a suspended account.
that 3 am for me lol
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
would Xiuh know?
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
also what is staff pick role
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
oh ok
let me guess someone hack this discord from one of the bots they picked or something along those line?
One message removed from a suspended account.
or did they just stop
One message removed from a suspended account.
ok
One message removed from a suspended account.
@scarlet cobalt are you familiar with discord.py
One message removed from a suspended account.
ok
One message removed from a suspended account.
ok
don't need help anymore. figure it out.
Hello, I am on your website to find the api, I just wanna ask
What is “yourbotid”?
The id of your bot
One message removed from a suspended account.
One message removed from a suspended account.
which one i use?
One message removed from a suspended account.
He meant the bot user id and the application id
the server id?
One message removed from a suspended account.
oh ok
One message removed from a suspended account.
?
Where?
nvm
Alright 😄
i do the first step - the url thing
but it takes me to my bots webhooks page
how do i get the api??
can i get the api or do i just have to use webhooks?
You can use the API by getting a key under your webhook settings of your bot on top.gg
That is where you obtain your token to use the api
https://docs.top.gg has the API usage documented
oh ok
I've checked the api , but Still getting erorr
try {
const response = await axios.get(`https://top.gg/api/bots/${client.user.id}/check`, {
headers: {
Authorization: TOPGG_API_KEY,
},
params: {
userId,
},
});
if (response.status === 200 && response.data.voted) {
return true;
} else {
return false;
}
} catch (error) {
console.error('Error checking top.gg vote:', error);
throw error;
}
}```
error
```Error checking top.gg vote: AxiosError: Request failed with status code 401```
Ensure the header contentType is set too
Nothing changed still getting that erorr
try {
const response = await axios.get(`https://top.gg/api/bots/${client.user.id}/check`, {
headers: {
Authorization: TOPGG_API_KEY,
'Content-Type': 'application/json',
},
params: {
userId: authorId,
},
});
if (response.status === 200 && response.data.voted) {
return true;
} else {
return false;
}
} catch (error) {
console.error('Error checking top.gg vote:', error);
throw error;
}
}
Then your token is invalid
Press regenerate, refresh the page, then copy the token there
Refreshing the page is required
Print out the headers, the content and the response entirely
Replace the token with just "token"
AxiosHeaders {
date: Wed, 21 Jun 2023 06:43:29 GMT,
content-type: application/json; charset=utf-8,
content-length: 24,
connection: close,
access-control-allow-origin: *,
access-control-allow-headers: Authorization,
etag: W/"1-xewnavbar1/PADAS",
set-cookie: [ ... ],
cache-control: private,
cf-cache-status: TONAHTE,
strict-transport-security: max-age=2678400; includeSubDomains; preload,
x-content-type-options: nosniff,
server: cloudflare,
alt-svc: h3-413=":443"; ma=86100
}```
```Top.gg Error Response Data:
{
error: 'Unauthorized'
}
Error Response Status: 401
Error Response Full:
{
status: 401,
statusText: 'Unauthorized',
headers: AxiosHeaders {
date: Wed, 21 Jun 2023 20:13:29 GMT,
content-type: application/json; charset=utf-8,
content-length: 24,
connection: close,
access-control-allow-origin: *,
access-control-allow-headers: Authorization,
etag: W/"1-XPOV/My/PGA)/94/ST"",
set-cookie: [ ... ],
cache-control: private,
cf-cache-status: DYNAMEC,
strict-transport-security: max-age=15552000; includeSubDomains; preload,
x-content-type-options: snift,
server: cloudflare,
cf-ray: 7descontosasor-BO
}
}```


Why is Authorization empty
I need the request headers
Not the response
ok
Just deleted the bot from dev.portal
, 57 h wasted
Lol
I'm a bit confused on what /check?userId= is returning. Does it return voted:1 if you've voted in the last 12 hours, your total votes, vote streak? Not entirely sure what it's returning to use it properly and I couldn't find any information other than it shows if they voted.
I'd have to wait 12 hours to check to see if the number resets or goes up to 2
It returns 1 if the user has voted in the last 12 hours and 0 if they haven’t
Thanks 👍
One message removed from a suspended account.
Hello, I'm trying to do the on_dbl_vote event from the python libs.
But I don't understand nothing. When I just put all in my main, replacing all, An error show's up and tell me to put the topgg.WebhookManager in an setup_hook. I did, and now the dbl_web.run(5000) didn't work
what do you mean dbl_web.run(5000) didnt work? in what way did it not work?
Do you mean bot.topgg_webhook.run(5000)?
yes
I tried to put it in my setup_hook too
class Altium(commands.Bot):
def __init__(self, *, intents: discord.Intents):
super().__init__(command_prefix=Prefix, intents=intents)
self.Token = Token
async def setup_hook(self):
self.dbl = topgg.DBLClient(self, Token)
self.topgg_webhook = topgg.WebhookManager(self).dbl_webhook("","")
self.topgg_webhook.run(5000)
@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":
return client.dispatch("dbl_test", data)
print(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."""
print(f"Received a test vote:\n{data}")
this discord.py?
Yes
have you try to put self.topgg_webhook.run(5000) in await? so like this await self.topgg_webhook.run(5000) idk if that will work tho
yea like this:
async def setup_hook(self):
self.dbl = topgg.DBLClient(self, Token)
self.topgg_webhook = topgg.WebhookManager(self).dbl_webhook("","")
await self.topgg_webhook.run(5000)
in the example code maybe it talking about this?
maybe keep the /
maybe just included the webhook token and not the https://discord.com/api/webhooks 🤔
or is it maybe the token from top.gg website? 🤔
I put this one ?
maybe...
did you include the / in the beginning?
good!
maybe your @client.event are not working?
huh
I think
or you could try the webhook token and not the top.gg token. like what battleless is saying
if your running the bot on your home internet you likely need to do port forwarding
don't know what is this
top.gg webhooks have nothing to do with discord webhooks
oh ok 👍
well you need to forward the port your using if your using your home internet
And, how can I do that ?
your routers control panel
via the router or i think firewall.
If you don’t want to do that you could always just create some mock data to test the code on. your VPS should have all ports forwarded, so it shouldn’t be an issue when you host it
that’s probably what I would do
Those are the only solutions ?
All, if they don't involve my ports
I gave you a solution to that above
create mock data to test your code on
Is that the same for guild vote ?
is what the same
I need my ports forwarded
So, if I host it on an server it will work ?
yes
Any others solution to just send a message with an webhook when the bot/guild is voted ?
there's this: https://webhook-topgg.com/
Simplifying top.gg webhooks for all users, allowing non-developers and developers to use webhooks for their bot and server without confusing configuration.
it's unofficial however it's made by a Top.gg moderator
thanks
Did the bump command still work on @wild lantern ?
wym?
top.gg doesn't have a bump command, you can only vote on the website
Wasn't there one before? for guilds
I was sure there was one, I may be wrong on the platform
My bad
Was speaking of disboard
Can some1 help me? python
How do I get my bots webhook?
https://top.gg/bot/BOT_ID/webhooks
hi
what is this??
How do I know which url to provide for receiving webhook's data?
The webhook url is the url to your web server.
It'll depend on your host and code
I'm asking to my host
I made a significant pull request to the top.gg rust api, and it seems to have been ignored- do i need to do anything here?
cc @woven coral since you're the maintainer seems like
nulls PRs are being ignored too 
what PRs
Top.gg Rust SDK. Contribute to top-gg/rust-sdk development by creating an account on GitHub.
oh it took two weeks
The current state of the library is extremely worrying. No HTTP api library should directly use unsafe.
in addition, https://github.com/top-gg/issues should be archived, as it's just being used for advertising
Report bugs related to Top.gg. For feature requests: https://feedback.top.gg - GitHub - top-gg/issues: Report bugs related to Top.gg. For feature requests: https://feedback.top.gg
I would appreciate a review here from nullrs, though.
My host told me that I need to use ip+port but top.gg support only url
a url can contain both of that
http://10.0.0.1:2020 for example
Mac still haven't granted me maintainer access
so i can't approve it even if i wanted to
cc @upper granite
alright- would you mind making an informal review and commenting on it?
imo, forbidding unsafe code in rust is not that necessary since unsafe is sometimes useful whenever you really know what you're doing
though i would say that i completely understand some of your concerns like https://github.com/top-gg/rust-sdk/blob/main/src/bot.rs#L113 (i don't remember why i used unsafe there
)
I brought this up in the tokio discord, just to get their opinions- The general consensus was “yes, this is true, but none of the unsafe here is even close to justified”
i can remove the forbid directive
unwrap_unchecked is not something that should really ever be used
not really tbh
for things like DateTime, in theory it should never errors as discord snowflakes are always valid UNIX timestamps
i'll further review your issues and pull requests later - it's still 6 am for me 
your concerns are understandable though, thank you for bringing this up! 
then unwrap() and panic, don't unwrap_unchecked and cause UB- it's perfectly reasonable
an Undefined Behavior in this case is completely unlikely
why run the risk
checks exist for a reason
again - runtime checks are completely unnecessary here, unless discord API returns an invalid user ID for some reason, which is impossible
it's not impossible
in software, nothing is ever impossible
There is no reason to use unwrap_unchecked, because unwrap takes so few additional cycles, and it's just... better practice to halt and catch fire then to catch fire and hit someone's house
https://godbolt.org/z/ooczc6Yvb
godbolt example of how little code we are talking
from nomaxx117 (tokio core team):
I agree about #![forbid(unsafe)] being over-emphasized, but that is an unsafe function I almost categorically do not recommend using. It doesn't give you much performance (generally it gives you basically nothing, even in a hot loop) for the debuggability you lose, and if its enough of a hot loop that it makes any difference, then you probably should be writing your code a bit differently and not relying on option so much anyways.
fair fair
my philosophy on unsafe in rust is "use it if you have to, or if it's the only way to fix a performance issue"
I'm all for premature optimizations, but not unsafe ones.
i'll probably review/merge them once Mac gives me maintainer access to the repository
since currently i don't have commit/merge access and have to send pull requests to make changes (which is incredibly tedious)
cc @golden adder
Hi, I would like to ask how can I make vote rewards so when someone vote for my bot, it gives him some rewards
Pls ping me
Hey, you'
re probably looking for webhooks
Thx <3
When I clicked on url whew I should set it, it showed me this
Did you fill in :your-bot-id ?
You can also just go to your bots edit page, in the webhook section
Where should I fill it?
I clicked on this (its written that I have to set it up there) https://top.gg/bot/:your-bot-id/webhooks and it showed me the error
Oh
So in bot set up page, I am going to try
Actually in webhook page it does not require bot id, just webhook id so I will full fit it
👀 what
Hi, when I vote for my server the vote count stays on 1. There were 4 votes in total a while ago and then the number reset for whatever reason. How to fix this?
Ah okay
But why big bot votes wont reset?
they do
I haven't saw that before.
https://dblstatistics.com/bot/432610292342587392 example being on mudae
larger bots just have reset votes barely noticed due to how many votes they're actually getting
What about tacoshack?
same thing, you can freely view any bots votes per day on https://dblstats.com
View the historical performance of up to 39300 bots listed on Discord Bot List (top.gg). Updates hourly.
👍
All the time I have been using top.gg, I thought that count next to stars is votes, but that was servers, I am so stupid.
how to make my bot give coins to user if voted?
One message removed from a suspended account.
how can i get the api?
One message removed from a suspended account.
One message removed from a suspended account.
i got a token
One message removed from a suspended account.
One message removed from a suspended account.
-api
This channel is for suggestions, help, and bugs related to our official API libraries and documentation found at https://docs.top.gg/
If you need help with other development, please use #development.
There's only this
bruh what
How can I enable the display of the number of servers on the bot page?
-servercount
To have your bot's server count displayed on Top.gg, please read the documentation on server/shard posting.
Hi, I was following https://docs.top.gg/libraries/python/ and this happend to me: Traceback (most recent call last): File "/home/container/bot.py", line 37, in <module> bot.topggpy = topgg.DBLClient(bot, dbl_token) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/container/.local/lib/python3.11/site-packages/topgg/client.py", line 98, in __init__ self.http = HTTPClient(token, loop=self.loop, session=kwargs.get("session")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/container/.local/lib/python3.11/site-packages/topgg/http.py", line 84, in __init__ self.session = kwargs.get("session") or aiohttp.ClientSession(loop=self.loop) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/container/.local/lib/python3.11/site-packages/aiohttp/client.py", line 228, in __init__ loop = get_running_loop(loop) ^^^^^^^^^^^^^^^^^^^^^^ File "/home/container/.local/lib/python3.11/site-packages/aiohttp/helpers.py", line 289, in get_running_loop if not loop.is_running(): ^^^^^^^^^^^^^^^ File "/home/container/.local/lib/python3.11/site-packages/discord/client.py", line 140, in __getattr__ raise AttributeError(msg) AttributeError: loop attribute cannot be accessed in non-async contexts. Consider using either an asynchronous main function and passing it to asyncio.run or using asynchronous initialisation hooks such as Client.setup_hook
Can someone help please?
I guess he means AttributeError
yeah
theres no api for top.gg/servers
it will remove it after 13
1 hour to allow the user to re-vote to keep the role
-botcommands @restive otter
@restive otter
Hey! Bots aren't given permissions to send responses in this channel. Please use #commands to run commands.
does avatar support link or just the avatar string?
What are you referring to
Iirc that's the discord CDN
It's not hard at all to build that url yourself, just refer to discords docs on cdn avatars
i mean yes but thats just the string?
this one
That is the avatar hash yes
ok thx
You need to build up the URL yourself, refer to above
Are you trying to send the avatar of a user in a message?
oh so https://docs.top.gg/api/bot/#example-structure is the result of GET and cant POST them all?
only for servers and shards?
Only for stats posting yes
oh ok thx
how do I perform a test vote? And what url do I put in here when I'm trying to test?
yes but I'm testing it locally
is there no way to test it locally?
and is there like a way to input a test vote?
theres not no
there is the test button to make a test event
where? o.O
but theres no way for you to test it locally, unless you're developing locally
I am developing it locally rn
I'd like to test if it works before pushing to production
oh I'm blind x.x
you cannot provide something like localhost
ah alright guess I'll have to trust that my code works
or just like, create a test app for the webhooks and test with that
If you're just testing if the code works you can send a "fake" request using curl locally, or the postman client.
What am I doing wrong here? The callback in webhook.listener isn't being called
public setUpVotes() {
const webhook = new Webhook(process.env.VOTE_AUTH);
this.app.post(
"/dblwebhook",
webhook.listener(async (vote) => {
// Doing stuff
})
);
this.app.listen(3000);
return this;
}
and MYIP is publicly accessible?
the MYIP is my vps's ip adress ofcourse
yeah
wait maybe the port isn't
how do I check if it's publicly accessible?
So I opened the port and when running netstat -na | grep :3000 and then pressing test vote I get this in the terminal:
POST /dblwebhook HTTP/1.1
Accept: application/json, text/plain, */*
Content-Type: application/json
user-agent: Top.gg Webhook/1.0.0
Authorization: AUTH
Content-Length: 81
Host: IP
Connection: close
{"user":"259776081316282368","type":"test","query":"","bot":"425331296705708032"}
But it isn't being picked up by the express server, any idea why?
Anyone has an idea?
Please tag me if you do
fixed, had to expose the port to the dockerfile
at this point i don't think the issue and pull requests will ever be resolved

how do i use the api without discord.py but with py-cord?
yeah it is a little concerning
at this point i think the project is pretty much dead
which is very sad
blame the staff for pretty much abandoning the open source side of things 
yeah…
maybe we should fork
lots of people already made unofficial Top.gg Rust libraries
way before i did
ah

how do i use it? is i am gonna look for authorization header and match the value?
yep, thats all it is.
oh thanks
i dont need topgg token for that right?
No, its just an authorization header.
Whatever you put there will be the auth header sent in the request.
All you do is check if its the same one
yh.. btw is top.gg down?
No
Whats the endpoint for post_stats? Also may i know what headers / json i have to send while sending req to post_stats?
I kinda not able to find in docs.top.gg
lemme check again ig.
This channel is for suggestions, help, and bugs related to our official API libraries and documentation found at https://docs.top.gg/
If you need help with other development, please use #development.
um may i know why is it still showing my stats network is 0?
even tho i am updating my stats
I want to ask if the TopGG API can only send requests to HTTPS URLs?
yes
umm
fixed it..
File "/home/container/247-casino-bot.py", line 89, in <module>
CLIENT.topggpy = topgg.DBLClient(CLIENT, 'mytokenhere')
TypeError: __init__() takes 2 positional arguments but 3 were given``` hey why am i getting this error
im using py-cord
show code
lmao
I cannot get a vote messages in my server channel. What did I miss??
Top.gg doesnt support that natively, you'll either need someone to develop a bot for you to send those messages or use a third party tool.
hi guys, i'm trying to check my bot status but i cant with the api, that only give me a empty list
https://top.gg/api/bots/801705774426095639/stats
Your bot has no stats posted
is possible to check if the bot are online, or just the server_count?
Our site has no access to that data.
Only bots that share a server with your bot can get online info.
What is the bot stats update URI again? I forgor.
nevermind i'm fucking blind LMAO
Hi. I can't vote in karuta.
I heard china and indian users are in the blacklist.
But I live in Taiwan.
Can I verify my account?
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Yup
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Okay. Ty
any progress on https://github.com/top-gg/rust-sdk/pull/13
I am using python and i am unsure on how to use the topgg api. i am trying to create a vote message so that if a user votes for my bot, the bot DMs the user.
The problem i have i think is something to do with this:
topgg.DBLClient(bot=bot, token="TOKEN",autopost=False)
Error:
Unclosed client session
client_session: <aiohttp.Client.ClientSession object at ...>
This code is placed in the @faint geyserevent on_ready.
Do i have it in the wrong place?
Also is there a way to get a test vote?
can i have the library dev role due to my open PR on the rust sdk
One message removed from a suspended account.
One message removed from a suspended account.
the current developer seems quite happy with it, i was just hoping i would be able to actually get someone from top to listen to me in the lib dev channel.
One message removed from a suspended account.
that’s not what topgg open source is for?
oh wait the open source contrib role, not the lib dev role
oops
One message removed from a suspended account.
bruh
the open source channel is dead anyways
i have a question how to see how many votes does a specific user have ?
- OTHER then database does it automatically store in top.gg ?
Is there an api which i could use to see if the user has voted?
Why does the token have 2 "."
In between
Is it seperated
Should i use the first to Authorization header?
Or the whole?
I used the whole
Didnt seem to work-
Wondr why its saying unauthorized
show your code, replace your token with token
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Hey! Could someone please send me a link to get my API key? 😁
you need an approved bot
Is there a way to utilise top.gg to give a role to a user every time they vote and take it away when the vote cool-down has finished? (Python)
For servers we have a role option that @wild lantern can give a role and remove it after 13 hours.
For bots it will require using webhooks(not a discord webhook); give the role when the webhook is received, then remove it after 12-13 hours.
So if a user voted for my bot through the website, I’d have to use a web hook to give the voting role to the user
Yeah, you would receive a webhook request every time someone votes.
Gotcha, thanks 🙏🏽
part of the reason for that i would imagine is that pull requests just get completely ignored by the top team
One message removed from a suspended account.
One message removed from a suspended account.
a site powered by bots, which often use open-source tech to interface with it... which is utterly broken
we'll have to wait for Mac to make me the repository's maintainer first, since i don't have merge or heck even commit perms on the repo for some reason
Mac has been ignoring my messages about the Rust SDK so i don't think we'll be getting one anytime soon considering how busy he is, i assume
it's not just the open source channel, it's the entire Open Source side of Top.gg as a whole 
oh well, at least i got to make the Rust SDK fully working without any concerning bugs/vulnerabilities before the project died 
the library is still not perfect, yes, but i just don't care anymore honestly
you're formatting a http/1.1 request manually....
One message removed from a suspended account.
One message removed from a suspended account.
i know - i tested it and it works
read the message following that
sigh
ok? 👍
One message removed from a suspended account.
so true breastie
One message removed from a suspended account.
such a rust thing to do
Yeah
One message removed from a suspended account.

is it possible to retrieve the id of the user who voted up your bot?
One message removed from a suspended account.
One message removed from a suspended account.
i'v been suggested along the lines of:
'offering free premium to a guild per x votes per month'
tho im not sure how the api would work in terms of catching the guild id?
One message removed from a suspended account.
i can get the ID of the user voting
but for the purpose of my bot, the premium is tied to the guild the bot operates into
One message removed from a suspended account.
One message removed from a suspended account.
you could always pass the guild ID as a paramater
ah-a! that's what i was guessing
noice
nice pfp btw 😄

/help
There's not
Has the api been timing out recently?
website was down earlier so yes
Thanks - thought it was just me
Is it possible to receive guild votes with a webhook?
That's the only way to be honest
Why doesnt my server count show up on my bot page? https://top.gg/bot/1112469341062045837

i verified the requests are being made correctly
it's been like a week and they still arent showin up
You have to post them
i am
:p
theyve been getting automatically posted for a week now
and they still dont show
what language are you using
Go
try this
data := fmt.Sprintf("{\"server_count\":%d}", len(s.State.Guilds))
request, err := http.NewRequest(http.MethodPost, TGGStatsURI, strings.NewReader(data))
if err != nil {
fmt.Println(err)
break
}
request.Header.Set("Authorization", auth)
_, err = http.DefaultClient.Do(request)
if err != nil {
fmt.Println(err)
}
``` is what I'm doing
yeah but like
even when I manually try to post the data
nothing happens
it doesnt return any errors
it gives me 200 
this worked
awesome
because that does not refresh cache for whatever reason
that just refreshes the data and stores in the DB, but it takes time to refresh cache
wild
i am also just noticing that i forgot to set content type in the request
time to force a certain big bun to rebuild a certain bot :)
hey bunnnnn :3
::uhh

done
ty bestie
Best pfp in 2023 award goes to you
Hey guys, anybody able to help me with some top.gg API intergration. Looking to change the cooldown of a command, depending on if somebody has voted that day or not.
Bot's in discord.py, currently using hybrid commands, and handling command cooldown via built in method.
@commands.hybrid_command(brief="Claim a random card for your collection.")
@commands.cooldown(1, 600, commands.BucketType.user)```
Hey, your best bet is to store that data in a database.
When a vote is received via webhook store it until the next day.
Then every time a command is run check that database(probably should cache results)
I'll pass it on thanks mate. I think that's the route he went down but had issues for whatever reason.
cant find it in the docs, whats the url to give people to keep track which guild they'r voting for?
*the bot they'r voting for, and the guild they'r voting from
hey, I want to make sure I understand your question.
Your goal is to have people vote for your bot and know which guild they got the link from?
ya i think i got it just adding the parameters on the link. Tho is there a way for the webhook to return the amount of votes your bot has? Or do I have keep a db made by myself for this?
I think there's an api to query that, thought might be more straightforward if the webhook returned that directly
One way would be to fetch it when the webhook server starts. Every time you get a vote increase the counter by one.
That way you don't need to fetch it all the time, and don't have to store it in a database.
Sadly it's not something we send with the webhook. I do agree it would be a nice to have!
Might be a good suggestion for https://feedback.top.gg/
Let us know how we can improve. Vote on existing ideas or suggest new ones. If you require support or would like to report a bug, please go to our Support Page · Make a suggestion · Top.gg
when they use a vote command inside a guild, append ?guild=guildid on it and fetch that from the webhooks
if i was to vote for @abstract moth in this server, it would be https://top.gg/bot/264811613708746752/vote?guild=264445053596991498
Spice up your Discord experience with our diverse range of Discord Bots and Servers as well as other spaces to discover DAOs.
So I was redirected here, and I would need help with using a webhook to send a message every time someone votes for my server. I don't have a bot (well, I do but through web builders), same with the website, so I don't have any hosting either. I'm green at this, and would appreciate any help
Hey, top.gg doesnt provide a direct way to send a message in discord via webhooks.
You'll need to hire a developer or use a third party tool(you can find them on google)
Simplifying top.gg webhooks for all users, allowing non-developers and developers to use webhooks for their bot and server without confusing configuration.
Thank you
Can someone help me with updating my bot servet count on botghost?
um your bot can’t use botghost in top.gg
But I am in somehow.
Why you think so?
yeah but —> #mod-logs message and other denials???
we allow botghost, but as long as it has 5 custom commands and doesn't mention botghost on their description, as botghost is a competitor
ahhhh
ahh makes sense
I still need help with that.
With making link.
idk if you can my guy
I needed to contact reviewer and tell what commands were custom.
Because I failed 3 times.
it is
you need to POST the server count with the API
or use a library for the language you use
do you have a exampel for javascript
yes
Thanks
how long does it take for it to update?
it takes time for cache to clear
but you can speed it up by going to Edit Bot -> Save Changes (don't make any changes)
and give it a sec and it should show updated version
np
One more question, about the programming itself
Ye?
If I wanted to start writing (technically - rewrite) file bot, i.e. normally using Visual Studio Code, what would I need additionally (some libraries or something) and where I could host the bot (if possible, for free, at least just to test what I create)
I host my bot on my phone lol
Nice, Would you mind helping me get started? Just the basics, I should still get it looking at the my experience of html, css, php and js
the users endpoint is outdated
for example, still shows Xetera as admin and mod
and some mods as not mods
not that major of an issue, just wanted to put it out there lol
👀
I'm gonna make a really bold statement, might not reflect what's actually the case but
The user endpoints aren't getting updated internally
Because "Ae" is iirc what I had before being a bot reviewer at all
just an assumption
Yeah that’s what I thought
And they’re not really endpoints I can imagine people using?
Plus the docs are incorrectly showing socials in the response object
But that’s not in the real response
One message removed from a suspended account.
I ask again, can someone help me making bot servers count update command on botghost.
I need only link.
How to make?
Command itself I can make.
POST <link>.
-servercount
To have your bot's server count displayed on Top.gg, please read the documentation on server/shard posting.
the docs mention that
That didn't help, I got 10000 characters long error.
no clue what that means
I dont think you will get far with using the api at all with botghost
if at all
It has post url and http headers.
https://top.gg/api/bots/:bot_id/stats/server_count
Is that wrong url?
I tried that.
its not hard to read the docs and combining that
base url: https://top.gg/api
what you wanna do: post stats
reading the second docs link will tell you that: https://top.gg/api/yourbotid/stats is where to make a POST request towards, with the post data server_count in json as the body
Where I should put server count?
@rain heart
URL params?
It requires key and value.
yes
I should change that manually?
Ok, thank you very much!
@tidal idol Thanks, I just made smart auto event.
Bot joins new server and updates automatically.
Hello, please help, here is such a problem on your site, after adding the bot to the channel.
Looks like you're on probots site.
We are top.gg not probot, youll need to get in contact with their support.
Alright, I'm stumped on why I'm not receiving any votes. In main.py i've got this event:
@client.event
async def on_dbl_vote(data):
print(f"Received a vote:\n{data}")
And in vote.py i've made this function that is called after a couple things in on_ready in main.py -
async def init_topgg_client():
post_stats = True if production_build else False
client.topggpy = topgg.DBLClient(client, dbl_token, autopost=post_stats, post_shard_count=post_stats)
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("/dblwebhook", "password")
client.topgg_webhook.run(5000)
The stats autopost fine, but sending a test vote does nothing. (webhook url being https://publicipv4:5000/dblwebhook)
Any ideas?
Didn't change anything
try visiting the url on your browser
Does the top.gg return when a user voted or just whether or not they voted
Because I'd rather not re-poll every few hours
im trying to fetch https://top.gg/api/bots/1063817771114315816/stats i get an error.
says im unauthorized
yes
if you visit in your browser, you are logged into Top.gg
that is valid authorization
otherwise you need to pass your bots token
is there a way to get the server count without authorization?
no
you already have an API key though
go to your bots edit page, go to "Webhooks" and your API key can be generated there
but i cant just put it there. do i need to do some expressjs magic and create my own api?
yes :)
i wouldn't use Top.gg API for that
how is your website built (framework, etc)
since you should probably find a way to get it from your bot
like discordjs
your website though
oh um. its just html
i would recommend for the time being just putting an estimated server count
since being 100% accurate is probably not necessary
what's the time period of the individual user vote endpoint
12 hours
sure then wait someone who can help
Ok
Do you have a specific question about it? I
I'm probably not going to have time to help you from start to finish tonight.
code your own webhook or use https://webhook-topgg.com <— is easier
Why does the python sdk still installs discord.py even if its not in the github requirements?
it shouldn't per the requirements.txt yeah
Yea it still does, thats weird. And I installed a fresh bot with py-cord no other lib that probably need discord.py
can you install the pre-release and tell me what happens on that one? https://pypi.org/project/topggpy/2.0.0a0/
Ah thank you that works now, so that was probably because it defaults to the none pre-release version without version specification.
I try to reset my token, but nothing changes even after I refresh the page
The first part of the token is always the same, just regenerate, refresh the page then copy the token
Also remember to set the content type to json
try: data = await res.json()
no
I fixed it though, it was an issue with my topgg_api url ig
is there still a function in the javascript library that can return whether a user has voted the bot, like in the old wrapper dblapi.js?
does dblapi.js still work? altho apparently its not been maintained for 3 yrs
is the only way to retrieve user voted information by setting up the webhook?
Knowing the point they voted at, yes
but what if i dont care abt when they voted
If they voted, no, use the API check endpoint
just whether they did or not
i couldn't locate info on this within the javascript library
Which Library
@top-gg/sdk





