#topgg-api
1 messages · Page 7 of 1
are you responding to the webhook quickly?
we have a retrial system, if the webhook isnt responded to quickly it will retry the webhook because it didn't think the webhook was received.
It wasnt an issue a few days before none of my code changed either so thats why Im wondering
Well, for example if you send a message to discord and wait to respond to the webhook until after then it might just be the discord api being a bit slow.
The other way to correct it is just storing votes temporarily in memory.
If someone voted a second ago ignore any votes from the same person shortly after.
It worked fine before so idk whats wrong but ill see what I can do thanks!
no
ok
future: <Task finished name='Task-96' coro=<WebhookManager._run() done, defined at /usr/local/lib/python3.11/site-packages/topgg/webhook.py:144> exception=OSError(98, "error while attempting to bind on address ('0.0.0.0', 5000): address already in use")>
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/topgg/webhook.py", line 150, in _run
await self._webserver.start()
File "/usr/local/lib/python3.11/site-packages/aiohttp/web_runner.py", line 121, in start
self._server = await loop.create_server(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1519, in create_server
raise OSError(err.errno, 'error while attempting '
OSError: [Errno 98] error while attempting to bind on address ('0.0.0.0', 5000): address already in use
Can somebody help me? Why am I getting this error?
Error says it all
error while attempting to bind on address ('0.0.0.0', 5000): address already in use
If I already learned js. I wont ask it again here 😑
Ive try write code app.post.user as vote but it say "vote is not defined"
And yeah im not a developer ok. So if you cant help anything or cant give any solving. please just up my post ok!
Thank you mate 🙏
I appreciate it
Its not a bot for vote but server. My server already up on topgg
if you dont wanna even develop why are you even writing code
also your code has so many mistakes that a person who knows at least js basics wouldnt do
then why dont you have a role?
you dont get a role if you add your server
Fetch the user id provided in thr webhook, check if your bot shared a server with itif yes try to dm
I never say to don't want to develop. I just say I'm not a developer. I just want to learn how to build a bot and now I've problem and need help. I know my code so terrify but because of that I ask here to someone help me. I'm here to solve my problem not to show off my code. Read first before typing. You're smart but you have 0 reading and 0 thinking before typing man and also 0 attitude
Do you think every people learn coding like saying bullshit like you?
Ok, I don't want to argue with people who have 0 attitudes like you man. Done man, thank you for your bullshit@restive otter
There is no requirement on this server to get a role before asking. So, why do I have a role first before asking?
1: before learning how to develop a bot, at least learn the language youre trying to work with
2: if you need any help not about top.gg api, #development
3: i am pretty sure i have the ability to read
4: you should also learn english too
oh I didnt see server
I saw wrong
^
The bot client.
if i put DJSPOSTER it shows not defined
const poster = AutoPoster('topggtoken', client) // your discord.js or eris client
What do you not understand?
client is your bot which you define with
const client = new Client()
In the example of event with topggpy, what is on_dbl_test?
on_dbl_test is, as the name suggests, the callback for when a test vote is made using the test button on the webhook settings
the docs should contain appropriate examples on usage
can someone help me with the topgg vote managing. I code in python, and im honestly not understanding what I need to do to set up a vote handler
did you download the library?
i think i did once
The normally there is no test vote?
You can trigger a test vote from your bot's settings page on Top.gg
@zenith quest
Also @restive otter Being Turkish Doesnt Promote You
???
????
People are such drama queens 
fr ong
how to make python code if member vote on top gg do ting
thank you i founded in docs called BotVoteData
It somehow fixed itself so ig it was a top.gg/discord isssue after all
Very odd but it works again now so thats good
#development would be the channel for general development related questions
do mind that people will not just give you the code
where do i get the webhook url from?
Where you host the webhook listener
e.g. http://IP:PORT/something
Where IP could be your VPS IP and PORT the port where the listener is running
If you're running it locally you'll need to enable port forwarding, which is not recommended so I'd recommend you to use a proper VPS if it's the case - same place where you host the bot itself
read channel name
Ask in the support server of the bot
Ok I’ll try it now @restive otter
How do I set up the Webhook to count how many servers my bot is in? I'm just not understanding the Docs...
ok slow down lol. All this shit your saying is the first im hearing it. what port, where can I get/create it?
what does that do, I mean I see what it's saying it is doing, but how does it play a part here?
➡️ google is your friend ⬅️
how am i suppose to google what ion even know what im looking for
and that tells me what it is, but how does it play a part here?
in me getting the webhook url
dude, reading, and understanding is 2 different things
that's the part it plays
i see wtf yall typed, do i understand...nope
IK WHAT IT IS NOW!! Where do i use it?? WHY ARE U SHOWING ME IT? HOW DOES IT PLAY A PART HEREEE
Jesus
bro
read what I highlighted
that's where you set the port
that's?
yes?
dude, if your done asking me the same thing 3 times in a row...
why would i sit here asking about smth i understand...
make it make sense
I asked you to read because your saying you don't understand. what doesn't make sense?
ok, your showing me the port and what it is right?
i did awhile ago
ok?
goodbye 👋
im done
What port to port forward? Whatever port your webapp is listening on.
How to use a port?
IP:Port
127.0.0.1:3000
my webapp?
...
Please read 
maybe I need to emphasize on the fact that all these terms and shit im new to, telling me things ur familiar with is gonna puzzle me.
And stop treating me like ion got eyes. I see wtf your showing me. If I could see the shit to make it work I think I would have been pretty set by now. What I dont do is understand what exactly your showing me, why your showing me, and what it means
idk how else to stretch this
Okay; Why do you want to set a webhook url
idk, why?
Because it would help me help you
no, im literally asking why
cause i literally dont know
is it so the website knows where to dump the information?
Oh.
Set up your own service to reward users in a server. If you're not a developer, dont worry about these settings.
You don't need to set a webhook url
Why not?
Consider checking out how networking works if you're confused by ports
I am answering his questions...
Unless you have a reason to receive top.gg events there is no reason to set a webhook url
Didnt seem apparent on your wording then
I do, I need to know when someone votes. So i can preform a set action
he literally replied to me bruh...
I mean It was formatted like a Q&A
Q1. How does x work?
A1. x works by...
@dusty stone ^
.
^
mysql? postgres? mongodb?
The easiest would be to spin up a small node web server.
I don't have top.gg access so I don't actually know what data it sends
so why r u helping if you've never done it before?
how does it matter?
Because the same applies for other services
can I make webservers in vs code? Ik i can in replit
Wait one more week
Ok
Okay so you need to install node & npm
what if i just choose to create it in replit?
since i alr use a webserver for hosting?
I have never used replit
I self host or use ovh dedicated machines
im talking about the webserver though
well you need to do it wherever you are going to host it in the end
so transfer this to replit?
imma try it and see
replit, it host where ever my bot is hosted
but that code... doesn't look right
well if your gonna tell me that atleast tell me whats not right about it
i really dont get why people do that lol
Well, you're starting the webhook when there's a vote only
Which means you'll never catch any votes
As it never started
wdym
When someone votes, you run the handler
Which means until someone votes it will never be ran
Since it will never be ran, it will never catch any votes
So it will never do anything
i see
await bot.topgg_webhook.run(5000)
is what starts the webserver.
You don't run it until you receive a vote event... which you cannot receive without it running
Yeah exactly what Krypton said
Start it in the on_ready event or similar
oh, ok
Ideally setup_hook if you have your own bot class as people should have
yh, I do have setup hook
this good?
Better than before yep
aiit, imma try it first in vs code, then in replit
also, can i create webservers in vs code?
yeah
if you mean running your code in vscode
python3 yourfile.py
vscode should have a "play" button in the top right though
ik how to start the code thx 😅
You can, though it won't be reachable by Top.gg or other external devices unless you port forward which is not recommended to do. Just test it on Replit, will be faster and better
yh, just ran it and nth pops up
@restive otter isnt it import topgg?
Have you installed it
Probably doesn't work correctly 
If you can run commands then install with pip
getting this error
Traceback (most recent call last):
File "main.py", line 14, in <module>
import topgg
File "/home/runner/Truth-Bot/venv/lib/python3.8/site-packages/topgg/__init__.py", line 24, in <module>
from .client import DBLClient
File "/home/runner/Truth-Bot/venv/lib/python3.8/site-packages/topgg/client.py", line 42, in <module>
from . import errors, types
ImportError: cannot import name 'types' from partially initialized module 'topgg' (most likely due to a circular import) (/home/runner/Truth-Bot/venv/lib/python3.8/site-packages/topgg/__init__.py)
do yk why?
Most likely due to the double installation of the package
how do i fix this?
Remove the package and have it only once?
Or if you have a topgg.py file/module, don't name it like that
how do i find this file, cause this is in replit
There's a file explorer? Make use of it
ok I fix it, but this is showing up
That's a web viewer, not a file explorer
ik, before it printed connected
^
but ever since i inputted the port or code, it's giving me that
can u not bro
You can stop the memes here and use #memes-and-media
Have you removed the package you've installed
Especially the one with replit's package manager
Uninstall it and just install the one with pip
i installed it somewhere else, cause on was in my venv, the other was just in replit itself ig
so when i installed it in the replit files, thats what i call em lol, and not the venv, it started working
it ran
alr
@restive otter remember im trying to get the webhook url so i can do smth when a vote comes in
@restive otter Hey so I did some research and watch a couple video's. And I understand the port and IP and all that. So the webhook url is the url or webserver that collects data from another webserver through a webhook. Well, idk if that makes sense lol. But how do i create webhook url to give it? Is that done in the code I have alr?
The URL is as you said the web server
So it may be an IP or a domain, depends how Replit works
Never used Replit but I suppose it's something like xxx.repl.it/yyy
On what? and for what?
Its a network port
https://www.cloudflare.com/learning/network-layer/what-is-a-computer-port/
(you dont have to use cloudflare, its just their learning resource is really good)
D
Hoist the sails!
No, credits are obtained by votes
Plize
No.
Error: 504 Gateway Time-out
at Api._request?
site down
Well the go for it and code it yourself
Examples how it works are available in the docs in this channel description
Is api still down?
So I need to select a port not used by my computer?
Yes
Also port forward if you are running it locally
how to get it?
"Edit" button on your bot's page, go to the "Webhook" section on the left menus and click on reveal
how to get auth
Literally read above...
I'm having some issues getting my bot to update it's server count, my bot runs on discord.py btw
anyone able to help me?
Not without code, error and more information
the error's huge
the code:
bot = discord.Client(intents=discord.Intents.default())
dbl_token = os.getenv('top.gg TOKEN')
bot.topggpy = topgg.DBLClient(bot, dbl_token, autopost=True, post_shard_count=True)
@bot.event
async def on_autopost_success():
print(
f"Posted server count ({bot.topggpy.guild_count}), shard count ({bot.shard_count})")
print(f"Failed to post server count\n{e.__class__.__name__}: {e}")
then it blows up in my face with an error like 30 lines long
Well having the error would help
I may or may not have deleted the code
The main point tho was that topggpy wasn't a subcategory of bot

oh okay any ETA?
Soon hopefully, its been coming back for the past 20 minutes or so.
its back
how can I get the time that the recent voter can revote?
you need to calculate that yourself
once a webhook request comes through, get the current time, calculate +12 hours to it, and there you have the time they can revote on
there is no way to do it without webhooks
ah okay
Either IP:PORT of your VPS
Or domain and port if necessary
How do you connect to your VPS
Then ask them
^
None is better
The difference is what's used, IP or domain
In the end it's an URL containing either IP or domain, and if needed a port, of where the web server is running so that Top.gg can make a request there and your web server is handling it correctly.
Then the port used will be 5000
Then it won't run because its a coroutine and must be awaited
No
It will be http(s)://domain:port/path
.com is part of your domain
Path will be whatever path you use to catch the request Top.gg will make
There is only one port, as shown above
http(s)://domain:port/path
But where I put the top.gg port ?
No where, it doesn't need any port
Top.gg will make a request to the URL you give
In that URL you give the port of the web server that is running
So what is the bot.topgg_webhook.run(5000) for ?
To start a web server on port 5000
And where write the number of this port ?
^
But I already have a port in my heberger
Just as side note, you don't need to reply ping on every message. We're only 2 talking it's not like we get lost.
And it doesn't matter if you already have a port assigned for something
A computer has multiple ports, so does a server
65535 ports
But what happen if the port is already used (I disable the ping)
Then use another port
Not all 65535 ports are used on a computer
If they are, it has a serious problem
But it's an hoster
Doesn't matter
They have multiple servers
Not one server for all customers
So I need to use the higher port ?
A different
Higher or lower, doesn't matter
Okay, thanks
Shall I modify "/dblwebhook" ?
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password")
That would be the path
So http(s)://domain:port/dblwebhook
You can change it or not, doesn't matter much
I do it in the init or outsite the init (I use class and cog) :
await bot.topgg_webhook.run(5000)
Where the cog is loaded
Or where the bot is starting
Ideally that
The bot isn't starting in a cog
You can very well start the webhook listener in the main file
so just before the bot.run ?
That could be one place, yes
Maybe better to put in into the on_ready event ?
If I run the bot.togg_webhook in the main, shall I import topgg into my cog (to get the event) ?
Definitely not
No
If someone dos me with my url and port, can I have more latency?
If yes, how to set up a whitelist ?
the https://docs.top.gg provides IP-addresses that top.gg will reach out with
so you can whitelist these
But if someone do a lot of request can this impact my bot's performance ?
depends on how your webhook will handle requests
thats why its probably best to whitelist the ips from the docs
If I set a password is it right?
How to White list in Python?
If you haven't gotten it working yet I wouldn't worry too much about dealing with a dos yet.
IP whitelisting won't be done in Python
API for voting discord servers?
Webhooks, like can i get a webhook for when a user votes my server?
Waiting on my bot application, but my server application has gone through
Thanks
says bots on the docs but it applies for servers too
And it tells me the difference?
wdym
I only see https://docs.top.gg/api/bot/ here, and im unsure how one could tell the difference between a user voting for my guild and my bot?
Guild:
{
"user": "471409054594498561",
"type": "test",
"query": "",
"guild": "906981869340487700"
}```
Bot:
```js
{
"user": "471409054594498561",
"type": "test",
"query": "",
"bot": "1009848030951907530"
}```
Thanks
Am i able to test vote my server to test my code?
Dont see it on the docs...
you do it on your servers page under "Webhooks" --> "Send test"
does the top.gg api for https://top.gg/api/bots/920327318285717525/check?userId=${userId} reset back to 0 after 12 hours
yes
And how to do ?
Is there way to check how much time is remaining for user to vote again?
thats something youll want to track on your end
Through webhooks?
When you receive a vote through a webhook you should save when they can vote again in a database.
Then you can just check that database
when i instal @top-gg/voting-sdk it return a error: Permission Denied
is timestamp also saved in webhook ?
Whatever the current time is when you recive the webhook can be used as a timestamp.
Whatever programming language you use should provide that information for you
Thats something you'll want to track in your own database
@jaunty plank 😢
That's not publicly usable yet
hey i have been trying to log votes from top.gg, my console shows nothing when i tested this vote.
Yes i have modified the bot webhook page, webhook url as http://my.ip4.address:port/dblwebhook, my port is 80 here since iam using to test votes on my local pc. Would you mind having a look at this and notify me whats wrong 🫣
https://pastebin.com/LfbGWP1H
How do i send a test vote?
There's a test vote button
In the webhooks settings where you put your webhook URL, password, etc.
how do i get a api
do we need 2 ports or one is enough?
Port forward the port of where the server is running on your local machine
Where do I get a webhook
You create a web server
Listen to an endpoint for data
Expose that web server to the internet
Get the IP:port / domain:port and put that as webhook URL
How do I create a web server (I’m dumb)
And then?
read
No
too bad
Can you give an example?
Google has examples
Great help
Why does the api keep saying in my terminal it sends when I have the autoposter? I could continuously restart my bot and a second later it will always say that it posted stats to topgg.
No one will spoon feed you lad.
If you are using the example code with the autoposter it logs every time it posts.
The autoposter posts on ready
Ah.
TopGGAPIError: 503 Service Unavailable
at Api._request (/home/xxx/Documents/code/Bots/public/Paradise/node_modules/@top-gg/sdk/dist/structs/Api.js:76:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Api.postStats (/home/xxx/Documents/code/Bots/public/Paradise/node_modules/@top-gg/sdk/dist/structs/Api.js:99:9) {
response: Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
[Symbol(Response internals)]: {
url: 'https://top.gg/api/bots/stats',
status: 503,
statusText: 'Service Unavailable',
headers: [Headers],
counter: 0
}
}
}
This keeps happening when i restart my bot. I have no idea why.
Okay.
Hey. I am a doubt. Is it possible to make top.gg auto voter which automatically votes a bot?
@golden adder, hello! Sorry to disturb you, but I'm the one who created the Top.gg SDK's C++ version. When will you upload it to Topgg's Github?
https://github.com/top-gg/cpp-sdk there is already one, you can create a pull request on it with your code
The official C++ wrapper for the Top.gg API. Contribute to top-gg/cpp-sdk development by creating an account on GitHub.
aight
no permission to push 🤷
Isn't it Johand that manages that now that Mac left
Hey, (using node.js sdk) how can I get all the bots of a developer (user id)?
You don't as there's no endpoint for that
remember
you can always scrape :trollface:
Hey, nothing happen when I click to test vote. My code :
main :
async def setup_hook(self):
for ext in self.initial_extensions:
await self.load_extension(ext)
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "hygJHGfdsf*-s/df")
await bot.topgg_webhook.run(7564)```
cog :
```py
def __init__(self,bot:commands.AutoShardedBot):
self.bot = bot
@commands.Cog.listener()
async def on_dbl_vote(data):
print(f"Received a vote:\n{data}")```
Did you fill in your webhook url and auth on topgg?
Not with a discord webhook
also when your code is running, try visiting either the ip:port or the url (whichever is applicable) in your browser and see if that works
When I go to the URL I have an error
what error?
On a ptero panel
what port have you been allocated
My server's port ? Or the port for my webhook ?
the server port
My server port is 4512
then change py await bot.topgg_webhook.run(7564) to py await bot.topgg_webhook.run(4512)
OK
Traceback (most recent call last):
File "/python3.10/site-packages/aiohttp/web_protocol.py", line 332, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
File "aiohttp/_http_parser.pyx", line 551, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'Invalid method encountered'"
do you get that when you visit the ip:port
sent an incorrect response
You don't know what I can do ?
nope sorry
when I go to url:port I have white screen
like this?
Nothing is written
And when I do https://url:port I have this error
.
Maybe is I remove https:// from top.gg webhook
https:// is only if you have ssl, if you dont have ssl it should be http://
Dns probe refers to that domain not being accessible, has nothing to do with your website
It works thanks
any way to make like this?
iirc?
If I remember correctly
ok

@clear pecan did you get it to work? I tried 2.0.0a0 and still hangs for me
Yeah same dude
yes topgg down
Hm
Error: 504 Gateway Time-out
at Api._request (/root/Ares/node_modules/@top-gg/sdk/dist/structs/Api.js:76:19)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async hasVoted (/root/Ares/commands/information/profile.js:76:15)
at async getBadges (/root/Ares/commands/information/profile.js:42:15)
at async Object.run (/root/Ares/commands/information/profile.js:24:18)
at async AresClient.<anonymous> (/root/Ares/events/messageCreate.js:117:5)```why is this constantly coming?
):
Top gg down ?
See above
Do you have an approved bot?
yes
Yh@rain heart
octor monitor
Can’t see any log of your bot being approved all were declined
Can you send message link here when it was approved?
Umm basically, it's mine and @steady sand
Octor monitor
It's verified here
I'm owner of it, but it is applied by alto
Then you won’t get bot dev role then the one who submits bot gets role
But as I'm the owner of it, cant i request for it
As it is in a team in topgg where I'm in
bruh
Then I recommend submitting it from your id
@chrome pier the bot belongs to him actually
No need to argue about this
am just a partner
Then he won't gtv
Ah fine, thanks for time
If you want you can delete bot and they can submit from their id
Np
bruh
Nvm
No need to argue further
Ahh
Dm
Why is topgg api downing so often?
This happens very often
Well yea recently site is going down more but I believe engineers are aware and already working on it, so these types of issue won’t happen again.
hmm thank you
TopGGAPIError: 504 Gateway Time-out
at Api._request (/home/xx/Documents/code/Bots/public/Paradise/node_modules/@top-gg/sdk/dist/structs/Api.js:76:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Api.postStats (/home/xx/Documents/code/Bots/public/Paradise/node_modules/@top-gg/sdk/dist/structs/Api.js:99:9) {
response: Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
[Symbol(Response internals)]: {
url: 'https://top.gg/api/bots/stats',
status: 504,
statusText: 'Gateway Time-out',
headers: [Headers],
counter: 0
}
}
}
Getting this even though they stated it was back up.
Its still having issues yeah, we're aware
But they have stated it was back up. I would update this to miss confusion.
The captcha?
Cloudflare verification?
There's no point in posting your stats to the API now anyway. We're only serving cached versions of pages.
It'll be back when the site's fully back
In my opinion the TopPHP library is too little object-oriented like it's a simple "funcion collection".
Actual (user vote check):
$api = new DBL([
"token" => "YOUR TOP.GG API TOKEN HERE."
]);
if($api->connected)
{
$isVoted = $api->get_user_vote(799697654279307314, 242351388137488384);
if($isVoted) echo "This user voted!";
}
in my opinion it is easier for developers to use one that is truly object-oriented like:
$api = new DBL([
"token" => "UWU"
]);
$api->exceptions->manage('notConnected', function(\DBL\ErrorException $e) {
echo "Error: {$e->message}";
}
if ($api->bots->get('1234567890')->hasBeenVoted('12346782899939')) {
echo "User 12346782899939 has voted this beautiful bot!";
}
Because you can enter the required data less times and do more things like:
"I need to get the bot's informations and check if the user has voted!!!"
With normal:
$api = new DBL([
"token" => "YOUR TOP.GG API TOKEN HERE."
]);
if($api->connected)
{
// Omg first i need to get the bot's information because i need the prefix idk
$prefix = $api->find_info(Http::BOT, 799697654279307314)['prefix'];
// Ok NOW i need to check if the user has voted :)
$isVoted = $api->get_user_vote(799697654279307314, 242351388137488384);
if($isVoted) echo "This user voted!";
}
With a more object-oriented version you can create a "bot object" and you won't need to insert the bot ID twice:
$api = new DBL([
"token" => "UWU"
]);
$api->exceptions->manage('notConnected', function(\DBL\ErrorException $e) {
echo "Error: {$e->message}";
}
// Only if is connected
$bot = $api->bots->get('123467783238475');
// Now get the prefix
$prefix = $bot->prefix;
// And check if an user has voted
$has_user_voted = $bot->hasBeenVoted('15637485968547');
// Perfect
And one other important thing: objects take less memory than arrays so they're better
Yeah the original maintainer of that Library either left or got banned
If you'd like to, you can create a pull request on that repo and improve how it currently is
I see to work on it, finally something interesting to do
Same
Can I set automatic role taking when voting ?
yh, create an event listener
Can you explain to me in more detail?
what programming language r u using
why API Docs speak only about users and bots but not about guilds and auctions?
Hello, how can I create a command that will list the top voters?
You must first collect these votes somehow (preferably with a webhook), then store them in the database, when you want to get the top voters you take their number of votes and sort them from the most
In what language?
There are so many possibilities to do something like this, it's all up to you how you do it
realistically in any programming language someone here would be using.
*not lolcode 👀
hmm why top.gg API aren't in a SocketConnection but you use webhooks for managing events
Are there any open source snippets of bots that do this?
I'm not sure, I've never been that interested in it
sockets would require a lot more development, and are kind of pointless in this case.
Webhooks are the 'proper' way of handling something like this.
Especially since things can be retried(if your webhook/bot is offline for 10 minutes you shouldnt miss any votes)
sockets aren't as hard as some people say
Anyways you're right about the webhoock possibility of retrying but for me (who is developing the new PHP library for Top.gg) webhook management will be harder than WebSockets
oh yes, I stupidly didn't think about socket load balancing
I have considered making a webhook to websocket thing for my webhook service, and the only reason I havent is it would have to be a premium feature.
Even at my much smaller scale its still not simple.
i have used sockets only for creating a stupid online game (written in JavaScript) so I don't know as much about them however they are easy to manage, mainly for events.
Discord that has money uses them while top.gg uses webhooks
Discord has to use sockets tbh
But even they are moving to webhooks as much as possible
slash commands use webhooks
If they could, they would make every bot use this.
https://i.imgur.com/4EFyqPO.png
what?
DiscordPHP if i'm not wrong get slash commands by websocket
not four?
is it four? 👀
I'm not counting how long discord gets angry because the bot stumbled over some mistake I made but I think it's about four seconds but I could be wrong
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
its three
But yeah, they are webhooks.
https://discord.com/developers/docs/interactions/receiving-and-responding#responding-to-an-interaction:~:text=Interactions--both receiving and responding--are webhooks under the hood.
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
at least webhooks are simple ^_^
Not one supported yeah, using it anyways won't give you any support for it
I don't really have the URL so even if I wanted to I couldn't
just one more question.
When I get a Webhook I get a POST request with the fields given in the documentation but where do I check the Authorization parameter?
Is it in the headers by any chance?
Authorization header it is called
Why would you add or want to add an unecessary library to the topgg-php-library to manage webhooks?
All it takes is to enter the entire url and callable php file as webhook url and get the request data calling file_get_contents().#
React is no-stopping so if you want to use the topgg-php-library for example in a DiscordPHP bot it will be ok
As well as using the $_SERVER GLOBALS to verify the source IP and get the headers calling getallheaders() to verify the authorization if somebody is using it
it will work only in a web-development situation, in a CLI situation it won't
and because of this we need to open a webserver on the library
I feel like you're thinking into it a bit too deep.
Did you take a look at the other libraries by any chance, for example the JS one?
Js includes asynchronous function handling, PHP does not
I would actually provide a standalone build people can add to their environment not providing an entire library that covers any possibly way of handling requests.
I wouldn't add react to just make use of the webserver.
reactphp doesn't weigh that much come on
*non-blocking
is not a normal webserver
while that is true, I would always try to avoid unnecessary libs if possible
also me but reactphp is used by a lots of projects
and is better to have ReactPHP as dependence than cURL
the (other) lib(s) actually doesn't serve a webserver, just simply the request management
what?
it's optional to include other libs as webserver or spoken middleware
so would you suggest making the react/http library optional
i can do this but removing react for the webhook management is inconvenient
That would at least follow the same way how the existing libs are handling it
Using your own middleware using the JS lib is the default, too
Optionally you can go with the one in the script examples
The lib for example doesn't include express as dependency
err np, just wanted to share my thoughts
as it's totally up to you how you wanna do it anyways
I wonder anybody even has the time to touch the topgg-php lib anyways :D
is "you're welcome" correct in this case?
Omg idk english wery well
I am rewriting it from scratch because I have nothing to do 😢
sounds about right, yeah 
just a question
do you prefer the old style (example:
$api = new DBL([
"token" => "YOUR TOP.GG API TOKEN HERE."
]);
if($api->connected)
{
$isVoted = $api->get_user_vote(799697654279307314, 242351388137488384);
if($isVoted) echo "This user voted!";
}
)
or the new style (example:
$api = new DBL([
"token" => "UWU"
]);
$api->exceptions->manage('notConnected', function(\DBL\ErrorException $e) {
echo "Error: {$e->message}";
}
if ($api->bots->get('1234567890')->hasBeenVoted('12346782899939')) {
echo "User 12346782899939 has voted this beautiful bot!";
}
)?
well personally I would go with the fully oop style 2nd one but you gonna keep things as simple as possible as not everybody using the libs really knows what he does
What is this dude ?
so handling the exceptions internally would probably be better
In my opinion, a well object-oriented library turns out to be easier for everyone

Even if everything is documented and explained correctly a lot of people still don't read it or understand what things means or do
if people would only understand oop 
but if you wanna maintain this than choose whatever u prefer I guess
let's try the oop library
i just hope to document it well
anyways internal exceptions manager is a little bit ugly because you can define the return functions for all the errors UNTIL you don't "open another object" (like $topgg->bots)
true, if you wanna keep a non-blocking style throwing an exception wouldn't make much sense here, too
👌
Error: 504 Gateway Time-out
at Api._request (/root/Ares/node_modules/@top-gg/sdk/dist/structs/Api.js:76:19)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async hasVoted (/root/Ares/commands/information/profile.js:76:15)
at async getBadges (/root/Ares/commands/information/profile.js:42:15)
at async Object.run (/root/Ares/commands/information/profile.js:24:18)
at async AresClient.<anonymous> (/root/Ares/events/messageCreate.js:117:5)```
why is the api most of the time down 
Pretty typical, as well as the fact that in an hour or two everything should be back to normal
That's probably why they recommend using webhooks to collect information about votes
what’s the api path to post bot server counts & shard counts?
bots/:bot_id/stats
-> https://docs.top.gg/api/bot/#post-stats
How can I get info if someone voted for my bot (webhook, etc)
sooooooooooooooooooooooo been a hot take since ive talked here (my main was token sniped, got it back but i only use to when updating my bots discovery page now)
can i update my bot server count on top using a separate file like the deploying of slash commands? i wanna keep less stuff in my index as possible
sure
Was there a update to the docs I can no longer find how to access the server count?
Nope, still there were it was previously at
I have this error;
FetchError: request to https://top.gg/api/bots/stats failed, reason: getaddrinfo ENOTFOUND top.gg
at ClientRequest.<anonymous> (/home/xxx/Documents/code/Bots/public/Paradise/node_modules/node-fetch/lib/index.js:1505:11)
at ClientRequest.emit (node:events:512:28)
at TLSSocket.socketErrorListener (node:_http_client:496:9)
at TLSSocket.emit (node:events:512:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
type: 'system',
errno: 'ENOTFOUND',
code: 'ENOTFOUND'
}
@rain heart.
And where is your bot ID in the request as the documentation says?
It's api/bots/:bot_id/stats
how can we setup server vote tracking system.
like if anyone vote our server it will log in a channel
like bot voting track system
because i can't find server webhook api
Server-based webhooks work the same way as bot-webhooks, just with a different format provided. Refer to the webhooks docs @ https://docs.top.gg
@rain heart
@gloomy crypt
refer to what Krypton said
Exactly where it should be. It has not changed.
so more related to your server's connectivity, try making a wget https://top.gg
Aswell as posting your code please
It is working fine now. It was only that one. And I took the boilerplate code.
then that error is related to a timeout
It is using the autoposter.
a timeout from the recent site issues is what I'm referring to
Oh.
Well that would explain the mass 503 errors.
That I have ignored as I got no ping about them.
Your API goes down an awful lot. Maybe it should be rewritten along with the entire backend or site.
I say this because it seems very unstable with the amount of errors that are present.
If only it was that easy.
A production site the size of topgg would take a lot of time to rewrite it, especially with having such a small dev team
Well, do not do it on the production site, rewrite it on a test site.
If you need more people on the development team, open applications I say.
👀 and pay them with what money?
If you really need this to be with how bad it has gotten. I am willing to help do it for free. If of course you are willing to give me access.
maybe students apply
Honestly, I doubt it's even possible for us to offer it free.
but professionals? hard to say
It would need to be a senior developer.
Someone with a lot of experience with large projects
^
a senior comrade works for free only if it's for his own projects.
I speak for myself :P. I would never work for free on a project that isn't even mine.
I've been developing websites for years, and I don't think I have the qualifications.
Especially with the product stack being quite a few programming languages
Especially someone with the experience we would require
Most people underestimate my experience.
can I see some of your works
Most of my work is work related, and is private.
people with more experience have their unversioned side projects. would hardly get into a project that is not his or that is being paid for it
you are at a crossroads lol
don't think you're still qualified
That is what you think.
also a lil bit off topic, is this your main discord account?
Not what you see
seems like an alt
yeah, cannot change it 'til you show me some of your works
just like awoo said, ↑
I could apply too, but will be rejected
Declined what? Job application?
the offer
All of mine got declined
I've been working with web/mobile development for over 10 years, there comes a point where language is irrelevant. Languages are just forms of different syntaxes.
unfortunately
i can tell you're very experienced
It's okay, I've improved a lot since my last application.
I'll keep learning as much as I can as I go.
yeah
tbh I'm working free rn as a library contributor
Our backend is c++ iirc.
So at minimum that would be needed as a language
just waiting for them to review my contribution
i'm working in a crawler discord bot for curiosity
damn
Yeah
Hangi botun sahibisin
my bot listing shows an old pfp, how can i resolve this?
Unrelated to the API
How can i get a "API Token"?
Bot Page > Edit > Webhook
Hello, yesterday, i got an API key. today i got an error '503 unavailable', resetted the token and now it says unauthorized, what can i do
Website is down, hence why the 503
when do you think it will be fixed
hello, i have
@client.event
async def on_dbl_vote(data):
print(data)
if data['type'] == 'test':
print("TESTING VOTE")
else:
print("BOT VOTED")
but when my friend voted the console did not print anything
Python?
yea
I am suggesting you to use auth
That has nothing to do with it
must i use webhook, so just setting up client.topggpy = topgg.DBLClient(client, dbl_token) wont work?
ah, how do i get a webhook url tho? not faimilar with this part
^
thanks : )
how to get "topgg_auth""topgg_api""topggWebhook_auth"
?
Because you have to set it
Read the pinned messages and you'll understand what's going on
Can I know exactly when a user voted for my bot with api endpoints in python? Or the only way is using the on_dbl_vote event with a webhook because I want to reward users but I can't make sure that they don't repeatedly claim the reward
Webhook
axios({
method: 'get',
url: `https://top.gg/api/bots/${clientId}/check?userId=${userId}`,
Headers: {
"Authorization": topGgAuth
}
})
.then((response) => {
console.log(response)
})
``` i have this code to try and check if a user has voted for my bot however it always returns unauthorised
when i go to the same url but just in my browser it works
going to your browser is correct behaviour as it uses your authorization
go to your webhook section, press "regenerate token" and then refresh the page
the token you then see is the valid one
just regenerated it and i still get the same error
now i changed my code to this and get forbidden ```js
axios({
method: 'get',
url: https://top.gg/api/bots/${clientId}/check?userId=${userId},
headers: {
"Authorization": topGgAuth
}
})
then "topGgAuth" is not the correct token
aka is empty
also ensute that the clientId is indeed your bot and not a different one, as you can only make requests to your own bots endpoint and not a different
nvm got it working
Can you send the code that sends a message to the channel when top.gg is voted for node.js, I really need it please
It's up to you to write your own code
The API docs already give you an example and idea how it works
does anyb know why my bot return 401 when sending a test vote from top.gg. the tgg token is the one found on top.gg/bot/.../webhooks
log tgg and see if it is valid
Press regenerate token, refresh the page, use the one you see now
just retried with the token stroked badly
still same issue
the autoposter works and it uses same token
And you're copying the whole token and not part of it?
then your token isnt properly being passed on your code
I just make a simple proposal:
But why not implement (like Discord) in the headers the number of maximum requests, the number of remaining requests, and the time when the rate limits resets?
It would be much easier to handle rate-limiting with the libraries
I'm not being able to regen the token for my bot api, it just says "success" and ends up giving me the same one and also I'm getting this error 401 for the same piece of code I used to upload stats successfully about an hour ago
It worked before I regened the token, the new token doesn't show up even if it was generated
regenerate, refresh the page, use that token
regened twice, refreshed page like 3-4 times each time I regened the token. it still didn't give me a new one
the first part of your token is always the same
then cant help
try it out using postman or just a dummy application to ensure the token is right
or you're not passing it through correctly
welp, I used the same exact code before regening the token for the first time and it worked normally. let me try postman
Also providing content type json?
hold up, the api key before regenerating worked
so in conclusion this feature doesn't work
However, I also abusively integrated the possibility of retrieving server information.
Reviews would be appreciated :D
https://github.com/top-gg/php-sdk/pull/4
it does not, trust me, I did exactly as you said. "click here" -> refresh page -> copy full token -> replace it with the old token in the code (which works currently) -> run the code -> get an error 401
Just tried again, the same code after regenerating, started working after 2 minutes
I'm not sure what's going on, did that like a few times the old one worked. Just redid the same thing again and the new one works
thank you
the exact same stuff, 3 minutes apart
not really but it seems though as if it works without setting the content type here
but oh well, it works now, thanks!
The api expects it to be set
so you mean it may not work if it's not set? basically working always when it's set right
I set it in this with the new token after refreshing, didn't work.
I assume this user too had the same issue
they're using the library, which does it itself
I am getting a error in this file
Error: TypeError: topgg.getVote is not a fuction
@jaunty plank @rain heart really sry for ping can u guys help
no i cannot
Ok
getVote(...) obviously doesn't exist
Isnt the function called hasVoted()?
I think so
Where do you even get this method name from?
I thought it's getVote
Yeah sorry, I cant help for awhile 😦
This gives me error
503 service unavailable
503 are server errors
So you can't do anything besides trying again later
The website is also does at the moment, so try again in a few hours
No
But your name is similar
Not a bot developer at all
Ohk
Similar name doesn't imply similar person 
Hehe i fixed the error
🙂
It wasn't getVote it was .getVotes
Stil thanks Krypton
I found from the link you gave
I don't understand for you
In the "Libraries" section on the documentation you can choose the language you use & see examples
The webhooks section is for you to learn how to use webhooks
I am an Arab I don't understand much English
And the pinned messages here explain how things work w/ examples
You can use a translator
I use but I don't understand it
Then we can't help
If you use PHP i can help you, otherwise I can't
how can i make vote notifications were when someone votes it is sent to a channel?
Use the webhook functionality, see https://docs.top.gg/resources/webhooks/ && pinned messages in this channel
How do I fix authorization issue with password
👀 I dont know what you mean by that
Nvm I found a fix, it was just returning an error cause it was being a dor dor
But new issue, when someone votes my bot, a message isn't sent to the webhook, how do I fix this
You're not using a discord webhook correct?
hey, I'm using the python-sdk, and the autoposter isn't doing anything
unfortunate
Thanks for sharing them 
np
btw, if anyone is curious of that personal problem, I just used the direct api to fix my problem 👍
However, I need an official response that I will apply without reply, preferably from a moderator:
Is using an undocumented but very common endpoint that is used by all top.gg clients, for a purpose that mirrors what it was created for, using documentation that is guessed by simply analyzing the requests that top.gg makes, however alerting the user that that part of the library is "abusing" an endpoint and that it is not remotely safe to use it, legal or not?
Thank you www.DeepL.com/Translator (free version)

ooops😅
i have a limit for translations in english with my mind
so DeepL sometimes helps me
(for example for long messages / important messages I use DeepL because I can make mistakes)
anyways sorry
Legal? Don't know but you probably won't get sued in court for making a request to an endpoint.
Simply don't expect consistency nor you will get any support for what you will be doing.
Oh, i know that i'm not supposed to expect consistency or support about this endpoint but i was asking only if it was legit because i may insert this in the library
What is even the endpoint's purpose
https://top.gg/api/search
You can imagine by yourself (i think)
oh sorry i was just forgetting
Thank you www.DeepL.com/Translator (free version)
Doesn't the API have that endpoint already?
is not documented
i need this endpoint for guilds
I gave either you or someone else an answer already
Yeah well then you probably won't get sued for making a request to that endpoint
a user-based endpoint is not an api endpoint, especially if not documented and shouldn't be used for libraries
yeah you wont get sued, but its still undocumented and a user facing one, essentially considered scraping
I didn't have specified some parts like "however alerting the user that that part of the library is "abusing" an endpoint and that it is not remotely safe to use it"
Scraping is pretty different tbf
Far from being scraping
I personally wouldn't do it, if you want to go ahead I guess
theoretically scraping is using endpoints that are:
- undocumented
- often used by user clients (such as normal site navigation)
doesnt need to be directly involved with reading the html site content
No, scraping is more mass data gathering
That is just simulating a user's normal interaction which isn't scraping
Scraping is:
$page = file_get_contents('https://top.gg/servers/123456');
and then with regex getting the informations
i may be wrong
scraping is that too, since you're not interacting with an api endpoint thats documented
wrong
not that only
Then every browser is doing scraping which shouldn't be allowed 
thats a user interaction, browser-used API endpoints
should I consider "reading top.gg's undocumented API endpoints" as selfbotting then? is essentially the same as reading official ones amirite
Well either way, to answer your question @fair osprey; Do what you want, you won't get sued for doing a request to an endpoint and providing it to others.
keeping it short:
if you wanna do that on a non-official library, cant stop you nor wont the devs unless using that endpoint is actively causing issues to the site
if you plan this to be part of the official library, likely wont be approved to be in it then as it is an undocumented endpoint that is not meant for bot usage
Just don't expect it to become the official PHP library
the docs still refer to a newer version ||for probably the past 2-3 years now|| of the API, which might contain that endpoint of not, I dont develop the api endpoints
I'd rather make it a suggestion and wait for it to be official, though it will take ages to become implemented so yeh
Perfect, thanks you guys for the answers, I'll update the library removing this funcionality and i'll make an extension for this which won't be official
:D
anyways
PLEASE check out my pr because I've been working on it a lot
You got an answer already
https://github.com/top-gg/php-sdk/pull/4#issuecomment-1484878675
F
The thing with 'renews' is that they may not be needed if it works fine at the moment
Though with caching not being in the current implémentation it's definitely better
It is literally a block of functions put all together inside a class.
Ewww
I was forgetting
Thank you www.DeepL.com/Translator (free version)
IntelliJ ig
PhpStorm yeah
Though that should not be pushed in a GitHub repository
Sometimes it should be, but those files are pretty much irrelevant and have no point on being pushed
I found it and like a good developer I didn't touch it 
Yeah, you can remove that 
Too much work 
Especially because that will be different for every user that is using PhpStorm
https://github.com/top-gg/php-sdk/blob/main/.idea/php.xml#L10-L12
true
anyways i just removed it
and...
I appreciate your time and effort but this is probably better off as a third-party library. There have been no changes to our API that would justify pushing out breaking changes.
I still think your work would be useful as an alternative to this one though so people have the option. Feel free to offer it as a third-party sdk! 🙏
F for the caching system
Yeah it's pretty much understandable
Me when i see not-object oriented libraries: 
I mean, you can always try to make it more popular - eventually make a PR to get a link on the current PHP library page on the documentation website
true but now i need to cry with DeepL
i should wait an opinion from they
F
We don't promote any third-party SDKs in our official documentation. You are free to use "Top.gg" and Top.gg-related tags on your GitHub repository though as long as you also include a clear disclaimer at the top of your readme file and documentation homepage saying your SDK is an unofficial one.
Yeah then try to make your library to have a better SEO when searching for "Top.gg php library"
Can have your own documentation site hosted on GitHub pages as well
Because people shouldn't really use that outdated library
I cannot understand how can I authorize to use the Api
Nor it should be encouraged for people to use it
Add an authorization header to the requests you make with the token you got from your bot's page on top.gg at Bot Page > Edit > Webhooks
Where can I add this header? In my code?
Yes
Alright
Ty
No
Well, yes and no.
Yes because my bot requires a webhook request to be made to send the message, and no because it's a custom url that I'm using in top.gg


