#topgg-open-source
1 messages · Page 3 of 1
oooo nice
node-docs?
The official docs for the Top.gg node vote SDK. Contribute to top-gg/top.gg-voting-node-docs development by creating an account on GitHub.
would be neat to get those merged into the main docs site
lol
just shoot me a DM 
i believe everyone deserves to be able to see our progress too
send me the link and i'll post it here and pin it
sure sure
added a v0 mark to differentiate between which has been successfully tested on v1 and which has successfully tested on v0
should the SDKs accept raw JSON dictionaries? because this will vary depending on language
what do you think @steady kite
as an escape?
Validation is like non existent from raw?
what
no wait i mean
do server owners get access to the API as well? i dont remember if i've asked this before
because you need to visit your bot page to retrieve your API token
and now that servers are back, who knows if they also want to give API access to server owners
and maybe more things down the line
this
yeah i know
manage server or admin can't add servers to top.gg
so ofc the owner would get access
cause they are the only ones who can add it?
in v0, the API is very much discord bot-based because it was prior to servers becoming available again
correct
will v1 be the same or can server owners retrieve API tokens from their top.gg server page now?
still confused cause the API key's are historically on the server page, so yes server owners would have acces to there own page because they are the only ones who can add it. Maybe a missing something so imma just step back and maybe Veld understands and can answer your question.
or maybe they already can? (i dont have a server on the site atm)
on the staging site, I don't see an option for API at the moment
oh
because if they get the same kind of token as the ones devs get for discord bots, i need to adapt the documentation accordingly
I get it
if my name was veld, I would create different API keys for different apps
that way you can share it to trusted individuals wihtout sharing your whole account
me too
You'll be given the <@&844267965742186619> or the <@&412346069675147264> role if you make a recognized contribution 
Yes
Yes 
API is live on test-top.gg
its also live on top.gg/api/v1/ now
yipppeeeee
it would be nice if we could atleast update the node & python sdks sooner rather than later
so no more new endpoints?
two routes are available
POST /api/v1/projects/@me/commands
GET /api/v1/projects/@me/votes/:source_id?source=discord|topgg
alr alr
any expected errors are passed through the problem+json spec
thank u null
I would recommend making a new class for v1 api clients btw
since they need a new token
god damn
but any V0 api endpoints can be used for them still
didn't you say that they were deprecated
they're not going away
huh
the v0 api isnt being updated
should the documentation state that they're deprecated
alright
we still support the API
new tokens are not 100% relative to discord bots right
but we dont add new functionality to v0
which means that server owners can have them
no, discord servers also have tokens
wdym
because we used to unpack its base64 to get the ID
/bots/:id/stats
you can use /bots/stats
or something like that
i added that back
that fails for tokens relative to discord servers right
yes
good good
should we refer to discord bots/servers as entities or as projects
projects
alrighty
will work on it as soon as i can
(note that i have priorities atm so be patient, other developers are more than welcome to help!)
@dense barn do you know why this is the case? i've already asked xiuh to give me the lib dev bot's v1 token
you're getting an error which does not give you json?
if (!res.ok) {
throw new Error("Error updating commands: " + await rest.text());
}
...
empty
do you have "Bearer" in front of ur token

How do JSON Web Tokens work?
In authentication, when the user successfully logs in using their credentials, a JSON Web Token will be returned. Since tokens are credentials, great care must be taken to prevent security issues. In general, you should not keep tokens longer than required.
You also should not store sensitive session data in browser storage due to lack of security.
Whenever the user wants to access a protected route or resource, the user agent should send the JWT, typically in the Authorization header using the Bearer schema. The content of the header should look like the following:
Authorization: Bearer <token>
no, legacy tokens used to work without Bearer
guess it's required now
does Bearer work with legacy tokens?
Yes, but i would recommend keeping legacy as-is
Bearer is required now yes
the new API will follow the spec for anything
POST /v1/projects/@me/commands has been implemented to the Python SDK 
other SDKs have also saw several changes (see pins)
i'll continue tomorrow (or whenever i have time)
lots of TODOs 
oh btw test-top.gg/api/v1/projects/@me/votes/asdf gives out 500 when it should've been a 400 error
oh wait i didn't realize test-top.gg/api/v1/projects/@me/votes existed
i'll switch over the SDKs to use this endpoint over /bots/check?userId=
yeah i think the validation right now throws an error instead
actually -- dont move it over; it'll break for legacy tokens
make sure there's a V1Client instead if you havent already
oh alright
creating a separate v1 client will take a while tho
how so
class V1Client (token: string) extends V0Client(token) {
updateCommands() { ... }
}
V0 api works with v1 token
to get the token version you can use this:
const checkTokenVersion = (token: string) => {
const segments = token.split(".");
if (segments.length !== 3) {
throw new Error("invalid token");
}
const data = JSON.parse(btoa(segments[1]));
if ("_t" in data) {
return "version 1";
}
if ("id" in data) {
return "version 0";
}
throw new Error("invalid token");
};
oooohh niceee!
oh damn
what does /bots/.../stats use again
the legacy ones
do they use both
i forgot
wdym
the optional bot IDs
new tokens are still preferred right
so do you mind if i throw a warning whenever people use legacy tokens
i could add checks so that new tokens use the new /v1/projects/@me/votes endpoint while legacy tokens use the older /bots/check?userId= endpoint
GET /v1/projects/@me/votes/:user_id has been implemented and tested on the Python SDK 
i replaced has_voted with get_vote
should be compatible with both legacy and new tokens

