#topgg-api
1 messages · Page 4 of 1
can get it because nothing showing
ex.printstacktree not print anything
can't help then if there's no errors at all
completableFutures should have another method call to get the exception
Has topgg api changed or is there some error in the api.. my bot has 1 one yet it seems it handles or gets 14 votes even the member who voted their usernames aren't updated with votes yet
elaborate "gets 14 votes" and "usernames arent updated with votes yet"
Sorry
let b = await api.getBot('960381632471240744') // returns bot info
let a = b.monthlyPoints
This should return 1 but returns 14 (previous month)
Sorry problem was at my side i restarted the project and it works fine sorry and thanks
Yo
This isn’t the right place for that
.-.
A quick Google search would help you however
send me server links at dm
i searched all github and nothing
and when i try someone
No, sorry. Like I mentioned, this is not the channel for that, for general conversation move over to #general
it doesnt even work
eDDy#0001
I've got an error while auto sending server count
It only takes discord.Client? Not commands.Bot?
Oh I probably can't use this anyways, I use nextcord.
Just make the appropriate POST requests, you don't need the library
krypton appears to be offline, don't be so pushy
Yep!
But it seems you're missing a lot of the code related to webhooks, which is required for on_dbl_event.
Oh, yeah.. I'm not too familiar with request or webhook stuff..
So I'm too sure about that one
I won't be helpful with that.
I've never used python, however the code example I linked to is everything you need.
Does in (replace your bot id) in the webhook tutorial mean the in-app discord id,application id or client id
The in-app ID, the application ID and the client/bot ID are all the same. Simply copy the ID from either in-app with right click, or go on the developer portal and copy the application ID
uh i dont quite understand what url im supposed to put in the "Webhook URL" part in top.gg
Is there api to reward people through bot when they vote for servers?
Once user vote it will send a request to given webhook url from that you can then give user role by using discord api or various other discord api using packages. ig
you can add a webhook
like the man above me said
@jaunty plank
Can I make my bot say how many votes it has on TopGG?
https://docs.top.gg/api/bot/ and the endpoint would be https://top.gg/api/bots/:bot_id
uh i dont quite understand what url im supposed to put in the "Webhook URL" part in top.gg
It would be the url to your webhook.
It's the location of your webserver which topgg sends the webhook to.
whats a webserver?
A web server is computer software and underlying hardware that accepts requests via HTTP or its secure variant HTTPS
https://en.wikipedia.org/wiki/Web_server
where you host your website
but how do i make one my own
im trynna do the voting reward system thing
and im very much struggling lol
@
Assuming you’re using node js, you could look into something like https://expressjs.com/ or https://nestjs.com/
They make the job easier, but you could use any http module that can create a server that your language supports
Our JS library implements express already if that's what you prefer.
https://docs.top.gg/libraries/javascript/
can y'all not
This channel is related to questions about the Top.gg API
If you need to find a discord server, use the Top.gg site search (https://top.gg/servers/search?q=bloxfruit trading) if you cant find it on top.gg use google
Stats posted but vote system didn't work
deleted, code contained token
reset the token before asking again
const { AutoPoster } = require('topgg-autoposter')
module.exports = {
init(bot){
try{
AutoPoster('', bot)
.on('posted', () => {
console.log('Posted stats to Top.gg!')
})
const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express() // Your express app
const webhook = new Topgg.Webhook("hama1234+") // add your Top.gg webhook authorization (not bot token)
app.post('/dblwebhook', webhook.listener(async (vote) => {
const dUser = await bot.users.fetch(vote.user)
const member= await User.findOne({userID: dUser.id}) || await User.create({userID: dUser.id});
member.money = member.money + 1200;
member.save();
dUser.send({content:`You are Voted BoBo amd gave your 1200 BoBo money`}).catch(()=>{});
const logsChannel = bot.channels.cache.get(config.votes.channel);
if(logsChannel){
logsChannel.send({content:`${dUser.tag} Voted BoBo bot id: ${dUser.id}`})
}
// vote is your vote object // 221221226561929217
})) // attach the middleware
//app.listen(8080) // your port
}catch(err){
return console.log(err.message)
}}
};```
Ok why vote not working
my fair guess would be, have you set your webhook URL on the webhook section of your bot page settings?
Like discord webhook?
I set discord webhook
Nope.
It's the webhook to wherever your code is being hosted
I hosted in replit
Classic rookie
I wouldn’t call that a rookie thing, whilst it’s not the best option it’s usually the only option they can use within their budget (usually 0)
Also that’s kinda off topic for this channel so 👺
Eh replit isn't good.
I Know
When my plan of replit ened I will change host
Hello! Im trying to setup the webhook but the request body seems to always be undefined
nvm figured it out
expressjs needs a middlewear to get body
Jo Hey
I have question, since discord.py was updated to 2.0, topggs server count post isn't working anymore... any fix or something?
Make a POST request by yourself with aiohttp
how to make notify upvote bot discord(in my sv discord) in top.gg ( it maybe a webhook?)
Same this
Correct, using webhooks https://docs.top.gg/resources/webhooks/
Create link webhook in sv discord?
How can i find Authorization�
In your bot's page when clicking "Edit" and in the "Webhooks" section
You can use https://webhook-topgg.com/
It you don't like it, you will need to setup a custom web server to handle the requests for the webhook - see pinned messages
Simplifying top.gg webhooks for all users, allowing non-developers and developers to use webhooks for their bot and server without confusing configuration.
question, how do i make it send as in embed?
reach out to their support in this case
where?
"Contact" in the bottom left corner
cant i get help in the discord server?
this channel is for support around the top.gg api, not 3rd party tools
reach out to their support to receive help
@rain heart how can i add webhooks in the profile ? cuz i cant (bot still pending)
@rain heart sorry to say my bot ArPmix that i have sent to verification is offline due to the hosting provider error
Or
I would like say "Host error"
Bot needs to be approved to do that
If you know the precise date when it will be back online, use the bot reviewer note section when submitting/editing submission of your bot for telling when it will be back online
I don't the date
Know*
In that case it will get declined for being offline, you will always be able to resubmit it
Hmm
My bot hardly can hop into big servers
Total users 1002 and 16 servers
@restive otter is there sevrver count require?
Like 75
We are not Discord, so Top.gg approval has no requirements other than respecting the guidelines
Hmm
Oh now i understand

Discord's verification is once your bot is in 76 servers.
For Top.gg's approval we just ask you to follow our guidelines.
Hey, is there anything in the api that will let me remind users to vote for my bot? For example once they vote a timer is started to remind them to vote for the bot in 12h but will not reset the timer unless they have voted so it does not message them every 12h even if its not time for them to vote.
There is no support for that from top.gg’s api, you will have to implement your own way to do that
Maybe add in an extra 1 hour as grace which will be a total of 13 hours and once a user crosses this limit, you can remind them
Oh.
so I've clustered my bot, and that caused by bot's cache to be split between multiple processes. Does top.gg provide a way to sum the counts when posted by each cluster or do I have to use an IPC to upload the total stats?
alright, thanks!
Not using direct url but ye using my I'd it's a 404 but using my friend's it's working
hi. I`m trying to post amount of guilds of my bot but getting error (language c++)
dpp::snowflake guilds_amount = dpp::get_guild_count();
std::multimap<std::string, std::string> tgg_args = {{"Authorization",topgg_tocken}};
std::string post_data = "{\"server_count\":" + std::to_string(guilds_amount)+"}";
std::cout << post_data <<'\n';
bot.request("https://top.gg/api/bots/"+BOT_ID+"/stats",dpp::m_post, [=](const dpp::http_request_completion_t& e){
std::cout << e.body << std::endl;
},post_data,"text/plain",tgg_args);
and getting output
{"server_count":1}
{"error":"Required parameter server_count or shards missing"}
where fist is postdata , second returned body of request.
What am i doing wrong?
also make sure you're including the content type application/json
thank u a lot
did you fill in the url & auth on top.gg?
This code seems to be for real votes and not test votes, are you using test votes or real votes?
Did you fill in the url and auth on topgg?
both of these fields are required.
https://i.imgur.com/39uG1kR.png
You cannot use a discord webhook(the code you have is the webhook listener).
🤔 So you want to use the discord api to receive voting info from topgg?
Yeah, that uses topgg webhooks
Sends it to discord using the bot once the webhook is received.
Well, The url and setup will depend on how you are hosting it.
Ie, a vps will use something like http://YourVPSIP:PORT/PATH
he already explained, you can't use Discord's webhooks
you have to create your own webserver listening for incoming POST requjests from topgg
Then use the data you receive to go on, do whatever u like with it
anyone you like to of course
you just need to handle the incoming post request
Resolving general misconceptions and questions about "Webhooks"
- To make things clear, a webhook is not only something discord related. A discord webhook is discord using webhooks to allow sending messages into channels.
- Webhooks allow applications such as a discord bot to talk to other applications such as another discord bot to for example make things happen on that application.
You can read more about webhooks here: https://zapier.com/blog/what-are-webhooks/
So what are the differences between a Webhook from Discord and a Webhook from Top.gg?
- Discord webhooks allow an application to send messages into a discord channel. Top.gg webhooks itself DO NOT, Top.gg webhooks do not support the use of Discord Webhooks.
- A Top.gg Webhook is a way for your bot or an application to know when someone has decided to vote for your bot or server. That webhook includes data that allows you to know who voted for example.
To again make clear: A discord webhook cannot be used within Top.gg to allow you to know when someone voted. The data Top.gg sends is simply not supported on how Discord wants the data within the requests to be.
I only want logging of voting, not rewarding users, how can I do that?
- You can use something like https://webhook-topgg.com/ to only send a message into a channel when someone has voted for your bot or server. This is not an official tool provided by Top.gg but provided by a volunteer of the staff team.
- Please note that for support, you should reach out to their support instead, as this channel is reserved for official API questions. Their support server can be found here: https://discord.gg/tUSjPNp7R9
I want to reward users with currency/access to commands/anything else after they have voted. How can I do that?
- It is highly recommended that you have a general understanding of how programming works. If you do not, you should consider hiring a developer on either https://fiverr.com or https://freelancer.com
- You will need to be able to host a webserver that is publicly accessible. This is often done by hosting that webserver on a bot directly. A few libraries support that directly.
My bot can receive webhook requests once someone votes. How can I let Top.gg know about these?
- You can let Top.gg know about your webhook urls through your server/bot page settings.
on bot pages, under https://top.gg/bot/yourbotid/webhooks
on server pages, under https://top.gg/servers/yourbotid/webhooks - The Webhook URL field should contain your publicly accessible webhook url. These can be either a domain for example
https://mybot.com/webhookor an IP-Address such ashttp://1.1.1.1/webhook. Port-based URLs work too, such ashttps://1.1.1.1:5000/webhook - The Authorization should contain text that allows you to confirm that the webhook request indeed came from Top.gg.
More help such as what data Top.gg sends and about the use of Retrials can be found at https://docs.top.gg
Helpful links:
- Creating a vote-only command: <#topgg-api message>
as mentioned above, you cannot use a discord webhook directly, as Top.gg does not support it. If you're planning on only receiving logs if someone voted, use something like 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.
Is your goal rewarding users with currency for example?
or for example allowing the use of commands once someone has voted?
What language is your bot coded in?
You could possibly use part of this tutorial on setting up a webserver that is able to receive requests from top.gg: #topgg-api message
And you have a webserver running already, correct? what is the port you've used?
The library you're using should have one included, on pypi theres an example on "Using Webhook" in the description
when i go to the api endpoint for bot info, it works in my browser but not with axios or node.js http. I get a 401 error
Do you have a token?
no
docs dont say i need one for that
Its covered in getting started.
https://docs.top.gg/api/@reference/#authentication
why does it work without token in browser tho
it uses your user authorization to use the api
o
though its mainly used to test endpoints and shouldn't be used as an actual token to use the api
Using topggpy
# bot is defined as a commands.Bot
import topgg
bot.topgg_webhook = topgg.WebhookManager(bot).dsl_webhook("/dsl", "Authorization hidden")
bot.topgg_webhook.run(5000)
@bot.event
async def on_dbl_vote(data):
await ctx.author.send("dbl")
await ctx.author.send(data)
Not exactly sure what to put as the webhook URL (I'm using an aws ec2 instance)
Does ec2 provide an ip?
It provides with a public ipv4 and a private ipv4
and also a link i use to connect with
ec2-(IP).eu-west-2.compute.amazonaws.com
you would need to use the public ipv4.
http://IP:5000/dsl
Okay, I'll try that
topggpy```py
bot is defined as a commands.Bot
import topgg
bot.topgg_webhook = topgg.WebhookManager(bot).dsl_webhook("/dsl", "Authorization hidden")
bot.topgg_webhook.run(5000)
@bot.event
async def on_dbl_vote(data):
print(data)
Webhook URL: `http://{IP}:5000/dsltestwebhook`
`on_dbl_vote` does not get triggered
/dsltestwebhook but /dsl is used in code.
This hackathon targets me, please stop
Also, on dbl vote is only for votes on the real vote page.
https://top.gg/servers/422087909634736160/vote
If youre testing its the test event
🤔 what?
Oh
yeah I know.. I changed the URL in the code I'm using.. forgot to change here
on_dbl_test?
oop sorry for reply ping
on_dbl_test yeah
Alright, thanks
I'll be back if I have any more issues 😂
I added on_dbl_test event but still nothing 🤔
Is your authorization in Authorization hidden the same as the auth youve set on topgg?
https://i.imgur.com/AJowoJS.png
Yes
Does ec2 have a firewall on the port you're using?
If they have a firewall it will cover all ports
oh
If youve opened it then its fine
This is on your server right? not at home.
Yeah
This is on the aws online console
Anything I can do to fix this?
Or will I have to find an alternative?
I dont use ec2, windows server, or python so I think I've helped as much as I'm capable of. Sorry about that.
We've had people use window server and ec2 so I know they work.
There was no option to do that
Is this channel the place to post about topgg-autoposter?
Anything related to the API belongs here. Only official libraries though, if it's not official use #development
topgg-autoposter isn't official, anything on https://github.com/top-gg is official
topgg-autoposter is a tool within node-sdk
Yeah, tough https://www.npmjs.com/package/topgg-autoposter doesn't seem to require the node-sdk to work; according to the example shown at least.
hey, why im getting this error?
I have 4 shards per cluster, so does that mean I have to make 4 requests per cluster, posting each shard's stats?
You could do that I think
But to reduce that to a single request, I’d request each cluster to return an object mapping shard IDs to guild counts. Once that’s done, while posting your stats to top.gg, the server_count property must be an array of numbers and each element will be the number of guilds each shard has
And internally, top.gg would add all those values to show a total server count on the page and the length of that array would be your total shard count
alright, then I can just leave the shard_id field empty?
Yep, as per the docs, it’s an optional property
thanks, I'll see if this works
.
Are you still getting it?
@restive otter mach überall prints rein
Dann siehst du wo es geht und wo nicht
Bzw. Ob es geht
refer to what I last said
Yes, sometimes
Why am I getting this error? My goal is to show if the server owners on the servers where the bot is located have voted or not
Too Many Requests
aka you got ratelimited on whatever endpoint you wanted to use
Don't spam the API with requests
Only thing you can do now is wait, and after that don't spam the API with requests
my bot shares random gifs to the specified channels so when the server owners don't vote that system will be automatically shut down I use client.guilds.cache.map
how are you checking that the owners voted
You're probably checking every X time for every single server, so you're spamming the API and therefore get rate limited.
const topSdk = require("@top-gg/sdk");
let topApi = new topSdk.Api(config.api_key, client);
client.guilds.cache.map(async guild => {
const owner = await guild.fetchOwner();
await topApi?.hasVoted(owner.id).then(async voted => {```
yeah thats your issue
you're essentially getting yourself ratelimited right away
consider using webhooks, collecting the votes and checking if they voted internally
when they vote, let me record it on mongodb and then check whether they vote or not, right?
yes
For example, we save the person after voting, either the time has expired or the right to vote again has come, can we pull it from the topgg api example; app.post('/vote/del')
I'm not sure what you mean
are you referring to when a user can vote again that your webhook should be notified?
I save the voter with mongo db and then I want it to be deleted after 12 hours. There is a feature like mongo db ttl automatic deletion for this, but I could not do it. do you have any information?
A much easier way is to progress a delete-on-request action
Means you’re storing the timestamp when the user voted in your database
Then the next time you have to check the last voting status you check the saved timestamp and the current timestamp to see if it’s older than 12 hours
If so delete the record, if not keep it
Iterating through the entire database to remove those records doesn’t seem to be really efficient or needed imo
It might be easier to just spend more time looking into TTL indexes.
I don't use mongo, but they seem really simple.
https://www.mongodb.com/docs/manual/core/index-ttl/
imagine ruining my entire point with this
I'm getting 400 errors when posting stats, I'm not sure if it's because I'm only sending the server_count field
Because the last time I sent it was several months ago, the topgg record was like around 10k servers, and we have grown to over 100k
Is it suspected by topgg that the number is incorrect?
post your code
fetch(`https://top.gg/api/bots/${bot.id}/stats`, {
method: 'POST',
headers: {
Authorization: process.env.TOPGG_TOKEN
},
body: JSON.stringify({
server_count: counts
})
})
i got twilight-gateway as my gateway, then discordeno for handling commands, so i can only retrieve total guilds
Its possibly because you're missing the content type header
if(client.config.voteManager.status === true && client.config.voteManager.api_key){
const { AutoPoster } = require('topgg-autoposter')
const ap = AutoPoster(client.config.voteManager.api_key, client)
ap.on('posted', () => {
})
}```this is how I send server count
umm guys
{ error: 'Required parameter server_count or shards missing' }
i am getting this error
body:JSON.stringify({
server_count:123456,
})
while using this
how ?
ohhhhhhhhhhhhhhhhhh tysm ill try now
i always forget to add content type
I want him to delete the data after two minutes, but he doesn't delete it, what's the problem?
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const schema = new Schema({ UserID: String,
expireAt: { type: Date, default: Date.now, index: { expires: "2m" } } });
module.exports = mongoose.model("nsfwvote", schema);```
ohh content type header
my goal is normally to save it after the person has voted and delete the data after 12 hours
it returns 200 now but the number is not updated
my bot id is 584213384409382953
would you like to try what I shared above? @balmy root
#development please
It can rake awhile to update visually on the site.
i'm sorry :(
im not using discord.js so i think this would not be working for me
its updated
tysm
pins under My bot can receive webhook requests once someone votes. How can I let Top.gg know about these?
yes, you're planning on wanting to use webhooks like before
yes
webhooks
https://pypi.org/project/topggpy/ there's also an example implementation on using webhooks
that should be enough, might need to change that password later as that is the authorization used by top.gg
yes
on this channel
yes
what you're essentially doing here with .run is starting a webserver through your bot. Through this webserver you're able to receive http requests. Top.gg can use that to let you know when someone has voted.
The requirement is though that the port 5000 is publicly accessible. If your bot is on a VPS for example, it would be something like http://yourserverip:5000/dblwebhook
I suggest you to read https://zapier.com/blog/what-are-webhooks/ to understand the concept of webhooks
you need something to handle these http requests, directly doing it through your bot is the most convenient one
u have to host ur bot to get an ip
or u can also host locally but u have forward ur port
which can be done through ur modem or router settings
for that particular ip
Bump
yep thats it
Hey,
is there something wrong with the api?
Somehow it's not responding...
I'm using Java
define "not responding"
what tells you it is not responding? Post your code
we can't do much with that statement
Hi
TopGGAPIError: 401 Unauthorized (You need a token for this endpoint)
Can anyone help?
I have the token already
from top.gg
You're not using a valid one then
press regenerate
refresh the site, then copy the token
What to do?
please read the pinned messages
The question is what you want to do?
How can u help
People can only help u if you tell em what u wanna do
I'm using topggpy and this is my code:
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("/dbl", "myauthcode")
client.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":
# this is roughly equivalent to
# return await on_dbl_test(data) in this case
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}")
and im not getting the test vote printed to the console. could anyone help me?
read the pinned messages
what would i put this as?
also refer to the pinned messages
My bot can receive webhook requests once someone votes. How can I let Top.gg know about these?
- You can let Top.gg know about your webhook urls through your server/bot page settings.
on bot pages, under https://top.gg/bot/yourbotid/webhooks
on server pages, under https://top.gg/servers/yourbotid/webhooks
- The Webhook URL field should contain your publicly accessible webhook url. These can be either a domain for example https://mybot.com/webhook or an IP-Address such as http://1.1.1.1/webhook. Port-based URLs work too, such as https://1.1.1.1:5000/webhook
- The Authorization should contain text that allows you to confirm that the webhook request indeed came from Top.gg.
More help such as what data Top.gg sends and about the use of Retrials can be found at https://docs.top.gg/
ah
How do I check if the user with ID 123 has voted for the bot with the xxxx token
wdym xxxx token
I do not understand
What I need is to check whether the user with the id 573504001732116490 has voted for the bot. ||Vote Check||
https://docs.top.gg/api/bot/#individual-user-vote is your pick then
how can i fix this error,????? ping if u have solution
Wait and try again later
Hey is it working?
Idk is it
-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.
Can u give me full source code of thT
Once again all you need to receive vote webhooks from topgg or how to do api requests is described in the docs
If you got trouble with that, post your code and error and a short explanation
Unauthorized What kind of request do you need to send? Is there an example for JavaScript?
I’m using topggpy and for some reason the test vote event is working (printing to console) but the normal vote isn’t working.
well we cant do much with code
without 
without yeah
🤔 are you sure your incrementing line is actually running correctly?
it might be easier to both sql lines in one.
There's no reason you couldn't
insert a new row if the user hasn't voted previously
if they have update the row
and select the data on the row(result)
all in the same query.
you're using the resultset from before the update
also what woo said, it's more efficient to do that
or well, more clean
It should be more efficient.
Two db requests should be slower, especially if its not a local database.
hey i want help.
i was trying to listen to topgg webhook
whenever i vote it doesn't log anything as well as the test webhook also doesn't logs anything
am i doing anything wrong?
i have put the webhook in the top.gg/bot/id/webhooks part properly
is your webhook URL publicly accessible?
nvm i fixed it. i forgot to convert the request to json
anyways thanks for trying to help 👍
anyone here that uses aoi.js idk how to setup the voting reward thing
uhm? no discord.js/aoi.js
do you need a website to detect votes?
just wanting to setup some sort of vote tracker for my own bot
you need a webserver (either externally or provided through your bot directly) that is publicly accessible
refer to the pinned messages
What is the authorization on the webhooks page?
Is that the auth for the webhook?
like whatevers after the url
@rain heart so you can't detect votes etc with just a discord bot?
no you set that yourself to verify the requests are from top.gg
no you need a web server that top.gg will send requests to
I think I got the webserver but for some reason nothing happens when I press test
onst express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express() // Your express app
const webhook = new Topgg.Webhook('redacted') // add your Top.gg webhook authorization (not bot token)
app.post('/dblwebhook', webhook.listener(vote => {
// vote is your vote object
console.log(vote.user) // 221221226561929217
})) // attach the middleware
app.listen(8059) // your port
If your hosting it locally you’ll need port forwarding
refer to the pinned messages
Did topgg remove server count from their widgets?
If so, is there a way to opt in again?
Pleas ing me when replying
could you elaborate what tells you server counts were removed
Previously this would also display server count
Looks like you haven't posted your bots server count yet.
Hm but I have... though it is not displaying on the website anymore
I have not changed any code
Can you check if I got ratelimited?
But even then, previous data exists
Shouldn't topgg just take the last posted count?
Interesting, I will check if it's the same tomorrow, if so I will investigate. May just be unfortunate timing with caching Ig?
Thanks for the help
is the api down? we cant seem to reach it even though it worked previously
Any idea on this?
I have been trying to create a webhook on a discord bot and ive finally got it but keep getting this error when i send a test from top.gg
any idea how to fix this?
🤔 are you using the topgg-py library?
yes i am
ive got the same code as in the example on the api docs for receiving test votes and votes
and when i send a test vote, it sends this error repeatedly every few seconds, i assume a timeout retry
Its strange that it happens on a test vote.
is the test event firing?
it doesnt look like it, it looks like it just errors straight as it recieves data, before it can go through any of the events in the code
Everyone always asks this question and I hate it, but is it possible your host is preventing the request from completing?
Are you possibly sending something to discord(or anywhere else) in the event and that's causing the error?
Or that your thread is being pushed really hard, and the request times out before its handled?
i will do a few tests using a test bot and other applications and see if i can get any different results, there seems to be some problems with the hosting service at the moment but that might just be on my end, but i will give a couple things a try
The error says its an invalid http method, which if it was a result of a bug on Top.gg's webhooks end I would see it on my webhooks too.
An idea, could you be receiving these errors from someone else(it sounds like its from topgg, but I'm just double checking)?
Another idea, do you have accented characters in your request? ex: é in the authorization on top.gg
I know that can cause some issues.
im not sure, ive set up the firewall on the hosting service to accept packets from the ip on the documentation, and my bot is clearly recieveing data when i press the test button, nothing happens until i press test, and then when i press it it starts saying these errors again
Are you using accented or unicode characters in your auth or url?
nope :/
@jaunty plank i have figured out the problem
o what was it?
the link i was using on topgg website i used "https" the secure http request, but obviously python bots dont use that format of http
i just changed it to a "http://" requst and i get all of the information
I didn't even think python would give an error on that and just ignore the request, if you had any other issue I would have asked about that!
Fascinating. Thanks for figuring it out.
thats actually really interested me, it must just be a completely different format, and it might be to prevent this exact thing so loose code cant just get information from a https request
thank you for your help!
https://top.gg/api/client/entities/search?platform=discord&entityType=bot&amount= is there any way i can use this but set it to newer bots
?
i get the same bot over and over again
@jaunty plank <@&817055174613794826>
I don't have any experience with endpoints that are not documented.
I won't really be helpful here.
u know who does?
Nope, I dont sorry.
It's an undocumented endpoint Ive never seen anyone ask for support for one.
Who manages ur api
Our developers? They don't provide customer support.
You might need to send a support ticket, but I have a feeling they will send you here, or tell you we don't provide support for undocumented endpoints.
the API endpoint is undocumented and may not return results you'd expect
thus no support
yeah its for the website but it works alot better then the imported api
😫
Maybe it's my time to shine and finally get the occasion to ask this to someone like you
Why on earth do people create such useless servers?
One message removed from a suspended account.
that will not crash the discord api
wym
Pretty sure you can't get 100k bots in a server nonetheless.
Other than that, discussing such things is against Discord ToS and against the rules of the server - so please stop
You won't get help to abuse our API and Discord's API.
my guy 💀
You might want to reread that
That as well
im using python top.gg api to run this ```py
client = commands.Bot(command_prefix="$", intents = intents)
client.topggpy = topgg.DBLClient(client, os.environ["topgg_token"], autopost=False)
and it is raising this error ```
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
how do i fix
pls
Pls help
hello, i need some help
i need to run a function as soon as a user upvotes my bot….
i also need to get the name/id of the user who upvotes my bot, so that my bot can dm them
pls help me
both things can only be done on an approved bot
mine is approved
Got to love luca going down all the time
this might be helpful. https://docs.top.gg/resources/webhooks/
We dont provide the name with the webhook. We do provide the user ID though, which can be used to fetch the user via your bot & the discord API if you need it.
ok thanks
POST /api/bots/:botid/stats?server_count=10 Is it correct?
I'm getting the error how do I do it
{ error: 'Required parameter server_count or shards missing' }```
How should I use
endpoint takes in a json body, not query parameters
Is there an example?
Simply search on the internet how to make a POST request in the language you're using
@restive otter
thanks i did 🎉
I want to get request vote reminder, what does it send?
Our webhooks dont provide vote reminders. Vote reminders you would need to create on your end.
i mean, when user click on the button remind after vote
what does api send to my server?
it doesnt send anything to you
only to the user
thankyou
hello, I'd like to know how can I check whether a certain user voted my bot on top.gg with the API
check weather??
sorry typo
If you're only goal is to check, you are probably looking for this.
https://docs.top.gg/api/bot/#individual-user-vote
If you're looking for an event, youll want to use webhooks.
not an event actually but I'm trying to check if the user voted on not before executing a certain command
I assume error: "Unauthorized" means that the user hasn't voted
ah i need to pass a header
Just a note, the ratelimit on that endpoint isn't very high.
If the command is ran somewhat frequently you probably will hit a ratelimit on topgg.
how can i check if a user has voted in the last 12 hours? (JS)
tysm!
i need some help, i want to add query params safe search for api suggest.google.com but i don't know query about it?
it search for youtube music
That is not seem related to Top.gg's API. Consider asking in #development
https://docs.top.gg/api/@reference/ doesn't mention anything about any servers related endpoints
and if you were able to discover any using inspect element, these are undocumented and will not receive support for until these are officially supported
suddenly my bot webhook does get request from api. I don't know what's wrong with it
I haven't made any changes, it still received yesterday but not today.
I tried send test, but it still doesn't response
My Vote endpoint gets triggered seperately multiple time (exactly 10 times) on vote
Anyone else facing this? Could also be an Issue on my Providers site
if you're not responding with a 2xx and/or the request times out, retrial will occur
refer to the docs under retrial
hm could be that the response takes to long yes
My webhook doesn't get request from Topgg API
I added this to my client
makeCache: Options.cacheWithLimits({
...Options.DefaultMakeCacheSettings,
GuildMemberManager: {
maxSize: 200,
keepOverLimit: member => member.id === client.user.id,
},
}),
sweepers: {
...Options.DefaultSweeperSettings,
messages: {
interval: 3600, // Every hour...
lifetime: 604800000, // Remove messages older than 7 days.
},
},
Does it related?
my Webhook from Topgg is now bugged
I can no longer receive request from vote
is that any changes in API?
dont randomly ping staff members, wait for someone who can help
sorry for that
my Webhook got wrong from yesterday, I've tried many ways but unsuccessful
what the wrong?
send me error AxiosError: Request failed with status code 401
idk where proplem
These two values are identifiers and have been confirmed more than once
Actually try to regenerate your token a few times before trying to post the server count again
Also don't forget to update the token in config after
regenerate your token do you mean change token topgg?
Yes
thanks
can barely make out any structure, could you post your code on pastebin or in a codeblock here
Can I have help with making a vote webhook for my bot, I’ve never done it before and I’ve tried to do it but it doesn’t seem to work.
Maybe I’m doing it wrong, but need help with it in general
No errors and no code, nobody can help unfortunately
dblapi.js has been deprecated for years.
try using our library https://docs.top.gg/libraries/javascript/
This is confusing, what would I do just to get the test thing to send to a channel?
if that is your only goal, third party sites offer that(you can find them easily on google).
But, if you want to implement it in your code you need to use your own webhooks.
I’m trying to implement it into my code, and I have a webhook for my votes channel for testing but not working
🤔 not a discord webhook right?
uhh, it is a discord webhook I think
Topgg webhooks are not discord webhooks.
The url to your webserver hosting your webhook listener.
Odds are your bot is hosted somewhere that has a public ip, or url.
My bot is currently hosted on Heroku so I don’t know about that
Heroku provides web dynos with a url.

https://devcenter.heroku.com/articles/dynos#web-dynos
[name of app].herokuapp.com
Ok
Hi
I want to know what is the topgg api for the voting and how to get it to work
I'm assuming you need help with setting up voting rewards/a way to get to know who and when a person voted
This is what you need to take a read of! https://docs.top.gg/resources/webhooks/
thank you
I've made a file called Topgg.js
And written the webhook on that.
then I exports to index.js like this
const { AutoPoster } = require('topgg-autoposter')
const ap = AutoPoster(process.env.TOPGGtoken, client)
ap.on('posted', () => {
console.log('Đã xuất thống kê lên Top.gg!'.bold.brightGreen)
})
const { init } = require('./Topgg')
init(client)
and my process can't receive posted request from TopGG votes..
can anyone tell me where I was wrong?
Well, that is not a webhook listener
That simply posts your server counter automatically
"not working" is not very helpful
Though that still doesn't change the fact that this is not a webhook, so you can't listen to POST requests which is normal
Look at the documentation there are examples for both of them
I mean here is the top.gg file
I exported it as a function
and called on index
but it's can't receive any post even test
Probably want to use a pasting service to not flood the chat and make it easier for everyone to read
wait a sec, I'll post it on source bin
here's the file
i have the same problem :(
i just needed vote system for the music system like hydra bot thank you
What Enigma linked if your way to go, you won't get spoon-fed with code unfortunately
for the update_stats tasks.loop whats the minimal loop time we can set it to?
You really don't need less than 30 minutes, our site cache only updates every 30 minutes to an hour.
oh ok
@tasks.loop(minutes=30)
async def update_stats():
try:
await client.topggpy.post_guild_count()
print(f"Posted server count ({client.topggpy.guild_count})")
except Exception as e:
print(f"Failed to post server count\n{e.__class__.__name__}: {e}"
update_stats.start()
AttributeError: loop attribute cannot be accessed in non-async contexts. Consider using either an asynchronous main function and passing it to asyncio.run or using asynchronous initialisation hooks such as Client.setup_hook```
idk if this is a discord.py issue or a top.gg
and it not the loop
cause i took out update_stats.start()
One message removed from a suspended account.
One message removed from a suspended account.
I'm assuming its like trying to await outside of async. I don't know python either.
but; https://gist.github.com/Rapptz/6706e1c8f23ac27c98cee4dd985c8120#interactions-with-exttasks
class MyClient(commands.AutoShardedBot):
def __init__(self, *, intents: discord.Intents):
super().__init__(intents=intents, command_prefix=check_prefix)
async def setup_hook(self):
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
await self.load_extension(f'cogs.{filename[:-3]}')
await self.load_extension('jishaku')
async with client:
update_stats.start()
await client.start(token)```
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```
Traceback (most recent call last):
File "main.py", line 69, in <module>
client.topggpy = topgg.DBLClient(client, dbl_token)
File "python3.8/site-packages/topgg/client.py", line 98, in __init__
self.http = HTTPClient(token, loop=self.loop, session=kwargs.get("session"))
File "python3.8/site-packages/topgg/http.py", line 84, in __init__
self.session = kwargs.get("session") or aiohttp.ClientSession(loop=self.loop)
File "python3.8/site-packages/aiohttp/client.py", line 227, in __init__
loop = get_running_loop(loop)
File "python3.8/site-packages/aiohttp/helpers.py", line 289, in get_running_loop
if not loop.is_running():
File "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```
i did it in setup_hook
fixed it
nvm not loggin now
now the bot doesnt want to work
@jaunty plank
been stuck for 11 mins
class MyClient(commands.AutoShardedBot):
def __init__(self, *, intents: discord.Intents):
super().__init__(intents=intents, command_prefix=check_prefix)
async def setup_hook(self):
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
await self.load_extension(f'cogs.{filename[:-3]}')
await self.load_extension('jishaku')
dbl_token = "token" # set this to your bot's Top.gg token
client.topggpy = topgg.DBLClient(client, dbl_token)
await update_stats.start()
@tasks.loop(minutes=30)
async def update_stats():
try:
await client.topggpy.post_guild_count()
print(f"Posted server count ({client.topggpy.guild_count})")
except Exception as e:
print(f"Failed to post server count\n{e.__class__.__name__}: {e}")
I dont know python sorry
oop
why does it won't send anything even test votes. i already provided webhook url and auth both in top.gg and in code.
library: topggpy (1.4.0)
class FirstCog(commands.Cog):
def __init__(self, client: Client):
self.client = client
self.top_gg_client = topgg.DBLClient(bot=self.client, token=topgg_token, autopost=True)
self.webhook_manager = topgg.WebhookManager(self.client).dbl_webhook("/webhook", auth)
self.webhook_manager.run(2333)
@commands.Cog.listener()
async def on_dbl_vote(self, 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 self.client.dispatch('dbl_test', data)
print(f"Received a vote:\n{data}")
@commands.Cog.listener()
async def on_dbl_test(self, 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}")
that url doesnt seem to be properly formatted.
http://IP:2333/webhook
looks like you may be using http:/ not http://
Also, the IP seems to be way too short to be an ip
i changed it to http://127.0.0.1:5000/webhook since it was run locally. still no response.
127.0.0.1 is localhost
we(the site) need to be able to reach your server
alr. i'll try again. thanks
If you're hosting locally youll need to use your public ip address, and you'll need to change some router settings to port forward.
nodejs version?
One message removed from a suspended account.
Correct
19.x.x
NVM it fixed on restarting the bot automatically
Hey, the python library is still maintained? 'Cause I can't make it work and I'm not the only one
I dont think we have anyone currently maintaining it, but it should be working.
What is the issue you're facing?
Top.gg does not support discord webhooks by itself #topgg-api message
ty
I followed the example on https://docs.top.gg/libraries/python/ to post the guild count.
At first I didn't understand what bot.topggpy was, so I tried replacing it with several things, including my discord.commands.Bot instance. But that didn't work, and I saw that in the documentation the bot.topggpy.DBLClient function took an instance of discord.Client as a bot parameter. So in my code in addition to doing discord_bot=commands.Bot(command_prefix=config.PREFIX, intents=intents) I did client=discord.Client() but it still doesn't work, in all tests it returns me several errors caused by topgg.DBLClient(). I think the library uses endpoints / functions that no longer exist or are obsolete
The loop attribute error from what ive gathered is an error related to changes in the way loops work in discord py. Which can be fixed by modifying the example.
https://gist.github.com/Rapptz/6706e1c8f23ac27c98cee4dd985c8120#interactions-with-exttasksI
Interestingly, when searching the py libraries code, it doesn't seem to use _connector anywhere.
It's possible it's used in a deprecated function(or I just didn't search properly), but I'd have no way of finding if it's a deprecated function not using python before.
That said, if you find any deprecated functions we are using you should submit a pr request and let me know.
Ok, i wrote ```python
client = discord.Client(intents = intents)
@client.event
async def on_ready():
print("client")
dbl_token = config.TOPGG_TOKEN
client.topggpy = topgg.DBLClient(client, dbl_token, autopost=True, post_shard_count=False)
@client.event
async def on_autopost_success():
print(f"Posted server count ({client.topggpy.guild_count})")
client.run(config.TOKEN)```
It's not exactly as it says in the link you sent me but it was just to see if it worked once.
And the bot return "Posted server count (116)" so i think its good. There is a delay between the bot posted and topgg show in the website ?
Its 2am in my house so i go to bed, i see tomorrow
It really is very simply... just don't forget to provide the authorization and content type in the header and your server count as body
how long does it take until my server count on top.gg updates
nevermind it updated
for webhooks
is the bot approved?
Webhooks/tokens are not usable on unapproved bots
oh
it is not approved
how do i find my dbl token?
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
It works @jaunty plank, even with a discord.command.Bot instance. You just need to redo the documentation. Here is my code :```python
discord_bot = commands.Bot(command_prefix = config.PREFIX, intents = intents)
@discord_bot.event
async def on_ready():
dbl_token = config.TOPGG_TOKEN
discord_bot.topggpy = topgg.DBLClient(discord_bot, dbl_token, autopost=True, post_shard_count=True)
@discord_bot.event
async def on_autopost_success():
print(f"Posted server count ({discord_bot.topggpy.guild_count}), shard count ({discord_bot.shard_count})")
discord_bot.run(config.TOKEN)```
I'll be back in a few days to say if it still works
Should just make the example more complete, the library itself needs some changes though
But since the maintainer is banned from Top.gg, won't happen any time soon until someone decides to do it 
Anyone can submit a PR though, once we have verification the new example works we can have an employee push it.
I wouldn't mind doing it, but I consider that I don't have the skills required for it yet, I'm still a beginner, but maybe one day then 👀
The thing is that the api is not super complex
So lots of people don't even use the sdk hence don't notice the issues with it
I see, but in theory using the sdk is easier than using the api, isn't it ?
Not really no
eh, imo its not easier.
I dont know python and I feel like I could get it setup faster without the sdk.
theres so many online resources for learning to use an api in python
it's true that now for topgg it would have been faster to use the api, but with a updated documentation using the sdk would have been faster
tbf most sdks need a rewrite
I don't see how, for example in Python, topgg.DBLClient makes any sense
And why it has been approved like that
Package name clearly shows it was after the brand rename from dbl to top.gg
because that package originated from back when top.gg was called DBL, which would break entirely if the class was renamed
is my fair guess
the client that package is based on was DBLClient, aka from back when the term DBL was still used
Correct
Now here comes my question
Why was the package renamed from dbl to topgg
But the class kept to DBLClient
Yes it was named dbl.DBLClient before
Or actually just dbl.Client but doesn't matter
Old code example
import dbl
import discord
from discord.ext import commands
class DiscordBotsOrgAPI(commands.Cog):
"""Handles interactions with the discordbots.org API"""
def __init__(self, bot):
self.bot = bot
self.token = 'dbl_token' # set this to your DBL token
self.dblpy = dbl.Client(self.bot, self.token, autopost=True)
# autopost will post your guild count every 30 minutes
def setup(bot):
bot.add_cog(DiscordBotsOrgAPI(bot))
It probably just wasn't thought about
So the package got renamed, but not the class
Ideally someone would rewrite the thing from scratch.
So I'm surprised it has even been approved
how do i use api to find if a user has voted?
I want a code. When a person votes, he receives a private message telling him “thank you.” I want the code to be Discord.js
We won't spoon feed you and are not working robots as well.
Use the documentation to get at least a base code and then we can help you fix your issues => https://docs.top.gg
How can i create a webhook
Server settings
I know is old post, but this help me, thank you
Please help me
Am really in need of help now
Please
Guys
Am hungry
And I don't have money to eat
I and my family have not eating over 2days now,
Please 🙏
Help me
uh
Poor begger don't beg code here 😂😂
Please mate am really Hungry
check the pins
im legally blind
the last pinned message #topgg-api message+
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
I’m not sure how I’m suppose to help with that
When I am using python API Wrapper, what webhook url should i use
This isn’t library specific, your webhook url should be a url of your public web server listening to POST requests from top.gg
Hey, is there a way from the topgg api that i save the user's vote and check if it's like a votes streak or not?
Like if they voted for 2 days in a row and forget to vote in the 3rd day the total votes reset to 0
Okay
Hi, so I've read the docs for the python on_dbl_vote, but I've put it in a cog and nothing is returning.
Am I allowed to put it in a cog, or does it have to be in the main file
self.bot.topgg_webhook = topgg.WebhookManager(self..bot).dbl_webhook("/dblwebhook", "password")
and is the /dblwebhook this?
You need to host the webhook on a reachable web server, aka not your computer, and write that down in the webhook URL, will most likely be http://<ip>/dblwebhook
ok thanks, and then do I put that in the webhook url settings?
Correct
excellent thanks
That question isn't specifically api related, so #development is the better place
Just log your var result and you will possibly see the issue already
Since you didn't show the initial statement to get the user data, there's not much more help possible
Also a few tips, when incrementing the data field, use the field as value, e.g. SET votecount = votecount + 1
Also since time and votecount seem to be an integer, then set INT as field type (if you haven't done already)
This will also require you to update the INSERT statement
The placeholder would be %i for numeric field types
Doesn't make any sense to convert the string to a number all the time
For any SQL related engine
But still that won't fix your issue until you show the initial statement and log result to be able see the issue
Now let's move to #development since this isn't api related

Where is Total Votes?
points is the total votes of the bot.
How to show it vote tracker
like Thanks for Voting Kronton
Total Votes is - 500
You'll need to use webhooks(not discord webhooks).
https://docs.top.gg/resources/webhooks/
for some reason i have been receiving this error
i tried hosting my bot on other device, and it work
nvm it was a incorrect token
Is there any way to "test vote" just trying to figure out the webhook atm
Where do you see this
same place where you got your webhook token, where you've put the webhook url and where you've set the webhook authorization password
What do you put in the webhook url?
the url to the endpoint
no
i don't know. my bot still works fine and it's returning a number for me.
0 has not voted
1 has voted
well it seems like an issue on your end
nothing has changed my bot has been running the same code for our vote command for months and it's working fine.
have you checked what it's returning?
if your checking if its greater than 0 would it not work either way then? i believe it's something on your end though.
it's something on your end.
try posting your code in #development. the api is returning 1 and 0 for me.
also, why do i randomly get these errors
- gateway timeout
I've been getting those 401 too for a few days
The weirdest part is how random it seems, sometimes days pass without a problem and sometimes I get three in a single afternoon
yeah
more of them 🙀
👀 are they occurring sporadically?
Yup
For me the hour always ends in 05 or 35 but I guess it's because topgg-autoposter triggers every half hour and it sometimes just... fails?
Look at these for instance. I got a bunch on the 20th, and a few others today. In-between, all good.
aaaaand I just got one, right now.
seems so
just started around the 20th?
Its possibly related to some other issues we've been having with bots voting pages disappearing for a bit then coming back.
hm
20th is the earliest I got one yes
Its possible it started on the 19th too.
the errors probably can be safely caught and ignored, its most likely a site issue.
A possible solution might be to regenerate the token, but its unlikely to fix anything.
yeah
can i post stat without this?
ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
})
Thats just an event
(so the answer is yes)
can someone help me fix my python code
Wrong server
huh ?
There are plenty of servers about devving and even more specifically Python but this ain't one of them.
People can ask about python in #development.
oh thx
but generally we don't have many python devs here for some reason.
{ error: 'Required parameter server_count or shards missing' }
let todo = {
"server_count": 312,
"shards": 1000
};
fetch('https://top.gg/api/bots/1014207340188270673/stats', {
method: 'POST',
body: JSON.stringify(todo),
headers: { "Authorization": botConfig.voteAuth }
})```
Did you post it in the development room? i don't see it
nope how can i post so casually
you mean like this?
your code is here
or sth else?
someone skilled at it can only help
we should really change channels though
sth else
You're missing the content type header
how can i specify the content type?
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type
You just need to add
"Content-Type": "application/json"
As a header like you're doing with authorization
It's one line of code
lets say i make a post request and say my bot is in 1000 servers.
How will it check that thats even true
cant ppl just say there bot is in 10mil servers or will it check for it
It depends.
Some libraeies will add it for you.
Yeah, if we receive reports of you posting the wrong count we will manually check.
well it doesnt check
you could make it a billion
i have
And that's a good way to get banned from the bot list
would be dumb on antother level 🤡
Server owners see on how many servers a bot is active when they invite the bot. if the desciption reads 1_000_000 and discord tells 'em it's actually 5, it would seem very fish and probably prompt users to abbort the invitation.
so
🚨🚨
Hey, i just want to point that some months ago, i had an issue with one users voting in the page, but when i was asking for their vote status the API was returning false. One day, the issue just stopped by itself, but now it's happening again with some other user. Other users are just fine as far as i know
I don't know if that's a bug or something related, but yeah, i just wanted to know if you ever had the same issue
I dont think that issue has been reported by anyone else.
That said that endpoint is generally reccomend as temporary solution.
Using webhooks and storing votes is the better way to handle tracking votes or vote locking commands.
It sounds like a really rare issue, and it probably isn't something that can be looked into anytime soon.
how i can make vote only command using top.gg? in discord.py
https://docs.top.gg/api/bot/#individual-user-vote make a GET request to that endpoint
hey, how can i fix this error?? it's so annoying
Very simple, you stop spamming the API with tons of requests
i just send a request once my bot joins a guild or leave
what's the minimum requests limit?
@restive otter
I'd recommend not using topgg for that 
why just update it every 24 hours
hey so i have no idea why im getting this error when it should request the person using the bot to vote for my discord bot
this is what I have
i thought this was going to be easier but i guess i did something wrong and I have no idea what to do
soo, im not receiving any errors in the console but the vote that should be required for my commands dont seem to be responding
what's the request limit?
when using api endpoints tying to set the server count i get "error": "Unexpected token s in JSON at position 0"
60/minute I believe
Because it expects JSON but you’re sending url encoded values
Those 2 are different
-> moving this here from #support : Why is my bot page listing my Server Count as 1 even though it is in 5 Servers and I'm pretty sure I passed the right amount to the api 🤔
When did you last posted the metrics
Yesterday... and it has been on 5 then
Post again, and make sure you don't have some background tasks that may put it back to 1
Didn't change
what was the nodejs module to check if user has voted
Can take up to 30 minutes to show
Ah ok
https://docs.top.gg/ use the library you need
k ty
Seems like you've only posted the first time statistics around 3 hours ago
Before that it has always been at 0
Huh? I think I restarted my bot 3 hours ago or so, but it showed 1 before that
So it never showed 5 on the site
Actually I just added a check to my bot and it seems it sends 0 🤔 Sent Servercount of 0 to top.gg! I might have to fix something on my side
Looks like it, feel free to share the code here if you need help regarding that
The weird thing is, I used the same code that works somewhere else
Oh wait... I think I might be getting the Servercount before the bot is fully started
Sent Servercount of 5 to top.gg! Nice :)
const topgg = require('@top-gg/sdk')
const tapi = new topgg.Api(config.topggtoken)``` is this wrong? because i get you need a token for this endpoint error
oh my bad
Okay
topggtoken was incorrect, i fixed it but i still get the same error
still same
now i receive if the user has voted but still gives an error
i dont get any data from top.gg now 😃
yeah well without errors and code, nobody can help 
im 100% sure topgg token is true
Most likely not
lemme try again
make sure you regenerate a token and then refresh the page before copying it
yes i do that
it's working now, i was 100% sure topgg token was true 😃
4|ares | TopGGAPIError: 504 Gateway Time-out
4|ares | at Api._request (/home/ubuntu/Ares/node_modules/@top-gg/sdk/dist/structs/Api.js:76:19)
4|ares | at runMicrotasks (<anonymous>)
4|ares | at processTicksAndRejections (node:internal/process/task_queues:96:5)
4|ares | at async hasVoted (/home/ubuntu/Ares/commands/information/profile.js:73:15)
4|ares | at async getBadges (/home/ubuntu/Ares/commands/information/profile.js:41:15)
4|ares | at async Object.run (/home/ubuntu/Ares/commands/information/profile.js:23:18)
4|ares | at async AresClient.<anonymous> (/home/ubuntu/Ares/events/messageCreate.js:104:5) {
4|ares | response: Response {
4|ares | size: 0,
4|ares | timeout: 0,
4|ares | [Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
4|ares | [Symbol(Response internals)]: {
4|ares | url: 'https://top.gg/api/bots/check?userId=701643179212013568',
4|ares | status: 504,
4|ares | statusText: 'Gateway Time-out',
4|ares | headers: [Headers],
4|ares | counter: 0
4|ares | }
4|ares | }
4|ares | }
```why is this error coming?
is this because of the issue with the api?
Yes
oki
@top-gg/sdk is official package right
yes
Vote required command!!
Made by - Me
Follow the steps
Step 1
npm install @top-gg/sdk```
**Step 2** Put this in Index.js
```js
const { Api } = require ("top-gg/sdk");
client.topgg = new Api(top.gg token); //your top.gg token ```
**Step 3** Put this in InteractionCreate.js
```js
// Starting
let hasVoted = await client.topgg.hasVoted(interaction.user.id);
const voteme = new MessageEmbed()
.setTitle('Vote me to use this command')
.setDescription(`You must vote me on [TOP.GG](https://top.gg/bot/1016392200516550736) to use this command`)
.setFooter('Made by DEVANSH#4075')
.setColor('#03fcdb')
const actionRow = new MessageActionRow()
.addComponents([
new MessageButton()
.setLabel('Vote')
.setURL("https://top.gg/bot/1016392200516550736")
.setStyle("LINK")
.setEmoji("1018200886268412017")
.setDisabled(false)
])
if(cmd.voteOnly && !hasVoted){
return interaction.followUp({embeds: [voteme] , components: [actionRow]}
);
}
//Made by DEVANSH#4075
//ending```
**After doing this come in your command on module export and put ```js
voteOnly: true,``` and its working!**
Output =>
what an horrible solution
imagine doing an API request whenever a command interaction happens
Be nice
also this isn't a promotion channel especially when recommending possible API spam
whats the point of the endpoint then
literal husk code
Ideally when using hasvoted, you would cache results.
ie, if the endpoint returns 1, cache it for a few hours. if they haven't cache it for 5-10 minutes and tell them where and how to vote.
Even then, you're bound to hit ratelimits eventually, and api downtime will break those commands.
Ideally, hasvoted should be a temporary solution
once a beautiful day it might be a reliable way of handling votes
what if im lazy
😗
have fun with ratelimits
ill throttle it myself tho so no issues with that
Its one of those things where its not a problem unless many people are using it.
when it does become a problem it can result in dozens or hundreds of people trying to use a command they voted to get, and now cant get.
@west shoal
@cinder moat no ads here
help?
i got a lot of errors cause of their api
5xx are server errors, not client
but the lib returns it as an error
so they have to catch it
How do you show the server count of bot on topgg
read the docs
i figured it out
my bots servercount isn't showing (it's been recently approved). Is this just a recent approval thing or do i have to do something?
oh
how did you do this if you don't mind me asking
read the docs
thankyou
Does anyone use this code 😅
Do you have any better idea?
I created new webhook and put link here, but when i do send test it doesn send there. why
https://docs.top.gg/resources/webhooks/ you need to create your own web server with webhook
Alternatively you can use https://webhook-topgg.com/
Yes, HTML & CSS as well
Ok
Please once check my bot it is everything ok ?
I changed the description with html
No
Waiting time is up to 2 weeks and that for everyone
Oh bro my bot is already approved i was telling that like i updated my description so check it! That everything ok and following top.gg tos
Seems fine, just note that all your Activities Command are against Discord's ToS
Oh
Should I remove that from description?
You should remove that from your bot entirely
Yes, either cache the results for a certain time per user using your commands or much better, let topgg send webhooks to your endpoint once somebody votes.
You can still get rate limited quickly when multiple people are using commands fast and frequently, not so when using webhooks.
The data you receive from topgg includes the Discord user ID. The time you receive it, is the timestamp when the vote happens.
Store both in a database and query the database when executing a command.
You can now cache the result for the time you saved in your database + 12 hours.
After the user needs to vote again.
Over all the most recommended and useful way.
Hindi me bata dogee?
Try to respond in English so others can understand you
But i didn't understand what you say
What part of it you don't understand?
Whole
I'm getting this error: Error: 401 Unauthorized (You need a token for this endpoint)
I've tried regenerating the token and applying it, but it persists.
Where?
in my console?
Lots of people are currently experiencing this issue
It’s an issue on the server site, not your site
You don’t need to regenerate your token
That won’t fix the issue as you already noticed
alright
yeah i was getting this too as fake says it seems to be an issue with top.gg
hii, I'm using requestbin to detect votes in top.gg, but the code just isn't detecting, does anyone knows what is the problem?
Pretty much doubt you have to add the FQDM and path as option to your app.post() method
I also tried using ip
Another thing is regarding your first screenshot the protocol is HTTP not HTTPS
I also changed https to http
You don't add this, too
You usually just specify the path
It will be bind to your server ip per default since your didn't specify anything as option inside app.listen() except the port
app.post("/dblwebhook", ...);
The URL to enter on topgg then is http://<ip>:3200/dblwebhook
(or hostname)
Must be a valid A record not IPv6 (AAAA)
Where do I find the API stuff so I can give rewards for voting?
tysm
I'm new to this http stuff and it's hard 💀
Yep, just started experiencing this error :(
If you recently refreshed your token, try refreshing it again, then refreshing the page, then copying the token.
Most of the reports lately didn't touch their token before the error existed
Same goes for me
Same error randomly appearing after the app is running for months
did you get the 401 error sporadically(for a period of time) from the 19th-now?
then got them consistently after refreshing the token?
I think it may be two issues.
the 404 voting page issue I think resulted in bot tokens getting 401's.
Then some devs are refreshing tokens, but getting the refresh token bug
Could be since the 19th, can't tell you exactly atm
But no I haven't regenerate my token for months/years
still getting it sporadically? or did it stop yesterday?
oh, yea, refreshing the page after regenerating it fixed it. Thanks!
is authorization header required or can we do it in the url
It's required in the header.
hey! i got it to work
quick question, im coding a voting only command
will voted property only be 1 if they vote?
ik weekends count as double votes
so will it ever hit over 1? like 2
It's a boolean, 1 meaning true, 0 meaning false.




