#topgg-api
1 messages ยท Page 18 of 1
eagerly awaiting a fix :-)
I think that Ctrl + R restarting the server already solves itself like my bot :)
The API is still not back?
Another question related to sharding, do I need to make any changes to my top.gg code?
not yet
no when its fixed it'll work again
anything we can do to get the stats onto the site?
i see some bots having relatively active stats so they must be doing something
having the same issue
Damn still error code 500 gets thrown
and 405 on /bots/stats
@cold cairn Api down
Seems like only topgg autoposter is experiencing issues , webhooks which are coming from votes are perfectly working
the posting api isnt working
bunch of API issues should be resolved! not all, but majority
Please let us know if something specific isn't working still 
/api/bots with working again, many thanks ๐
I did check individual user vote and it returned true even though i didn't vote in the last 12 hours. I did vote in the last 24 hours though. I didn't change anything and this was working before for years
. Do i need to update anything? (I tried with the api module and using fetch)
API still not working?
/botid/stats work? @signal hawk
is it working for you?
I'm not at home right now but I want to know if it works or not
@jaunty plank
atleast it is no longer 405 :)
I told you what you should do, restart the machine and that's it.
machines have restarted around 24 times in the last day
if you delete the end point there won't be a 500 error anymore
DROP DATABASE :)
ez fix KEKW
Very little compared to what I restart my bot
Fine
i dont think u should be restarting that often broski
how many times do you restart your bot
LOL
up to 50 times by mistake :)
100 times if my free host no cooperate
stan veld
just use pm2, leave a bug in that crashes the bot, automatically restarted, memory leak proof.
my host rips me off so much they want to call me on monday 
do it slowly but surely
ez token burning speedrun impossible challenge
just automate refresh token
what is pm2 i am beginner :)
its a process manager
yesterday I discovered that they are shards
exactly
Not really, it keeps your bot online even if it crashes.
Or when you restart the server it auto starts.
vps?
@jaunty plank sounds interesting
PM2
If its not a vps I dont think you can use a process manager.
fck
search in google vps free 100% real for my verified discord bot partner please help i am poor
I mean, google themselves provide free VPS's
https://cloud.google.com/free/docs/free-cloud-features#compute
oracle does too
Error code that is returned recently changed
oh you recently have been having 500?
i've had the error code 500 for a good bit of time
/bots/ endpoints with issues @restive otter @dry mantle
humm @jaunty plank he get 405 and 500
uh
1 hour later
Hii
Veld is aware
hey is the api slow?
we call it progress
sorry i had to move on to a more pressing issue, afterwards I'll finish the API work
That means the API is still down.
hey veld, is there a specific role i can opt into so that i can get pinged when fixes to the api are pushed out
Are there any updates on the status of the api?
Still waiting for ...
we pushed more fixes yesterday but i slept afterwards
Veld works hard...sweating
@gritty hemlock 405 Method Not Allowed relatively Fixed but 500 Internal server error No
$top
has /<botid>/stats been fixed cuz i haven't seen any error from it in about 8-9 hours
the sdk libaries running all on /bots/stats without the bot_id component so i think this is most important to fix
still 405 for me
ig it just stopped trying to update for me then for some reasons but won't complain lol
also there's other bugs that are more important to fix
a fancy guild count isn't really important imo
It's fixed, but not deployed
should be deployed now
SOOOOOOOOOOO
?
yep works
it updated after i refreshed data
topgg before veld: it's weekend, we don't care
and after veld?
between veld
that sounds sus
it sounds that way you want it to sound
Can I get the last time a user voted from the api
the problem is everytime we post server count we have to click on refreshed data or it wont update. its a bug.
nah it just takes time to refresh most likely
Good morning everyone, apologize but I've got an odd issue coming from the get_user_vote method. Being given a type_error (<class 'TypeError'>, TypeError('string indices must be integers'), <traceback object at 0x7f4851584cc0>)
Any ideas what might be causing this?
Not really, it's something you need to track yourself
it's cached, so it takes some time, but generally you don't have to
sounds like you pass a string to smth that wants a number, though send your code here
voted = await ctx.bot.dblpy.get_user_vote(ctx.author.id)
According to this code in the DBLClient class provided by topggpy:
` async def get_user_vote(self, user_id: int) -> bool:
"""Gets information about a user's vote for your bot on Top.gg.
Args:
user_id (int)
ID of the user.
Returns:
:obj:`bool`: Info about the user's vote.
Raises:
:obj:`~.errors.ClientException`
If default_bot_id isn't provided when constructing the client.
:obj:`~.errors.ClientStateException`
If the client has been closed.
"""
if not self.default_bot_id:
raise errors.ClientException(
"you must set default_bot_id when constructing the client."
)
await self._ensure_session()
data = await self.http.get_user_vote(self.default_bot_id, user_id)
return bool(data["voted"])`
It should be providing me with a boolean?
This was working fine just a couple days ago
K guess I'll track it myself
looks like data is a string think you have to convert it to json
https://top.gg/api/bots/:id/check is sending "1" (true) even when i didn't vote in the last 12 hours
"voted": 1
}```
That's really odd. This isn't my method, that's from the official topggpy python Library:
https://pypi.org/project/topggpy/2.0.0a0/
Thanks for reporting -- found the issue
Is there documentation for vote rewards?
https://docs.top.gg/ is the top.gg docs
Thanks
Looks like for me it's returning a string:
'{"voted":0}'
Which could be why the Library method is no longer working?
this issue was fixed!
thank you so much!
when i check my id it says i didnt vote but when check my bot page it says i have to wait 2 hours to vote again. https://top.gg/api/bots/botid/check?userId=userid
i think its a bug
have u check https://webhook-topgg.com/ ? its easy to setup
same
didnt know that was a thing
whats going on with this vote stuff.... i get { voted: 0 } no matter what
i dont think thats the endpoint to check ig you voted
i use this one
oh nvm is the same im dumb ๐
๐ค let me see, a few hours ago i synced it up to the vote cooldown backend
so what does that mean for me
it means im deploying a fix for u rn
probably the reason why it stopped
being deployed now.
the problem was kinda stupid
Yay you fixed the stats posting ๐
thank you, can you update us when it does get fixed
@maiden pumice it's already fixed :)
can anyone know what could be the issue
for?
@vital anvil does avatar return the full avatar URL now instead of just the avatar hash?
ah yes 
we no longer store hashes, only urls
oh this would be pretty breaking lmao, you didn't tell this in the changelog

Did break our site :^)
is avatar nullable or not?
it is not nullable
thank you
top.gg fallback avatar?
why not something like this?
infra is built for not just discord
i see i see
thank you
does this apply to user avatars as well?
like /bots/{id}/votes
and will its extension be GIF if possible?
@vital anvil
I don't think so
oh okay
same goes for support 
Is that our api?
is support not nullable as well?
no, top.gg api
ah

thank you for updating the sdks
btw do you have plans to remove vanity any time soon?
no plans
thank you
vanity back when:(
Hi,
Is there a public API key, as I am currently working on a bot list and I am trying to get bot data from topGG to my bot list, the user has to press a "Find" bot that they will find the data from topGG on my list too
another - now abondened botlist - let bot devs put their own topgg token into a field to fetch bot data (idk if that was client side or not though)
though kinda silly to ask on top.gg how to "scrape" data for a competitor
no API keys can be retrieved without
having a bot listed, or becoming a library developer in which you would get your API token for testing your SDKs
i have a bot on topgg
Even if you had a token, it still has rate limits. Giving people the ability to click a button that would send requests to top.gg is not a very good idea

Yes, but you would have one token for the entire bot list
Lots of users, lots of bots, one token (assuming of course that anyone would use this bot list at all)
@vital anvil is donatebotguildid going away any time soon?
hey, is there any known issues with vote webhooks not including the referer?
for example I add a referer query to the vote url:
https://top.gg/bot/853327905357561948/vote?referer=EMBEDS.GiveawayEntered
I stopped getting this info on the 19th
yeah this is being re-added soon.
okay thanks ๐
Hello everyone, I tried to update my guild count with the tiny C# program below, basically copied from the docs for the dotnet library
The variable me appears to be set correctly, but when executing the UpdateStatsAsync method it returns a 400 Bad Request.
Anyone happen to have any idea what I could try to fix this?
static async Task Main(string[] args)
{
AuthDiscordBotListApi dblApi = new AuthDiscordBotListApi(BOTID, TOKEN);
IDblSelfBot me = await dblApi.GetMeAsync();
await me.UpdateStatsAsync(50000);
}
heya, I don't think you need the "GetMeAsync" anymore you can just directly update your stats through the dblApi
we decommissioned the api route which gets your own user because it wasn't really used for anything since you can use any api url without your own ID anyways
heya veld, do you know where i got this wrong?
i'm trying to find info about issues resolved, for what i read bot stats updates has been resolved but i still have problems: since yesterday seems like the bot is sending the stats, but i don't see them updated (now shows 0) in the bot page
Hmm, still seems to be giving me a 400 Bad request sadly, I think I'll try the Java library for now and see whether that works
check pinned message in #support
@scarlet cobalt can u check if the C# library needs an update with the rewrite?
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
thanks, that says fixed and for what i see mine replys correctly but i don't see the stats updated in the bot page in the website. it says 0 in top.gg but should be ~330 as server numbers
Java library last updated 3 years ago, let's see whether that works 
One message removed from a suspended account.
im sure you do
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
loool
veld do you have any idea? #topgg-api message
it worked in the python sdk but not this one lmao
Java library still works, thanks for the help though and hope dotnet works again soon 
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
I mean it's been broken for probably several months, and I figured out how to make Java work for myself, so I don't think it is particularly urgent
One message removed from a suspended account.
One message removed from a suspended account.
@vital anvil posting server count where the server count is 0 doesn't work
possibly because of truthiness(?)
from the server's end
so it doesn't recognize the server_count property
which is why i got this #topgg-api message
oh we dont allow 0 yea
wouldn't see this as a huge issue
i recommend you change the error message for it
as i could get confusing
the error message should be
server_count cannot be lower than 1 and higher than 999,999,999
something like that
yup
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.
yeah
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
entity sounds like it could also be a user (if the user API wasn't removed)
bot it is
One message removed from a suspended account.
[Uncaught Exception]: Error: 404 Not Found
at Api._request (/home/container/node_modules/@top-gg/sdk/dist/structs/Api.js:61:19)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.execute (/home/container/src/Events/Guild/MessageCreate.js:119:29) uncaughtException
umm guys?
this is really messing my commands that are vote locked up for users
T_T
using hasvoted? ๐
i assume that means yes?
whats the error tho it was perfectly workin
yes
When its a user who has voted it returns true right?
its only users who dont exist it gives a 404 on.
(exist on top.gg)
oh?
wait a min
uhm before it would jus tell em to create account no? by jus telling them to vote
The API has been updated, now it returns an error when a user has never used Top.gg.
I'd suggest placing your hasVoted in a function, something like this
import Topgg from "@top-gg/sdk"
const topgg = new Topgg.Api("HIDDEN")
async function checkVote(id) {
try {
const voted = await topgg.hasVoted(id);
return voted; // Return true if voted
} catch (err) {
if (err.message === "404 Not Found") {
return false; // Return false for 404 error
} else {
throw err; // Throw error for any other error
}
}
}
ah
All this does is handle the 404 error. Since the user doesn't exist(404 means it doesnt exist) they couldnt have voted.
ah so it jus tell em to vote anyway ryt?
Yeah
kk
*also some URLs like support links, avatar links, and invite links return the entire URL instead of just the hash
that's not mentioned in the pinned message but it would most likely break many bots

One message removed from a suspended account.
One message removed from a suspended account.
@keen belfry You'd need something like this
app.post("/dblwebhook", new Topgg.Webhook(config.TopggToken).listener(async vote => {
console.log('Vote received:', vote);```
Replace the config.TopggToken with your process.env.TOPGG_WEBHOOK_AUTH though
const Topgg = require("@top-gg/sdk");
const express = require("express");
const app = express();
const webhook = new Topgg.Webhook(process.env.TOPGG_WEBHOOK_AUTH);
app.post(
"/topgg-webhook",
webhook.listener((vote) => {
// vote will be your vote object, e.g
console.log(vote.user); // 395526710101278721 < user who voted\
// You can also throw an error to the listener callback in order to resend the webhook after a few seconds
})
);
app.listen(process.env.PORT);
this is what i have
give me a moment
Hi
const Topgg = require("@top-gg/sdk");
const express = require("express");
const app = express();
const webhook = new Topgg.Webhook(process.env.TOPGG_WEBHOOK_AUTH);
app.use(express.json());
app.post("/topgg-webhook", (req, res, next) => {
const authHeader = req.headers.authorization;
if (!authHeader || authHeader !== `Bearer ${process.env.TOPGG_WEBHOOK_AUTH}`) {
return res.status(403).send("Forbidden");
}
next();
}, webhook.listener((vote) => {
console.log(vote.user);
}));
app.listen(80);
replaced
Let me know, although It may not work with your environment
Where's my thank you 
https://top.gg/bot/1300551799731654665
The first bot was added without any problems, but it is not displayed in search
EggWise - The Ultimate Mu Online Discord Bot!
Automate your server management, reward players, and enhance your Mu Online experience with po
You've got to wait for the SEO to update, takes a day or 2
ah okey thank you.
No problem ; )
Yeah it worked?
?
if (!authHeader || authHeader !== `Bearer ${process.env.TOPGG_WEBHOOK_AUTH}`) {
return res.status(403).send("Forbidden");
}
lmfao
Doesn't look like your authorization header looks like Bearer .... Just remove the Bearer part from the check
Sometimes I just....

