#topgg-api
1 messages ยท Page 8 of 1
Where do you try and host your code? At home?
Hey im unable to vote since morning as im unable to login due to multiple logins
Im unable to redirect to the karuat bot
Help me
Spamming your question in all possible and random channels won't be of any use.
Ask in #support and that's it.
@restive otter okay
Does the API have an endpoint that allows you to update your bots about me on its top.gg page?
No
Hi
-api
This channel is for suggestions, help, and bugs related to our official API libraries and documentation found at https://docs.top.gg/
If you need help with other development, please use #development.
topgg's APIs need to be updated, have been the same for almost two years or more
i mean they should add some features like servers API or update the bots API to allow you to perform more action such as changing the bot's description
Let us know how we can improve. Vote on existing ideas or suggest new ones. If you require support or would like to report a bug, please go to our Support Page ยท Make a suggestion ยท Top.gg
๐
Can someone help me pls
Go explain for me (again) please what isn't working, what u wanna do real quick
Whenever my bot is voted on top.gg, I want it to send a request to a webhook I have set up on the bot but whenever someone votes the bot, nothing happens
Does your endpoint receive the webhook coming from topgg when somebody is voting?
I have it use console.log to log who voted, and nothing was logged, so I'm guessing it didn't receive the endpoint, do note that this is a modified version of Pogy.
And I would like to have the votes logged
So since you aren't receiving any webhook from topgg, that's the first issue to solve
How would I solve that
Where do you test and host the code (endpoint)? At home?
Well there's your first issue
The webhook is creating an incoming connection.
Without port forwarding and opening this up in your firewall you wont receive anything.
How do I fix that
Which will most likely be impossible in your school as I guess you don't have access to a router, firewall etc.
I do have access to my coding software though
You can only fix that by forwarding the (selected) (webserver) port to your device (in your router).
And, if it's the default Windows firewall, create an exception in your firewall for that app and port.
Or literally just the stuff on a server.
Is it possible the webhook url I'm using is not getting the information from top.gg? I'm currently on a Chromebook rn
Which doesn't require any of this steps.
Oh
Which webhook URL do you use? No need to expose an IP or domain here
I'm using a custom one that is used with my bots dashboard which is ||https://mee8.ml/dblwebhook||
Is that your domain or is this simply a webhook forwarder tool?#
Yes
(the one hosted on your PC)
Supposedly
Ok but still you will never be able to receive this
And incoming connections has to be pass the router (firewall) and the one in your PC (most likely Windows I guess)
And those are forbidden (blocked) by default
I don't really know about the default firewall in ChromeOS tbh but still step 1 (passing the router) will fail
๐ yeah I was about to ask, does chromeos have a firewall?
Not that it's the main issue right now
Is it required to have a webhook or no
If you wanna receive the vote event (when it happens) in real time, then yes
Unfortunately you can't without whitelisting the incoming request (from topgg) forwarding it to the right device (your chromebook)
Only possibility is to host the endpoint on a server then
The router of your school, of your home etc. will be default drop the request - in other words will not forward the request to your device
It simply doesn't know where to forward it to
@jaunty plank your tool just receives the webhook and sends a webhook (message) to a channel, right?
Mine does as well
Yeah but unfortunately you can not receive it
May sounds dumb but theres no way for you to bypass the school's router in the first place receiving the request from topgg
Then I'll just remove the url from my bots top.gg page
Unless I need webhook.listener
Not really as the webhook listener aka. webserver listening for post requests wont ever receive any request
hmm?
Wait
I think I just noticed something
One sec
Okay
So when I vote Pogy, it sends the webhook
You mean you receive the request in your dashboard?
Pogy receives the request when someone votes for that bot, I want mine to do the same
I'm not really aware what Pogy is
Your bot or just a bot you're using?
or something else?
It's a bot that I was voting
And it sent me a DM
After I did
And I want mine to do the same
I'm viewing the markdown file rn
And Pogy isn't your own bot, right? Not hosted on your PC (at home or school)?
It's not my own bot
My bot is using the repository, but on the v13 repository
Since the V12 one broke
Yeah well then it doesn't have to deal with your issue
It's probably running on a server that can receive this request by topgg
I'll ask in the Pogy support server then
Sure but keep in mind you wont be able to receive any request by topgg ever unless you can do the steps I explained above
Ok
Yeah
Okay, I realized I had to use a custom password
So I just spammed a bunch of random letters
Only thing I can think to bypass his restrictions is to let your tool send a specific message to a hidden channel of his he then will receive through the bot's message event
wut? setting the auth password is not required
hmm interesting
where can I access bot token to access api
Pogy I guess requires that auth password as they sent me an image showing the declarations
and opened up router receiving your requests in your school... damn I must get access to this thing, too
ah, you mean you wanted pogy to receive the requests for you
well that's an entirely different story
didn't you tell me you wanna receive those requests on your bot from topgg?
ah ok, thought I missunderstood you
on the topgg website
It doesn't send the test webhook but idc about that
Edit your bot > left menu Webhooks
well if works, it works I guess
Yep
so I was using the api for counting and logging the votes and I used my port of my pterodactyl server in app.listen(), and when I was trying to shard the bot and at the time of launching the shards,
getting error that the port is already being used. Which I was using for listening the votes.
Anyway I could prevent this thing.
By not using a port thats used already
The sharding thing was automatically taking the port that was being used for listening the votes
I tried changing it to 3000/8000 in the app.listen() still same error
Post the exact error you're getting
a sec, I'll send the vote part, error, and shard part
my sharding file
const { ShardingManager } = require('discord.js');
const { bot_token } = require('./config.json');
const manager = new ShardingManager('./index.js', { totalShards: 2,
token: bot_token });
manager.on('shardCreate', shard => console.log(`Launched shard ${shard.id}`));
manager.spawn({timeout: Infinity});
a part in index.js where i listen to votes of top.gg
const User = require(`${process.cwd()}/Models/User.js`)
const Topgg = require("@top-gg/sdk")
const express = require("express")
const app = express()
const webhook = new Topgg.Webhook("my-webhook")
app.post("/dblwebhook", webhook.listener(vote => {
// my code stuff
}))
app.listen(20376)
error am getting
node:events:491
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::20376
at Server.setupListenHandle [as _listen2] (node:net:1740:16)
at listenInCluster (node:net:1788:12)
at Server.listen (node:net:1876:7)
at Function.listen (/home/container/node_modules/express/lib/application.js:635:24)
at Object.<anonymous> (/home/container/index.js:182:5)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
Emitted 'error' event on Server instance at:
at emitErrorNT (node:net:1767:8)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'EADDRINUSE',
errno: -98,
syscall: 'listen',
address: '::',
port: 20376
}
this was when i kept the port according to my ptero panel server, when i changed the port to 3000/8000 same error came just in the error the port 20376 changed to the port i used in app.listen()
anyway i can listen to votes as well as shard my bot?
ping me if anyone replies
Yes, just like the normal way
wdym the normal way
but am getting the error of port already in use cuz am listening to the votes
and when i change the port same error
Because you're starting multiple times the web listener instead of only once
it isnt mu;tiple times, its just in the index.js and no where else in the code, and the sharder file reads it
I guess the manager will execute that file X times the amount of shards you have
Why can't you just use something like
const client = new Client({ shards: "auto" });
Shards will be created automatically
Not sure if that's up to date code though, but docs says it's a thing
Otherwise if you want to use that shard manager, it will execute your index.js files X times, X being the amount of shards you have. So it will start X times a web server on the same port, which obviously won't work.
To solve that you can start the web server outside of the index.js file and either share the information to all shards when a user voted, or you can probably just make a global web handler for it. Not sure how that could be done in JS though 
The sharding manager should contain the webserver, from that point you can broadcasteval whatever you need to
can someone tell me
what kind of encoding/encryption they use for voting payload
Neither
how so
It's just a webhook sending json data
encryption definitely not
and the data is not encoded, besides the json encoding
Its using normal https, and does have the ability to send a user set password in the headers (to allow you to validate that the request is coming from Top.gg servers)
But nothing more that as Krypton said
and the schema is https://docs.top.gg/resources/webhooks/#schema
Why would there be one @grave vigil?
Giveaways are over since like 3-4 months, you're just a little bit late.
Also wrong channel to ask for that sort of thing
hello, is there any aoi.js users who know how to use the voting system?
could you elaborate a bit?
Yeah sure.
You cant listen to a single port multiple times, for example in each shard. So what you do is have it run in the sharding manager file.
const { ShardingManager } = require('discord.js');
const { bot_token } = require('./config.json');
const manager = new ShardingManager('./index.js', { totalShards: 2,
token: bot_token });
manager.on('shardCreate', shard => console.log(`Launched shard ${shard.id}`));
manager.spawn({timeout: Infinity});
const express = require("express")
const app = express()
const webhook = new Topgg.Webhook("my-webhook")
app.post("/dblwebhook", webhook.listener(vote => { // running with the sharding manager
manager.broadcastEval(async (client, { vote }) => { // broadcasteval to every shard
// my code stuff
}, { context: { vote } })
}))
app.listen(20376)
The above code will only run once, but every webhook request will be sent to every shard via a broadcast eval.
From there you can do any necessary checks, or do anything you would typically do.
Just a bit of warning, all shards need to be ready before doing a broadcast eval. If your shards are not ready before receiving a webhook it can cause crashes. This most often happens when someone votes shortly after your bot is restarted. Top.gg will then retry the request up to 10 times over a period of 17 minutes. That can cause a bit of a crash loop. Which is no good ๐ฆ
I would offer a solution, but I'm still in the early stages of working on this and I'm not entirely sure what the best way of handling it is.
My current solution is just wait to start broadcast evaling until the manager.spawn() promise resolves, but if an individual shard restarts the error would occur again.
what if I host the vote listening codes in another server just alone? As I use mongo, so database will be ok with different servers.
I guess that should be most less risky way to do it
๐ if you dont need the code to run on every shard you dont need to do any of this right.
If you're just sending data to a database it doesn't matter.
Just got this
TopGGAPIError: 504 Gateway Timeout
at Api._request (/home/container/node_modules/@top-gg/sdk/dist/structs/Api.js:61:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Api.postStats (/home/container/node_modules/@top-gg/sdk/dist/structs/Api.js:86:9) {
response: {
statusCode: 504,
headers: {
date: 'Thu, 30 Mar 2023 18:25:48 GMT',
'content-type': 'text/plain',
'content-length': '14',
connection: 'keep-alive',
'cf-cache-status': 'DYNAMIC',
'strict-transport-security': 'max-age=15552000; includeSubDomains; preload',
'x-content-type-options': 'nosniff',
server: 'cloudflare',
'cf-ray': '7b02643cdb70adbc-ATL',
'alt-svc': 'h3=":443"; ma=86400, h3-29=":443"; ma=86400'
},
trailers: {},
opaque: null,
body: BodyReadable {
_readableState: [ReadableState],
_read: [Function: bound resume],
_events: [Object: null prototype],
_eventsCount: 3,
_maxListeners: undefined,
[Symbol(kCapture)]: false,
[Symbol(abort)]: [Function (anonymous)],
[Symbol(kConsume)]: [Object],
[Symbol(kBody)]: null,
[Symbol(kContentType)]: 'text/plain',
[Symbol(kReading)]: false
},
context: undefined
}
}
am sending data to a db as well a message to a channel
504 Gateway Timeout
5xx are server errors, nothing you can do besides trying again later
tried this and it kind of didnt work, no data was sent, or message was sent
but the same code use to send data & message before sharding
What code did you use?
//sending vote message & saving votes to db
//const User = require(`${process.cwd()}/Models/User.js`)
//const Topgg = require("@top-gg/sdk")
//const express = require("express")
//const app = express()
//const webhook = new Topgg.Webhook("mywebhook")
//
//app.post("/dblwebhook", webhook.listener(vote => {
//
// User.findOne({ userId: vote.user })
// .then(olduser => {
// if (!olduser) {
// const newuser = new User({
// userId: vote.user,
// voteTime: Date.now(),
// voteStreak: 1,
// });
// newuser.save();
// } else {
// olduser.voteTime = Date.now();
// olduser.voteStreak = olduser.voteStreak + 1;
// olduser.save();
// }
//
// User.findOne({ userId: vote.user })
// .then(voter => {
//
// if (voter) {
//
// if (vote.isWeekend === false && voter) {
// const nonweekend = new EmbedBuilder()
// .setTitle(`Vote`)
// .setDescription(`Thank you for voting for me! You have voted for me **${voter.voteStreak + 1}** times!`)
//
// client.channels.cache.get(`1073909878516629526`).send({ content: `<@${vote.user}>`, embeds: [nonweekend] })
// } else {
// const weekend = new EmbedBuilder()
// .setTitle(`Vote`)
// .setDescription(`Thank you for voting for me! You have voted for me **${voter.voteStreak + 2}** times!`)
// .setFooter({text: `It's the weekend! You get double rewards!`})
//
// client.channels.cache.get(`1073909878516629526`).send({ content: `<@${vote.user}>`, embeds: [weekend] })
// }
// } else {
// console.error(`No user found with ID: ${vote.user}`)
// }
//
// if (voter.voteStreak > 0 && voter.voteStreak < 7) {
// //first week rewards
// } else if (voter.voteStreak > 6 && voter.voteStreak < 14) {
// //second week rewards
// } else if (voter.voteStreak > 13 && voter.voteStreak < 21) {
// //third week rewards
// } else if (voter.voteStreak > 20 && voter.voteStreak < 28) {
// //fourth week rewards
// } else if (voter.voteStreak > 27 && voter.voteStreak < 35) {
// //fifth week rewards
// } else if (voter.voteStreak > 34 && voter.voteStreak < 42) {
// //sixth week rewards
// } else if (voter.voteStreak > 41 && voter.voteStreak < 49) {
// //seventh week rewards
// }
//
// })
// })
//
// .catch(error => {
// console.error(`Error finding user: ${error}`);
// });
//}))
//app.listen(20376)
So this was used in my sharding file this without the commenting+broadcast eval part
This code used to work when I didn't had sharding
Looks like you dont have a client in that code, so you're fetching a channel from nothing and sending to nothing.
It honestly might just be easier to use a discord channel webhook rather than sending the message via your bot and then run it on a separate process(a separate NodeJS program).
Then you can just avoid the sharding issue all together.
Sadly, this is one of those things when you go from non sharded to sharded you'll want to rewrite and not use previous code.
why do I keep getting this error when I try testing?
If you've spammed it a lot in a short period of time like that you're probably ratelimited
try again later.
oops
b
is there anyway to use top.gg API to get the announcements from my bot and send it to my support server?
no
Any idea what the other stuff are except this that could potentially cause issues while sharding
Well, you'll need to broadcast eval that since you're sharded, check if its the shard that has the channel cached.
You'll want to check that before performing database actions(Since it'll run on every shard).
(also the fact everything is commented out doesn't help, but I know you mentioned that)
this was the untouched code how it used to work before sharding in my main index file. Ignore the commenting
sharding changes how things work
fundamentally you have to think about it a different way.
Webhook comes in, goes to sharding manager.
The sharding manager isn't a client, it doesn't have channels or guilds cached, nor any "bot" related stuff.
You need to find the shard which has the client which has the channel cached that you want to send webhook messages to.
Which means broadcast eval to all shards and check if the channel is cached.
then handle it as normal.
Which is why I think this might be the ideal way for you.
Handle the Top.gg webhook like you used to, but instead of sending a message via your discord bot use a discord webhook on that line. That way you avoid all the sharding issues.
Ideally on its own process since it shouldnt depend on your bot anymore.
This is assuming all you want to do is access the db and send that message.
hi i have a qn:
is it possible to use the api to check if the user has voted in the past 12 hours and direct them to the link?
We do have an api endpoint to check if someone voted in the past 12 hours https://docs.top.gg/api/bot/#individual-user-vote
is there a lib for it?
iirc, api.hasVoted() returns a promise, use await or else your result would be undefined
yeah will do it from now, thanks for your help 
can anyone explain what the difference between avatar and defAvatar? because i still don't understand it from their description alone
when is the proper time to use one or the other?
think defAvatar is for the default avatar icon that discord gives once you sign up to discord
avatar is the normal avatar hash ig
top.gg API documentation says otherwise
they also give out different hashes 
could you copy and paste that hash
turned out that avatar matches the hash from cdn.discordapp.com
but i still dont know what the defAvatar hash correlates to
tried that hash and didnt work
sec
huh
still cant find anything about that hash
the default avatar is calculated using user discriminator as far as i can see in d.js
yeah i know that
but the default avatar url looks nothing compared to that hash

its simply just 0.png 1.png 2.png 3.png 4.png
yeah
wait
are top.gg bot avatars loaded from cdn or not
i mean
if the icon is missing
shrug
anyway
what is clientid for? it's in the examples but not documented on the Bot structure 
what's it's purpose when you already have id
god the API is so poorly designed
yes but what's the difference between clientid and id
is shards actually a number[] or a string[] 
๐๐
gotta love misleading documentation
Well in the API most likely string
Since it doesn't make sense people use number/int in API wrappers
Can't the client/app id be different than the bot id sometimes? idek
Only thing that would make sense to me otherwise it's just redundant
doesn't sound like it
Love to see it
What else can it be 
Users can only choose between a small range of pre-defined colors, why would it not return a valid hex value
wym by pre-defined colors
and how can pre-defined colors generate invalid hex values
Aren't these the UI colors?
Yeah that's my point 
oh 
watdafuk
It's color? just don't return it if the user hasn't set a color or something
One more thing added to the poor designs
also they seem to have removed the color option
so should it be marked as deprecated? 
i don't see the color applying to my user profile in any way either
It's not on your profile
It's when you click the user icon at the top right
You can choose color there
That thing
tried changing it and the color property doesn't change after re-requesting
apparently it was from an older database
because you used to have customization for profile colors with hex

Sorry i apologize for using the wrong channel 
Wait how did you use text with colors
thats just formatting by discord
Can you tell me how to use colors?
Maybe read above
see what Krypton said
theres also docs on discord for that https://discord.com/developers/docs/reference#message-formatting
``language```
:b1nzy:
Just give an example on how to use color cause there's too much to read
quick question
blazingly fast question
if you post your bot stats to some random bot ID will it return 401
or something else
i mean you can try
I'd say 401 but seeing how the API is
Could very well return anything at this point
Eventually 403
It will return with a unauthorized error if requesting a endpoint that the token doesn't belong to
so 401 or 403
too much effort

is that battless taking control over null
battleless*
Test
Nevermind I fixed it
Ok
nah dw, just confirmed it recently
@restive otter @rain heart looks like it's actually 403
Yes, as per docs
oh my god
Unauthorized is 401 btw
So it doesn't return an unauthorized error
401 is only for invalid token ig
It literally has the same meaning, both mean that you do not have access to a certain resource
Unauthorized has not the same meaning as forbidden, no
no
401 is no credentials or invalid
Cry about it then
403 is valid credentials but no permissions
So 403 makes sense
Though not documented anywhere
Can i ask doubts here?
Unless I've missed that part in the docs
Where have you seen that 
it's not documented in the docs 
as usual
ngl the docs has a lot of missing things - i might make a pr in the future
At this point just use the api and make some deductions 
agreed
ran into some bugs, despite fully complying to docs once 

yeah
thanks krypton

use tokio::task;
for i in 0..5 {
task::spawn(async move { client.post().await; });
}
``` 
very good
Hi. When I hit the top.gg/api/bots url, the .body is an extremely long string of html. I was expecting it to return a JSON response (like what the docs say), but it didn't. Is there a reason for this?
Small portion
Hmm, are you sure you're using the right url?
When I send a request to it I get json results https://top.gg/api/bots
what is the status code?
Anything with api?
where can I get my api key?
Why the votes that were in my bot went
Votes reset monthly
Ok
Is it possible to put a discord webhook to be notified when voting for my bot?
Top.gg ----POST----> Your Web Server ----POST----> Discord
You will need a web server in-between to catch the request of Top.gg
hi ! sorry to disturb but I've got a problem with the kvote in the karuta server / game... can I ask some help to anyone ?
my "vote" check keep being in ๐ when it should be ๐ ... it's been like 1 week, or 2, the issue won't get fixed... idk what to do... and I don't receive the notifications on my private messages anymore to remind me to vote...
does anyone knows what's going on ? thank you so much in advance !
-wrongserver
Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Discord Support Server" button on the bot's page of the bot you need support for. If there isn't a button that says "Discord Support Server" or nothing else mentioned about a support server, the server invite is invalid or you were banned from the bot's support server, then we can't help you. Sorry :(
oh sorry.. when i click on that it keeps sending me to this discord
Scroll down, click on the "Discord Support Server" on the bot page of karuta
Not on the Luca bot for example, on the karuta bot page
I'm stupid ๐ญ tysm for your patience !
I won't bother anymore ๐๐ผ thank you very much
final url = Uri.https(baseUrl, "api/bots");
final response = await http.post(url, headers: {"Authorization" : token});
return response.body;```
api/bots translates to top.gg/api/bots, I'm pretty sure
Can you tell what URL it's hitting from what it was printing?
What happens under api/
Looks like you might be positing on that endpoint. That endpoint is intended to be for getting.
That's the problem, thanks
cc @hearty lintel https://github.com/top-gg/node-sdk/pull/77
The discriminator property doesn't exist in the objects returned in /bots/votes. (see https://docs.top.gg/api/bot/#example-response-1)
couldn't access #topgg-open-source so i'm just gonna send it here
still thinking about how to handle this. type changes can be breaking
fair point
also, did you verify this against the api or are you just going off what the docs say
both
Read pinned messages
oh ya got it @topgg/sdk
btw will this code still work? I made it long time ago
const Topgg = require("@top-gg/sdk");
const app = express();
const api = new Topgg.Api(process.env.topggtoken);
const webhook = new Topgg.Webhook(process.env.topggauth);
app.post("/dblwebhook", webhook.middleware(), (req, res) => {
// req.vote is your vote object e.g 221221226561929217
console.log(`${req.vote.user} Voted the <bot>!!`);
// database add
});
Hi can someone provide me with an example of how to use topgg api in commands like if the user hasn't voted it sends them a message saying they have not voted and if they have voted it lets them use the command
There are examples in the library you will be using
I'm using discord.js but I can't find it anywhere
I can though, read the docs
I did
https://topgg.js.org
https://topgg.js.org/classes/api
https://topgg.js.org/classes/api#hasVoted
Definitely not otherwise you would've seen that
resolve Promise { { voted: 1 } }```
anyone know about this error?
My code: js let voted = await topgg.hasVoted(user.id)
It's not an error?
the servercount is posted by your bot, ensure you're using the correct token
regenerate, refresh the site, then copy the token visible
Yea I'll try that thanks
Multiple resolve error
Sorry, thank you
hi, how do i check for that if a user has upvoted my server?
Thats not possible with the api as servers do not have one
You will either need the role rewards feature (refer to https://support.top.gg) or use webhooks, which requires programming
yeah I can program thats where my question came in, does it work the same way as the bots do as far as ive understood it works by hosting a webserver that recieves webhooks from top.gg containing the information?
Correct, just provides different data but essentially the same
whats the endpoint i cant figure to find it? and also afaik from what ive understood you need a bot from top.gg to do this, like for discord
Its not an endpoint, top.gg/servers does not have an api like top.gg/bot does
The only usable feature to collect votes is webhooks
oh, so I can listen for both servers and bots, individually without having to have different routes? so the only route required is for the server?
also cant find where to get the token from
Again
Theres no api for servers like bots does
Yes you can theoretically use the same path on a webhook, as long as you ensure that the data you're receiving is categorised by what is being voted for
Meaning there is no api token to obtain for top.gg/servers as it does not exist
yeah ive understood that i landed up here: https://topggpy.readthedocs.io/en/stable/webhooks.html
reading rn
import topgg
# This example uses topggpy's webhook system.
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password")
# The port must be a number between 1024 and 49151.
bot.topgg_webhook.run(5000) # this method can be awaited as well
@bot.event
async def on_dbl_vote(data):
"""An event that is called whenever someone votes for the bot on Top.gg."""
if data["type"] == "test":
# this is roughly equivalent to
# `return await on_dbl_test(data)` in this case
return bot.dispatch("dbl_test", data)
print(f"Received a vote:\n{data}")
@bot.event
async def on_dbl_test(data):
"""An event that is called whenever someone tests the webhook system for your bot on Top.gg."""
print(f"Received a test vote:\n{data}")
``` this is an example for how to listen on server votes right?
ohhh
nvm
its for the bot
Unsure if topggWebhooks also supports servers
so what kind of webhook am i supposed to create to check for the server upvote
this server bit is very confusing the bot bit looks simple
The same one essentially, just unsure if the Library has support for it
dont i need an api token for the library
Then it won't work yeah
You might need to make your own webhook using flask for example

all this hassle to have 3 more views on server listing
is there a way to speed up bot submission? like payment or something
with enough money, yes
realistically, no
Not at all
BRs don't accept bribes, and if you try you may even get banned
So all you can do is patiently wait like everyone
-servercount
To have your bot's server count displayed on Top.gg, please read the documentation on server/shard posting.
thx
here is my code and err .. i don't get it why it says cannot initialize ..
Why are you subtracting api from this.client.config.topgg
You can't have variables named like topgg-api
Something like topgg_api is possible though
you can do config["topgg-api"]
but ah, bad
why i got this error after i added auto poster
is there anything i need to do to fix it?
taking a fair guess that whatever that anticrash is, is the cause
Never tried to bribe just ask if thereโs like a premium waitlist
That's what happens when you copy pate code from GitHub
Also unrelated to this channel, ask in #development
Also give the source of where you've copied the code as it may help others to help you
what copied
its from docs
Here is an example
If you copy paste code without even knowing what it does you will face such issues
So give from where you've taken it and ask in #development
Unrelated to the API
dude it was given to me by a dev from discord developers to fix my unknown interaction problem
bro pls shut
????
That's unrelated to the channel, use channels correctly jeez
You get the error because of copied code, ask in #development my god
Without that copied code it would most likely not even throw an error
read the channel topic - #development is for coding help (what you need), because this topic is not related to the API libraries or the API itself
It's not about my opinion
@rain heart
It's about you keeping on asking in the wrong channel
#development for api-unrelated issues
Use channels correctly for once
since your issue turned into a general development issue rather than an api one
ya i would dude but this dude is like copy and paste issue
Is there way to check all voted users in 12 hours ? i need those for save external database (webhook bot is down for Capple hours some users vote are not saved that's why i need this)
There's no efficient and reliable way except hosting your own webhook
There's a last 1000 votes endpoint, but does not reflect times
how do i call it
Check the docs, though again keep in mind that it does not reflect times, meaning it will still show votes that have long expired
Hm, then there is no way
Except again webhooks you'd host yourself but yeah
is there any way to count the votes of a user
like when a user use /vote command
it shows him the how many times he had votes
is there any way
Only if you collect this data yourself every time someone votes
guys how to get toppgg token?
Read the pins
Object {
error: Unexpected token o in JSON at position 1
}
this happens when I try to post bot server count with http requests
You're probably posting content as being [object Object]
Print what you post and analyze it
And you most likely need to JSON.stringify({...}) your body content
Yes, it was this, btw on the topgg page I don't see server count, but if I do a get request to the endpoint, I see it. How much time will it take to update?
~30 minutes
Thanks, let me say thanks also to the other user...
Wait...there was another user in this channel that helped me...he has probably deleted the message...
so gateway timeout means that my bot got rate-limited?
No
Just means that cloudflare doesn't like top.gg or vise versa
Read the docs on ratelimiting
petition to make /bots/:bot_id/reviews public
an undocumented private api endpoint already exists so i don't see why it's not a part of the official API by now
wait that exists

that would be a great endpoint icl
love how the api bug i reported last week still happens and i did not get a reply
always has been
ah
doing some testimg
https://top.gg/api/bots/866364881917837312/votes returns 24 votes, not the last 1000
my bot has 41 votes so getting 24 is weird
yes
jk i was testing
nothing harmful ๐
found some bugs where it returns json { "error": "Unauthorised" } when no auth provided, but 404 returns a html page when valid auth is provided, error should be better handled for trying to access bots you don't own via api, same for ones that do not exist
*when valid auth is provided, but 404
just check the status code
Monthly
i have more monthly votes tho, i have 41 not 24
Hello, Can someone tell me how i can make an announcement and give a role with the bot when someone votes? but for it to be auto
Read the pinned messages, maybe look for some library depending on what language you use and that's it. The rest depends on your programming skills
How can i know when a user votes on python?
Like how some bots pm me after i vote for them
using the check endpoint
but you will not be able to get realtime votes
that is ONLY possible with webhooks
a very bad workaround but perhaps
Some people have done it, but yeah its not how it should be used.
if that's your only option then that will be what you have to do.
a fair number of developers do use the service that way, its just very iffy and not something I can give support for if/when something goes wrong.
down again?
I really don't like to do this but I can't think of any reason why this code is running on my macOS system but on the raspberrypi the endpoint gives me back the Error 401 Unauthorized I don't change the code in any means it's the same token the same everything.
@restive otter bro bot ko bekar kariya hai
Content type json
Then it should work
Krypton is not a flantic dev, pinging multiple times will not help 
#general anyways
He sold it
I used the method and get an error message in the console. Can someone help me?
File "/app/main.py", line 27, in
bot.topggpy = topgg.DBLClient(bot, dbl_token)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/topgg/client.py", line 98, in __init__
self.http = HTTPClient(token, loop=self.loop, session=kwargs.get("session"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/topgg/http.py", line 84, in __init__
self.session = kwargs.get("session") or aiohttp.ClientSession(loop=self.loop)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 228, in __init__
loop = get_running_loop(loop)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/helpers.py", line 289, in get_running_loop
if not loop.is_running():
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/discord/client.py", line 140, in __getattr__
raise AttributeError(msg)
AttributeError: loop attribute cannot be accessed in non-async contexts. Consider using either an asynchronous main function and passing it to asyncio.run or using asynchronous initialisation hooks such as Client.setup_hook```
This channel is for suggestions, help, and bugs related to our official API libraries and documentation found at https://docs.top.gg/
If you need help with other development, please use #development.
330139565
Well now it gives me back this response that the json is invalid?
what does your json data look like
I do not give a json especially I use the data parameter instead with a dictionary
from the requests libary
then it will not work, you need to provide valid JSON data
as what you can see at the top screenshot
but it works on my macOS system, why should python requests behave differently than on a linux system
well okay I'll try it
sounds like different python versions on both tbf, newer versions of python could be converting the data variable automatically when providing it to requests, others not
generally good practice to have it done through json.dumps nonetheless, so you can both ensure it is, aswell as ensure it is valid data before passing it on (as invalid one will not even attempt to send it and just break on that)
now it says that " is a unexpected token?
the json looks like this {"server_count": 155} what should be wrong with that?
Do you add the content as data or as body?
Can you show the entire request please the code
I've tried it from Postman to manually send a Post Request and from there it worked
now I tested it from my macOS system and on there it also doesnโt work with the json
could you concert the whole json dumps into hex?
print(string.encode("utf-8").hex())
this should allow you to see the raw text and allow you to see what is literally being added there from somewhere
there is a \ before your json data
or just print(repr(string))
yep
lol
what
now it didn't give a error back?
but I changed nothing from the code?
i just added this
can someone help me??
and now it also wworks without that
well now it works so leave it as it is rn and never touch it again
THOUGH YES I changed something
I changed the parameter back to data from json cuz I tried something different
so even if I pass a json I should use the data parameter and not the json parameter makes sense yes for sure
Ah there we go, I didn't notice earlier but already asked you about this
If it is already solved then nvm
Yeah I thought tbh that the json and the data parameter does the same thing
Idk if I'm misunderstanding but isnโt there standing that it does the same thing?
Correct, simply in a different format
They're both optional so you give one of them only
Hi all I want to know how to get my api key
The settings for this can be found while editing your bot or community, underneath the โWebhooksโ section located on the left.
How does the topggpy handle the on_dbl_vote function? I mean how does it work with a webhook or what
It uses the webhook right.
what does '/dblwebhook' do?
is that a placeholder for the webhook url?
No, it's the endpoint that needs to be called
e.g. if it's /webhook you'll need to put the webhook URL in your bot's settings to
http(s)://<DOMAIN/IP>:PORT/dblwebhook
e.g.
https://my-awesome.bot:5000/dblwebhook
and obviously you need to own my-awesome.bot and run your web server there
and if you don't have a domain it's just your web server's IP like
http://123.45.67.8:5000/dblwebhook
just curious; what is the use behind this?
I used it for vote reminders before, being able to tell if they clicked the link on the reminder to then tell them "thanks for voting again"
Also probably analytics too
yeah but i don't remember a query string existing there
Its an optional parameter, you can add it to the vote url and will be provided on the webhook data
ah i see
thank you!
is it possible to get the guild of a user who voted for my bot?
You can use the query parameters above
awesome ty
Why am I not able to use @top-gg/sdk?
I did the same as it is on the npm website and it won't
there are no errors, just nothing happens when someone votes for the bot
I don't know how to do this in VSCode
This will be hard to do on a local machine
is it me or the /api/bots endpoint just straight up doesn't work? (https://docs.top.gg/api/bot/#search-bots)
like it just constantly sends the same response
with the same bots, no matter your input
the same response in its entirety?
because i could totally imagine that auctioned bots will be the first appearing 
probably
it matches ~38k bots
and the first bot in the list is always Hydra
despite the username query not having to do with it ๐ญ
like try
fetch("https://top.gg/api/bots?search=" + encodeURIComponent("username: usernameHere"), { headers: ... })
and see how the result is always the same
its been broken for months
i remember testing it over a year ago with that shitty topgg-simulator site i made, it has returned the same thing for probs over a year
LMAO
also might just be me but i think the docs should be remade
it's poorly formatted and feels over complicated
literal pepega
bearing in mind most of its users are beginners it just feels cluttered and needs reworking
nah i think the only thing they're working on is Auctions at this point 
but the API and docs is broken 
and i'm concerned how the website goes down very frequently
true
the API does need rewriting 
and also features like review editing, deleting and replying needs fixing
either people are constantly DDOSing it or the website is badly maintained
i doubt its ddosses
well i can't 
Without pasting apollo docs would be nice as well 
yes
inb4 i use my tailwind template one from tailwind ui ๐
should use that
well it's not bad
at least better
and you don't have apollo in every social card like https://docs.top.gg
noice
damn time flies fast
lots of things are much needed though
also true
yeah

testing with that tailwind one
the API's bugs should be more prioritized than the docs
The top.gg/api/bots endpoint (https://docs.top.gg/api/bot/#search-bots) always return the same response no matter the query. Other people have also reported that this bug has been happening for months to years now.
also nice issue 420
yes but like this is something which we can help with, we are unable to help with API bugs 
i doubt they will update the documentation at this point
the last commit was a year ago 
lmfao
Should make one post with all issues it has tbh
like what
Like one post with all the api issues
that's the only major api bug that i know
e.g. inconsistency, /api/bots not working, etc.
inconsistencies like the whole camelCase snake_case thing can break lots of bots if they're changed
Not really no
๐ breaking changes are expected with an unreleased api like ours!
we're not even on v1 yet!
lmao
nice
Ideally, updates would be on its own endpoints and the old ones no longer receiving support.
sooo when will v1 come to existence?
kind of like how discords api is v1 v2 v3
Soon, like it has been for the past what 5 years?
Some internal stuff last I heard
internal stuff 
will this be one giant pull request
i have 0 clue i am currently just playing around with it
honestly worth it
because it genuinely looks good
are you saying theres something wrong with out litterally perfect docs that may or may not look like they were made in 2009
it's not like it won't change anything for the api itself
the stolen ones 
^_^
and definitely looks better than some randomly pasted apollo docs
lmfao
me when the private api endpoints are better maintained compared to the public ones 
lol
dw, I'm like a year into asking for stuff too
@woven coral @restive otter i deployed what i have done so far
Integrate the Top.gg API into your bot!
i like the style of the codeblocks
i have done everything up to dotnet, and the source code is at https://github.com/bchurton/topgg-docs
Might want to change the prose links color
oki doki
Same for bg color, because on the sidebar it uses that apparently
Isn't there an option to enable the sidebar for mobile as well?
Otherwise looks pretty nice
Where did the
We're going to be working on the next version of the top.gg API (v1) soon, stay tuned!
go
Removed that to prevent false hope 
Afaik yeah, will get that sorted in a bit

@restive otter @tidal idol they have been "working" on v1 for 2 years 
currently
yeah right
lmfao

v1 is just very very large.
our dev has been working on it consistently the whole time! I promise!
/s

colours changed
just gotta figure out how to get mobile navigation working
poggies
make sure to also add proper documentation for the Go and Lua SDK
alrighty ๐
i'll go through those and make sure they are added here
@golden adder do you have the link for the Top.gg assets drive link?
Trying to find the red logo for the favicon
iirc there was some google drive folder around
me when favicon is a png and not ico
also mac pls pass to the team that https://top.gg/favicon.ico needs updating, thats why Cloudflare shows the incorrect one
virgin ico vs chad png

yipee
๐ how is that not updated
That's been the case for years 
also its github.com/top-gg/go-sdk not github.com/top-gg/go-dbl right
yeh
the PR (2 years old) for adding go docs says go-dbl lol
Github keeps aliases so not that much of a big deal tbh
yeh
Integrate the Top.gg API into your bot!
deployed
copied every page over
and fixed prose colour
just gotta figure out mobile sidebar
now good luck getting them to merge your pull request
lol
if they ever will

doubt
could be possible though, maybe they want to get rid of the apollo copy pasta as well
it's not really copy pasta
templates are made to be used lmfao
that apollo yoink isn't a template
it's a stolen ui 
lmfao
which is a template
with nice ads
i'm gonna go add better meta tags
at least they showcase they may be using apollo in the backend for graphql
at least top.gg is not as bad as replit
replit uses a websocket for an API
and now
Integrate the Top.gg API into your bot!
Better meta tags
lol
Put some space between top.gg and the logo tbh
i started the mass migration nearly 2 hours ago
oki doki
and imagine in the end they just ^
no thanks we'll keep it as it is
ah fuck i closed photopea 
also some spacing between the top and bottom text maybe
how does it look on - https://top.gg
the inconsistency is real
well keep it as small T
everywhere else it's big T but not the social card
yeah
as in the logo?
every person we know has left 
wym some people i know are still here
e.g.
every dev ever
yeah i mean the devs, not the staff kek
then
how many Team members are there
since it's unhoisted we'll probably never know for certain
<@&742408262648987748>
isn't there some bot that can list all members that has a role 
This better?
^
oki doki
otherwise it's good
lmfao
at this point
just a new repo is needed
because this is replacing all the code and basically making all the PRs sorted
also this is entirely new code 
can probably make that an href to https://discord.com/channels/264445053596991498/412006692125933568
could just merge and close all the others as fixed in pr #x
also true
Hi
code href โค๏ธ
yeh they look amazing
Hi guys ๐
honestly idk why i love that
i love it a lot
i'll push this and then try figure out how to fix mobile
also fixing the contrast on this
yeah especially with the icon
yep
also not sure about mobile navigation
search uses algolia which is a pain
might try modifying for local searching lol

yeah search is pretty much useless as well
it's such a small doc
can't really get lost 
lol
i'll add lgtm to you pr 
@restive otter @woven coral https://github.com/top-gg/docs/pull/79
This PR contains a complete redesign of the Top.gg API documentation.
It:
Merges several pre-existing PRs, including some that are years old
Redesigns the documentation using a modern Tailwind the...

Netlify couldn't handle it
lol
wym
its a 3 year old workflow
oh and also
i think it was brought up in #topgg-open-source
go ahead 

make sure to follow my format 
i have a diff repo as well
that was my one i just merged all from because it meant i could generate the preview myself with vercel (better then netlify fr)
Is it actually the right person?
so should i fork this one instead
yes
i might add a servers bit, stating that a servers endpoint does not exist, but webhooks etc still work
lmfao
that explains why netlify doesn't like it
and also why it hasn't been updated since march 2022
yeah its annoying 
top.ggโข๏ธ
very clear
I'll make some review 
Would replace docs with documentation though
also the package json name
yep
Would remove that credits page @tidal idol
Instead add like a author badge on each SDK's page
Thats a good idea