POST /v1/projects/@me/commands and GET /v1/projects/@me/votes/:user_id have been implemented on the Node.js SDK 
both endpoints have been tested!
both endpoints have been implemented on the Rust SDK
the latter has been tested. the former is yet to be tested.
Bro cooking
nah i'm suffering
exactly....
same thing
100%
the former is finally successfully tested! this is legit probably the most complex test code i've ever written 😭
🔥 
@steady kite changes are now live in https://github.com/null8626/node-sdk! 
@faint fern
is this ready for PR?
will need feedback first
is the latest version of the API final?
(aka you won't add more features for the time being)
the current feature cycle is done yes
i might add new features with new features or launches
the C++ SDK has been updated and tested for the new v1 endpoints!

i'll update the documentation accordingly soon 
hey veld, do you mind if i incorporate the changes in your v1 pr in top-gg/docs to my fork?
looks good to me

what does that mean?
are the changes PR'd?
I don't see any PRs open
i mean i'll add documentation for the v1 endpoints to my fork (https://github.com/null8626/docs)
yes
i'll sync it soon
is it live on top.gg/api? not just test-top.gg/api
yes
oh great
nice
i'm currently updating my docs fork
so far it seems like the Node.js, Python, Rust, and C++ SDKs are ready
as soon as i can
it would be beneficial to let people use them earlier rather than preparing every single one then all launching
what other languages need done?
Lua, Java, Go, Ruby, C#, and PHP
it also avoids other people doing duplicate work if a PR is atleast open
they are still stuck at v0 (on my forks at least)
yeah, i'll try releasing those 4 first before working on the remaining 6
(i also have uni)
you know PHP right
wait wait lemme push my changes on my php fork
wait i'll work on it later, i gotta focus on these 4 first
sorry william 
Your good XD I can take a look
alright all four's documentations (readmes and .mdx files for top-gg/docs) are done, working on finishing touches
also working on syncing my fork, this will take a bit
@dense barn so the old endpoints require /v0/ right?
no thats a docs link
right
also just realized i forgot to work on the source query parameter for the 4 sdks
one sec guys
is the user source always accompanied by a snowflake?
thinking of making an enum for my rust sdk for this
something like ```rs
pub enum UserSource<I> {
Topgg(I),
Discord(I),
}
also this is non-exhaustive right
this is all possible options for now.
right
what do you think about that veld
should i treat it as an enum or as a variant
either is fine
fair
@dense barn hey uhm in top.gg/api legacy endpoints don't work with new tokens (with or without Bearer)
but test-top.gg/api works fine
Oh prolly my bad will update config
alright source has been implemented and tested for the 4 sdks and the documentation for the 4 sdks are done, which means all of them should be ready for release
now all that's left is to sync my top-gg/docs fork with the upstream commit and finalizing it

hey @dense barn, i just found out that POST /v1/projects/@me/commands works with { name: '', description: null }
{} gives out 500
same goes for { description: 'test' }
you should add checks for these
just dont send bad data
it's only that "" and an empty body give out 400 😭
is the validation just to check if the body is an array of objects or not?
i believe 500 should be reserved for unexpected errors, don't wanna send the wrong message to bot devs
alright, the documentation is complete! i'll make a pull request soon

changes to the four SDKs are now pushed!
your amazing
cc @faint fern too
man these are some insanely large PRs for a route addition
why so many breaking changes on the node sdk
why didn't we just make a new class called ApiV1
why shoehorn it all into the same api client
I left comments on all of the SDK PR's
will work on it
thought it'll be more appropriate to combine them (since i thought most bot devs would probably miss it or something), guess i'll use a child class now
Biggest thing is that there’s too many changes in one go
Would be awesome if we can merge the changes one by one instead of all in one go
It’s really hard to look at a pr that changes how releases work, tests are structured, docs are set up, and then also the separate features
No need to apologise! I still really appreciate you taking the effort and ownership to handle this
i am aware i am very much imperfect and this is a learning process for me, thanks!

for the python SDK pull request, i'll split my pull request into four pull requests:
- the one that fixes/updates the v0 endpoints (also incorporates changes that make it compatible with newer python versions)
- the one that adds v1 endpoints
- the one that rewrites the readthedocs.io documentation
- the one that rewrites the github actions
i'll do the same in subsequent pull requests, i hope it makes reviewing them easier for you
pull request 1 (of 4) is issued -> https://github.com/Top-gg-Community/python-sdk/pull/83
i could split it more if you think this is still too much 
for the C++ SDK pull request, i'll split my pull request into four pull requests:
- the one that fixes/updates the v0 endpoints
- the one that adds webhooks
- the one that adds v1 endpoints
- the one that adds tests
pull request 1 (of 4) is issued -> https://github.com/Top-gg-Community/cpp-sdk/pull/13
pull request 2 (of 4) is issued -> https://github.com/Top-gg-Community/cpp-sdk/pull/15
there's not much going on in Rust SDK's pull request, do you mind if i split it into two batches (v0 and v1)?
pull request 1 (of 2) is issued -> https://github.com/Top-gg-Community/rust-sdk/pull/30
this one still renames files that breaks all the actual reviewing
doesn't the Rust SDK does it as well?
it is able to find them as moves there
ahhh
done for the C++ one
can you check that one again? thanks
merged Rust SDK's pull request, now working on a second one.
finished, i'll issue the pull request tomorrow
since the other SDKs are virtually done v0-wise, i'll issue a pull request for all of them very soon
to help everyone keep track of things, the list of pull requests is added to the google spreadsheet. it will be actively updated. see pins. 
pull requests under "Pending review" are in need of review.
the pull request for the Node.js SDK is also updated -> https://github.com/Top-gg-Community/node-sdk/pull/92
breaking changes to webhooks reverted 
issued a new pull request for the docs repo: https://github.com/top-gg/docs/pull/101
issued a new pull request for the Python SDK repo: https://github.com/Top-gg-Community/python-sdk/pull/84
issued another new pull request for the Python SDK repo: https://github.com/Top-gg-Community/python-sdk/pull/85
issued yet another new pull request for the Python SDK repo: https://github.com/Top-gg-Community/python-sdk/pull/86
issued a new pull request for the Go SDK repo: https://github.com/Top-gg-Community/go-sdk/pull/13
issued another new pull request for the Go SDK repo: https://github.com/Top-gg-Community/go-sdk/pull/14
issued a new pull request for the .NET SDK repo: https://github.com/Top-gg-Community/dotnet-sdk/pull/30
issued another new pull request for the .NET SDK repo: https://github.com/Top-gg-Community/dotnet-sdk/pull/31
issued a new pull request for the Lua SDK repo: https://github.com/Top-gg-Community/lua-sdk/pull/4
issued another new pull request for the Lua SDK repo: https://github.com/Top-gg-Community/lua-sdk/pull/5
Bro is his own webhook notif 

ah package lock
classic
dark mode in the older version?
in the PR
oh sure
left one comment
will check in a sec
approved
commented a better solution.
reviewed
all are reviewed
replied to some, can you check on this one? ^
replied
thanks
do you think old features (especially things like the old widgets and get_user) should be deprecated or removed?
mark them as deprecated but nothing else
alright
this is taking a bit longer than expected. i'll work on other things first, sorry everyone!
alright, reverting changes is done for the Rust SDK. it also has been linted via cargo check and cargo clippy. all that's left is to test it and double-check its documentation. 
^ also done for #30, but it's not tested yet.
is fine but generally you dont want to set styles inside classes inside variables, now ur just complicating css again
- .GET {
- --header-color: blue;
- }
+ --header-color-info: blue;
+ --header-color-danger: red;
but the colors for GET and POST HTTP Headers are different, no?
yes but now you'll get this
lightmode:
variable:
.GET:
blue
.POST:
red
darkmode:
...
lots of complexity for a simple variable usage
you can set the variable in react to the static value
you already know the method here
so you can just set it to the correct variable as well
the variables will be reliant on CSS so there's no desync
for example: here's how dynamic colors work for top.gg:
variable is used to set a dynamic color based on the application state
then flattened so it's consistent everywhere
so if you're on dark mode, all colors will be on dark mode regardless of your theme
the components themselves have control over the visuals needing any race conditions on CSS-in-JS
aaaand that way there are also no re-renders in the react tree
because css is managed by the browser's DOM, not the react virtual tree
tl;dr keep color variables flat, use react to render which variables
don't mix concern of responsibilities
alright
was planning to do that before this but worried it would somehow still desync
TIL
@dense barn done, is this right? https://github.com/null8626/docs/commit/06c9c84143079ae7ac0b5e278da5fd0cba5b51c8
done
also both pull requests for the .NET SDK should be resolved by now
hey veld, can you check the docs pull request again? thanks
breaking changes in the Node.js SDK reverted. it has been tested with npm run test. (for more info, see https://github.com/Top-gg-Community/node-sdk/pull/92#issuecomment-3308224964)
all that's left now is updating its README. 
both of the Go SDK's pull requests' breaking changes have been reverted (with one exception) and can be reviewed!

Lua SDK partially done -- working on reverting breaking changes tomorrow or next week.
Pretty blue gradient right there
done (also already tested): https://github.com/Top-gg-Community/lua-sdk/pull/5
done (also already tested): https://github.com/top-gg-Community/lua-sdk/pull/4
@dense barn just making sure, is /bots deprecated or is it just the search parameter?
no need to change anything
all of v0 is deprecated lol but we're not changing the api
my answer every time will be the same
"the current state is how it'll be"
no more. no less
i am aware of this, but it's clearly still working so i don't think it's going away any time soon
exactly
its not going to change

so no need to change or depracte it
there will be an announcement when things get deprecated
i remember you stating that before the entirety of v0 is marked as deprecated, the /bots endpoint is deprecated (in the same vein as the user endpoint and legacy widget endpoints)
is deprecated here in the same vein as the deprecation of the entirety of v0?
i mean yeah but we dont change the client for that
its more of a line of thought where we arent changing v0 anymore ever
its legacy
no need to mark it as deprecated because it's not for user's pov
they use the endpoints and there are no alternatives so you can't deprecate the endpoint
neither is there plans to remove it
so just keep things are they are and focus on v1
changing and fixing right? because to my knowledge the search parameter of the /bots endpoint is no longer working as intended
yep no need to change it
no need to change it 
yes
should i still mark it as deprecated
no
damnit
guess most of the pull requests are back to WIP

working on them as soon as i can, thanks veld!
wdym
just pretend v0 doesnt exist anymore, it's an old api with buggy functionality
why waste time on it when the current apis for the routes work
people are using really only post-stats and the /vote one
because i realized that in the latest version of the rust sdk i removed the get_bots function
there was a pull request for it and it got merged and everything

lol
im unsure if i should bring it back
don't bother
same goes for the get_users function
don't waste your time on it
some of the sdks no longer have it (as in they are deleted)
i've been an advocate for consistency, guess you're not too serious on that 
I'm an advocate on impact
wait what about attributes like shards? should those be marked as deprecated?
because i'm sure the docs page will reflect this
If you've done the work, we can merge and release it
but im more keen on getting command uploading across man
i dont really care about the v0 api because it's more of a thorn in our side atm
i hope bot devs are not mad at my rust sdk cuz it does not have the get_bots endpoint even though it's there on the docs page 😭
okay nvm you know what i'm bringing em back
i couldn't stop thinking about the bot devs man 
i'm bringing the sdks back to when it had the most of the v0 features
btw since you value impact, do you consider adding a parameter to a method as breaking? because some languages do not support optional arguments @dense barn
incremental changes are not breaking changes
if they do not support optional arguments we should use objects with optional properties instead
the highest impact thing the clients can do now is support v1
alright
alright, reverting has been done for the Rust SDK! 
so far, its api feature has been tested. other aspects such as its autoposter and webhooks are yet to be tested.
diff against an older commit can be seen here: https://github.com/Top-gg-Community/rust-sdk/compare/a7ed300e4a8ad62b4823aab84c2c59fd7bcaf955...null8626:rust-sdk:split/revert-v2
after 6 hours of debugging the Rust SDK's doctests (including autoposters for both discord libraries) have finally been tested 
all that's left is to do test its webhooks and we should be good to go!
axum webhook port tested 
warp webhook port tested 
rocket webhook port tested 
actix-web webhook port tested
everything has been tested! expect a pull request coming up in a few moments!
debugging this SDK has made me nearly maxed out my laptop's storage several times lol
but at least every docstring example has been tested! 
@dense barn regarding this (https://github.com/null8626/dotnet-sdk/commit/128cbedd58492433a07622a36a227e104127bf35#r166358039)
how would i achieve it? to my knowledge, BackgroundWorker demands a synchronous function
should i run a Task inside that work function?
i read it directly from my github notifs so i was confused lmfao

i'm gonna be mostly unavailable tomorrow, so i'll see if i could get last-minute fixes done at this hour (it's 12am)
i'll work on updating it to use a timer tomorrow when i can!
done! -> https://github.com/null8626/dotnet-sdk/commit/0bcec1cb760a0717028b43886a7f06613c33d6f3 (but not yet tested.)
^ also done for .NET SDK's v0 revert branch. yet to be tested when i have time.
please be patient
so sorry for the delays everyone! i'm giving my best for all of this
you’re doing well!! good job!
i'm taking a break from this so i can focus on uni until next week. the first half of this week has been non-stop SDK development lol 
yeah ive seen you working a lott
good luck with uni!!
mcp server for top.gg api would be a great
idk if anyone else would use tho tbh but can be a feature for sure
i think the priority should be kept on what it currently is, such as stability and improvements rather than LLM buzz

true and it's understandable 😭
its just tools made easy for plug and play but that itself is annoying cuz theres loads of servers and the general ai users dont know how to set it up
😂 valid
ill make one anyway as i want my ai bot to suggest other bots if user asks 😅
alright, time to start working on testing the .NET SDK 
the split/v0 branch has been tested! which means that it's now time to file a pull request 
hey @dense barn, can you check the pull request above again? i've responded to your comments
that's fine I would've preferred to do
public string SupportUrl { get; init; }
public string SupportInviteCode => SupportUrl;
but there's no real downside to your solution perf-wise
i wanted to keep it consistent with the rest of the code, since most of the properties are just defined like that
yeah thats fine
alright
now the pull request can be merged
(i don't have permissions to do it)
maybe you or faithie
done
epic
tested!
@dense barn see https://github.com/Top-gg-Community/dotnet-sdk/pull/31
most breaking changes have been reverted!! -> https://github.com/Top-gg-Community/go-sdk/pull/13 (this is also already tested btw.)
currently reverting the breaking changes done on the C++ SDK, this will take a while, sorry!
changes reverted and tested for the v0 pull request!

changes reverted and tested for the webhooks pull request!
the pull requests for the C++ SDK are now ready to be re-reviewed!
now working on adding v1 functionalities to the .NET SDK 
and also maybe a dsharpplus adapter
(oh btw i just noticed that some of the .NET functions have inconsistencies like for example a method that does not end with Async is actually async
)
im gonna mark the old methods as obsolete and create an async version of them, because the method names can be misleading
also i just realized that the .NET SDK has never handled HTTP exceptions properly 
sadly to work on this and test the v1 branch, i would need for the discord.net adapter pull request to be merged 
cuz otherwise it will be super messy
then do it after the v1 changes
if you need the .net adapter first work on that first
get that merged first
then work on the next dependant
alright
im pretty much done now, about to test it
but to test the post bot commands functionality, i would need to depend on a discord library because the raw functionality depends on an generic type which would be serialized to a JSON format. while i could theoretically create a mock application command class for this, that would be too complicated is it not?
wait i think i have a workaround for this, one sec
alright, done!

other pull requests in the SDK are also available for review btw
i'll focus on the documentation side of things tomorrow 
documentation for Rust, C++, Node.js, Go, .NET, and Lua SDKs is now complete!
TODO: document v1 features for the C++, Go, and Lua SDKs
both pull requests that adds v1 functionality can now be reviewed (see pins)
currently working on reverting breaking changes for the python sdk. this will take a while, please be patient!
alright, i am finally done with porting its structures! now it's time to port its webhook and autoposter, this will take some time 
i'll work on it tomorrow! 
alright, autoposter and webhook done! now it's time for make some finishing touches and finally start testing
API methods and autoposter tested!
webhook tested!
alright, i'm pretty much done! i've split my changes into three pull requests (because previously the diff was really big):
- the one that adapts it to the latest version of v0 (
split/v0) - the one that simplifies its tests by reducing them into two files (
split/tests) - the one that overhauls its readthedocs documentation (
split/docs)
alright, time to work on the Java SDK 
most breaking changes reverted!
alright, i've split my changes to three pull requests!
- the one that adapts it to the latest version of v0 (
split/v0) - the one that adds an autoposter functionality (
split/autoposter) - the one that adds a webhooks wrapper for Spring Boot, Dropwizard, and Eclipse Jetty (
split/webhooks)
alright, my job is done for the day
finally 😭
i'll work on the Ruby SDK tomorrow! 
breaking changes has been reverted and everything has been tested, it's time to work on adding v1 functionalities 
alright, everything has been tested!
PHP SDK done! now it's time to test it 
alright, everything has been successfully tested!
alright, i'm FINALLY done with every SDK!!! 

now all that's left is to continue on with the pull requests 
god it feels so good to finally have a break 
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
yeah
they made the channel open not too long ago
afaik they created a role that allowed people to send messages in this channel and added it to id:customize, i'm not sure if that role still exists
kinda sucks that i've been getting unrelated messages here :/
One message removed from a suspended account.
i've checked the sniped messages, it's always deleted scam messages
One message removed from a suspended account.

thank you so much bhai
you are the only mod i rely on when the others are asleep lol

no worries times zones are weird
added and tested support for v1 in the C++ SDK!

now it's ready to be issued immediately once the v0 pull request is reviewed and merged
every tests now work for the Python SDK!

https://github.com/Top-gg-Community/python-sdk/pull/88 is now closed. the SDK is to continue using pytest.
#87 has gotten pretty big (over 1,700 line diffs), i'm splitting it into three pull requests.
two new pull requests from #87:
added v1 support for the Python SDK! 
Have / will the examples on the repo be updated?
of course
in fact i will rewrite the entire README and documentation
the former will apply to ALL SDKs
yay
@tawny nest the readme changes will be be carried over by the split/docs pull request, it will be issued once the split/v0 pull request is reviewed and merged

i am briefly taking a break from the SDKs because i am not really in a good mental state right now, sorry everyone!
mental and physical health always comes first
take care 
hey everyone, just wanted to let you all know that i should be able to return to this by mid-november. so sorry for the delay! 
like... source code for the website?
yuh
thats not public
thought so thanks
Hey, I would like to help every now and then with top.gg's lib for Go language, how do I get about it?
I'm a Go professional, core developer of one of discord libraries (officially confirmed by discord)
I don't know if I can send links here, if so tell me.
hai! you can make a pull request, or dm one of the community managers to become one of the core maintainers and become a library developer (but in the end you still need to make changes via pull requests)
Got you, well pull request out of the blue might feel rude so let me try to DM first. Can I DM anyone? Let's say Marco Rennmaus or you have specific person in mind?
huh really? to me it's not rude imo
feel free to make a pull request right away
but if you really wanna become the core maintainer, sure dm marco 
Well tbh. the Go version of top.gg lib feels abandoned so if I were to make any changes - I would likely try rewriting most of it, normally it's seen as very bad / rude.
Thing is, the way it is written is not very in Go style
It feels imported from somewhere else
i understand, many of the other SDKs are abandoned as well
i've been updating most of them for the past month 
i have a pull request on the Go SDK that updates it to the latest API's changes, but feel free to rewrite it 
kinda
i'm sure Veld is fine with you rewriting things, just make sure that you DO NOT make breaking changes
unless you make it a major release, but i don't think he's too keen on that atm
Do we get some testing api keys for automated test cases?
yes
Then it should be fine if I can setup maybe some github workflow tests
feel free to request a community manager for this bot's API token https://top.gg/bot/1026525568344264724
Gotcha, I'll try talking to Marco and we'll see.
Oh... should I rather talk with Xiuh then? To not confuse them more
He was helping on my other ticket just few min ago
mb
Hey @drowsy thistle could you link me the current, most up to date Top.gg API docs? It seems broken / incomplete what I found:
I would like to avoid having to scavenge throught other language libraries to reverse engineer endpoints and models...
well, this is the docs as is
Those are the most recent ones
https://docs.top.gg/docs/API/v0/user
https://docs.top.gg/docs/API/v0/bot
if you're searching that
the latest version API is in docs.top.gg, it's just that it is not that well written atm imo
Hmmm...... they are totally not in sync with my old go sdk I just cloned
i have a docs pull request that overhauls it coming up
I use that right but but please tell me why there's v0 and why v0 and v1 seems to operate on objects / models that are not documented under models/ ? It's really confusing from outside.
okay so
user source is essentially an enum
you can use this in the query param for the API endpoint that mentions it
both API versions are basically the same in terms of input/output types
the value can be "topgg" or "discord"
try it out with top.gg and discord IDs and see what happens
Ok, so for now - would it be correct to call it all as just v1 and have 3 API segments:
/bots (strict rate limits)
/users (regular rate limits)
/projects (strict rate limits)
I'm also currently crafting logic for rate limiter
/bots and /users are v0
which is technically deprecated but will remain supported
Well, you see this is confusing because if v0 is deprecated -> this technically means any new code should ignore it / omit it, so logically I should only handle v1 but from what I see it only supports setting slash commands right now to be displayed so... developers using this library would have no control regarding bots/users?
Or no wait
what Veld's view on this is, v0 is technically deprecated BUT all SDKs should not mark it as so, it's just that it will NOT be maintained anymore.
therefore libraries should not mark them as depecated or dismiss them entirely
because of this he is opposed on breaking changes
and instead encourage lib devs to extend their sdks to add v1 support
(and also fix existing bugs, but thats not his priority rn)
Hmm... got it but it's very confusing way of doing things, it's against any normal practices...
v1 alone as is - is not really usable on it's own from what I see, so v0 support is a must anyway
thousands of bots depend on top.gg's sdks, and i kinda understand him
he doesnt wanna upset the bot dev community
Well, many things must keep backward compatibility, that's fine on it's own, just calling it v0 + @deprecated is weird
Anything under v1 is usually considered experimential, not production ready, comes with no promises whatsoever.
it's just that it's unmaintained indefinitely, existing bugs on v0 will remain forever
Ok, I'll try adding commets to each method signaling which API version it uses.
most of v0 still work, you should not dismiss them
sagu honestly i did this too when v1 was announced, i rehashed many of my SDKs, and Veld was not happy with that
Are those object descriptions in docs 100% up to date?
*or actually almost if we're talking docs on the v0 endpoints, my bad.
Would rather avoid that... it costs a bunch of time but also I have no guarantee I won't miss some optional field that just won't appear in my case.
i understand
Let me create what's available in documentation for now and cry later when things fail
if you want a frame of reference, see my python SDK
it does not have v1 atm but it has the newest version of v0
well, i am working on them
and i am waiting for Veld to review all of my pull requests lol
or Luke
but days has passed
I warned Xiuh I'm gonna drop a pull request with like 3k lines of code at once
to not be scared
uh
Veld had advised me that it's better for me to split big diff pull requests
reviewing 3k diffs is not fun
Go lib version is absurdly behind and weirdly made for Go standards so it's really a good idea to rewrite most/all of it.
but in your context, maybe he'll be fine with it idk
commits will have to do
it wouldn't pass tests when I'm rewriting nearly everything and I was now to split whole rewrite into few pull requests
good luck!
@drowsy thistle unclear:
bot.defAvatar?string | "The cdn hash of the bot's avatar if the bot has none"
Do you mean the cdn of the discord automatic avatar (one of five) when bot has no avatar?
The description makes no sense
defavatar is deprecated
avatar also now holds the ENTIRE url, not just the hash
how the go sdk docs was worded was kinda wack
It's not just go sdk, same naming is in docs
@drowsy thistle it's not completed, I'm heading to sleep for today but leave me info if using this kind of naming is fine. Default, raw values in API are commonly misleading without context so I modified few field names to better match + add some description. Also gotta love even API sometimes uses snake_case just for other time to use camelCase...
Also why docs says server & shard counts may be empty/omitted? It doesn't really make sense, I did few test API searches and every single bot appears to have those fields defined.
V0 needs to continue to be supported because V1 doesn't contain all api endpoints to cover the full API yet. But, people already built integrations on top of V0 so it makes zero sense to change V0 in any capacity.
V0 is just what I called it because the API really just wasn't good. V1 is my setup for an actual strong standing, strongly typed API
v0 is not deprecated. but it is not getting any more support.
v1 is the current recommended API
yeah there's no need to mark it as deprecated because in a sense v0 is no longer going to be updated from an API endpoint so whatever is there now will be there until it shuts down
if the client supports something it shouldn't it can safely be ignored and focus for libraries should be on building v1's clients
true
Got some time on my hand lol, holidays
yipppeeeee
Bot.vanity?
It doesn't seem to exist anymore?
I do test API requests with testing token but I got 0 bots with vanity field
yea
vanity is a feature exclusively for certified bots, bot certification was removed a looong time ago
bot.donatebotguildid?
ok, so certifiedBot is also invalid? got it
yes
Pls tell me if that matches up to date standards
I had to get bit creative with naming because what API uses in field values is really random
i'll check when i'm available
i'm very busy right now
maybe veld will
or someone else
Hmmm
Could someone confirm if https://top.gg/api/bots/:bot_id/stats endpoint works properly?
I tried my own bot and got back:
{
"server_count": 2,
"shards": [],
"shard_count": null
}
But it should say servers: 0 as I never published this data
Confused why it got 2
oh
then i don't know
i've always used {"server_count":2} for the lib dev bot (1026525568344264724)
Could it be that it just totally ignores what's in uri and targets bot from where it has auth token?
@deft merlin could we get clarification? I assume you have access to API spec details.
nah you'll have to talk to @dense barn
Also
im not a technical resource 
https://top.gg/api/bots/:bot_id/votes is also broken
It even ends up getting 200 OK answer with empty [] array if data is invalid
It should never happen
It's all coming from v0 category so I'm confused if I should implement it knowing it's broken anyway or don't bother and ignore altogether...
xiuh can you teach me how to build a bot list /s
shards is no longer at all used
i think we still read the data if sent and aggregate it, but we dont store them individually
Could we maybe get some list which endpoints works / partially / not at all?
for backporting purposes
Well, if I'm about to rewrite whole lib then I won't held back
Yeah but you said it yourself quite a bit of stuff exists in v0 only
For stats, only server_count matters and should be used moving forward
Ok, could I get confirmation if that's correct? Those tables in docs website are outdated af
ApprovalDate is actually creation date iirc
Library is not stored anymore so dont include it in the library you're writing
I can rename it but it might be misleading*
By creation date insdie bot object, people might think it means when bot was created in general sense
Well, I used Discord valid uint64 snowflake
in the UI we only accept both, but, will always map them to our internal IDs
FeaturedGuildIDs we don't expose in the API afaik
for my sdks, i added a new property approved_at and marked the former as deprecated
we don't display approval date tho?
oh wait what
it's created at date
when the user submits the draft to top.gg
ShardCount should be removed
other than that lgtm
I may try in future but I'm limited with my time, I'll try to help regarding Go lib but I cannot do any promises.
I might do huge PR in 3 days or in 2 months
Realistically
for reference
here's our legacy backporting function:
export const createLegacyApiSchema = (b: LegacyApiItemFragment): LegacyApiBot => {
return {
invite: b.__typename === "DiscordBot" ? (b.inviteUrl ?? undefined) : undefined,
website: b.socials.find((s) => s.type === SocialPlatformType.Website)?.url,
support: b.socials.find((s) => s.type === SocialPlatformType.Discord)?.url,
github: b.socials.find((s) => s.type === SocialPlatformType.Github)?.url,
longdesc: b.longDescription,
shortdesc: b.shortDescription,
prefix: b.__typename === "DiscordBot" ? b.prefix : undefined,
lib: "",
clientid: b.__typename === "DiscordBot" ? b.applicationId : undefined,
avatar: b.iconUrl,
id: b.externalId,
username: b.name,
date: b.createdAt,
server_count: b.socialCount ?? 0, // eslint-disable-line camelcase
shard_count: 0, // eslint-disable-line camelcase
guilds: [],
shards: [],
monthlyPoints: b.votes,
points: b.totalVotes,
certifiedBot: false,
owners: b.owners
.map((o) => o.connections.find((x) => x.type === "discord")?.id)
.filter((x) => x != null),
tags: b.tags.map((t) => t.slug),
reviews: {
averageScore: b.reviewStats.averageScore > 0 ? b.reviewStats.averageScore / 20 : 0,
count: b.reviewStats.reviewCount,
},
bannerUrl: b.__typename === "DiscordBot" ? (b.backgroundUrl ?? undefined) : undefined,
};
};
^ turns out we do backport them to discord IDs so i guess there's that
i swear i remember someone saying that the date property is when the bot was approved 😭 time to change it on every sdk i've worked on
date: b.createdAt,
i know
since i haven't touched it since the last time i fixed bugs for it
Not using at least TS here is a crime tbh
lol my bad then, it was some time since I got free of any javascript/typescript in our codebases and I forgot how messy it was
everything here is a type narrower
I thought at first API was slow as server is dying
But if it's JS based then it would make sense :/
I don't know larger canvas but having some map/set and calling .find() method each time is suicidal for performance.. especially when it has lots of elements - just heads up
Yeah, just saying, just in single return - single call you do at minimum 7 for loops in this piece of code
Where it likely can be limited down to 1, maybe 2
And in case of JS it means new stack calls, etc.
Both yes and no... I won't attack you about it or anything, just saying there's lots of hot spots blatantly on view.
While in a test case it's just a few nanoseconds or like 1ms, at scale it can quickly grow, especially in case it's single threaded. V8 uses IO loop (async/await stuff) but it's still ultimately bound to single core. V8 allows for child processes (aka threads) but they are very heavy, hard to use well.
Also it probably hits your GC like crazy, you create & instantly drop a bunch of stack frames and variables so my assumption is it makes GC way more frequent than it needs to be.
why would it hit my GC, im iterating over a list of references
we currently run 250 requests per seconds on three tiny machines, i think perf is fine for the website :p
opportunity cost is higher than to refactor legacy apis
I don't have all the data but yeah, moving fast is commonly more worth
Because you call new functions, they allocate blocks of memory, shuffle addresses, etc. generally do a lot of stuff that is really pointless for such simple stuff - then GC has to mark & sweep them.
Calling functions is not free, especially in interpreted languages
Also as you use map/set, you likely want to access data via key, otherwise use arrays because data is then allocated next to each other, resulting in way faster for loops
Map can store data that can be all over the place, making memory lookups take longer time
While what you're saying is true, it doesn't work for my usecase
Maps aren't serializable
btw. that... I have no idea of all the inner workings but it sounds crazy. Like if you render in real time som graphics and return then it's fine but for Rest API that accepts some json body, does bit of processing and returns other json - it sounds crazy.
its the entire react web server
For example, our work services are made in Go but a single docker container with 1GB ram, 2vCPUs locked at 3GHz & 1gbps connection (2 sides) - it's able to handle about 60k req/sec
Ah, so the website and API are same codebase?
It runs as single process?
I guess it's fine... like react and fast are opposite words lol
I have no idea about C# stuff
C# fast
based stack
Used to use TS way more back in the day but Go is just too good
It just works and is 5-10x faster just by being here lmao
both are cool, plan to use one of them in the future
Yeah, well if you don't need to do front end stuff, you basically always want Go between it and TS.
It's like free upgrade
If you know TS well, moving to Go is simple
I never tried C# so idk, only know that after Java I have PTSD with classes
Yes, I would love 7th deep class inheritance
C# and Go are equally cool, love both
I use Go for nearly everything nowadays as my "go to" language, not just some web servers
Obviously don't do super low level drivers or databases in it - althought you can if people do similar shit in Java..
But it's fully capable as backend for some apps, game server, etc.
Yeah, coolest part is that how freaky simple it is to start - like imagine teaching junior Go vs C++ now
Sure C++ in good use can be faster but honestly not all that much
Good Go code can get like I would say to even 90% of what good C++ code can achieve
But you'll pay a lot of time and sanity to do C++ good code*
C# I've also heard it is rather easy to pick up, just similarly to Java it is bloated with a lot of patterns, specific expectations how to code...
i don't really compare languages lately, imo it depends on the ecosystem, if it has the crucial things i need for my project, i'll use it
Yeah, for the most part I use it as tools
After all that's what they are
Just pick a correct tool for the job
Just never cry later when someone picks rust and is now behind with competition because it takes ages to make new features or when you have server in python and it's beyond slow...
well obviously you also need to be aware of its downsides prior to using it
Yeah but being good at gathering information in short time is one of the skills of any good engineer/programmer
It's obvious you won't know everything from start

- #support
- go to your bots page, and click the 'refresh data' button
- ensure your bot has a pfp, go to your app on the dev panel and ensure the pfp is there in the general info and the bot section
and lastly, dont post in 3 channels to get help.
Well its not the first time i ask so figured spam a few channels someone will open there mouth.
Also my bot page on top.gg?
yes
spam is against the rules, and thats also a bit rude
Yea not sure where u see a 'refresh data' button bc i just looked threw the tabs and dont see it anywhere
Yea i was lookin in setting where it should be.
@wary spoke
- please use one channel to ask for support, we have a designated channel here: #support
- please be more respectful when interacting with other users
thank you

what is
Top.gg Lib Dev API Access
and can i use it
and how do you use it
hello
any help at all
a bot listed for the sole purpose of library developers being able to access the API without having to list their own bot in order to gain access to an API token
so it will list my bots for me so i don't have to get them revied
what
no?
what
the libraries listed at https://docs.top.gg/docs (eg. https://docs.top.gg/docs/Libraries/python) are developed by people.
these people need a way to test their work
the Top.gg Lib Dev API Access gives them the token access to test their work
it doesnt list bots to avoid reviewal
Welcome to Top.gg
still don't get can you show me an example of what it does
it does not do anything
its only purpose of being listed is to give non-project creator Top.gg API library developers (like me) an access to its API token
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
how do you get the certified develipor role
One message removed from a suspended account.
?
?verify
i miss when this channel was locked 🥀
How exactly
@wraith pulsar 
ty
okay
Hey
veld, can you try checking some of the pull requests in pins? thanks 
just as a quick reminder
or maybe william can check them whenever he's free
I say hallo
i say hola
i say bonjour
i say vanakkam
💪
Does anyone maintain the top.gg JavaScript library? I'm getting the error Autoposter is not a function
I just copied and pasted the code that was in the documentation

reviewed
It should look like this?
I would avoid renaming the Api since it causes for a breaking change. For an incremental improvement I would call it "ApiV1" for now.
hum
I fixed that husky generated files thing
If you want, I can try to help create this class








my bad


