#topgg-api
1 messages · Page 167 of 1
help plz anyone....
Your headers include { "Content-Type": "application/json", "Authorization": "your-topgg-token" } ?
And the bot you wanna post stats for is already approved?
What language are you using wumpus
yeps
I dont wanna post
I am making a get request
means english?
js
It shows the json data just with the link! then why do I still need the auth token?
?
It explains how to use them there
Is the bot you are trying to get approved
yess
Yeah I see the resource doesn't require an authentification
Yeah no that doesn't require a auth
@jovial kiln in code what is your Top.gg token ?
then why Am i getting 401? 😅
Still the same error?
You're still missing the header
content type
just to make sure, define the method as well
it gave the same error with that too
fake can u say?
{ method: "GET", headers: { "Content-Type": "application/json" }
yeps trying that now
wdym
Well your topgg token you can find editing one of your approved bots.
my bot is approved on top.gg
what should i do??
you can find editing one of your approved bots
means how bro?
Do you even read what I write?
Go to topgg, edit your bot, take a look at the left menu, choose Webhooks
ya i looked
You will find your token there
Token for this bot:
If you haven't generated one, then click the button
Token
You will need a token to perform certain actions with the API such as posting your bot's server count and checking who has upvoted your bot.
API documentation can be found here
Generate token
Show token
Webhook
Don't rustle your feathers for no reason, if you're lost you can read more about our webhooks here
Webhook URL
We will attempt to perform a POST request to this URL when sending you webhook data.
https://web.hook
Authorization
You can use this value to verify the requests are coming from us.
^
does it not work on http?
Well CORS is blocking your (external) request
brb stack overflow time
me?
I'm running real webservers tho, not using JS
There are no limitations
But you can adjust your CORS policy
You're using JS fetch in your index html?
yeps
If it was nodejs I would have been done and dusted by now
Well this fetch is "supposed" to fetch local files only, not external sources for security reasons
But as I said you can allow cross-site requests
Authorization
You can use this value to verify the requests are coming from us.
The authorization (code) for webhooks is a secret you can define, not you have to define.
It's like a password you can set but not need to.
Probably because your user-agent will be empty
You could try to send a user agent string within the request as header
Still with mode no-cors
what If I use nodejs and then just render the html template 😅 🤦♂️
fetch(...,
{
method: "GET",
mode: "no-cors",
headers:
{
"Content-Type": "application/json",
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"
}
}```
Try this.
yeps
nopes
same error
well then idk anymore 
lets try XML directly
Try node-fetch just for fun
lol
Works for me tho
401 with xml too
Can u send me the link, please? Don't wanna type the bot ID
it shows the results directly on the browser
yeah ik that's why I suggested to use the user-agent
It somehow block your request for a specific reason, thought it is the user-agent
it gave the same using httpie too
actually can't tell you why cloudflare is blocking ur request
somehow still think it's an issue with the user-agent
do u have httpie?
or any cli for api testing?
gimme a second, testing rn
k
will send u the link in a few seconds
ohkk
Lol! Np! Thanks for the efforts
which options?
Wtf is going on
Dude
Read the docs
You need to authorize your requests with a token
It's not related to Cloudflare
@sullen nymph read the whole chat buddy
What are you doing
It gave the same error with the auth header too
Now you're getting a 401. Try regenerating the top.gg token you're using
Repeat until it works
@sullen nymph it's not because of the top.gg token, how does it show the json data in the browser with just the url then?
Because you're logged in
Takes a session hash and uses it instead of Auth token
Good luck reverse engineering that if you feel like Auth header isn't convenient enough
Is there an issue with login?
I am just being redirected to the home page
Sorry I’ve got no luck
This is what I get with auth token too
Cloudflare is blocking my requests as well
yes sirr
From the /webhooks page of your bot?
Manipulating the user agent etc will not even result in a response
Suckss
yess sirrrr
Regenerating tokens isn't gonna make CF bitch about you
You won't do it fast enough to get ratelimited
I made a new token for this now, but now My bot will get errors!😅 🤦♂️
still same error after regen too
The JS fetch method is the issue
How is it the issue
tried xmlhttprequest too
As I said using node-fetch for example will work
Use reqbin or Postman
Maybe it sends a fucking user agent Cf has blocked god damn
These questions
You wouldn't be getting the response he's getting from top.gg
It's top.gg bitching about its own tokens
Which isn't new
He’s not getting a response from topgg but CF
The JSON received here isn't from CF
Tested it out a few minutes ago, same issue
CF doesn't respond with JSON, does it
Idk
Which isn't the case here
<p>something here</p>
Well then we’re both unlucky and topgg is fucked up once more
Did expect this as CF error
😆
Gizmo can you confirm that you're copying the token one-to-one without any newlines or spaces?
yess sirrrr
This has been an issue for months now
🤷♂️
No fucking clue what causes it
@craggy sentinel if you don't mind helping us out with this
Great that proves devs are working "hard" on it
I copied a working token which I use in the main bot too
As I said I tried the authorization token too with the same result
It's probably not a priority, can't remember if anyone bothered to report it even
Even if I expected this to be a CF error it doesn’t matter at this point
Nah CF ain't the bad guy here
Yes works for me too without any issues
I was looking for a way to post bot stats on the web page, Thought top.gg would do the job in minutes! It took hours instead😅
It's usually fucking you over when you use non-/api endpoints specifically
Wonders of technology...
If I dont get a solution then I'll just use node and render the html template
Well I’m sure not if tested POST or GET event
Might be POST which seems to work anyways it seems
I mean you can test it tho, pretty much the same syntax
If you init the lib as fetch
(Var name)
it works for post in my bot
Yeah should have tested the GRT method too in node fetch
Thank you auto correct
Whatever grt means
I have been using post for a long time
never tried get
nvm I'll just use express , pug, and djs tomorrow and get this done
+1
i want make code if one vote my bot send in the channel message thanks or user name voted me
About webhooks
i'm saved things in weebhok . but i'm try to open weebhook agien no can't fined any thing !
help ?!
How i get webhook url
like for your code?
you have to make it
https://en.wikipedia.org/wiki/URL#Syntax
what write here ?
webhook url > my name in the project repl
authoriz my passowrd and i'm saved and try refresh the page can't find any thing please help
your repl url with the path at the end, auth is the auth for the webhook
you should really focus on getting the webhook working and getting logs working before sending messages in channels
i want to get webhook url at top.gg
to make a vote system for my bot
top.gg does not provide webhook urls, you need to format them depending on your hosting for the webhook
i can't make it please help me or sending video to try!
[dblapi.js] Warning: No DBL token has been provided.
You can speak arabic?
no
Your endpoint, it’s IP or domain name and port
As valid URL (and the path your webhook is listening to)
Looks accurate
this code is right?
No the path is not the same as the one you entered on topgg
i'm need only < any ony vote bot send message thanks in room only need it
URL …/dblwebhook
Code /webhook
here what i write ? link in top gg webhook
/dblwebhook not /webhook
how?
Btw. did you import discordjs and init the client? If not your code will return an error
Change it?!
Change this
to :?
To the same path you entered on topgg
here write my password in top gg authroize?
Btw. did you import discordjs and init the client? If not your code will return an error
how i solve it i cannnnnnt make it
Hmm you need somebody speaking your language I guess
im need video !
this code is wrong
Not wrong but not complete
@plucky lance imake one and write it .
now code is solve?
client does not exist
const client = ???
there but in the top
i'm add code to send in room
can you send me client .
You need to require your discordjs
using discordjs?
Obviously 
https://discordjs.guide/ can help you with using discordjs
I wonder if replit can even listen to the port 80.
Don’t think so.
@jaunty plank enjoy explaining him tho, I’m off the highway, no more phone
I dont know either tbh, not a repl user
Puh 👍
Possible iirc
If not, just use another port
See pinned messages
ty
in node.js where do i put the params?
const topggapiAuth = await fetch('https://top.gg/api/bots/823063174378029096/check', {
method: 'post',
headers: { "Authorization": "token" }
})
this is what i have so far
@sullen nymph would you be able to help by any chance?
oh right
am i doing everything else right?
My cookie says "probably"
But I already ate it so all I can do is suggest trying it out
The uh
Oh params
You can just append ?userId=<user ID> to the URL
No idea if there's another way
Encode the numbers kekw
make a reverse string with reversed ID in the URL and then reverse them back when sending a request
why make it simple when you can complicate it
Obviously
dblhelp
with webhooks (not discord webhooks)
Can you explain further?
Pls help
read the docs
what help do you need
@smoky marten sorry, i want to ask about heroku, default memory is 256MB. can i increase for free?
its 512mb max and its off topic
Is there a support?
My vps ip got banned by cloudflare, i don't know why
So i'm coming here to ask if you can unban it
512 mb
It expands upto 1024 before they kill the app
#development
You sent too many requests
can i, with the topgg api, get how much times people pressed to the invite the bot button?
First of all,
You don't have a bot so you can't
Second,
It's not in the api docs so probably you can't.
i have a bot but it's in the starter phase where the bot need an acceptation from moderators to be added to the list
You can use the api after the bot have been approved
And no, I checked again the addBotButtonPressCount dosen't exist in the api docs :(
its in the anlytics
hi , haw i can create vote log system !
with webhooks?
receive http requests with vote data.
you can see what data on the docs
i need creat system, when the user voted bot send a message in his DM
and you need webhooks to receive votes
const client = new Discord.Client() // Your discord.js or eris client (or djs ShardingManager)
const { AutoPoster } = require('topgg-autoposter')
const ap = AutoPoster('Your Top.gg Token', client)
ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
})```
what the next !
you need to use @top-gg/sdk for webhooks
you dont need a token for webhooks
but its found on your bots page in the webhook section
🤨 @jaunty plank
const ap = AutoPoster('Your Top.gg Token', client)
^
please link of that
whare i can find (webhook auth)
auth you make
gift
I don't have Authorization of api and can't get now
import json
import dbl
from discord.ext import commands
class TopGG(commands.Cog):
with open("token.json") as json_file:
data = json.load(json_file)
def __init__(self, client):
self.client = client
self.token = self.data["top_gg_token"]
self.dblpy = dbl.DBLClient(
self.client, self.token, autopost=True
)
async def on_guild_post(self):
print("Server count posted successfully")
def setup(bot):
bot.add_cog(TopGG(bot))
Has topgg dbl libary been discontinued/replaced? Can i still use the old version?
does topgg allow servers to have webhook votes like bots?
ex. can i check if someone voted for the server
i couldnt find a wrapper for my language
Kinda, it's better to use topggpy instead since it supports Python 3.9
okay thanks!

so how to increase that? with free service
What am i missing at await
read the channel name and #development
how do i get how many times someone voted my bot
use webhooks and save it to your db when the user votes
is the same true for servers?
Yup
hi added the top.gg server count posting code to my bot and it seems to be not working, this is the code i used, is this wrong? js const topgg = new top.Client('token'); setInterval(() => { topgg.post({ servers: client.guilds.cache.size }); }, 3600000);
help
you need to wait 30 mins
i deployed tht like almost 20 hours ago
is there no way to use discord webhooks for the votes?
which module are you using
top.gg-core
thats not the offical module...
oh damn i thought it was
use @top-gg/sdk or topgg-autoposter
oh ok tysm for the info
what do you need help with
did you set up the webserver correctly
and is the pass and link is correct on top.gg
ye i think so
wait
its not discord webhooks
huh
what webhook
you need to enter the webserver link
what ???
http://SERVER_IP:PORT/dblwebhook
or if you have a domain, http://domain/dblwebhook
where do you host your bot
heroku
do you host the webserver seperately or with the bot

the server where you host your webhook server
?
am host in heroku
your url will be your heroku project url with the webhook path at the end
youll also need to use the port env variable for the webhook

https://devcenter.heroku.com/articles/runtime-principles#web-servers
^ heroku's guide on ports
then the url is just
YOURHEROKUPROJECTURL/dblwebhook
@jaunty plank this link ?
Nope that's just the dashboard.
It's something like
[name of app].herokuapp.com
ughh
🙂
you dont visit it in your browser, its a webhook not a website
@jaunty plank hes prob not even hosting the webhook
👀 ?
so thats why i gave up da help
his web dyno isnt even on
kek
I dont use heroku so cant really help with explaining how to enable web dyno's, but here is the pages which explains it.
https://www.heroku.com/dynos/configure
https://devcenter.heroku.com/articles/dynos#dyno-configurations
also heroku provides the port in an env variable,
process.env.PORT rather than just 80.
or even
process.env.PORT || 80
where to put the process.env.PORT
app.listen(80) to process.env.PORT ?
app.listen(process.env.PORT)
I don't think you can
Not when you're free
If you could increase RAM without paying Salesforce would go bankrupt
What should I receive when I use the test button?
a webhook to the supplied url
I didn't get anything.
well, wheres your webhook being hosted?
Uh can I share the link?
if you wanna dm it to me sure
kk
I can't find the documentation of a vote object, is there one?
ah ty
😐
Do you need to supply an address, or will a Webhook object set it for you?
an address? like a url?
Yeah, sorry.
Ah, ok. Thanks!
how do i make it so that when i vote for my bot it dms
youll need a webhook for that https://docs.top.gg/resources/webhooks/
Anyone know of a vote listener event for java
You can just make a webhook listener using httpServer
Here all I find is js
Hey woo, does the webhook sandbox not support localhost for testing? how am i going to test it out lol
@pastel raptor
?
all i find is code for javascript
not for python
docs have somrthing tho
There is code for python on the docs
i think dbl api to post servers is failing with 504 from cloudflare
Do i need to put it in guildCreate and guildDelete event or ready is good ?
only ready and you can also set up an interval to keep it updated
okay thx !
like that ?
oh sorry i didn't notice it was the autoposter and not the top gg api manually
you should create the autoposter on the ready event or wherever you want but make sure it's called only once
you don't need the interval as it posts stats every 30 min
The ready event is not reliable
Nah! Create a webserver
ima use your vote thingy
how do I link top.gg webhook to my discord channel, I provided a discord webhook , clicked test and nothing happened, am I missing something?
Yeah indeed that’s not how it works.
You will receive webhook events from topgg (if somebody votes) and need to deal with it yourself.
For example sending a message via your bot to a channel.
You will receive webhook events from topgg (if somebody votes)
yeah I get that
What’s the issue then?
I am asking what webhook do we put there is it doesn't work with a discord webhook..
ahh ok, thank you for the clarification
I thought it was similar to how github to discord webhooks work but I guess not
so a normal discord webhook url should work with it then, no?
no its to your bot.
if you want top.gg to discord you can use this.
https://webhook-topgg.com/
if you want top.gg to discord you can use this.
https://webhook-topgg.com/
This is more what I need thank you
Ads 👀
yes smh 😔
Jk i've recommended it to people here before too 
how to check if someone has recently voted my bot?
So after doing this still when I try to use the widget in top.gg widgets the server counts show undefined
what is "bot"?
and show me how u defined it
What endpoint is that?
Don't think you can get a single user vote per 12h
i received ir when i tested mt wh
It shows a total but not if it has been 12h or not
Do you know what the endpoint was though
idk what ur talking about "endpoint"
where does it show undefined
Where are you logging that from
not related to the api but u can destructure the properties all in one line
from my code?
route.post("/topgg",wh.listener....)
so the API is returning that?
im using an api wrapper
I am aware of that
Umm like when I try to create widget in top.gg widget page while editing my bot , at that place it's shows the server count is undefined most probably I didn't define the "bot"
node-sdk?
So that's why it's not show the count ig
No that isn't the issue, try refreshing your cache
K leme try
const express = require("express")
const route = express.Router()
const {wh} = require(`../class/top.gg.js`)
route.post("/topgg",wh.listener((vote)=>{
console.log("vote")
console.log(vote)
}))
route.get("/topgg",(req,res)=>{
res.send("pog")
})
module.exports = route
thats the code and the full object

Basically useless
Umm so I was changing the types of widgets available in the widget page of the bot so when I choose the "small servers" or "bot owner" it doesn't give the edited code in html like https://top.gg/api/widget/bot id.svg is the only type of image it give even if I choose other than the large type of widget. Like it should show https://top.gg/api/widget/servers/bot id.svg but still it show only the one for the large pic
Small servers
Like ik how to edit that https://top.gg/api/widget/servers/868900571183185932.svg and that image will come but still like its an issue who doesn't know.
Oh the issue is the undefined thing?
Kinda 2 different issues
Did you refresh your cache?
Not yet I was testing these in the webpage but I saw this problem so told here like in html it doesn't edit the code there to /server or /owner but in markdown it's edits it
It's a known issue
Refresh your cache to fix the servers undefined issue if they were already posted
I tried clearing the cache but still it's showing undefined
Try manually posting
K
so ill just have to use my own db?
Yeah just cache it when people vote and remove after 12 hours
Posted through eval but still
that's not what I mean
Post without the lib
Ok
Hii how can I make webhook to post message in #voters
Another Lovely Vote By UserName and tag of the user who voted thanks for voting
How to make this ^ message
I didn't understood the docs
So I'm using the top.gg autoposter and it's posting the wrong amount for server count.
My bot started sharding as I hit 1.5k guilds so I'm assuming that's the cause and wondered if I need to do anything special to make it count correctly?
Discord and my DB agree on 1,540 guilds, autoposter sends 1,563...
(Note, using discord.js v13)
Make sure your guild cache isn't getting fucked somehow
I'm not sure how it would other than if discord.js is doing something - I don't touch the cache at all
const fetch = require('node-fetch');
const key = config.site.topgg;
setInterval(() => {
fetch(`https://top.gg/api/bots/${client.user.id}/stats`,
{
method: 'POST',
body: JSON.stringify({
server_count: client.guilds.cache.size,
}),
headers: {
'Authorization': key,
'Content-Type': 'application/json',
}
})
}, 3600000);```
hey for some reason this code doesn't post the stats for my bot
and it says its posted
help pls im getting this error often ``` topgg.post({
^
TypeError: topgg.post is not a function```
hey where i put the api code in a form of event or a command??
const fetch = require('node-fetch');
const key = config.site.topgg;
setInterval(() => {
fetch(`https://top.gg/api/bots/${client.user.id}/stats`,
{
method: 'POST',
body: JSON.stringify({
server_count: client.guilds.cache.size,
shard_count: client.shardCount
}),
headers: {
'Authorization': key,
'Content-Type': 'application/json',
}
})
}, 3600000);``` this code where i put it
ok i am getting problem in it
can plz anyone provide full code ??
We have a library for it, can just use that.
https://docs.top.gg/libraries/javascript/#posting-bot-stats
ok
Ok
once your bot is approved, https://docs.top.gg/resources/webhooks/ can help with how to do it
Thx
const { AutoPoster } = require('topgg-autoposter')
const stats = AutoPoster(process.env.api, client)
stats.on('posted', () => {
console.log('Posted stats to Top.gg!')
})``` its not working for me 🥺
did u put the right top.gg token?
Token from Webhook??
Hi
Hey
What did you put in process.env.api ?
Environment variables
what's the environment variable api contain ?
Token from top.gg webhook
webhook auth key or api token ?
api token
Does it show Posted stats to Top.gg! in console ?
No
Thats my problem
Last question,
How long has that code been running ?
Normally autoposter should post stats every 30 minutes or something
I'm looking at docs
😁 okay
Couldn't find anything (your code seems good)
Can you try this
const Topgg = require(`@top-gg/sdk`)
const api = new Topgg.Api(process.env.api)
api.postStats({
serverCount: client.guilds.cache.size,
shardCount: 1
}).catch(console.error)
@fading phoenix ^^
Okay ty >_<
Also that posts the stats once. It's for getting what's wrong. Add a setInterval in production
D
what language @pliant pewter
javascript
you need to use webhooks https://docs.top.gg/libraries/javascript/#webhooks
library does most the work for you
alr
2 messages above yours i linked it
@jaunty plank sorry for bothering you and being the idiot i am (since i took a break from coding for school), where exactly do i put in those codes?
i downloaded the topgg autoposter thing
and i put in the topgg token
but it always says something like' "express" has already been declared
@restive otter what programming language?
discord.js v12.5.3
thanks
what i have to put here ?
The url to your webhook listener
idk how to do that 
What programming language?
i already have const express in my code
do i remove the one on the api, or the other one that i already had
Keep the one which is first in your code
I dont know how to use discord bot builder. Your probably best off seeing if they have a support discord or something to see if express or any form of http server can be used
i know that i can request an api
you could try using this api https://docs.top.gg/api/bot/#individual-user-vote
Will only tell if someone voted not when
const mmLol = await fetch(`https://top.gg/api/bots/861084943794438165/check?userId=${interaction.user.id}`,
{
method: 'GET',
headers: {
'Authorization': 'token',
'Content-Type': 'application/json',
}
})
console.log(mmLol);
i get this response
Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: {
body: PassThrough {
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: true,
[Symbol(kCapture)]: false,
[Symbol(kCallback)]: null
},
disturbed: false,
error: null
},
[Symbol(Response internals)]: {
url: 'https://top.gg/api/bots/861084943794438165/check?userId=749732650209640529',
status: 200,
statusText: 'OK',
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: 0
}
}
is this alright?
const express = require("express")
const app = express()
const mySecret = process.env['Token']
const webhook = new Topgg.Webhook(mySecret)
app.post("/dblwebhook", webhook.listener(vote => {
// vote will be your vote object, e.g
console.log(vote.user) // 395526710101278721 < user who voted\
// You can also throw an error to the listener callback in order to resend the webhook after a few seconds
client.channels.cache.get('883766764490592266').send('I am Voted by <@' + req.vote.user + "> ( " + req.vote.user + " ) ")
}))
app.listen(80)``` Can Anyone Say Doesnt this work?
why this*
its vote.user, not req.vote.user
oh ok
is this how my url should be structured? (im currently self hosting my bot on my computer)
As long as you don't use localhost, yes
wym by "As long as you dont use localhost"?
Because localhost is an alias for your local host, your system and no public address.
ah i c
should i just use my wifi ip instead?
Hosting at home will also require to configurate your local firewall and your router to allow incoming connections on the specified port
It will get even more complicated if you don't own a static IP address
(public IP address)
const res = await fetch('https://top.gg/api/bots/861084943794438165/stats', {
method: 'GET',
headers: {
'Authorization': 'tokeb',
'Content-Type': 'application/json',
},
}).then((r) => r.json());
console.log(res);
why does this only log object with an array of shards, it doesnt display server count or shards count
{ shards: [] }
// the object logged
Visiting https://top.gg/api/bots/861084943794438165 will show you why
guilds and shards are empty arrays
Do you actually post your server count to topgg?
(frequently)
how would i do that?
no ive never posted it frequently or at all
It's basically not much different than ur prev used method
Instead of using GET as method you gonna POST your stats
Including the body
👌
hey how can i make it so when someone votes for bot the bot add some items
can i do from api
Nope. or well from the api you can only check if they have, not get notified when they do
How to get top.gg vote api
im a nub in apis so can anyone help
my bot got a approved recently,i wanted to make vote rewards,i have made the code,now i need a api key for my discord bot
For vote rewards you need the webhook auth key not the api key/token
also you can't get it, you have to set it
Is there a function for Java to register when a user vote on your bot?
(or some way to get votes & who have voted?)
hii there, does this api include getting votes for servers too?
umm
servers dont have api
...
i mean like using the bot api
to get server votes
etc
server lb position
top server votes

ok
don’t think so
only users and bots related stuff are sectioned in the api docs
where to go to hget api key
Dblpins
whow would i check the response text for user voting
if r.text == "voted":
doesnt work
The response isn't text, it's json.
https://docs.top.gg/api/bot/#individual-user-vote
i fixed it
can someone help me out with the webhooks?
right now, i currently have this
and i'm not reciving any votes
What's your hosting location?
Did you fill in the webhook url and auth on top.gg?
my home server,
and yes
Did you port forward?
Home networks have firewalls in place and need to be told which device to send requests to
ye
Did you provide a public ip not internal in the url?
95% sure i did
Double check just in case.
You'll also probably want to do some postman request tests
let's just say, for me to connect to my home server, the ip is 123.456, and the public ip is 987.654, i put it 987.654
aight
Also since your doing ip you'll not have ssl so the protocol is http not https
http://ip:port/path
Few seconds
k
Also it's a webhook, should only support post
i'm getting nothign
Postman getting connection time out? Or refused?
timeout
How to make vote rewards ?
How to make vote ?
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}")
where do i get the password?
is it the token?
and what about the /dblwebhook part?
the path for the webhook
Must be the same one you set on the site
it should ask you for the webhook URL in the website, you put http://<your VPS IP>:5000/dblwebhook
??
Authorization would be the password
Must match the one you have in your code and vice versa
umm i'm new to these , didn't get it
i use heroku currently
oh
can i use a discord webhook?
@rocky bough sorry for the ping, can you show me an example?
@smoky temple if you're on heroku you can do it like this
@restive otter
why my bot vote required command is not working is any changed in const @top-gg/sdk
show code
show code error brother
Hey can we get uer total votes through any methods?
You have to use databse to store the votes of each voter and then make a command with it
Hmm ok
can anyone say why doesnt the invite link get edited?
like i am tryna put a new invite link
put it just keeps on showing the old invite link
I'm getting this error while using the topgg-autoposter for JS:
1|promobot | TypeError [SHARDING_INVALID_EVAL_BROADCAST]: Script to evaluate must be a function
1|promobot | at ShardingManager.broadcastEval (/home/maxim/promobot/node_modules/discord.js/src/sharding/ShardingManager.js:249:61)
1|promobot | at DJSSharderPoster.<anonymous> (/home/maxim/promobot/index.js:32:16)
1|promobot | at DJSSharderPoster.emit (node:events:394:28)
1|promobot | at /home/maxim/promobot/node_modules/topgg-autoposter/dist/structs/BasePoster.js:65:34
1|promobot | at processTicksAndRejections (node:internal/process/task_queues:96:5) {
1|promobot | [Symbol(code)]: 'SHARDING_INVALID_EVAL_BROADCAST'
1|promobot | }
I'm using discord.js v13 and I'm passing the Sharding manager to autoposter like this:
const manager = new ShardingManager('./bot.js',
{
token: process.env.promobot_token,
totalShards: 2
}
);
const ap = AutoPoster(process.env.topgg_token, manager);
that's OK
That is not ok.
You can do it with the top.gg api https://docs.top.gg/
Huh how exactly
You can't fetch how many times a user has voted your bot
You can fetch how many times your bot has been voted by all users tho
Oh I didnt understand sorry, I haven't sern the "user"
Hello
Using topggpy when checking if user has voted with get_user_vote, i am getting Forbidden (403) error
What could be the reasons for the 403 to happen ? Tried to regenerate a token in top.gg and i'm still getting that snif
What is the use of top.gg api?
??
Oo
Like
??
Data of number of servers and more?
What is shards?
@shut flume
I'm using the old dblapi.js and I don't have the 403 errors
The canonical code:
await topgg.DBLClient(self.bot, DBLTOKEN).get_user_vote(ctx.author.id)
python 3.9 btw
Why did you not store your dblclient un a variable 
it's stored i just showed a canonical example
since it's not related to the variable storing
Oh ok lol
Can someone help me out?
I want to trigger some code when someone votes
this is the currently code:
and this is the values in top.gg
Where do you host the webserver (webhook service)?
at the same file as my bot
Meant at home, on a server etc.?
currently I am checking it on my computer
with my public ip
but I tried doing it in my vps and it didn't work either
Well first of all, your firewall blocks incoming requests on that port, secondly your router does, 3rd maybe your ISP does as well.
You would make sure to allow incoming connections on the specified port for each instance I mentioned
oh crap
That doesn't automatically mean you got a publically accessable IP address
and in the vps, I just need to open it?
It would just require to open the port in the firewall, yes, if the default policy is to drop incoming connections (generally or on that port)
Make sure to press the save button before hitting test.
topgg has a lot of issues atm with it's site
Depends on the firewall your server uses
how can I know?
sudo iptables -A INPUT -p tcp -m tcp --dport 5000 -j ACCEPT
To allow inbound connections for the port 5000 (TCP)
The ufw syntax should look something like:
sudo ufw allow 5000/tcp (with or without /tcp, you need to try it)
Just execute sudo iptables --list-rules
Or just sudo iptables --list
it just doesn't do anything
Doesn't look like native shell access tho
so where can I find it?
Is that even a "real" virtual server?
Do you rent the server from an actual provider?
Never heard in my life... but I'm sure you can find your server address somewhere in your dashboard then
The address you painted in your hostname, you can use that, too
Well that's no server, that's just a virtual node environment it seems
Not sure if your provider allows incoming connections
but where should I use it?
It's part of your webhook URL
https://xxx.oxide.systems.xxx:5000/yourpath
(still not sure if you're able to allow incoming connections for a specific port you specified)
dude, you painted the hostname, I can't know 
It's just an example to give an idea how it should look like
Switch to .py
Yeah sure, learn a new language + 69 framework just cuz you can't fix a bug
No it's just better
What're you doing here you should go find cure or cancer ir something
If you wanna switch to "better" there are go, rust, C# and Java
wrong channel btw
lol telling somebody "py" is a better choice... god damn, what's wrong with the world
I don't come in here for help cause the errors are easy to fix
But okay wrong channel
If you ever think "Python errors are easy to fix" that means you never learnt R
vote.user shows the id. how can it show the username?
Which language ?
js
?
client.users.fetch(vote.user).then( u => {
console.log(user.username)
}).catch(console.error)
client is your eris / djs client
ty
Not sure if you're speaking about the API or webhooks
web
Webhooks won't the API does
He can fetch it from discord api
w!videos
read the docs for your lib
why does https://top.gg/api/bots?search=<query> always return a bot called tink
also what is A search string in the format of field: value field2: value2
const Topgg = require('@top-gg/sdk');
const express = require('express');
const app = express();
const webhook = new Topgg.Webhook('password');
app.post('/dblwebhook', webhook.listener((vote) => {
console.log(vote.user);
})
);
app.listen(process.env.PORT || 80);
someone can tell me what im doing wrong?
it just doesnt work
im using heroku
webhook url
response
i need help 
Are you specifically using <query> as the search parameters
403: Unauthorized
Are you using the correct auth token ?
no
i put something like dyno
@everyone
…
How do they make sure that whatever parameter is passed for the server count api is the actual count?
smart
Did anything change with voting webhooks recently? My bots one has just randomly stopped working
how do i run a test vote to test my bot's voting system?
Go to your bot's webhook page > webhooks > click on test > Done
thanks
I get stuck in the cloudflare ddos protection when trying to see the docs
Nothing we can do about it
Make sure you're not using a VPN or try a different browser
from discord.ext import tasks
import topgg
# This example uses tasks provided by discord.ext to create a task that posts guild count to Top.gg every 30 minutes.
dbl_token = "Top.gg token" # set this to your bot's Top.gg token
bot.topggpy = topgg.DBLClient(bot, dbl_token)
@tasks.loop(minutes=30)
async def update_stats():
"""This function runs every 30 minutes to automatically update your server count."""
try:
await bot.topggpy.post_guild_count()
print(f"Posted server count ({bot.topggpy.guild_count})")
except Exception as e:
print(f"Failed to post server count\n{e.__class__.__name__}: {e}")
update_stats.start()```
can i use this script inside another bot's script will it post my main bot's servercount?
or the bot I'm using to run this?
It will use guild count of whichever bot you run it on
hi
How do I get the hand of someone who I voted for, a bot, to sign him and thank him?
how do i do it
Can you explain to me the way?
Node.js
I explain and code
@orchid linden
const Topgg = require('@top-gg/sdk')
const webhook = new Topgg.Webhook('topggauth123')
app.post('/vote', webhook.listener(vote => {
console.log("User with id - * + vote.user + * Voted !")
let value = JSON.stringify({
embeds: [
{
title: "Top.gg - Votes",
description: `:Th_rank_up: <@${vote.user}> a voté pour Eclix, merci à lui !
[Vote toi aussi !](https://top.gg/bot/870653313559957504/vote)`,
color: "BLUE"
}
]
})
fetch("my webhook", {
method: 'POST',
headers: {
'Content-type': 'application/json',
},
body: value
}).catch(e => console.log('Error occured while posting webhook : ' + e))
}))
app.listen(2039)
console.log("Your app is ready to log vote :D")
What does this code do?
does a bot need to be approved for the api key or nah
So I tried the dbl stats api/bots , what timestamp is this?
root@ip-172-31-45-249:/home/ubuntu/real# npm i discord.js
npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://git@github.com/distubejs/prism-media.git
npm ERR! git@github.com: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-09-10T15_41_32_696Z-debug.log
?
no one can help me ?
Looks like unix
help?
When I try to use the vote check it just responds my bot's authorization token with some other stuff i added to it