i'm getting this error when checking for user votes:
i'm using the topgg python library
type error
string indicies must be integers not str
@vital anvil hey veld, is donatebotguildid nullable?
because it's not in the documentation
you're using an old version of the library
a newer version of the library is currently in the works! if you wanna see its progress, see #topgg-open-source message

yes its always empty
so it's deprecated
yes
oh okay thanks for letting me know! is there any workaround in place while the new library is being built?
make the requests yourself, without the library
WARNING:discord.gateway:Can't keep up, shard ID None websocket is 45.8s behind.
WARNING:cogs.levelling.levelling:Error checking vote status for XP multiplier: Cannot connect to host top.gg:443 ssl:default [None]```
Considering the 2 error messages above the top.gg message I assume you lost internet connection for a while
@vital anvil any idea?
Is there any way that we can check if the code is working without voting on top.gg?
as we can only vote once in 12 hours?
there's a test button in the webhook part
not working
what did you give as url
you need to give the right url w/ port if needed
discord webhook : )
yeah that's not how it works
I want to implement in the code that after xyz time they have to vote the bot to work again
its to send a webhook to your own server (code)
you need to setup your web server with your code and then listen for webhooks
then with your web server you can executed a discord webhook
but top.gg (still) doesn't support directly setting discord webhooks
at this point idk why it doesn't, it's just a if Strings.contains(webhook_url, 'https://discord.com/api")
tbh I don't know how to set up that
If you know any website/guide so please tell me
yeah what i also wrote some time ago x)
see pinned messages
ohk thank you buddy
is this related to the postgres migration? @vital anvil
It's rewrite related
alright
I can look into it soon but prioritizing the data migration
could you spell out the issue for us non technical folks
thats a user id correct
no, discord bot id
you mean /api/bots/
lol it's okay, me too sometimes

quick question does updating the python library break on_dbl_voteand on_dbl_test events? Cause I'm not receiving either anymore 
can i know why topgg api is used for?
In most cases to check if someone voted for your bot (although you should use webhooks for this to avoid rate limits) and apart from that there are sites that display statistics of individual bots on top.gg thanks to the API
What difference between topgg api and webhook like api is uses for if someone has voted but webhook uses for
I see like i want to show stats of my bot on my website i will use webhook like I want to show for example how many users added it to their discord I will use webhook right?
No, webhooks are only used to receive information that someone voted for your bot
๐
@runic creek
Am I the only one getting this error all the damn time? Like, several times a second?
What request are you making?
TopConnect.getVotes()
I've never had to insert any arguments, and it's not asking for any
I'll take a look at the sdk
Hey, the SDK needs to be updated, I'll look to update the SDK soon.
Hey,
when testing a vote webhook we dont seem to be getting the isWeekend property, has this been removed?
Tests havent provided the isWeekend property for a long time.
ah okay, but it still exists for "real" votes?
as far as I'm aware, yes
alright cool, thank you
None of my webhooks use it, but I'd expect someone would have reported it missing by now.
Is there a review POST ? would be nice, reward users for leaving reviews haha.
if there isnt it should be implemented but without also sending the number of stars given, to prevent devs from only rewarding 5 star reviews.
Rewarding for reviews is against top.gg guidelines and may result in your bot being removed from the site
There is no point in adding something that is also against the guidelines
breaks our guidelines btw
oh nynu said that, sorry
๐
Didnt know!
May i ask why?
Probably because people tend to give a biased reviews when there's a reward
I mean it's fairly common on trust pilot
Hello can i Get a sample code for webhook or api key for topgg
api key is on your bots edit page, in the webhook section.
I mean code
depends on the programming language
can anyone give me the code
like !vote bot will check if the person has voted yet, if not, the bot will ask to vote
If the vote is finished, the bot will say that this user has voted successfully.
There's two ways of accomplishing this.
The recommended way is using webhooks, save the vote in your own database, and checking the database.
The second way is using this: https://docs.top.gg/docs/API/bot#individual-user-vote
Its just an API call.
API resource for a bots or apps on a platform like Discord
i am using v13 js can i use it
v13 nodejs is really outdated, I don't think the library supports that far back.
Hi, small question, where can I find my bots api key? Just canโt figure it out ๐
your bots edit page, in the webhook section
Hello
when will reviews api come out?
Its mine, so I can vouch. But as always you should evaluate for yourself if you trust others with the data you're giving up.
One message removed from a suspended account.
One message removed from a suspended account.
@jaunty plank help me
sup?
One message removed from a suspended account.
One message removed from a suspended account.
I'm ngl, I didnt watch the whole gif before clicking it.
I just saw the bibbidi bobbidi boo yah
One message removed from a suspended account.
One message removed from a suspended account.
please give me the code where the remaining time is displayed to vote again
unless you use a webhook, you need a web server and database, to keep track of who voted when, not possible
@vital anvil
so uhm /bots returns the same results no matter your query?
i've tried the following queries:
/bots/bots?search=/bots?search=Luca/bots?search%3DLuca/bots?search=username%3A%20Luca/bots?search%3Dusername%3A%20Luca
and they all return the same results -- like mudae always being in the first search result -- as if i didn't enter any query
total here is 44,109 so it matched with every bot listed on Top.gg
This is like before this update even
yup
i thought it was already fixed considering #support pins listed it as fixed
maybe @signal hawk?

I'm trying to get the last 1000 votes from a bot (https://docs.top.gg/docs/API/bot#last-1000-votes) with the https://top.gg/api/bots/ID/votes link, however it returns 0 items in the response. Am I doing something wrong? Authorization seems to be correct.
API resource for a bots or apps on a platform like Discord
Im trying to send my current # of servers over to top.gg My console logs sucessfull. But nothing shows
async def update_topgg_stats(self):
if not topgg_token:
logging.warning("TOPGG_TOKEN not found, skipping Top.gg stats update.")
return
headers = {"Authorization": topgg_token}
payload = {"server_count": len(self.guilds)}
async with aiohttp.ClientSession() as session:
async with session.post(f"https://top.gg/api/bots/{self.user.id}/stats", json=payload, headers=headers) as resp:
if resp.status == 200:
logging.info("Successfully updated Top.gg stats.")
else:
logging.error(f"Failed to update Top.gg stats: {resp.status}")
def __init__(self):
super().__init__(command_prefix=commands.when_mentioned, help_command=None, intents=discord.Intents.default())
self.start_time = None
self.status_channels = {}
self.blacklisted = set()```
Nvm im blind
@jaunty plank i could make a pull request to the sdk to make this return false if u want
so this fix is not needed anymore
Honestly? I think it should error when someone doesnt have a top.gg account.
or have its own unique status or something
i mean, they technically would have never voted even if they don't have a top.gg account, no?
Yeah, so they might not understand what it means to vote and bot devs can use this to send them more indepth info

