#topgg-api
1 messages · Page 85 of 1
so now that you have a webserver running in your machine, that means your machine can receive requests from outside, just like if you were running a website in it
so the webserver will be on my pc?
you just need to give top.gg the correct URL of your webserver, which depends on where your server is hosted
uhm
if your bot is hosted on your pc, then the webserver will also be running on your pc
OK got this
so the address of your webserver becomes the IP address of your pc
So, my bot is hosted on a server I bought, how can I get the webserver adress? Is it just the IP?
I'm using vultr for reference
webhookPort: 5000 in this case 5000 if I got this right
yes
so your URL will be YOUR.VPS.IP.ADDRESS:5000/dblwebhook
/dblwebhook is the default page created by dblapi.js
thanks dude! I'm so new to this
Then I'll have to change some firewall settings too I guess
so basically what happens is that wen someone votes, its similar to if top.gg would open yourip:5000/dblwebhook in their browser
got it
and your webserver will do something with it
if vultr has a firewall, yes, you need to allow port 5000
There are issues with the site right now
Tim, so I can do all of that in another bot right? Doesn't need to be on the actual bot of my bot page.
yes
when you go to the bot's edit page, you can put whatever URL you want
since you only have one server, you can make all your bots sent webhooks to the same URL
and you can have a single webserver receive all of them
doesnt matter on which file this webserver is running
Why does it log this? Webhook running at http://0.0.0.0:5000/dblwebhook
This is wrong right?
no
Replace 0.0.0.0 with your external IP when entering the URL somewhere
and you get a proper URL
I did
already
//Votes on top.gg
const DBL = require('dblapi.js');
const dbl = new DBL('token', { webhookPort: 5000, webhookAuth: 'mypassword' });
```And that's the rest of the code
And I put my ubuntu server IP in the webhook
My.IP:5000/dblwebhook
oh
freak
thanks
Why does it log this?
Webhook running at http://0.0.0.0:5000/dblwebhook
this still shows up like this, but I get the votes. So it's all good right?
its also hardcoded in dblapi because it doesnt do IP discovery
lmao
maybe later™️ 
Diddly dick
I need help with the API. The /botid/votes endpoint isn't returning the correct number of voters.
I have 9 votes, and only 6 show in that endpoint.
if you mean a bot's server count, no
ah there should be an endpoint for that, let me check
or not
there's nothing about servers on their api docs
yeah i checked the docs
what im doing atm is really slow
just basically requesting the servers page and checking the status code
well there was a huge drama last year about server crawlers helping raids and shit like that
a lot of services that provided server lists were flamed to oblivion
might be a reason for why if there is an api it isnt public
i mean completly possible without an api
if (await self.bot.session.get(f"https://top.gg/servers/{g.id}")).status == 200:
topgg = f"[Top.gg](https://top.gg/servers/{g.id})"
else:
topgg = None
this is what i have atm
its just painfully slow
how many servers are you checking?
oh is it just like a server info command
yeah
then that should be fine
i might change it to servers/id/join
it shouldnt be that slow tho, how slow are we talking?
3ish seconds
jesus
you could try making a HEAD request instead
its like a GET request but only gets the headers and not the body
ill try
i changed it to /id/join
significant perfomance increase
head request is faster
im testing it with reqbin
a 200 takes 150ms, a 404 takes almost 2 seconds Lol
/join gives you 403 tho
i tested a few different methods and no luck
if the server doesnt exist, the 404 will take 2 seconds to respond no matter what
but if it exists, it takes < 200ms
so you could play around that lmao
or you can send a response with everything else except the top.gg url, and then edit it in
thats what ive been doing
oh
if(message.content.startsWith !=== "prefix") return
Not the right channel
I know
@restive otter @true sonnet This channel IS ONLY for topgg api questions. If you don’t have one don’t post here.
Does the vote.user.avatar return an URL?
The vote.user returned from webhook isn't a user
Yup
can I get the user avatar from the vote?
yes you can using dbl.getUser(userid)
then you get this object https://top.gg/api/docs#users
get user (from cache if possible) and get their avatar
ok thanks, is that the quickest way?
@jagged pine no, but you can't assume the user is in your client.users. So I chose that safe method
hey guys, can someone let me know if there's anything wrong with this code:
"""Handles interactions with the discordbots.org API"""
def __init__(self, bot):
self.bot = bot
self.token = "my token" # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='my password', webhook_port=5000, autopost=True)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print("got event!")
def setup(bot):
bot.add_cog(DiscordBotsOrgAPI(bot))```
for some reason the on_dbl_vote is never called when i vote for my bot
i know i'm doing something wrong but i'm not sure what
Make sure your server can listen to new webhook requests, and isn’t getting blocked by something like a firewall
You should have a setting about that in your customer panel
But not sure where exactly it is
u think that might be the issue?
does the code seem correct?
thanks for the idea 😄
yeah
Try running your bot locally, disable your firewall and stuff, and see if it’s a firewall issue
I honestly don’t know how AWS handles that
on_dbl_test
perfect
ty
oh ya
when i ran it
it said windows firewall blocked access
and i had to press allow
it's weird cuz even when i press allow access nothing happens when i test
@sullen nymph does the on_dbl_test go in the main script where i run the bot or in a separate cog?
sorry for the questions im really struggling
Anywhere where you can make it a listener/event
so i've tried both main and the cog
in the cog i do @commands.Cogs.listener()
and in the main i do @client.event
but still neither seem to be getting activated
Cogs or Cog
Are you sure your port is open and/or the URL you entered is correct
url is /dblwebhook
that's what it says on my bot's top.gg page
password is correct
the port is 5000
not sure what that means but it was on the docs so i kept it
Full URL
The URL on your bot's Edit page
is /dblwebhook
should i make it top.gg/ergegogh;iggw/dblwebhook
fuck im an idiot sometimes
And how do you expect top.gg to send a request to your machine without specifying an IP
wait i need an ip?
bro hoenslty idk
im new to this sorry
should my url be top.gg/bot_id/dblwebhook?
Why would it be that
idk
http://<ip>:<port><webhook_path>
Not really
i've tried it with boht the private and public ip's of my aws server
no luck
still trying
they're IPv4 does that matter?
IPv4 is supported, not sure about IPv6
this is weird
does anyone know how to allow aws to received stuff from dbl?
API runs normally, at how much servers is your bot in. But if the value change it sais API Permission Denied. Even is is run by sudo (administrator) any help? (ubuntu 18.04 vps)
@pearl coral you sure that port isn't blocked by your firewall
@jade shuttle wich port
The one their web server is running on
@restive otter I asked the other guy about the port, not you (I responded to "which port" because I thought you might be curious about what I meant)
I have no idea what your question means so can't help ya
sry
hey I was just wondering the vote checks take about a minute or so to update, is that normal?
yes
thank you
Why does the test feature for the API not send anything to my endpoint, I'm catching every type of request and there is nothing coming through..
I don't get it, and I've tried this Glitch setup too and still no dice 
did you save?
¯_(ツ)_/¯ i might just scrap it, nothing is even going to my requestbin
Bro this api is fucking trash I'll just work on something else
app.post("/dblhook", (req, res) => {
console.log("wow request found")
});```
This doesn't even work
did you test it with reqbin?
that should still technically return if dbl posts to it
so if its not working you should make sure your port is open sudo ufw allow <port> if that doesnt work make sure you're telling the lib to bind to 0.0.0.0 and then if that doesnt work idk, something is really fucked @solid wharf
is there anything close to a google images api thing
?help
@zenith trout
Hey! Bots aren't given permissions to send responses in this channel. Please use #commands or #265156322012561408 to run commands. In addition, bots with commonly used prefixes cannot read or send messages in any channel. This is done to prevent spam and bot abuse.
I have a problem where my bot has been showing offline since yesterday (it's been online this whole time), but the server count is updating just fine... 👀 It's showing online on other bot list websites. I haven't touched the DBL code. Any ideas?
It's clearly getting the count through ok but not the online status for some reason 🤔
But both of those are being passed to the DBL API using client
Status is determined by your bots status in this server
Btw, your support server's invite has expired
@wary hamlet
It may have been kicked from here
Yeah I asked for it to be removed
🤔
So that affects the online status for the website?
Then it will show ??? and offline as its status
🤦
The website pulls status from the data in this guild
Ask a mod I suppose
Any mods out there? I don't wanna ping you! 😂
As long as you ping only one it should be fine, just dont ping the role
@gloomy fractal could you please help me with this?
@golden adder With?
I need PixxieBot reinvited to this server for the online status to be set
It was removed because I requested it
But wasn't aware of the online thing
-api
THIS CHANNEL IS ONLY FOR SUGGESTIONS/HELP/BUGS TO DO WITH OFFICIAL TOP.GG API LIBRARIES AND API DOCS FOUND AT
https://top.gg/api/docs
DM me
console.log(`${vote.usename} just voted!`)
})```
Output:
``` ```
Its not logging when someone votes
const DBL = require('dblapi.js');
const dbl = new DBL(TOKENU TAU DBL, { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});```
where must I insert my bot id?
idk how this works
you need to put dbl token
setup webhook url and auth password
click "Edit" on bot's page and scroll down
no
that is https://serverip:port/dblwebhook
https://<project-name>.glitch.me/dblwebhook for glitch
yes
did you set the authorization key
new DBL(dbltoken, { webhookPort: port, webhookAuth: 'auth key' })
how can I find the webhook port?\
what port are you using?
only port 3000 can be used on glitch
new DBL(dbltoken, { 3000: port, webhookAuth: 'auth key' })
and the auth key how can i get that?
switch the '3000' and 'port' round
your auth key is chosen in the authorisation box, where your webhook url is
and the auth key how can i get that?
@cinder orbit what you wrote in "Authorization"
i wrote nothing
i wrote reallywow
const dbl = new DBL('token bla bla', { webhookPort: 3000, webhookAuth: 'reallywow' })
is it good now?
save and click "test"
check the console
yup
smh
lol

yes, it always helps to have the package lmao
awesome
now what? =))
click test now
check console
logs or console?
nothing
mhm?
wait lemme remove :3000
still nothing
hmm
wth
are you using the port for anything else?
lol
nice
you need to find the channel to send the message to first
i have the id
get it from client
^
<Client>.channels for discord.js
bot.guilds.get("699189120945094757").channels.get("707183850828070962").send(${vote.user} a votat voxility)
200 iq
yes
discord.js v12?
@tame edge wrong place to ask
are you using discord.js v12?
just do client.channels.fetch(CHANNEL ID);
Discord.js stuff in #development remember, TopGG api only in here, thanks.
sorry
yeah
Here i can advice for a bot?
that webhookauth can be literally anythiung right?
yeah
treat it like a password though i.e. make it a decent number of characters and use letters as well as numbers and special characters
Imagine doing it exactly literally anything
Im doing a kind of alternate sentencing
wut
http://0.0.0.0
why is it running it here
;-;
that is fine
ohkay
it means it is listening
Of course.
ITS NOT THE ALL TOKEN
this isnt offtopic bro
here is just for help
not to judge

aight then, just saying
i dontt need
If your using glitch (which it looks like) then use process.env.DBLToken
so it's safe and hidden
Since your project isn't probably private, so anyone can find your token
whats the point
it is private
-_-
so
where must i insert that
dbl.webhook.on('vote', vote => {@cinder orbit
@open garden *
Wherever you want the vote event to be
let user = client.users.get(vote.user)
let tag = user.tag
It won't work
Well it could
But please format it correctly, and don't copy and paste text
😉
tbh I'm getting tired, been helping on this one thing for hours and just not being followed all instructions/comments
If the user it cached(Chances are not) then it will work
^
else fetchUsers iirc, haven't coded in ages
or put it as "unknown" or smth so it logs
Well Yea but he is doing user.tag that will throw error cannot get tag of undefined
he will have to put that in else statement
Mhm
let user = client.users.get(vote.user)
if(!user){
var tag = "Unknown"
} else {
var tag = user.tag
}```
iirc?
I think so
So that means the bot hasn't cached your user.
But it shouldn't error as we added the unknown option
1 sec
if you don't want it to rely on cache stuff ^
Test it
@cinder orbit you are mixing client and bot
But your mixing client and bot again I believe
which one do you .login() with?
bot.login
then use bot, not client
but it works
client doesnt exist for you
no
@vapid cape https://discordapp.com/channels/264445053596991498/412006692125933568/707904907012734990 he is doing both bot and client
@vapid cape unfortunately it does, they defined both, I keep telling them to use 1 but
hmm?
so if you have bot and client, then you have 2 bots in your program
aa
if you do bot.login(), then bot is logged in, but client is not
The "bot" can't do stuff you tell "client" to do and vice versa.
are you using v11 or v12?
fetchUser is a promise, you have to await it
They downgraded to v11 since they don't understand v12; despitelinking the guide.
so what must i do?

