#topgg-api
1 messages · Page 96 of 1
Ah thanks
no problem
i!invite
what
@gentle hawk you just use webhooks im pretty sure
Anyone else have the issue that guild counts wont update after the bot is running for a couple of days?
I find a lot of entries in the log with
Traceback (most recent call last):
File "/var/discord/venv/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 275, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
File "aiohttp/_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: invalid HTTP method
But that seems to be an issue with the vote webhook.. at least what I have found ^^
Yup, an issue with the webhook I have no control over really
you mean that the count doesn't update or that votes throw that? 😄
The votes 
Something keeps sending random requests that aiohttp doesn't handle internally
Also, are you using on_guild_post?
How are you sending the request?
oh, wait.. maybe not
let me check the code 😅 did that some months ago
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/dblwebhook', webhook_auth=os.environ['AUTHORIZATION_TOP_GG'], webhook_port=5000)
Auto post. But I dont have an listener to on_guild_post yet.
Might be a good idea to put one up to see if the autopost is actually working
yes, I'll do that. Its working for a couple of days after I restart the bot.. but stops then for what ever reason ¯_(ツ)_/¯
#Magic
#programming ^^
hello how do you make a webhook? sorry I used the second account because I just tried to vote but hard
How can I get my dbl token?
hello how do you make a webhook? sorry I used the second account because I just tried to vote but hard
@empty current there are docs on https://top.gg/api/docs
How can I get my dbl token?
@little wolf You cannot get your DBL token without an approved bot
3+ currently
oof.
how do i check if my bot has been approved or not
so I have this and I getting this error but I am not sure why ```js
dbl.webhook.on('vote', async (vote) => {
^
TypeError: Cannot read property 'on' of undefined
at Object.<anonymous> (C:\Users\Gideon\Code\kettu\kettu\kettu\bot.js:224:14)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
at internal/main/run_main_module.js:17:11```
nvm I got it
How can I check whether a specific user voted for my bot in python? I'm trying to make a command where a user must vote for it to work.
best way to do it would be to use a webhook and store votes to a database for an x amount of time
making an api call every time a command is ran is highly inefficient and will lead to rate limiting
Hey I'm getting a 401 error
Error: 401 Unauthorized
Code: await dbl.hasVoted(member.user.id)
Hey, Kinda stuck with the webhooks. I have port forwarded already and used the public IPv4 of AWS Instance. http://public_ip:5000/dblwebhook in the TOP GG field + the password Still, The requests are not coming out. Any idea?
def __init__(self, bot):
self.bot = bot
self.token = 'dbl_token'
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='---`, webhook_port=5000)
@restive otter regen your dbl token
yep fixed it
Well that still works
@restive otter do you actually have the listener?
@restive otter do you actually have the listener?
Yes
hello because it gives me that error if I put the api that I give
at IncomingMessage.<anonymous> (/rbd/pnpm-volume/f714447b-03ff-4863-bf99-e7612c4dc859/node_modules/.registry.npmjs.org/dblapi.js/2.4.0/node_modules/dblapi.js/src/index.js:118:25)12:11 PM
at IncomingMessage.emit (events.js:201:15)12:11 PM
at endReadableNT (_stream_readable.js:1130:12)12:11 PM
at processTicksAndRejections (internal/process/task_queues.js:83:17)12:11 PM
(node:8861) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)12:11 PM
(node:8861) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```

mention if it helps me
@midnight lintel it means you aren't authorised, is your API key correct?
if I generated it right now @rapid kettle
DiscordBotListAPI api = new DiscordBotListAPI.Builder().token("my-token").botId("393887855274885121").build();
api.setStats(211);
This is in Java and this does not work for me, can anybody help me?
build.gradle:
...
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
compile 'net.dv8tion:JDA:4.0.0_66'
compile 'org.discordbots:DBL-Java-Library:2.0.1'
}
Ok it's Error: serverCount is not a number but a undefined instead
what is ur current code so far? @tribal kraken
@strange wraith has the bot been approved yet?
lol
```const dbl = require(discord-bot-list)
const client = new dbl({
token: "",
id: ""
})
client.postStats("Your bot's server count, MUST be a number, not a string", (err, res) => {
if(err) {
console.error(err)
} else {
console.log(res)
}
})```
@trail sigil
ahh, i would recommend you try using the official dbl api
did you get that from #312614469819826177?
ok lol, many of them are outdated
ohhh i see
just do npm i dblapi.js
ok
all you have to do is pass your client into the constructor and it'll automatically post the stats
Ok hold up lol, constructor? sorry once again imma noob
lol it's the line with the new keyword
const dbl = new DBL('Your top.gg token', client);
so this bit
np
does it support discord webhook
I had to reset my api key, but now even after changing the one in the code to the new one the bot says it is unauthorized
hmm
hello
hi
yeah
ok thanks
No. 1. Don't spam (newlines). 2. This channel is not for talking (only for support with the top.gg API)
your welcome
start it back up
hello
dbl.webhook.on('vote', vote => {
});```
what can i use on here
just vote.user?
that returns the voter id
vote.user returns the user ID
what can i use for user tag?
or vote count
user.tag im guessing
or user.username
you can use client.channels.cache.get("channelID") to send a message into a specific channel
idk im retarded and tired
I just want to know the variables I can use.
I just want to know the variables I can use.
how can i find m ypublic ip address
on my machine
in cmd?
on my machine
@restive otter what do you use to host
if you using windows open cmd and write this ipconfig
That’s private IP afaik
its on a pterodactyl panel actually
its on a pterodactyl panel actually
@restive otter you might have an ip somewhere on the panel
that’s all available ip’s for the host
idk pterodactyl
welp
I also have the problem. I have this as a code
const DBL = require('dblapi.js');
const dbl = new DBL(config.DBLToken, { webhookAuth: 'xxxxx', webhookPort: 'xxxx' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});```
He returns it to me
```JS
Webhook running at http://0.0.0.0:xxxx/dblwebhook
Why does it tell me 0.0.0.0?
same
Because 0.0.0.0 is all the IPs that are available to the host
it runs at your public IP
no
then what do we use
It should give me the ip i have in my panel api?
that’s not your public IP
It should give me the ip i have in my panel api?
@weak night yes that’ll work
How do we change it?
oh
you don’t change public IP
how do i even get my ip from my panel
idk how pterodactyl works you can prob look it up
I have an ip with a link on my panel but should I put it where?
your.vps.ip.address is the ip on your panel
Yes I have that but in the code you have to put where the ip?
Yes I have but the problem is that the code returns 0.0.0.0 when it should put the panel ip
ok
@weak night
Once I have this I must replace it in the panel link ?
no don’t replace the code
yea it should be http://your.vps.ip.address:5000/dblwebhook
hm
I will test
it doesn't work, thank you anyway i will try it alone
There is no youtube video that explains this?
You need to Port Forward (5000) Port in your Panel.
or if you use something like ufw or iptables allow it in that
Wait is changing status too quick is api abuse and what is the minimum time allowed for each status changed?
ok
im not sure about that but id say if its a question it's probably too much, how often were you thinking?
This seems like spoonfeeding but the only thing I am ever going to ask in my lifetime about the API is, how to detect when someone votes and get the user ID?
Wtf is the bot token why would i reveal my bot token
its the api token @restive otter
????
By opening a port and running an app this error is coming out. I have tried to change the ports 10-15 times. Also, there is no other application using the port in the background. If the port is not open, The script runs without any error.
OSError: [Errno 98] error while attempting to bind on address ('0.0.0.0', 4500): address already in use
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f549587f8d0>
@restive otter if you haven't figured it out.
Glitch and heroku limit what ports you can use.
@restive otter if you haven't figured it out.
Glitch and heroku limit what ports you can use.
@jaunty plank I am using AWS
But not every single port is limited though, As mentioned I have changed it 10-15 times to random one. The error is same.
I can't for the love of me get my bot to post my server count to the api using the javascript module
@dawn topaz use the npm module
dbl.on("posted"
Is there an easy way of getting the amount of votes from a user
like how many times he has voted yet?
No
The server count is not working, Is it down?
Does the bot need to include code to post server count info to top.gg api before getting approved for the first time
No, and even though you need an API token for using the Script. You'll get it once your bot is approved.
after the bot gets approved the code to post server count must be added in right?
or is it optional
It's optional
for some reason I remembering seeing that its compulsory to post server count
It's not compulsory but not less than that, You can operate it without that in my opinion and some other services may require you to post the server count.
Whats the easiest way to get the total amount of votes the bot has?
@rotund lake https://top.gg/api/docs#bots you can use the /bots/{bot.id} endpoint to get the object of a specific bot
then to get the number of votes that bot has, do either bot.points or bot.monthlyPoints
okay thanks
How would i read the data in javascript? @trail sigil
Is there like an overall explanation on how to do so?
no?
okay trough a function right?
you can use something like axios for that
ahhh nvm acc
you can use the dblapi.js package to do it very easily @rotund lake
okay is it explained in the docs?
ah i see
then you just do .points or .monthlyPoints on the object you get from that
its not the getStats one
it's the one below that
yup
oh okay thank you very much
What must i do there
{ webhookAuth: 'password', webhookServer: server }
So what do I have to write in "Password" and "server"? Please ping me
imagine using the dbl webhook when you can use express
?
🤔
Dbl api webhook uses http.
Express is built on http @true talon
Express likly will use more resources than the dbl api webhook(extremely small amount more but whatever)
lol
ping?
how would i make it so something happens when a use votes the bot?
https://top.gg/api/docs#pylib ok so check out this
kk
you want to use the webhooks
so you'll get a notification basically each time you vote for your bot
and just put whatever you want it to do within the listener
so i use this one?
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'dbl_token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
# 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())
@tasks.loop(minutes=30.0)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count"""
logger.info('Attempting to post server count')
try:
await self.dblpy.post_guild_count()
logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
except Exception as e:
logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
# if you are not using the tasks extension, put the line below
await asyncio.sleep(1800)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
logger.info('Received an upvote')
print(data)
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))
the thing is i dont have experience using cogs
yeah, you can just use that bit on_dbl_vote(self, data)
so i would have like
import imports
class TopGG(commands.Cog):
@commands.Cog.listener()
async def on_dbl_vote(self, data):
logger.info('Received an upvote')
print(data)
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))
as a seperate file
right?
honestly, idk because i don't do python
ah
you can try asking in #development
k
oki
sry for ping @trail sigil but for this part of the code
def __init__(self, bot):
self.bot = bot
self.token = 'dbl_token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
what do i need to change besides the dbl token?
just the password and the port (if 5000 is closed)
so what would i do for the port?
if u want ig
token is on https://top.gg/api/docs
and password is made yourself
@rapid kettle it would be on the my bots page?
@rapid kettle i can't find the place to set the password if you know now can you help me?
yes i'm there
yea
in URL is your host (including port and /dblwebhook)
i dont have anything there is it needed?
No, you don't need a webhook
kk
Ok then, anything else api related?
wdym?
You want to set up vote logging right?
yea
Ok, do you know it's IP address?
i belive i can find it
Yea, find it, then put http://your.vps.ip.address:webhookport/dblwebhook into the webhook url
then just mash some buttons for auth, then copy it into webhook_auth
its how i done my auth 
in the site
and copy paste the webhook auth into your code
k
return new Promise(function (resolve, reject) {
dbl.hasVoted(message.author.id).then(voted => {resolve(voted);});
})
this returns a false, even for users that have voted... then, after 5-10 minutes/sometimes a bot restart, it returns true. Is there a time that it takes to process the vote?
is there something going on with the api? my bot's stats are being reported at double what they actually are. i've tried updating it myself manually to make sure it's not something wrong with my code.
now when i query the api for the server count it returns the right one. anyone else able to see 3607 or? https://top.gg/bot/691003447603888158
.\
Nor the server count is working without hook
No one?
dpy webhook?
@grim lily Yeah
is there a java vote action listener
How do I get my dbl api key?
@raw void website. Check your bot list, hit edit, and it’ll be at the bottom the page.
Ty
.
@inner venture can i get some help with java api
-dotpost @restive otter
@restive otter
Please do not post dots to clear your messages/get attention. It adds absolutely nothing to the conversation and just causes spam.
If you need to get attention, then say hello everyone. If you need to clear your messages, then press the Esc key. If you do not follow these instructions you will be muted.
https://top.gg/api/docs#mybots
I only see approved bots?
@eternal sundial What's your code
@restive otter Are you sure the autoposter doesn't work without the webhook?
Yeah Shiva, It's not working. I have tried with my Local pc and with my VPS.
For both of my bots.
What does your code look like
Also, DM me the URL and Authorization key you use on the website for your webhook
@proven jasper what do you need help with?
Is there a way to get a vote event listener or does the api have a way of returning the number of votes on the bot
Event listener using the api, not the webhook
guys i have a question, how can i set the server numbers my bot is in, into the bot page?
last endpoint
@proven jasper no, there isnt
you can't get number of votes using webhook but the REST API to fetch bot info includes monthly and total votes @proven jasper
future: <Task finished coro=<DBLClient._auto_post() done, defined at /usr/local/lib/python3.6/site-packages/dbl/client.py:96> exception=Forbidden('Forbidden (status code: 403)',)> Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/dbl/client.py", line 99, in _auto_post await self.post_guild_count() File "/usr/local/lib/python3.6/site-packages/dbl/client.py", line 142, in post_guild_count await self.http.post_guild_count(self.bot_id, self.guild_count(), shard_count, shard_no) File "/usr/local/lib/python3.6/site-packages/dbl/http.py", line 169, in post_guild_count await self.request('POST', '/bots/{}/stats'.format(bot_id), json=payload) File "/usr/local/lib/python3.6/site-packages/dbl/http.py", line 143, in request raise errors.Forbidden(resp, data) dbl.errors.Forbidden: Forbidden (status code: 403) Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x7f60dc4bbe80>
what does this means
I got it at the time of posting the server count.
is the vote logging just putting the webhook url in the bot edit page?
Idk if this is under the api section but i just added my bot to top.gg and it doesn't say that my bot is online how does this work ?
can someone please help?
You can't do it without an approved bot
Did you provide the correct token?
@dense basalt Yes, Even though I have regenerated it thrice.
wait so how do we enable this?
https://gyazo.com/37c73042422d04328708d23f26454fd5
post server count to top.gg api
how im so confused'
using the api
.
-dotpost @gritty snow
@gritty snow
Please do not post dots to clear your messages/get attention. It adds absolutely nothing to the conversation and just causes spam.
If you need to get attention, then say hello everyone. If you need to clear your messages, then press the Esc key. If you do not follow these instructions you will be muted.
Okay, the API is not having the votes return true
After the users vote
Explanation 👀
I need a quick response
your webhook isn't getting responses? or a specific endpoint is giving incorrect info?
Nah, it's the dbl variable
const dbl = new DBL("That Token",{
webhookPort: 5000,
webhookAuth: 'dZ615dp0xeTKmmf39SQNM-THATSOMETHING'
});```
@jaunty plank is this correct?
yeah
Getting nothing back
no response
no vote requests
I'm still getting false back
The users who voted on my bot
It still returns false for them
🤔 the webhook is to be used when top.gg gets a vote
it has a vote event
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
do you have an event setup for votes?
okay, did you tell the website to use the right ip:port/path
👀
http://ip:port/path
Discord's?
yeah, you need to tell top.gg to use that
except with your ip
on your bots edit page
near the bottom
😻
I made a vote log, the code works, but when a person votes, nothing happens
Code (js):
dbl.webhook.on('vote', vote => {
ec.Global.findOne({_id: vote.user}, function (err, doc) {
let amount = Math.floor(Math.random() * 8000) + 5000
let money = amount + doc.money
doc.money = money
doc.save()
client.channels.cache.get("726135416238899210").send(`<@${vote.user}>`)
client.channels.cache.get("726135416238899210").send({
embed: {
"title": ":vote: » Voto",
"description": `Obrigado por votar, <@${vote.user}> !\nRecebeu ${amount} por votar!`,
"color": "GREEN"
}
})
})
});
The other things works
const dbl = new DBL('bots token', { webhookPort: 7487, webhookAuth: 'bots password' })
0.0.0.0 isn't the right ip.
It's actually hardcoded to say that in the code
So, change 0.0.0.0 to your VPS public IP
@plucky canopy
Ping me if that doesn't work
The VPS don't have dedicaded machines
Discloud
What plan
Diamond
You'd be cheaper buying a VPS at that point
yeah...
It is true that if my bot is in heroku hosted. Does the Vote api not work for you?
Is it good for heroku too?
It works but only on a certain port afaik
Please i need help for the status of my bot
How i can display the number of servers and members
You can't when it's not approved
What happens if my webserver is offline at the moment of a vote? Do I get another attempt from dbl to send me the vote later? (using webhooks)
No I don't think it retries
Use a web server that's separate to any in your bot e.g. not express.js or such. From there queue them to a db table or similar and have your bot query that
That way if your bot is offline you don't miss votes
My webhook handlers are simple PHP scripts for example
can anyone help me with discord.py?
future: <Task finished coro=<DBLClient._auto_post() done, defined at /usr/local/lib/python3.6/site-packages/dbl/client.py:96> exception=Forbidden('Forbidden (status code: 403)',)> Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/dbl/client.py", line 99, in _auto_post await self.post_guild_count() File "/usr/local/lib/python3.6/site-packages/dbl/client.py", line 142, in post_guild_count await self.http.post_guild_count(self.bot_id, self.guild_count(), shard_count, shard_no) File "/usr/local/lib/python3.6/site-packages/dbl/http.py", line 169, in post_guild_count await self.request('POST', '/bots/{}/stats'.format(bot_id), json=payload) File "/usr/local/lib/python3.6/site-packages/dbl/http.py", line 143, in request raise errors.Forbidden(resp, data) dbl.errors.Forbidden: Forbidden (status code: 403) Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x7f60dc4bbe80>
Anyone please? I have regen the token thrice, The auto server count is not working. It does work for my other bot but not this.
Thanks brain
Am I right your bot needs to be verified before you can use the api?
Verified on top.gg to make use of dbl api
how else do you want to use the api? you need the token, which u only get after u are verified
Ok thanks, I already thought so but wasn't 100% sure
Hey, when I set my API url to http://xx.xx.xx.xx:8080/dblwebhook it works, but when I set it to http://zsurvive.xyz:8080/dblwebhook it doesn't
I think it might be because I'm using cloudflare, any way to solve that?
Cloudflare supports port 8080, so that should not be an issue https://support.cloudflare.com/hc/en-us/articles/200169156-Which-ports-will-Cloudflare-work-with-
Please ping me if there is any answer!
@lavish elm just use the IP
It returns a 404 not found btw
So, I just recently got my bot approved and I want to start using webhooks and seeing when a users votes and such, I've read the documentation but I'm still a bit confused on how to set it all up. I'm currently using heroku temporarily for hosting so that it's not on my computer 24/7. Can anyone assist me with this?
Scroll up
This channel is filled with those questiobs
And answer about it
I did scroll up, but none of those things seemed worked for me.
If anyone is available to help me, feel free to ping me whenever you have the chance.
@restive otter need help?
hey what's the last version of dblapi.js? 2.4.0?
yes
@restive otter need help?
@rapid kettle Yes, I still do.
hi, anyone knows if rich presence works for mobile apps?
We have to host a webhook server in order for the vote webhook to work, or we just put the IP and port in the URL and then running the bot with new DBL() allows for them to work?
You need to have the webhook options in new DBL()
and if the ports are open and the ip is right it'll work
Yeah, but not need for an external webhook server, right?
No.
Glad I could help!
Ok, so what language are you developing in?
@rapid kettle Sorry for the late response but JS.
https://top.gg/api/docs has ecexapmles
Yeah, I looked at that but I am still confused on how to setup webhooks.
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
^ initilize webhook with port 5000, and password as the auth
I understand that much, but then what about the actual webhook url?
http://yourpublicip:5000/dblwebhook
if you use default settings
you can see it, in the example ready event aswell
Even if I am hosting the bot elsewhere?
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
the public ip of wherever the code is being ran
So, the public ip of heroku, is what I think would apply in my case.
So then what do I use?
some people suggest proxying from a static ip, to heroku.
but your looking at spending money to do that.
looking around i saw this.
https://devcenter.heroku.com/articles/quotaguardstatic
which suggests it gives a static ip
I'll take a look, thanks.
What’s the best way to pass the client into the new DBL() is using an external program to host this?
@jaunty plank I setup that addon and got a static IP, so now I should just input it in this right? http://yourpublicip:5000/dblwebhook Also apologies for the ping.
Okay, thanks.
does dbl have an issue because the webhook isn't passing the auth token that i give it see below for the headers
im tryna post bots stats, but it seems its not working,
but when i make a POST request, returns a status 200
but the stats aint updating hmm
what language @alpine robin
js
may i see your code that posts the stats?
yeah
ok
Just making sure
what are you trying to do?
post stats
how many servers he's in?
46
yes
why did you make it so complicated - not to be rude
When i post the stats, i get Status 200, says the API, but the stats on the site aint updating
under methods,
have you tried using the example
?
h-hello?
wait
I will
nvm
got it ;p
Good job I'm proud
hey idk if it's here but, how can i change my page's background?
oh
Your bot's Edit page -> Test button at the bottom
Don't forget to fill out the URL and authorization fields
lol
Hello, I'm having a hard time with vote listening on dblpy
Yea?
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token)
@commands.Cog.listener()
async def on_dbl_test(self, data):
print("User voted:", data)
So here's my Python code
you don't have any webhook settings afaik
I didn't know exactly what to put in the Webhook URL so it looks like 'http://ip/dblwebhook'
But whenever I press the test button nothing happens
I must have missed something
Probably a wrong URL
But I don't know what URL to choose and how to set a listener server side as I guess http://ip/dblwebhook doesn't lead anywhere
http://ip:port/dblwebhook
Also
The lib needs to be configured
How do I choose the port?
Ohhhh I didn't see the arguments when initializing the class, thanks
I can choose the path and port
Gonna try that later thanks
You relied on your IDE to suggest that?
Yeah, webhook_x kwargs are received internally from **kwargs so your IDE didn't know those existed
A webhook is just a reverse API, you listen to requests
Oh I see
hey there, my webhook handler isn't working due to dbl not sending the authorization header.
(for votes)
Ok so I tried configuring the webhook when calling the DBLClient class and setting up my webhook accordingly on the website :
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path="/dblwebhook", webhook_auth='mypassword (authorization field on the website)', webhook_port=5000)
@commands.Cog.listener()
async def on_dbl_test(self, data):
print("User voted:", data)
It won't print anything when clicking the Test button
hmm, difference between automatic and manual server count (and maybe webhook too)?
"Autopost" provided by dblpy accesses the client.guilds and posts its length to top.gg
Manual server count just allows for more flexibility with the interval between each post
As for the webhook,
A webhook is just a reverse API, you listen to requests
A webhook that you use for top.gg is optimally a webserver listening to POST requests to get data of votes in real time
Ooohh thanks that cleared out a lot for me

I can't get the on_dbl_vote event to work, I set the webhook path, auth, port and everything
but it doesn't work as expected
import dbl
import discord
from discord.ext import commands
import os
on_vote_log_id = os.getenv('ON_VOTE_LOG_ID')
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, client):
self.client = client
self.token = os.getenv('DBL_TOKEN') # set this to your DBL token
self.dblpy = dbl.DBLClient(self.client, self.token, autopost=True, webhook_path='/dblwebhook', webhook_auth='somepassword', webhook_port=5000) # Autopost will post your guild count every 30 minutes
async def on_guild_post():
print("Server count posted successfully")
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print("voted")
vote_channel = self.client.get_channel(int(on_vote_log_id))
member = self.client.get_user(data['user'])
embed = discord.Embed(title="New vote!",
description=f"{member} voted on your bot.",
color=discord.Color.green())
embed.set_thumbnail(url=member.avatar_url)
await vote_channel.send(embed=embed)
@commands.Cog.listener()
async def on_dbl_test(self, data):
print('ey')
print(data)
def setup(client):
client.add_cog(TopGG(client))```
Does anyone have any idea of what it could be?
I used the following format to form the path in the bot/id/edit section: http://that.is.my.ip:5000/dblwebhook
I tried many ports, tried using https instead of just http
tried using my own public ip instead of the application host's public ip
none worked
h
did you let the port through the firewall?
if you have one*
and if you need to, port forward
I tried using sudo ufw allow 5000/tcp
in the console
but I don't have perms
I mean, there is no ufw, so to install it I would have to have perms
it's an ubuntu 18.04.4
I'm using repl.it
to 'host' the bot
and a third party website to ping the flask application's ip
to run it
forever
repl it might have restrictions on what ports you are allowed to use
i used a website to check if that 5000 port was blocked
it apparently is
isn't there another port that I could use?
I'm not sure, ive never used replit
they will have it listed somewhere
I can't find anything
well, guess I'm not having an on_vote command
thank you for your time anyways
wait a sec, I'll take a look into it
@sullen nymph I get a [23/Jul/2020 22:18:02] "POST /dblwebhook HTTP/1.1" 404 - in my console
when I test the webhook
but it doesn't trigger anything
What's your webhook_path?
Yeah, a 404 status code is returned
/dblwebhook endpoint doesn't exist on your webhook
like that
def __init__(self, client):
self.client = client
self.token = os.getenv('DBL_TOKEN') # set this to your DBL token
self.dblpy = dbl.DBLClient(self.client, self.token, autopost=True, webhook_path='/dblwebhook', webhook_auth='justatest', webhook_port=8080) # ```
my flask thing also uses the 8080 port
am I doing something wrong? 
Could you send me the full URL and Authorization key in DMs?
sure
What are the different things I could sort by for the /bots endpoint?
It just says String for type but I don't actually know the different things I can sort by
I'm not entirely sure, maybe like points or monthlyPoints
those are what first come to mind, but I have no idea
I know there is points and guildcount
Is there a place where I could find a list of all of them?
marco would probably know, but he's offline so I wouldnt bother him
Simple, just generate every possible combination of strings that go to x length and eventually you'll find most of them 

Could try any key returned from /api/bots/XXXX
i got this error when testing locally, is this normal?
Error: connect ETIMEDOUT 104.31.87.28:443
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1128:14) {
errno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect',
address: '104.31.87.28',
port: 443
}
dblapi.js is the package
where do i get yourDBLTokenHere
your bot needs to get approved first
alright
afterwards, you will find it in top.gg/api/docs#mybots as well as in your bot's edit page
cheers 

i added mine a few days ago but also waiting on discord to verify my application and i bet that will take a few months 
if quarantine exists, yes
people in quarantine be like, "I have nothing to do.. guess I'll submit my unique moderation bot"
whats the webhook auth & password if you were to use the webhook?
Webhook auth is set by you
what is that supposed to be
Nice spam
-api @restive otter
@restive otter
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
!start
really...
-ask2ask
Don't ask to ask.
Just ask your question, it wastes time if you say "i need help" or "can someone help me?" instead of just saying what the problem is. Save your time and other people's time and just ask the question.
Please read https://dontasktoask.com/ for an explanation on why this is an issue.
ok
So what exactly is the api used for?
https://top.gg/api/docs plenty of reasons to use the API for
browse the Resources tab and see what endpoints are available
hi
Hello ,
How do I get my bot to kick the name of the person who voted for a particular channel when I voted from top.gg?
Can anybody suggest me a free chatbot api, that can respond to the user's messages?
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
-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
you have a api for server list ?
no, the server list is managed by @wild lantern afaik
^
TypeError: Cannot read property 'on' of undefined``` i get this error
ight
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
ight
never used heroku, so im not sure if you are limited to specific ports
@jaunty plank I don't know if you remember talking about the heroku addon that said would help me with webhooks but I was testing out the url with testing tool and it returnsThis is a proxy server. Does not respond to non-proxy requests.
Also sorry for the ping.
I want to connect the API to my bot so it shows the amount of servers it is in but I don’t know how to do this with discord.js commando
where can i get the DBL npm?
Happy day of birth
is it possible to receive the webhook with aiohttp
yes
With post?
hey what did i do wrong here
@restive otter aiohttp.web? listen to POST requests
const server = http.createServer(app);
const dbl = new DBL(`lmaokeyhere`, { webhookAuth: 'auth', webhookServer: server });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running with path ${hook.path}`);
});
dbl.webhook.on('vote', vote => {
const voted = new Discord.MessageEmbed()
voted.setColor(`RANDOM`)
voted.setAuthor(`XBot DBL Webhook`)
voted.setDescription(`${vote.user.tag} just voted for XBot!\nID: ${vote.user.id}\nThank you and don't forget to vote again!`)
voted.setTimestamp()
voted.setThumbnail(vote.user.displayAvatarURL({ format: "png",dynamic: true, size: 1024 }))
bot.guilds.cache.get(`652474899511640074`).channels.cache.get(`736862394466304011`).send(voted);
});``` hey anyone know what i did wrong here?
it doesnt send anything after a user voted
Hello ! I would like to know where I have my webhook password? Thank you !
{ webhookPort: 5000, webhookAuth: '' });
Your bot's edit page
thx 
const server = http.createServer(app);
const dbl = new DBL(`no`, { webhookPort: no, webhookAuth: 'no' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path} - Works`)
});
dbl.webhook.on('vote', vote => {
console.log(`2`)
const voted = new Discord.MessageEmbed()
voted.setColor(`RANDOM`)
voted.setAuthor(`XBot DBL Webhook`)
voted.setDescription(`${vote.user.tag} just voted for XBot!\nID: ${vote.user.id}\nThank you and don't forget to vote again!`)
voted.setTimestamp()
voted.setThumbnail(vote.user.displayAvatarURL({ format: "png",dynamic: true, size: 1024 }))
bot.guilds.cache.get(`652474899511640074`).channels.cache.get(`736862394466304011`).send(voted);
});```
ehh now it logs the ready part but doesnt work when someone votes
Hmm
anyone know why?
vote.user is a just a id
oh
but you're using vote.user.displayAvatarURL() 
Use fetch or get
o
const server = http.createServer(app);
const dbl = new DBL(`no`, { webhookPort: no, webhookAuth: 'no' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path} - Works`)
});
dbl.webhook.on('vote', vote => {
let voter = bot.users.get(vote.user)
console.log(`2`)
const voted = new Discord.MessageEmbed()
voted.setColor(`RANDOM`)
voted.setAuthor(`XBot DBL Webhook`)
voted.setDescription(`${voter.tag} just voted for XBot!\nID: ${vote.user}\nThank you and don't forget to vote again!`)
voted.setTimestamp()
voted.setThumbnail(voter.displayAvatarURL({ format: "png",dynamic: true, size: 1024 }))
bot.guilds.cache.get(`652474899511640074`).channels.cache.get(`736862394466304011`).send(voted);
});```
soo this should be okay?
sairam why do you really want to announce it, it's not even public yet
const server = http.createServer(app);
const dbl = new DBL(`no`, { webhookPort: no, webhookAuth: 'no' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path} - Works`)
});
dbl.webhook.on('vote', vote => {
let voter = bot.users.get(vote.user)
console.log(`2`)
const voted = new Discord.MessageEmbed()
voted.setColor(`RANDOM`)
voted.setAuthor(`XBot DBL Webhook`)
voted.setDescription(`${voter.tag} just voted for XBot!\nID: ${vote.user}\nThank you and don't forget to vote again!`)
voted.setTimestamp()
voted.setThumbnail(voter.displayAvatarURL({ format: "png",dynamic: true, size: 1024 }))
bot.guilds.cache.get(`652474899511640074`).channels.cache.get(`736862394466304011`).send(voted);
});``` this still doesnt send the message tho
@gusty citrus have you setup the url on your bot page?
where do you host
@gusty citrus are you certain that the port you are using is open?
uh idk i just put 5000 there
@gusty citrus Where do you host?
uh on a friend's host
get their host's IP address
uh ye
im quite sure i already tried that tho
have you opened the port?
how do i open
If it is your friends host your friend needs to open it for you
ye i used the node IP and 5000 as the port but it doesnt seem to work still tho
where do i set the path to dblwebhook in my code
webhookPath option
0.0.0.0 is all ips on the server
0.0.0.0 is just hard coded into the dblapi.js file
how do i know when its connected cuz whenever i test the webhook nothiing goes through
const server = http.createServer(app);
const dbl = new DBL(`no`, { webhookPort: no, webhookAuth: 'no' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at no - Works`)
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`)
let voter = bot.users.cache.get(vote.user)
const voted = new Discord.MessageEmbed()
voted.setColor(`RANDOM`)
voted.setAuthor(`XBot DBL Webhook`)
voted.setDescription(`${voter.tag} just voted for XBot!\nID: ${vote.user}\nThank you and don't forget to vote again!`)
voted.setTimestamp()
voted.setThumbnail(voter.displayAvatarURL({ format: "png",dynamic: true, size: 1024 }))
bot.guilds.cache.get(`652474899511640074`).channels.cache.get(`736862394466304011`).send(voted);
});```
why does this still not send
i checked the port is open and the IP is correct
http://ip:port/dblwebhook
and auth needs to be the same as your program and the website
Does anyone know how to add a music command to play music on the bot? It should connect to the voice channel itself
Does anyone know how to add a music command to play music on the bot? It should connect to the voice channel itself
its not coming now also
What is dbl base api url?
Is there a way to get an api key if your bot isn’t verified yet?
Like on the website if it still hadn’t been reviewed or no?
no
not that im aware of
you'll only get the api key once its approved
Alright thank you
@sleek hamlet here too

There is something wrong here?
const dbl = new DBL("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3NjE1MTExMTY4MTMxMDczMCIsImJvdCI6dHJ1ZSwiaWF0IjoxNTk1ODA3MDY5fQ.q4s4Fmo8aaMgA3lZ-tcwHotu-------------------", { webhookPort: 5000, webhookAuth: 'password'});
Do you think censoring only the last part of a token is a good idea
can u help me?
are you having an error?
or whats not working
I need to change something in the webhookAuth?
can u send a link to the bot's edit page?
this isnt working
import dbl, discord, cogs
from discord.ext import commands, tasks
import asyncio
import logging
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, client):
self.client = client
self.token = '<my bot token>'
self.dblpy = dbl.DBLClient(self.client, self.token)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
logger.info('Received an upvote')
print(data)
print(data["user"])
channel = self.client.get_channel(id=737102089800515655)
try:
u = self.client.get_user(id=int(data["user"]))
except:
u = await self.client.fetch_user(id=int(data["user"]))
await channel.send(f'**{u}** has voted for the bot.')
def setup(client):
global logger
logger = logging.getLogger('client')
client.add_cog(TopGG(client))
@vapid cape Where?
What know?
url would be http://ip:port/whateverpathissetto
the public ip of your bot, port and path you set in setup
auth would be webhook auth you set in init
You mean this?
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});```
where is your bot hosted?
It say Webhook running at http://0.0.0.0:5000/dblwebhook
yeah
is your bot in a vps?
Yes
just replace 0.0.0.0 with your pub ip.
if your hosting not on a vps, you may need to let your port through
How can I know my public ip?
this isnt working
import dbl, discord, cogs from discord.ext import commands, tasks import asyncio import logging class TopGG(commands.Cog): """Handles interactions with the top.gg API""" def __init__(self, client): self.client = client self.token = '<my bot token>' self.dblpy = dbl.DBLClient(self.client, self.token) @commands.Cog.listener() async def on_dbl_vote(self, data): logger.info('Received an upvote') print(data) print(data["user"]) channel = self.client.get_channel(id=737102089800515655) try: u = self.client.get_user(id=int(data["user"])) except: u = await self.client.fetch_user(id=int(data["user"])) await channel.send(f'**{u}** has voted for the bot.') def setup(client): global logger logger = logging.getLogger('client') client.add_cog(TopGG(client))
your vps company tells you
either in a control panel, or in an email, or whatever
when you buy a vps, you get its ip
in order to ssh into a vps, you use the public ip
yeah, thats the link they push webhooks to
then auth is the auth you set
webhookAuth: 'password'
@valid heath what exactly is not working
Authorization
Authorization (in top.gg) and webhookAuth (in your code) must be the same thing
Like that>
@vapid cape the data wont print and the bot wont post votes
did you read the example?
you're not using the example
its paramaters dont match up with my bot
no webhook = no on_dbl_vote
oh
the examples without webhooks are for posting server count only
and the end of the url should be /dblwebhook?
yes
Why when I start the bot it still says Webhook running at http://0.0.0.0:5000/dblwebhook?
even tho I changed the 0.0.0.0
So why its not saying http://myvpsip:5000/dblwebhook ?
So what I can do?
nothing, it doesnt matter it says 0.0.0.0
because it means, any ip this system has available
including your public ip
if you have a firewall, you need to let port 5000 through
how?
depends on the firewall
but I have used this port before when I created my web apps in express
I used localhost:5000
localhost doesnt need firewalls to have that port open
generally speaking, you install them yourself.
o windows
yes lol
yes
🤷♂️ might work, i dont know windows firewall at all
no webhook = no on_dbl_vote
@vapid cape I added a webhook, still doesnt work. Code:
import dbl, discord, cogs
from discord.ext import commands, tasks
import asyncio
import logging
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, client):
self.client = client
self.token = '<token>'
self.dblpy = dbl.DBLClient(self.client, self.token, webhook_path='https://discordapp.com/api/webhooks/73710970111******/****************', webhook_auth='hello', webhook_port=5000)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
logger.info('Received an upvote')
print(data)
print(data["user"])
channel = self.client.get_channel(id=737102089800515655)
try:
u = self.client.get_user(id=int(data["user"]))
except:
u = await self.client.fetch_user(id=int(data["user"]))
def setup(client):
global logger
logger = logging.getLogger('client')
client.add_cog(TopGG(client))
can you give me an example
so you just write "/dblwebhook"
if thats the path you want yes
at the end of your url
which an example of is
http://ip:port/dblwebhook
self.dblpy = dbl.DBLClient(self.client, self.token, webhook_path='/dblwehook', webhook_auth='hello', webhook_port=5000)
like that?
yeah

what now?
should be able to test it, on your bots edit page, very bottom is a test button
i change the code, it still doesnt work
full code:
import dbl, discord, cogs
from discord.ext import commands, tasks
import asyncio
import logging
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, client):
self.client = client
self.token = '<token>'
self.dblpy = dbl.DBLClient(self.client, self.token, webhook_path='/dblwehook', webhook_auth='hello', webhook_port=5000)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
logger.info('Received an upvote')
print(data)
print(data["user"])
channel = self.client.get_channel(id=737102089800515655)
try:
u = self.client.get_user(id=int(data["user"]))
except:
u = await self.client.fetch_user(id=int(data["user"]))
def setup(client):
global logger
logger = logging.getLogger('client')
client.add_cog(TopGG(client))
Thankssssssss @jaunty plank ❤️
😻
And another Q, how can I know how many votes there is to the bot?
thats a discord webhook
your creating a webhook in your code
a server, which catches requests
so what do i put there
http://pubipofyourbot:port/dblwebhook
you host on a VPS?
yeah, itll be the public ip of that host.
if your temp hosting it on your home network, itll be your home public ip(google "whats my ip")

wdym