At least thats what I'd use it for
imo i feel like most bot devs only care about the boolean
I think a seperate state for new users and existing users is a good thing
Its an SDK, I think the raw information should be passed. But others could have different opinions.
I cant type, I'm trying ^-^
my sdks are not that raw haha
tbh the only sdk we have is the js one, everything else is more library focused.
I'm not really against patching it in, I just like it and I think its a feature not a bug.
Devs have to implement error handling anyway themselves.
(503 errors)
what do you mean?
I might be wrong, but for example the python lib has some error handling built in right?
I havent looked at the github for topggpy for so long
yes
depends on your definition of error handling tho
It was intended to be implemented.
https://github.com/Top-gg-Community/python-sdk/blob/master/topgg/errors.py#L46
but it never was :/
what's implemented
Error handling
it just represents any exception coming from the Python SDK
what makes this different from the node sdk?
The node sdk has no intention of handling any errors iirc
what ๐ญ
after looking at the code i can somewhat understand
though it does handle invalid inputs, it doesn't handle any request errors
I'm not against it, it just seems weird to implement error handling when you have to implment it yourself anyway.
I think the docs need to be updated, not the actual code.
fairs
i don't think my sdks have error handling
just custom exceptions for different types of exceptions which is passed down to the user
maybe just slight error handling for ratelimits and 404 sometimes
๐ did you add handling of the 404's to yours?
oh derp
๐ so you return null on 404?
I dont know py
Hello guys, anyone can help boost my server members?
sometimes it can return 404 as None sometimes it doesn't
it returns 404 as None in endpoints that i feel deserve it
for has_voted, treat_404_as_none is False
because i dont think im doing an Optional bool type
or on second thought do you think i should just treat 404s are regular errors?
and remove that 404 check
you know what maybe i should 
would make the sdk more consistent with other sdks
Guys, my POST requests to the /stats route time out. Anyone else with this issue?
@woven coral have u fixed the api with python?
cuz im using py too
Hey Guys! We're using the @top-gg/sdk nodejs package... but sometimes is returning 503 error, it's okay?
The error is from api obviously
what's the error stack?
and what does the vote command do?
I fixed it , i use aiohttps
instead of request
and installed topggapi
Hi, guys. For the second day I have been trying to make this API work, apparently I am very stupid. I don't want to use any webhooks or anything more complicated, I just want to get api data on the people who voted for my bot, why is it so difficult to do in this api, I have already connected the Api warframe to the bot and there, given the more extensive version of the information, it was easier for me to work with it, but here I need not so much, but nothing works.
Can someone help me a little to figure out why this code does not return voices, I checked the ID and TOKEN of the bot several times, everything is correct. It returns the status of 200 but there is no content, although my bot already has 5 votes (2 of them recently)
import requests
api_key = "TOPGGTOKENBOT"
url = f"https://top.gg/api/bots/IDMYBOT/votes"
headers = {"Authorization": api_key}
try:
response = requests.get(url, headers=headers)
response.raise_for_status()
except requests.exceptions.RequestException as e:
print(f"Error in request: {e}")
else:
print("Status code:", response.status_code)
print("Content:", response.json())
most likely a known issue #support message
@vital anvil hey veld, i'm not sure if this is a bug or not, but whenever i send a request to top.gg/api/bots/{id} (which worked) and then send a request to top.gg/api/bots, it gives a 500?
but if i send a request to top.gg/api/bots without the prior request, it worked
also
someone is ddosing the site lol
sounds like fun
GET top.gg/api/bots/{other bot's id}/stats also gives out 500 btw
500 errors are coming back 
@vital anvil https://top.gg/api/bots/{id}/stats returns the same result no matter the ID argument, is this intentional?
(your bot's stats)
unsure
i can check
try https://top.gg/api/bots/stats
then https://top.gg/api/bots/1234567/stats
then https://top.gg/api/bots/1/stats
same thing
it redirects to ur bot

to be fair tho
it should throw a forbidden on other stats
so it doesnt matter too much
no, its not allowed by the API
alright
please return me my wallet
Hello is it possible to get the last timestamp of user having voted with API ?
support both api routes
but you've never been able to retrieve other people's stats out of the getgo?
getting mixed responses here. just to confirm youโre saying a getStats(id) and a getStats() should be supported y/n?
Will the type be "vote" when someone vote?
Yup https://docs.top.gg/docs/Resources/webhooks#schema ๐
The type of the vote (should always be "upvote" except when using the test button it's "test").
Check if user has voted in
v14
const {
EmbedBuilder,
MessageFlags,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
} = require("discord.js");
const axios = require("axios");
const apiToken = require("../config.js").topGG;
module.exports = {
voteCheck: async function (interaction) {
try {
const userId = interaction.user.id;
const response = await axios.get(
`https://top.gg/api/bots/BOT_ID/check?userId=${userId}`,
{
headers: {
Authorization: apiToken,
},
}
);
if (response.data.voted < 1) {
const voteLink = "https://top.gg/bot/BOT_ID/vote";
const embed = new EmbedBuilder()
.setColor(0x00ffff)
.setDescription("### Vote if you want to use this command.");
const row = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setLabel("Vote for me")
.setURL(voteLink)
.setEmoji("๐")
.setStyle(ButtonStyle.Link)
);
interaction.reply({
embeds: [embed],
components: [row],
flags: MessageFlags.Ephemeral,
});
return false;
} else {
return true;
}
} catch (e) {
return true;
}
},
};
Just use the function like this :
const vote = await voteCheck(interaction);
if (vote !== true) {
console.log("Bouta get a vote");
return; // just return since the function has already replied, no need to add anything here
}
does it fetch nad get all the voters ? without members need to verify by themself ? like it automatically get the current voters ?
No, this code only checks if the person executing the command has voted
@runic creek bro is there a way to create a code that automatically check the current voters ?
Yo bro you know me?
prodia user ๐
๐
As far as I know, yes, but the top.gg API returns only 1000 votes iirc
Prodia api not fixed
yes np !! how can i implement this !! i tried alot but fails !! for real !! is there any code for that ? example
@normal cradle bro can you help me in bot in a problem?
i know !! the service is dead !! they won't fixing it
Ok
sure ! np just please wait till i find a way to solve this vote issue !
There are no examples, it's a simple API request. How you do it is up to you, you are the developer
Ok can you Dm me after it
@runic creek check !! this is what i made !! and itz not working at all
100 - though paginated
why Looking for voters who've voted in the last 12 hours...
Error checking user 123456789012345678: 404
Error checking user 234567890123456789: 404
Error checking user 345678901234567890: 404
Error checking user 456789012345678901: 404
Error checking user 567890123456789012: 404
and not catch the last 12h voters
Thanks for clarifying
U can check how many votes ur bot got, in total
yes i do that but i want to geth the voters discord users ID !!
that's the problem
Let me check rq , I think thats not possible
ok
where is botId defined
hided it !
itz in the first lines of code with fetch js module
no point in hiding a bot id
you get an error 404 so the endpoint is not valid
everything can be traced back and seems valid besides the bot id, which may be wrong
note that if the users corresponding to the ids never used top.gg it will return a 404 error
considering you're using an LLM for your code, the ids you're checking are just random and do not correspond to a user, hence the 404 response
that's from where the 404 errors come from
and for when you check for the last 12h votes with the /votes endpoint, hard to see what's wrong if you don't share the logs related to that
Doesn't 404 meant they never voted before?
I am back
so
lets brake it down
u want to check every user who has voted ?
You'll probably be best off using webhooks for that
yes
sigma do u know python right !? i m coding this now in python and not node js
whats the rate limit when requesting stuff from topgg api , do u know ?
not great
let me see what I can do in node.js and I'll convert it
most people get ratelimited pretty quickly when doing stuff like this
I'll assume its 1 request per 2 seconds, which is safe
You'll want a decent caching system in place at the very least.
On the /votes endpoint i think it was around that, but veld may have changed it in the update
I havent messed with the API since then
the issue would come quite a lot if you have lots of votes
considering the result it 100 and paginated
you'd have to make multiple requests to get all votes if you have over 100 votes
You also wont have any info on when the votes expire, so you'll have to recheck often
better off using webhooks from the start
okay bro !! hold up
I got it
const axios = require("axios");
const { ChalkAdvanced } = require("chalk-advanced");
const apiToken = require("../config.js").topGG;
function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
module.exports = {
voteUsers: async function (abot) {
try {
console.log("Checking for votes...");
const users = new Set();
await Promise.all(abot.guilds.cache.map(async (guild) => {
try {
await guild.members.fetch();
guild.members.cache.forEach(member => {
users.add(member.user.id);
});
} catch (err) {
return console.log(ChalkAdvanced.red(`Failed to fetch members for guild ${guild.id}:`));
}
console.log(users);
}));
for (const userId of users) {
try {
const response = await axios.get(
`https://top.gg/api/bots/1121344235807977474/check?userId=${userId}`,
{
headers: { Authorization: apiToken }
}
);
if (response.data.voted < 1) {
console.log(ChalkAdvanced.yellow(`User ${userId} has not voted`));
} else {
console.log(ChalkAdvanced.green(`User ${userId} has voted`));
}
} catch (err) {
console.error(`Error fetching vote status for user ${userId}:`);
}
await delay(3000);
}
} catch (e) {
return console.log(ChalkAdvanced.red("Unexpected error:"));
}
}
};
use it in a ready event
make sure to run
npm i ChalkAdvanced axios
also make sure the bot has GuildMembers intent
@normal cradle
sorry i am back !
okay lemme test it with bot credentials
@icy laurel thank you bro !! but i want it to gets the voters's discord users id !!
log :
etc...
Bot Name: Nova-47
Monthly Votes: 11
Total Votes: 11
Server Count: Not available```
thats what it does...
it got total votes !! not discord id of all users who votes !!
I sent u the script just above
dont "!" me
thanks bro ! i edited the code and
Starting Top.gg vote checker...
Checking votes for bot ID: 1339242638892601405
Fetching guild members...
Successfully fetched members from guild test-guild
Found 2 unique users across all guilds
Checking vote status for user 123456789...
Error fetching vote status for user 123456789: Request failed with status code 404
Status: 404, Data: {"message":"User not found."}
Checking vote status for user 987654321...
Error fetching vote status for user 987654321: Request failed with status code 404
Status: 404, Data: {"message":"User not found."}
=== Vote Check Summary ===
Voted Users: 0
Non-Voted Users: 0
Errors: 2
total votes = 11 and it checked for 2 which they don't exists
u're welcome but dont use ai that much, it can lead into nothing
i rlly tried so much bro !! and didn't get what i wanted exact !!!
i just want to make the bot get's all available voters discord ids !! but your code seems didn't work !! can i give u datas topgg token and id to help me in that !!
ofc
My bot just got verified i was wondering how do i make it so when someone vote the bot knows
Is there a guide?
Sorry but im facing some issues
Im hosting my bot on a service do i provide the url of that service
I think i got dis part nvm

Do you know where to get an api token?
Hey! To obtain your token, you would need to go to https://top.gg/bot/:yourbotid/webhooks with replacing :yourbotid with your bot ID. If you want more information on this, you can check our guide. Please let me know of any other questions. 
Okay thanks !!!
Your bot will need to be approved first
Yes im waiting
when will the vote issue get fixed?
it's just an issue from their end apparently, it's been like this for almost a week
ye i got it !! brother โค๏ธ
alrdy chanegd the way of that
thanks btw ๐
Which vote issue?
https://docs.top.gg/docs/API/bot#last-1000-votes always returns an empty dictionary
API resource for a bots or apps on a platform like Discord
Are you using the library or making a request yourself.
The library hasn't been updated
And the docs haven't either
We use a page system now
request myself
Show code please
import requests
from collections import Counter
BOT_TOKEN = "BOT TOKEN"
API_URL = "https://top.gg/api/bots/{bot_id}/votes"
headers = {
"Authorization": BOT_TOKEN
}
def fetch_votes():
print("fetching")
try:
response = requests.get(API_URL.format(bot_id=1317736045067894804), headers=headers)
print(response)
if response.status_code == 200:
votes_data = response.json()
print(votes_data)
return dict(Counter([v['id'] for v in votes_data]))
else:
print(f"Error fetching votes: {response.status_code}")
except Exception as e:
print(f"An error occurred: {e}")
This looks like the old code
I'll try to write a Python example after the meeting I'm in.
apparently there is a parameter called page where is it set? cause I can't see it anywhere in the documentation. I tried:
params = {"page":1} with response = requests.get(API_URL.format(bot_id=1317736045067894804), headers=headers, params=params) but it didn't work.
The docs havent been updated yet
cc @woven coral is the new get last 1000 votes broken? Have you tested it recently?
Hey, votes is broken. I'd suggest moving to webhooks
#support pins
will it be fixed any time soon?
how to fix not showing the server count on my bot
Have you actually setup anything to send to the api?
nop
like what
code ?
As it's not an automatic feature, it has to be manually setup by the developer
oh like in evary 24h i will auto update to api
will it ok
but how
api ?
API resource for a bots or apps on a platform like Discord
can you show an example
It's just an api wrapper you setup, run it on port, add authorisation and use the docs I sent you which has examples and the variables you need to use.
What language are you using?
python
Are you fluent with python?
https://stackoverflow.com/questions/27977972/how-do-i-setup-a-local-http-server-using-python If you scroll down, this shows you examples of what it would look like to host get pages and what not.
No problem
why do people still use python
it is beginner friendly but it is slow
- node.js better for web development and is very easy
Personal Preference I guess
i updated
now how to update on topstats.gg
ayi
do i get raitlimited to update server cound evey 5mins
No need to update it that much damn
Not sure what the ratelimits on Top.gg are, but this wouldn't change the value on TopStats
can you give me exmit time
As we only fetch every hour
ok
Just do a guild create Event to push each new member
so i will set 1h
Or fetch hourly
oh i can make like that that good !
I wouldn't recommend it though
bruh hm so i will set 1h
idk what yall are talking about but i would just keep count of servers, guildCreate event +1 count and i would create an async function that has an hourly wait and it would post
That's what I just said
yes
Basically
Good luck
Why does that name sound familiar
Ha?
yep
yes! thx
where do you seen
I have a few questions. I'm setting up the webhook to receive when users vote for my bot but I'm facing some problems because I don't really understand how to do it and what I'm doing wrong.
class TopGGWebhook(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
self.bot = bot
self.app = FastAPI()
self.PORT = FASTAPI_PORT
self.HOST = FASTAPI_HOST
self.AUTHORIZATION = TOPGG_AUTHORIZATION
@self.app.post("/webhook/topgg")
async def topgg_webhook(request: Request, Authorization: str = Header(None)):
logger.info(f"TopGG webhook received")
if Authorization != self.AUTHORIZATION:
raise HTTPException(status_code=401, detail="Unauthorized")
data = await request.json()
user_id = data['user']
if data['type'] == "upvote":
logger.info(f"Upvote webhook received")
elif data['type'] == "test":
logger.info(f"Test webhook received")
return {"status": "success"}
async def start_api(self) -> None:
config: uvicorn.Config = uvicorn.Config(
self.app, host=self.HOST, port=self.PORT, log_level="info")
server: uvicorn.Server = uvicorn.Server(config)
await server.serve()
This is the code I have really now in my topggwebhook cog but when I hit the button send test it doesn't log "TopGG webhook received" that is the first that it has to do before anything else.
Also I don't know where I have to use the "Token for this bot" thing that I can see in the webhooks page from my bot.
The token is only useful when using the API. It is useless if you use webhooks
for what I'm doing then I don't need it, okay
if I create the uvicorn server with my private ip and port and (obviously) I put the public ip and port in webhooks page, I have to type in "Webhook URL" http://ip:port/webhook/topgg based in the code I sent above?
knowing I don't need the token then my error must be the Webhook URL I put in website or the code itself, and I want to discard stuff
and am I okay asking this here or should it be in #development?
Is this on a home network or a server environment(vps dedicated etc)
home network really now, after testing I want to upload and change ip and port to the one from my bot hosting
You'll need to port forward on your router.
oh okay, I'll try later, ty
I usually recommended doing it every 30 minutes
if you do it at exactly XX:00 on the hour it'll update
our fetcher runs at 2 minutes past
๐
hello. i didnt see isWeekend boolean in the test response. will it exist in an actual response or exist only if it's weekend?
noted, thank you!
is the voting system still broken? I try to fetch the votes with a request but it always returns an empty list
I don't think this will be a fast fix, there's no current ETA on a fix.
Webhooks do work and are more recommended anyway. I'd suggest moving that way
Hi guys, I want my uses to vote my bot to let them use it, could you help me to do that? My bot language is python
โบ๏ธ
set up the basic vote handler then make a system to enable users to use ur bot via their discord user id
since the bot and topgg votes both utilize user ids that should be pretty easy
Hi anyone know why the vote Tracking is not working?
it's not allowed to connect a Discord channel's webhook to the Webhook URL?
they have apparently updated it and made it only work with webhooks.
this is not sending discord embed data
and it never has as far as I know
you can use something like https://webhook-topgg.com though
this will allow you to do exactly what you're looking for I assume
it's run by a volunteer on our team too!
Can someone guide me to make a voting system and when I vote, the bot will send a message to the voter thanking you for voting for me.
I don't know how to do it
What which webhook u mean?
The top.gg API is still a bit bugged so if your code used the /bots/{id}/votes endpoint it won't work because it will always be an empty array and the webhook in the question is probably this one - https://docs.top.gg/docs/Resources/webhooks
Webhook integration for receiving vote data
how to get this badge ?
bot id?
I meant the bot in the screenshot, but thats not a top.gg feature. They used custom css to add that
i would like to know how to earn that badge for my bot
ohhhh
@jaunty plank but
how they did it in the name ?
Your AI friend with 1000+ characters ๐ | DALLE-3 Image Gen | Adaptation to match your interests ๐ง โจ
the css html code only for topgg description ? but the name of bot is from bot ID !! can't mess with name
You can edit a lot with just css
For example, this is all just custom css.
adorable cute aesthetic โจฏ per-server currency money economy system โจฏ 400+ crisis suicide hotlines โจฏ autoresponder custom commands โจฏ utility
@jaunty plank damn ๐ฅ thankkkk youu from topgg bot description right ?
yeah
bro it uses webhook
but why its not working?
very unspecific what the issue is
Its not sending the embed
When i vote
How do I get the API from my Discord bot to let people vote and earn coins?
How do I get the API from my Discord bot to let people vote and earn coins?
@vestal wasp
Help
what
hello, pls double check. heres usage example https://npmjs.com/package/@top-gg/sdk
Official Top.gg Node SDK. Latest version: 3.1.6, last published: 2 years ago. Start using @top-gg/sdk in your project by running npm i @top-gg/sdk. There are 15 other projects in the npm registry using @top-gg/sdk.
check the port your app (express) is listening to too
check out suggested example usage from the same link i sent above this message
Btw now fixed :)

What is the API to check if a user has voted for a bot or not?
How to get my API key?
Uh I went there ๐
You need to have an approved bot on top.gg
Uh alright
Am I cooked?
I don't know how these scammers work but if you didn't do anything or provide any information then you should be fine
Yeah I found out they wanted me to download discord again
Hopefully they didn't pull my IP
So, I'm trying to update bot stats via the api and looking at older questions I saw this
I don't have that button, my but was approved, but also the docs (https://docs.top.gg/docs/API/@reference) don't really make it clear that this is what you need, it sounds more like you provide your own via the custom webhook settings, which is different
So how do I get the API token exactly?
Basics of the API
Hiya ๐
You can go to https://top.gg/bot/<YOUR BOT ID HERE>/webhooks
and it's this option you're looking for in regards to the API key
I dont see this token option when i go to the page
Has your bot been approved yet?
Yes
Try logging out and logging back in, if it doesn't show after that, it may be a bug
Hmm still doesnt show
What does the page look like for you, are you able to share a screenshot, censoring anything private ofc
have you made sure you're logged into the correct account on discord in browser?
hmm. @jaunty plank has the API key section moved? or is it broken for new bots at the moment
Velds looking into it iirc
are you the owner?
yes im the only creator and owner
Yeah, veld was informed of the owner not seeing their token issue
lemme double check
oki
Yeah, he was informed earlier today
ok thx for help
it's a bug
new bots dont generate a token at the moment 
I reviewed their bot so yea one sec
1338896463509454939
nvm
lol
being on laptop sucks ngl
productivity down the drain
i can see it thx!
can anyone tell me the api to get whether the user have voted or not?
what
?snipe
it's best to use webhooks
no, i mean i need api, i don't wanna store it
i had saw someone using it but i totally forgot the url
you should because of ratelimits - but there is an endpoint
can you give me?
API resource for a bots or apps on a platform like Discord
will surely consider when bot gets good response
I directly started out with the webhooks - I'm not sure how many checks I do but it's likely in the range of thousands a day
Is there a way to mock webhook events ?
for testing I'd just use ngrok - you can also just replay webhook events from there
else just use curl or any other HTTP client
Okay! Yeah thought about that too, but how would i know what the request body looks like? Is there an example?
const schema = Zod.object({
bot: Zod.string().regex(/^\d{15,20}$/),
user: Zod.string().regex(/^\d{15,20}$/),
type: Zod.union([Zod.literal("upvote"), Zod.literal("test")]),
isWeekend: Zod.boolean().default(false),
query: Zod.string().optional()
});
Eg. i want to get the discord-id from the user that has voted*
body.user
eyyyy lets get it!! Thanks. <333
and the user object, is the same as you get from the discordAPI?

might be a stupid question but is discordId === body.user?
gotchu thanks for helping โค๏ธ
yw
any web server
sorry, I'm not a python developer, but flash and fastAPI should be fine options
Flask is lightweight and user-friendly but sync (has little to none async support) whereas FastAPI is also lightweight but has more security features and is async. For something like this I would recommend using Flask but run it in another thread to not block the bot's heartbeat ๐
I have a problem,
for the discord token in topgg
whats that random ass server bto
no thanks mate
anyway
dang
Anyway the problem im facing is that in the bot's webhook settings i cant get the token.
It returns some random data?
Instead of the actual token
I'm also having the same problem.
I'm not sure if it's my bot's token (for top.gg) or not
Hey ๐
You can only link to the vote page.
We don't have an api endpoint to vote and we dont have any plans of adding one.
Preventing abuse, you could just send the api request for anyone without us actually knowing if they voted.
or wanted to vote
hey, where can I find my full top.gg API token?
when I reveal it under the Webhooks tab, I only see the header and payload of a JWT, but not the full token. I swear I saw a normal token earlier today-
it looks like this now
Its a bug ๐ฆ
oh 
do we just base64 encode tokens? ๐
you might just be able to copy the token and encode it
unlikely, there's probably a secret key
Someone was decoding them at one point right?
I can check with my api key if you want
yeah theres nothing like a secret key there
which is an issue
lemme check smthn rq
fun fact and slightly unrelated but the API technically supports multiple webhooks 

all it shows are algorithm, bot id and issued at timestamp
so yeah i wont probably get a token out of it from base64
bun :^)
But I'll still try though
also another thing like
the library for python is "topggpy" right?
I installed it with pip install topggpy and even after importing it, I get ModuleNotFoundError: No module named 'topggpy' ๐
I think u should install from GitHub
Ask them
A simple API wrapper for top.gg written in Python. Contribute to Top-gg-Community/python-sdk development by creating an account on GitHub.
if topggpy doesn't work then download from source
im not sure, this is where the docs take me
lot of discord.js tutorials -> newbie devs pick js -> js becomes the predominantly used lang
Python is simple but hard to master
JS is a mediocre starting lang but hella easy to master
js is pretty much confusing me
it doesnt help that discordpy's fate was unknown a long while back bc a new dev had to pick up taking care of the lib
it's personal preference at the end of the day tho
i personally prefer js just bc it was easy to pick up and just go go go
I'm really stuck here man and it's driving me crazy- just trying to make a simple command to check if a user has voted or not. even though there are no errors in VS, my terminal is going absolutely wild. here's the code:
topgg_client = topgg.DBLClient(bot, TOPGG_TOKEN)
@bot.tree.command(name="vote", description="A command that only works for users who voted.")
async def vote(interaction: discord.Interaction):
user_id = interaction.user.id
try:
has_voted = await topgg_client.get_user_vote(user_id)
if has_voted:
await interaction.response.send_message("โ
Thanks for voting! You can use this command.", ephemeral=True)
else:
await interaction.response.send_message(
"โ You haven't voted yet!", ephemeral=True)
except Exception as e:
await interaction.response.send_message(f"โ ๏ธ Error checking votes: {e}", ephemeral=True)
just can't figure out what went wrong, any ideas? ๐
Like I read the docs here https://topggpy.readthedocs.io/en/stable/api.html#topgg.DBLClient