async vote => {
await bot.fetchUser()
var user=bot.fetchUser() i guess?
@cerulean monolith that will just return the promise
^
Ah rip
changing "let" and "var" does nothing (in simplest terms)
i meant
i dont understand
more like it
WHAT?
I'm gonna leave Rip
what must i write
@cinder orbit We're saying the same thing
async vote => {
await bot.fetchUser()
change those bits so it's like that.
dude...
aaa
Damn nice editing lol
lightshot i think
xd
OwO i use ShareX never used editing lmao
Anyway, working now @cinder orbit ?
let me change
We are going offtopic lmao
i like lightshot better, i dont like that sharex always saves them in the history
Ah I like that function tho Tim xd
?
Since I can snap something and refer back ie ban reasons easily
still wrong.
You're mixing client and bot again
how did you even made this mistake lmao
as well as await needed
let user = await bot.fetchUser()```
etc, as said
^
whre is the unexpected token error?\
Ah here we go again
remove this }
it's even highlighted for you as well.
ok
Well here is a mod here who is spoon-feeding with me so i got no worries
Well here is a mod here who is spoon-feeding with me so i got no worries
@cerulean monolith your fine, we're not code dumping the correct code but trying to give the answers
Kewl
The error says it all
and glitch even provides a nice circle to see the error before testing it.
^
@cinder orbit what do you have at the end of line 11?
Ah well @vapid cape he never closed the bot.on ready bracket
also that, good one
^_^
bro what i am missing
the bot.on is closed
from vode is closed
the gbl hook closed
wth
you have to close vote
His bot.on is not closed only
others all are closed
@cinder orbit add }) after 5th line
1 sec
vote and .on("ready") are both open
wait no
you're only closing one of them on line 12
@cinder orbit after 4th line rip
no
now you're breakingDBL
Yea

ok your last one should work
oops
Oh Wew
a yes
user is undefined too btw in this case
bot.fetchUser(vote.user)
user.tag should be there
nope
😦
user.tag
Enjoy ^_^
pls can you vote 1 time to test it?
Lol now thats begging
It will work
Works for you? It'll work for everyone
😉
So please don't beg for votes.
GG's
Can i DM users with my bot when they vote?
LeL
i mean i know how to
am i allowed to do that?
let user_id = bot.users.get(vote.user);
user_id.send("You voted me");
That wont work most of the the time but thanks
u sure ? it will work all of the time, cuz i am using this method to dm me
Is there a way to do a voice counter for the votes with any api?
like the 111 thing
when someone votes
voice counter from 111 -> 112
It's one of the biggest bots
maybe they meant 'how can I do this to my botum™️'
@restive otter https://top.gg/api/docs
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
oh thx @median badger ❤️
401 is unauthorized
your token is incorrect
I would just regen it if you are sure it's right
Make sure there's no trailing spaces
py is shit
js is better smh
This is #topgg-api
good point
I already regend @spiral steeple
I know what 401 is, not sure why im getting it though with the correct token
In your request, you have a question mark after the bot id, try to get rid of that
.
any idea?
its installed correctly
ah sry i forgot
dbl.webhook.on
(it might be)
tried
worked?
no
whyyy
woah
impressive!
did you set auth, and URL correct?
nvm
but
how to make
auth
url
oof
@restive otter im not using glitch
Your bot's edit page
@restive otter im not using glitch
@restive otter me too..
i set auth
but how to set url
and wht
to be on that
Url can be http://yourprojectname.glitch.me/dblwebhook
oh sorry, not https
i dont use glitch x2
sorry my mistake
your vps ip
and where to set url
no
but how
nvm
i found out
yes
^^ works (test webhook)
How to make it work non-forced? I mean if i put it from test command in-panel it works but if vote someone it don't work
what is wrong
i dont understand
what to do?
that's the problem, it says missing permission but it's run by sudo
ufw disabled
any idea?
How can you send a message when a user votes
currently i have
await dbl.getVotes().then(votes => {
if(votes.find(vote => vote.id === message.author.id)) message.author.send('Thank you for voting!');
})
How to configure this?
discordbots webhook don't work with discord webhooks
So what, i must do?
you'll have to code your own webhook receiver
Pls ready webhook thanks vote code ❤️
omfl
no one is gonna give you that code
what kind of dev are you
and try to use google translate
it can do better than Pls ready webhook thanks vote code heart
huh
the problem is that webhooks depend on where your bot is hosted, so you cant make a video tutorial for every single host
like your own computer? then you will need to port forward your router
ah so then you should have some experience with servers
you need to create a webserver to receive webhooks from top.gg
top.gg's official libraries can also do that for you
yes
likely your server's IP address and webhook port
and afaik, the library sets up a /dblwebhook path as default
so the full url should be http://YOUR.IP:PORT/dblwebhook
unless you change the webhook_path option
just post here, someone will help you
api down too?
the sites down so yes
/bots/{bot.id?}/votes Is this for the month's votes, or just the last 24 hr's?
I need a way to get every user that's voted in the last 12h without having to GET that thing at 50 requests per minute which would take about 38 minutes to get it all
I mean i could just write it to a DB but that would be really inefficient as it means i have to get a webhook too
Its the entire month iirc
What does "API" means?
An application programming interface (API) is a computing interface which defines interactions between multiple software intermediaries. It defines the kinds of calls or requests that can be made, how to make them, the data formats that should be used, the conventions to follo...
How to use api in discord.js 
@restive otter depends on the api but this channel is for the top.gg api only
If thats what you need help with theres an example pinned i think
also
Ok
When it asks for a webhook auth password in the code for webhooks, what does that mean? and how does this discord webhook url get broken up into http://${hook.hostname}:${hook.port}${hook.path}
-e const axios = require('axios')
axios.post('https://top.gg/api/bots/645737776783949873/stats', {
headers: {'Authorization':'myDBLToken'},
data: {
server_count: mailbox.client.guilds.size
}
})
This still returns a 401
not sure whats going on
please ping
your dbl token is invalid @lusty hornet
i suggest use official dbl library
eh
yeah i know but if i can avoid another package i will
its just a request idk why it wouldnt be working. token is fine.
ill reset it for the 3rd time lol
Yeah same thing
This is the right token right
under that
dbl.on('posted', () => {
console.log('Server count posted!');
})
Can you see with this how many times your bot in invited by the top.gg page
What i must to write there?
You should pry click the link if you’re unsure :)
It’ll help you
Yeah, i know, but i read all of api, and i still don't know what to write there.
just enter the url where you want the webhook to be sent to
im trying to think of a way to explain it
basically
when a vote happens it send a request to the url you put there
the auth you can put whatever you want just make sure its hard to guess because thats how youll be able to tell if the request is real
const Discord = require("discord.js");
const DBL = require("dblapi.js");
const client = new Discord.Client();
const dbl = new DBL('hide', client);
const bot = new Discord.Client({disableEveryone: true})
dbl.on('posted', () => {
console.log('Server count posted!');
})
@kind trench Mamy problem ;b
nwm, próbuję włączyć
Ok
Nie ruszaj ustawień takich nowych, co siępojawiły
ok
No wm, ale mam w logach konsoli, że zły token ;/
no kk,
Ciągle zły
ReferenceError: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9 is not defined
at Object.<anonymous> (C:\Users\filip\OneDrive\Dokumenty\Strona titona\test.js:2:21)
at Module._compile (internal/modules/cjs/loader.js:1128:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:983:32)
at Function.Module._load (internal/modules/cjs/loader.js:891:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
:v
To jaki problem?
🤦🏻
Tak ma być ;)
A da się jakoś naprawić liczbę serwerów?
da
A jak?
const Discord = require("discord.js");
const DBL = require("dblapi.js");
const client = new Discord.Client();
const dbl = new DBL('hide', client);
const bot = new Discord.Client({disableEveryone: true})dbl.on('posted', () => {
console.log('Server count posted!');
})
@worn rivet
No ok, ale do dbm przecież tego nie wstawię
To... weź to zrób, ja nie umiem 😄
Umm
const DBL = require('dblapi.js');
const dbl = new DBL('my token', { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
yes this is normal
So, how to get ip?
you should know it
But public or private
Ok, i don`t use glitch
k
I will check it
what you use to host your bot
heroku
wait a sec
k
for heroku you just put https://[your heroku project link]:5000/dblwebhook
and the "authorization" field should contain the same as this https://link-is-qt.lumap.me/edcshf7g.png
bot
:/
I try, but it still not work
ok
un thze authorization field, put the same as here https://link-is-qt.lumap.me/khhlrsin.png
ok
for what
I was waiting for someone to explain this from many days but no one replied
oh
np
@true talon Im having issues with the webhook, you can use this for displaying votes in a server channel right? and how can you use the webhook code and server count code at the same time?
server count code is automatic, you dont need to worry about that one
yea
Im just having issues running the webhook code and the server count code at the same time
it displays errors whenever I try
Ehh, and now what?
ahh okay
click the test button and see if it works
okay
so can you use discord webhooks for this well?
no
is it for console log?
okay cool
then you can do what you want with it
cool
It doesn't work ;/
f
It didnt worked for me when i vote @true talon
whats the code for vote?
dbl.webhook.on(vote => {
console.log("test")
})
you need your bot to get approved
no
🤨
A min
see its approved
Green name ^
you are not @restive otter
why dont talk with it
Because i get many dms in this account
Cant ignore dms :/
Website isnt working i cant take developer role
Whenever try to add my account as owner it refreshes the page
you didn't submitted any bot
🤦♂️ oof


