#topgg-api
1 messages Β· Page 84 of 1
Yea got it lol
made a script
but
noooooo idea whatsoever
how to upload them to the bot
you run the token from your discord developer portal
Quick question... I have a bot that's sharded. How can I post the total count to top.gg?
in waht lib
Js
Which client should we pass into the js lib for it to eval across all shards? Does this matter? It seems top gg is only display 2/3 shards for guild count, but shows that there are 3 shards total
@dapper copper Heres what I got:
client.on('shardReady', (id) => {
// some other code
if (client.shard.id === client.shard.count - 1) {
const dbl = new DBL(`${process.env.DBL_TOKEN}`, {
webhookPort: 00000,
webhookAuth: `${process.env.DBL_AUTH}`,
statsInterval: 900000
}, client)
dbl.on('posted', () => {
util.success('Top.gg Stats Posted');
// code
})
dbl.on('error', e => {
// code
})
dbl.webhook.on('ready', hook => {
// code
});```
You need to have one central shard posting iirc, since if server_count is an array it'll combine them together and if server_count is just a number you can set shard_count instead
On the site: It shows I have 3 shards, but only the ammount of guilds for one shard
meaning you have to use fetchClientValues to get all the the guild counts from the shards then get the sum
Yeah I would have to do this, the JS lib dosn't do this by itself?
not iirc
I assumed it would handle posting sharded stats
Its open source
So should I just use the postStats method then?
yea
Should I remove client then as well?
up to you
Will it still post the other data?
what is with the site slowdowns rn
@mossy bay if you still have the problem try os.getenv instead of os.environ.get
and if that still doesn't work you might want to try python-dotenv
Now that I'm using manual posting, the posted event is never fired... any ideas? @dapper copper
How to solve it?
the posted event is only for the autoposter, resolve the promise for the output of postStats
the library should handle sharded bots
Hello,
I am looking to use webhook to get votes. All is working great but I am little bit concerned my server privacy for letting everyone make request to webhook. So I am asking what IP addresses send request to my server so I can firewall them. btw I am already using strong authorization key for requests.
Make a strong password and use it instead? 
Extra security layer. And I use strong authorization key.
Tldr; I am only asking list of IP address(es) where request are coming from.
At least move to #memes-and-media...
i have this problem:
i use this code:
console.log('Server count posted!');
});
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});```
but it dont post the servers count
Extra security layer. And I use strong authorization key.
Tldr; I am only asking list of IP address(es) where request are coming from.
@lofty saffron why not trigger several test webhooks and turn on apache logging to get the ip the request comes from?
can someone help me up?
Voting not working?
My server isn't getting anything when someone votes
@gaunt steeple any ideas? (sorry for ping)
what are you using to capture the vote?
if you just point it at an apache server, does the request appear in your apache log?
whats changed?
no idea
nothing in your code?
voting isnt working for dank memer either i dont think
nah i've not changed any code
lemme get a snippet
wait it is working for dank memer
idk whats wrong with mine then
@lofty saffron why not trigger several test webhooks and turn on apache logging to get the ip the request comes from?
Brain yeah I think that I need to do that. Do you know do top.gg use multiple ip addresses so I know how many request I need to send to get it?
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'that token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='that password bich', webhook_port=33, autopost=True)
# The decorator below will work only on discord.py 1.1.0+
# In case your discord.py version is below that, you can use self.bot.loop.create_task(self.update_stats())
@commands.Cog.listener()
async def on_dbl_vote(self, data):
global cursor
logger.info('Received an upvote')
voter=bot.get_user(int(data["user"]))
#the other code stuff```
and i've not gotten any errors in console
Try to use on_dbl_test and use the Test button
kk
@commands.Cog.listener()
async def on_dbl_test(self, data):
print("test")```
just like that?
@lofty saffron cant tell you if its multihomed as i dont know, i never put ip restrictions on my webhook just a long key π
Yeah
@sullen nymph I'm not getting anything from the test either

this hasn't happened to me before, i'm not sure why it would break now
@lofty saffron cant tell you if its multihomed as i dont know, i never put ip restrictions on my webhook just a long key π
Brain ok thank you
oop one moment
forgot to push the change
that might be why
nope still doesn't do anything
Mind sending me the URL you are entering on the bot's Edit page?
No problem
Hi all! I'm pretty new to working with API's, can someone give me a hand understanding some of the documentation? In the list of properties for a channel object, what do the question marks mean? I'm trying to get a list of recipients from a channel object but it's saying there's no property called "recipients"... Does the question mark mean I need to access it through a .get() or something?
read channel topic
This help to do with the api docs though?
-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
#development sounds more appropriate for your question
Okay cool I'll repost there
Hot to use member counter boT
read this
but you need your bot to get approved to get a api token
How can I receive vote logs when someone voted in js
webhooks
how can i get discord users' id who votes my bot ? nvm got it
what do i need to put here ?
What's your library
py
You can use dblpy
Hey, why do I have error 401 even though I have everything right?
I regen my token but still the same :v
Can someone tell me how to make a widget for my discord server on the description page?
to show discord users and a link
Go to your discord server go to settings go to widget and copy the one that says iFrame
Post it as HTML in your description
@next pendant
Though I donβt think this is an #topgg-api topic
hm
On dbl website for getting guild count to post in the example it says to use bot.guilds.size Shouldn't I use bot.guilds.cache.size?
For discord.js v12
You should
ok thx
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
Where can I get the password here?
you create it yourself, you can write anything there
How
go to your top.gg bot edit page
go to webhooks
you will see token, URL and Authorization
@restive otter
I'm trying to send voters to a channel.
So I created a webhook for a channel in my Discord server, and pasted the url I get to 'Webhook URL' section in my bot's edit page and I get following error:
How to get a DBL webhook @true talon
you need to use the webhook example code you can find at https://top.gg/api/docs#jslib (assuming that you're using discordjs) and put it in your bot
the port should be most of the time process.env.PORt or 3000
the password is the same as you put in your bot's top.gg page
and the URL you put in your top.gg bot page is http://vpsIP:3000/dblwebhook
replace vpsip by your bot glitch project link
or your vps IP
okey thx
if you have any problem/questipn feel free to ask!
I've done everything you said, a friend of mine voted but nothing happened @true talon
https://ibrahim.is-inside.me/ca30dbnB.png Authorization What should I put there ?
Is the api slow for anyone else right now?
It seems to be taking like 10-15 seconds to pull info
Nevermind seems to be better now
So how do I get the total number of votes is that with dbl.getVotes()?
Hmm too quiet π€«
@stray crow You do not have to put anything in the Authorization section if you don't want to.
Its not a requirement.
@stray crow you're still setting it wrong tho
discord webhooks !== dbl webhooks
you need a webserver
then you should catch every post request to that webserver
and filter out the ones that aren't from dbl
if you don't know how to do that there's this thing called youtube
i need yt api key 2015 π¦
-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
I wondered: is it possible for other people to use the dbl API without having a bot on it? (And without haven other's credentials)
Your choice
Where should it be placed tho
hey
what's problem
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guildsc.cache.size);
}, 1800000);
});```
client.guildsc
Where should it be placed tho
@jaunty sable just anywhere, but make sure the client is ready before you use it for making a connection to dbl
Ah I see ty
np
I wondered: is it possible for other people to use the dbl API without having a bot on it? (And without haven other's credentials)
okay nice
thought I could only get my own info / my top.gg bot's info, but reproducing it doesn't work
how zero two bot works
@restive otter what do you mean? Explain please
-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
already thought it was about something else ^
@junior tusk How does the zero two bot work in discord
-wrongserver @restive otter
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 "Support Server" button on the bot's page, not the "Join Discord" button at the top of our website. If there isn't a button that says Join Support Server, then we can't help you. Sorry :(
read this
What i have to do when i have added weekhook url
i have to wait to vertify again ??
??
you need to configure a webhook server in your bot
top.gg webhooks are sent to you, not to discord, they are not discord webhooks
Well make the /vote command send the link to your bots page
const dbl = new DBL(bot.voting.DBL_token, { statsInterval: 900000, webhookAuth: bot.voting.webhook_auth, webhookPort: bot.voting.webhook_port }, client);``` why does this not autopost my bot's stats every 15 minutes as it says in the docs? (I know there's also dbl.postStats())
it should
does your on("posted") not fire?
I don't use that event, but I joined a server with it and the amount should increase now
he joined it 45 minutes ago and after that nothing changed regarding guilds size
the event would be a better way to check if its working or not
okay will write that really quick
are you using the one I mentioned above? Or the postStats()? Or none?
restarted bot. So now I must wait 15 min
i dont use dblapi.js
ohh okay
Nothing logged
its not about being defined, its about being the same
there should be only one client in the entire bot (unless you have multiple bots in a single file)
all files should use the same client, the one you created with new Discord.Client() and made .login() with
Yes it's just the same
then what is bot?
Oh that is my config bot property
I store some colours there, token, standard prefix, dbl token
ah so its not a bot client
just curious, dbl doesn't seem to enforce https, doesn't that make having an Authorization redundant ?
with webhooks ^
it doesnt enforce it because most users will not have an https server
How do I make it so it says how many servers its in I dont understand the docs.
they either dont know or dont wanna be bothered with setting up SSL on their side
Seems like quite the security miss step
its not their problem tho, its the user's :^)
rip
How do I make it so it says how many servers its in I dont understand the docs.
What language are you using
And do you want to update the information on the website? Or are you looking to output the number of servers your bot is in?
I want make it show how many servers the bot is in @echo salmon
You shouldn't need the API for that
bruh
for what?
idk
Do you have a bot?
yes.
What did you make it with
he fs dosent code.
I am having some trouble with the DBL api. I'm trying to make a channel in my support server that announces when someone votes on the bot. I saw this code:
const DBL = require('dblapi.js');
const dbl = new DBL(yourDBLTokenHere, { 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!`);
});
``` but I don't understand the webhook part. Is it a webhook in Discord? And if so, what would the webhookPort, and the password be?
Oh yes I know I was just showing the code from the site so it wouldnt confuse people.
But does the port 5000 stay the same?
^
ooh
you're using the same port twice
yes
if you're using the sharding manager, then the webhook should be in the manager
not in the shard
https://top.gg/bot/619328560141697036 can anyone see the guild count here? I'm POSTing successfully locally but no changes seem to be made?
ah
im posting to the wrong endpoint

I want the bot to send in the Direct Message of the user who voted for him, can someone help me?
well first of all, webhooks, get the ID from the webhook that is sent from DBL, and go from there like normal
where do I get the id for this "webhook"
what language are you using?
yeah
then you just need to add the webhook configuration
have you checked the webhook example?
have you checked the webhook example?
@vapid cape I was already checking
@vapid cape here
?
aahhh
sorry
I understand now
your computer? vps? glitch? heroku?
@vapid cape glitch.com
go to your top.gg bot edit page
scroll down to webhooks
in URL put YOURGLITCHPROJECTNAME.glitch.me/dblwebhook
in Authorization put anything you want, like blabla123
then in your dblapi.js
in webhookPort you put process.env.PORT
and in webhookAuth you put your Authorization (blabla123)
ok
your dblapi should be like this
new DBL("top.gg token", { webhookPort: process.env.Port, webhookAuth: "blabla123" }, client/bot)
then you add these
π
then go to your top.gg edit page and press the test button
you should see "user with ID xxxxxx just voted" in your glitch console
when will the dblpy webhook issue be fixed?
Why don't you get the server count from the oauth2 link
/(?<=Used in )(\d+)(?= server)/i```
Can I talk to someone who knows a lot about the dblapi? All my dbl functions are working, like dbl.getUser(), but the automatic stats poster does not work, but the manual one does.
Automatic:js const dbl = new DBL(bot.voting.DBL_token, { statsInterval: 900000, webhookAuth: bot.voting.webhook_auth, webhookPort: bot.voting.webhook_port }, client);
Manual: using dbl.postStats() every 15 minutes
nothing wrong there, can you show more code? like how you use postStats
const dbl = new DBL(<TOKEN>, client);
setInterval(() => {
dbl.postStats(<TotalGuilds>, <ShardID>, <TotalShard>)
}, 300000)
wait, are you talking to me, @vapid cape? As HyperGame reacts
setInterval(() => dbl.postStats(client.guilds.cache.size), 900000);```
no errors there
@echo salmon why would I need to store vote time if I use the vote event
I can just clear it after 12 hours
But what if someone voted after 11 hours and 59 seconds
then checked
it would say they havent voted in the last 12 hours
And I check whether Date.now() - 12 hours < vote time?
If it is smaller, then they voted
dbl.on('posted', () => console.log('posted guild size'));``` now I did this in combination with the "manual" guild size posting, and the event wasn't emitted when it changed the guild size on the top.gg page.
How am I gonna cache the stuff? Should I use redis?
Thats up to you really
Do you do this kind of stuff?
Letβs say I do the check in the vote event, if no one votes, it wonβt remove the previous votes?
Yes, you could add a periodic timer to overcome that
but its probably not worth it unless you have thousands of people voting and you really need the memory
@junior tusk the posted event only emits on autoposting not on manual posting
which version of dblapi.js are you on?
@echo salmon no I didnβt mean that. I mean if I put the check in the webhook event, and remove from cache, and if no one triggered the vote event, the bot wonβt check, and then basically this method requires someone to vote frequently
What im saying is that you could perform the check on a timer, iterate through the list and see if there are any old votes
But mine is just a simple example, you can implement it however you want
Ah I see. Tysm for ur help
np
your postStats is in the same file as new DBL right?
Wait how can you manually post stats
by making a request?
you can do it with any top.gg/dbl library as well as with any http library
const dbl = new DBL(<TOKEN>, client);
setInterval(() => {
dbl.postStats(<TotalGuilds>, <ShardID>, <TotalShard>)
}, 300000)
What is this? Manually or auto
Wait so I donβt need setInterval and it can already auto post?
yes
Wtf
if you give it your client, it will autopost every 30 mins
Ah I see. Ty!
your postStats is in the same file as new DBL right?
@vapid cape yes
does it post if you remove the statsInterval option?
and if I do use postStats()?
or if I don't use any of postStats() and statsInterval?
if you dont use postStats
const dbl = new DBL(process.env.DBLAPI, client);
Can I use this to receive webhook events?
Like
dbl.webhook.on('vote')
yes
And I can place this in ready event right?
no need to be in the ready event
it is possible yes, but not recommended
Ah I see. ty
if you use postStats, the postStats can be inside the ready event
the autoposter doesnt, because the autoposter internally checks for the ready event
How i can make my bot dm me when someone vote ??
did you setup the webhooks?
dbl_w.webhook.on("vote", (vote) => {
bot.users.get("myId").send("Someone voted your bot");
});
?
@vapid cape yes
i did
and what isnt working?
Is there a way to test the vote event?
I can add 2 bots on my account ?
It is stupid to wait 12 hours to test
vote.user will return a user object right?
It's user ID
?
in your bot edit page
under webhooks
which by the way, you need to configure your webhook there too
you need to set the URL and Authorization
your on "vote" event will run
if everything is working
if it doesnt, then you're doing something wrong
then you're doing something wrong
what did you put in URL and Authorization?
so i created a webhook in my server, copy link and paste it in URl and in AUth my password
?
NO wait a second. vote.user is an ID?
Well yeah
How do i get the top.g webhook
dbl.webhook.on
it cannot read property of on of undefined
@sullen nymph top.gg should have big ass warning explaining what webhooks are and how they are not discord webhooks lmao
how i get the webhook
P.S whenever you enter a Discord webhook URL, it shows a warning.
Though ig it's not that big for people to notice
@restive otter where is your bot hosted?
heroku
then your URL is YOUPROJECTNAME.herokuapp.com/dblwebhook
oh
And I can fill it everything I want for Authorization?
Yup
dbl.webhook.on
it cannot read property of on of undefined
Alright last question
const dbl = new DBL(process.env.DBLAPI, client);
020-05-03T11:49:16.128754+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=bot-discord-cool.herokuapp.com request_id=575ff86d-ee76-4e83-8635-d04751bdda53 fwd="77.12.18.222" dyno= connect= service= status=503 bytes= protocol=http
-_-
?
@restive otter you need to enable a web dyno
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
``` I did this and it won't log anything
How i can enable
did you add the webhook options?
yea I did
const dbl = new DBL(process.env.DBLAPI, { webhookPort: 5000, webhookAuth: 'WebHookAuth' },client);
wait i will google it
and the ready event doesnt fire?
oh maybe now
at=error code=H10 desc="App crashed" method=POST path="/dblwebhook" host=bot-discord-cool.herokuapp.com request_id=fa21d9d6-59da-40b7-967a-df9856c6bc2d fwd="165.22.130.154" dyno= connect= service= status=503 bytes= protocol=http
yea the ready event wont fire
-_-
Probably I put it in ready event of the bot?
if you dont use postStats (https://discordapp.com/channels/264445053596991498/412006692125933568/706463235100114995)
@vapid cape okay so I'll wait 30 minutes now
Any suggest for free hosting
@restive otter now its working, but your bot crashed
so you did something wrong in your code
show code
your DBL and dbl.webhook
@jaunty sable it should work outside of the ready event
is it in your main file?
It logged the ready thing after I moved to my main file
But when I test the webhook nothing happened
what did you put in URL and Authorization?
I put nothing in auth and my server ip
x.x.x.x:1234/dblwebhook
@jaunty sable put in Authorization the same thing you put in webhookAuth
@restive otter i mean your bot code
I did and still nothing happened
is it a vps?
Yea
which hosting company?
Galaxy Gate
add http:// before the ip
@vapid cape I used the example codes ??
show code
It still doesn't show anything
wait
Webhook running at http://0.0.0.0:1234/dblwebhook
@jaunty sable dm me your ip and port
you dont need two DBLs, you can do dbl = new DBL(token,{options},bot)
ok
change this bot.users.get("545490362568015873").send("Someone voted your bot");
to console.log("user voted")
Any idea why mine isn't working?
for testing
@jaunty sable did you put the IP address of your server or your home pc? which one are you testing the webhooks on?
Yea I did
@vapid cape Ok
https://<Home PC IP>:1234/dblwebhook
for home pcs you need to portforward your router
because ports are usually blocked by default
maybe http://
That's annoying
not https
Ill try push to my VPS
use ssh
you can put a test bot in your vps as well
on linux is good cuz u have optimesed terminal
Wtf even I pushed to my VPS it still wont log the vote
hello, can someone help me?
did you change the ip and port to your vps's?
Yea I did
dm me your ip and port
How can I check if port 5000 is opened in the VOS
your ip and port are correct
dm me your authorization
@jaunty sable your webhook is working
i sent you a test request and you received it correctly
How did you know I received it
Uhh no
show your code again
is this in your main file?
Yea
I mean no
it is in bot.js
and my main file is index.js
Which is shardingManager
that will not work
wtf I have to put it in index.js?
ohw btw I see a possible error (nothing to do with what you're talking about): when the user that voted doesn't share a guild with your client, it goes wrong
because you cannot use the same port more than once, if you put it in the shards, each shard will try to open port 5000, which will throw an error port already in use
I don't have that error
or maybe you do but its not logged anywhere
Bot crashed one more time -_-
Oh wait now the console logged something
i changed to console.log()
@vapid cape I now did it without statsInterval, without postStats() and with dbl.on('posted') and nothing logged/happened
const dbl = new DBL(botconfig.api_token, {
webhookPort: 5000,
webhookAuth: "pasword",
}, bot);
OK
it crashed one more time @vapid cape -_-
Ah I got it working. Ty tim
you didnt give it your dbl/top.gg token
Ip:port/dblwebhook
Yea
you need to open the port in google firewall
oof
ye
added port 5001
Now
?
switched to webhookPort: 5001,
now ?
http://<ip>:5001/dblwebhook
but i it not working :((
when i type node index
output :
Webhook running at http://0.0.0.0:5001/dblwebhook
it is ok or it must display my ip andress
cuz here is 0.0.0.0
but when i press test nothing happend
put 0.0.0.0/0 on ip range
in firewall or in your code?
Hi
well still nothing happened with the autoposter from the dblapi. Guess it's just not working then
there is only two possible reasons
- the
clientyou gave it is wrong and/or not logged in - it is actually working but it doesnt log for some reason, for example in some cases, child processes on windows dont get logged to the main process's console
I guess it's not one of them though.
- index:
consoleLog.execute('Discord client is ready!');
intervals.execute(Discord, bot, client, con);
updateCounter.execute(Discord, bot, client, con);
});```
and in intervals.js:
```js
module.exports = {
execute(Discord, bot, client, con) {
const DBL = require('dblapi.js');
const moment = require('moment-timezone');
const consoleLog = require('./consolelog.js');
const dbl = new DBL(bot.voting.DBL_token, { webhookAuth: bot.voting.webhook_auth, webhookPort: bot.voting.webhook_port }, client);
...```
2. I'am logging guild joins/leaves, and I added my bot to a server and after hours, nothing changed on the top.gg website
did you try simply putting it in your index?
yeah
okay I have this now:
client.on('ready', () => {
consoleLog.execute('Discord client is ready!');
const DBL = require('dblapi.js');
const dbl = new DBL(bot.voting.DBL_token, { webhookAuth: bot.voting.webhook_auth, webhookPort: bot.voting.webhook_port }, client);
dbl.on('error', (error) => {
consoleLog.execute(error.stack);
});
dbl.on('posted', () => {
consoleLog.execute('posted guild size');
});
});```
not really nice how I've done it tho
good enough to test
π
Someone knows why the class DiscordBotListAPI can't be found even if I have the java maven package installed with no error? :p
Just had to invalidate caches
Still not posting, Tim
is it normal to get a 503 error from the dbl postStats endpoint? Or is this just some random issue with the server? just making sure its not rate limiting or anything.
When someone votes a bot, how can i get the user who voted the bot? Python discord.py
@restive otter read the api at the top.gg website
Ohw sorry it is not listed there for py
there is a py library there
I couldn't find the voting part for py. Or I'm blind
does your bot log this? consoleLog.execute('Discord client is ready!');
Yes
Consolelog is just a console log with time in front of it and I've used some formats to make logging easier
I just think it's not working, but yeah that's me
Is there an event called while voting a bot?
there is a webhook sent by top.gg to an URL of your choice (not discord webhook)
@junior tusk do you have any log saying undefined?
No
well then i have no idea whats going on
try console.log(error) instead
the error might not have a stack
also, you said it works with postStats?
oh wait
i know why
put it outside of the ready event
because new DBL(client) adds a client.on("ready")
to set the posting interval
so if you run it inside the ready event, its like creating a ready listener on ready, but since the ready is already over by then, it will never run
Oof π³
this is the code from dblapi.js
But it did connect to the webhook tho
tim u help me ?
So that doesn't wait for ready
can u help me ?
the webhook doesnt wait for ready, since it doesnt need the client
but not api
Ohh okay thanks!
Even I understand that code you just sent, never thought I could xd
When a bot restarts or something?
not sure if its because one of my bots is outdated, but it has been firing ready more than once, when the bot reconnects for example
might be because its outdated lol
Oh lol
Wait... maybe that's why client.once('ready' exists
I used that for a really long time
Then I changed it because I was the only one
yeah lol
So that's better to use if you're executing other files in the ready event
Otherwise my bot will do weird things
How do I get an API token without listing a bot on the site?
you dont
not sure how useful that would be
to access the api, you MUST have a bot on the site
If all I want is to search bots using the GET https://top.gg/api/bots route, I don't see how listing a bot is required.
because they dont want people spamming their api if they aren't users of the site
the api is already scuffed enough
I just want to get a list of top X bots by server count. Their site doesn't have an interface that does this, but it seems their API does.
View the historical performance of over 7600 bots listed on Discord Bot List (top.gg). Updates every hour.
dbl.marcorennmaus.de API Documentation
Lol, that endpoint works without any tokens @cursive monolith
idk if marco allows it without a token either
Let me try it again then.
GET https://top.gg/api/bots
{"error":"Unauthorized"}
It works for me, weird.
wanna show what you got then?
looks like being logged in is all you need
but thats gonna be difficult to do through the api without a token
Yeah. I refreshed it and it seems to have loaded this time.
It might be because I'm logged in. Go into the network tab and copy the request headers.
Yeah. I'm going to try doing this in postman and see what headers it's using.
I'd bet it just uses cookies
marco's rankings and statistics are always fun to look at, especially ordering by shard count lmao
there's a bot with 10 shards and 10 guilds
brilliant
Looks like all you need is the connect.sid cookie.
You can receive vote updates into a channel in discord right?
Swear I've seen someone do it
how to show the count of guilds that my bot had, i don't understand #topgg-api:( i tried but doesn't works
something is giving error in the api ...
heyo guys, so how exactly do i display the server count for my bot on DBL?
hey
im currently trying to make a bot that stops ip tracing in my discord server is there any way that would work ?
@wheat geyser oops thank you!
allg
because wiredshark use l2p and l3i and pings your ip address and sees what devices you are seeing and what you are use and multi ip address
hey uh i cant seem to edit my bot on DBL?
i tried editing its description just now and clicked submit but nothing changed
how do i earn the rank bot dev ? @ocean rain
i think you gotta get your bot accepted
yep
my bot isn't yet ready for the publish π
dw! you'll get there
did you try editing it again peanut
who's the owner for this server ? @ocean rain
@wheat geyser yeah and i just got pinged in #logs , i guess that means something did happen lol
lmao
@cobalt seal i dont know but you could ask a mod
who els uses gscc ?
pardon?
whats gscc
I am trying to use this code:
dbl.postStats(client.guilds.size);
but each time I get a return error of "postStats must contain 1 argument".
k
It worked now. Sorry
allg
I put in discord webhook into website but when I press test nothing comes through 
because it doesn't work with discord webhooks
it even tells you it doesnt
you need an actual webserver
listening for POST requests
is there is anyway to send a fake vote to test my code ?
dbl.webhook.on('vote', async (vote, message )=> {
let {body} = await get(`https://hd-development.glitch.me/api/fetchUser?id=${vote.user}`);
let embed = new RichEmbed()
.setColor('RANDOM')
.setThumbnail(body.avatarURL)
.setAuthor('KhangBot vote Webhook', 'https://cdn.discordapp.com/emojis/338808864352763904.png')
.setDescription(`***${body.tag}*** Just voted EDGE\nWith ID: ${vote.user}`)
.setTimestamp();
let U = client.channels.get('704011970478735450')
U.send(embed);```
(node:1384) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined```
if its djs v12, then client.channels.cache.get();
does channel exists with that id ?
so what should i use
client is not able to get the channel with that id
oh
and you can simply it,
return client.channels.get('channel id').send(embed);
i'll try it
can someone help me with this ? https://discordapp.com/channels/264445053596991498/412006692125933568/706783600363831327
@restive otter oh yes there definitely is
go to your bot's page, press edit and scroll down to the API part. There is a test button
It will send a vote with your own user id
Thanks @junior tusk
np
what are the possible values of type parameter in webhook json data
what can be the possible types of vote?
The type of the vote (should always be "upvote" except when using the test button it's "test")
its not that
wait
btw my automatic statsposter is working now, @vapid cape. Thanks for the help
@junior tusk amen lmao
handle the webhook
ok but if you just don't use test, you don't have to check if the vote was a real one or a test
should i check for its value in my handler?
@jade shuttle the same event is fired for test and votes, you can check for data.type
so i can safely discard that value
Yes you can just check if it's a vote or a test vote, if that's what you mean
string
what are the query params that can be passed
when you want to get bots?
what?
I mean
Query string params found on the /bot/:ID/vote page. Example: ?a=1&b=2
what can be those parameters
and what do they mean
@jade shuttle are you using this? https://top.gg/api/docs#bots
yes
oh I don't know how that method works
i'm using the dbl webhooks
although i'm not using the python library to handle webhooks
hmm idk π€· I'm sorry
yeah it should
How would I do it so that only people that have voted get access to a command
Can I have 2 bots connected to the same api key?
@jagged pine I think you can't as the dbl requires your client as a parameter
UHm
What is the event that receives a vote?
look at the api in the channel description
Actually there isn't an event for that, I have to use webhooks
but looking them up in the api I can't really understand how to set up a webhook
This user has no bots
?
@jagged pine go to your bot's page -> edit -> scroll down
Yeah, but I kind of don't know what a webhook is exactly and how to set up one, if someone could link me a guild it would be really helpfull
well duh yeah
how can i use the vote event?, i was testing and i don't understand
there isn't a vote event
You need a webhook for that event
we need a website to post webhooks?
@storm sequoia That's what I havent's understand about webhooks
you need a webserver
not necessarily a website
a webserver can be something as simple as express.js in node
the official top.gg libraries also create a webserver for you when you use webhooks
for example dblapi.js creates a webserver for you
when dbl submits the vote, does it go as part of the URL or is it part of the request body
test it with requestbin or a catch all in express
The API doesn't make sense. I have 7 monthly votes, but when I check the API for the people who voted, only 5 show up in the list.
is it possible one of those people has voted more than once
@signal hawk So it should show on the list more than once?
I voted 3 times, that shows up.
Can someone address this issue please?
@restive otter what code did you use?
@junior tusk Just a get request to "https://top.gg/api/bots/531167795824820225/votes" with my auth token as header.
Nothing over complicated.
Oh yes but I can't help with that one
@restive otter What do you do to have the profile picture animated?
@onyx temple Buy Nitro
Thanks
np
I have this error sometimes when I start my bot.
(node:1389) UnhandledPromiseRejectionWarning: Error: 503 Backend fetch failed
at IncomingMessage.<anonymous> (/home/AKMusic/node_modules/dblapi.js/src/index.js:118:25)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
It's because the site is down atm, dont worry about it
catch and ignore the rejected promise
s
Why is botblock blocked from using the api?
i read the server count pin but i still dont understand how to do it ;(
(im using d.py btw)
how do i get an API token?
i cant get a token tho
i clicked on "generate token"
and i tried ctrl ving but nothing happened
oh wait, my bad
π
is the discord.py example here still valid?
https://top.gg/api/docs#pylib
Spice up your Discord experience with our diverse range of Discord bots
this one i mean
@arctic arch the website is having that weird cloudflare problem again
if you access the docs page directly, this is what happens
if you access the main page, you get the cloudflare 5 second "browser checking" thing, after that the docs page works again
the docs page itself however doesnt do the cloudflare 5 second check if you access it directly, and without the browser being checked first, all the css files get blocked
this problem only happens if cloudflare decides to do the browser check on you, not sure what conditions they use to decide your browser should be checked
Why is the server count not updating?
ok
If I wanna use the dbl api webhooks do i need to have a website?
no
Why is botblock blocked from using the api?
no
Good, one step closer to understanding what them are hahha, guess I'll have to do some research
hi, I was wondering if I could get some help with the webhooks (which used to be working)...
I can see the traffic hits the machine from your ip (209.97.134.24) on to port 5000
but, I can't see a process listening on port 5000
apparently setting the webhook port activate the web server, here the code (minus the password) python self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='****', webhook_port=5000)
also, I don't get any errors outputed the console when I start the bot and it is successfully updating stats on top.gg
any ideas why this is happening?
also, I did try disabling the sortware firewall to test if that could be the cause
I'm runing Python 3.8.2, dblpy version 0.3.4
Are your ports definitely open
^ a portchecker might help with that
I turned off the servers software firewall as part of my testing in case it was blocking traffic on port 5000 as traffic is clearly hitting it when I use the test webhook on the top.gg page
do you actually have the one webhook test event then
those are the last 5
so whats the issue then?
has the ip changed
and no error is being outputted when I start hte bot indicate it's having issue setting a webserver to listen for traffic
if you look at the first pic you can traffic from top.gg external ip hit the server on port 5000
but has your actual external ip changed
the first line is the network bandwidth being used by the bot proccess the second is inbound traffic
seeing that most ISPs use dynamic ips so your changes every x time
I have a minecraft server on the same ip which is still accessable to friends so, no
also, it would be impossible for the dbl traffic to hit server if the ip changed

I'll try to do some testing to see if I can make the webhook webserver be more verbose as my second picture shows that nothing is listening on port 5000
I'll check it again but, I tripple checked everything before coming here lol
also, I'm using python
I copied and pasted the secret code from the top.gg page to my source code but still no luck
I've still got things I can check though so, I'll do some digging in /var/log/ and what not
:(( the webhook is not working
oh i didnt know the ip was changed
so no problem more xD
guys let's say i want my bot to do something every time someone votes for it on dbl. I'd call the dbl.on_dbl_vote(data) within the main.py of my bot?
It's a listener/event that will be emitted whenever someone votes for your bot on top.gg
thanks π
@sullen nymph do you know what the format of data is
like what the keys are
thanks π
wait
what does Snowflake mean?
like if I wanna get the discord Id of the person who voted
i'd do data['user'].what
an ID with type string
Yup
ty
Does someone know a guide or something to help me understand how to use webhooks to fetch votes for my bot and send a message in my server. I can't understand how to do it
@sullen nymph sorry bro im a little lost about how to set up the webhooks
I have the same question as @jagged pine
I don't think you should ping a mod xD
Official DBL libraries can host webhooks for you
Wait, is it that easy?
you still need to put a correct URL in your top.gg edit page
otherwise yes, its that easy
you still need to put a correct URL in your top.gg edit page
ok idk what that means
seemed to easy xD
URL of what?
a webhook is a reverse http request. instead of you sending a request from a website or api, the website sends a request to you
so when someone votes, top.gg will send a notification to the URL you specify, informing you that someone voted
in the form of a POST request
so you need to create something that can receive this request
usually with your own webserver or website
is there a guide for this?
usually with your own webserver or website
what if I don't have one
the official libraries do the setting up of the webserver for you
so if you use dblapi.js, and give it a webhook port, it will create a webserver for you
