#topgg-api
1 messages ยท Page 71 of 1
- install dbl's api for your language
- go to top.gg
- click "edit" on your bot
- scroll down to webhooks
- in "url", put your bot's address
5a. if your bot is in a vps, put your vps's ip address (YOUR.VPS.IP.ADDRESS:PORT/dblwebhook)
5b. if your bot is in glitch/heroku, put your project's address (YOURPROJECTNAME.glitch.me/dblwebhook or YOURPROJECTNAME.herokuapp.com/dblwebhook) - in "authorization", create a password of your choice
- in your code, use the dblapi library you installed in step 1, and put your port, dbl token and the password you created in step 6
7a. if your bot is in a vps, put the same port you put in step 5a
7b. if your bot is in glitch/heroku, putprocess.env.PORTas your port
bots address?
yes, the address of the machine/computer where your bot program is running
ip?
check 5a and 5b
im running it on my computer
then its YOUR.COMPUTER.IP.ADDRESS:PORT/dblwebhook
and you need to make sure those ports are forwarded and not blocked
port 80 is reserved in most systems
try port 3000 or port 5000
thats what most node.js apps do
that website doesnt really work for checking ports, because they will show as closed if not being used
you need to setup everything and then test in top.gg
public
so like xx.xx.xxx.xxx:2913/dblwebhook
yes
ok
epic nothing happened
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
print('TopGG Cog')
self.bot = bot
self.token = dbltoken
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print(data)
@commands.Cog.listener()
async def on_dbl_test(self, data):
print(data)```
whats the port your dblpy is using?
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
what ip did you put here?
my ipv4 because that's only thing it lets me put
your local ip right? like 192.168.x.x
yeah
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
print('TopGG Cog')
self.bot = bot
self.token = dbltoken
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth=webhookauth, webhook_port=3431) # Autopost will post your guild count every 30 minutes
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print(data)
@commands.Cog.listener()
async def on_dbl_test(self, data):
print(data)```
authorization = webhookauth?
how do I do that
im just asking to make sure, if your authorization in top.gg is the same as your webhookauth in your code
no, i mean if the webhookauth is the same as the authorization
they have to be the same thing
webhookauth = authorization in top.gg
the same as authorization
then idk what else
try making a simple http server
to test with your browser
im not a python user so idk, but look into creating a simple http server on a random port to listen to / and print anything that comes through it, then open your browser and navigate to 127.0.0.1:PORT
just to test if the server is working
idk anything about http
Was there a moment where you made sure the port is open and firewall isn't blocking anything
oh yeah, also check the windows firewall (assuming you're on windows)
how do I check if the port is open @sullen nymph
Router settings
Then make sure your firewall isn't blocking anything
I turned it off
self.dblpy?
Yes
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth=webhookauth, webhook_port=3431, autopost=True) # Autopost will post your guild count every 30 minutes
Are Authorization keys the samw in your code and on the website
Are you sure the webhook is actually running
yes first part
second part idk
it prints
what could prevent my router from port forwarding @sullen nymph
Firewall which is off
Improper port forwarding but God knows how you manage to fuck that up
Tbf BT routers sometimes don't even bother opening the port even if you port forward in my experience
bt?
@green mantle how do you fix that issue
@sullen nymph NetBIOS over Tcpip. . . . . . . . : Enabled
DHCP Enabled. . . . . . . . . . . : No don't know if these have any meaning
@vapid cape
Ethernet adapter VirtualBox Host-Only Network:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::41f3:1735:ee0:4cbc%3
IPv4 Address. . . . . . . . . . . : 192.168.56.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :```
I have this
where can i find some kind of crash course on setting up a voting reward system for my bot
@austere pumice You need your public/external IP
I do
Mind sending it in my DMs to confirm
are you running your bot inside a virtual machine?
I think thats just the network that gets installed when you install virtualbox
yeah, no wonder why it doesnt work then
pretty sure there should be more output than that
wait wut
Default Gateway . . . . . . . . . :
no default GW
how are you even online?
That is his virtualbox network info, his VM might be offline while he is online
Or he just didnt add that info to his copy/paste
hi, I'm trying to use dblapi.js but it's not working. It's running but I'm not receving the message when someone upvotes. The code is ok.
what is dbl.domain for?
what
ping me when responding pls
Does the "what" not indicate your question made barely any sense
well, I have the library running and it should send a message on discord when the vote event fires. But it's not sending it and I don't have any error in the console
Did you make sure your port is open and forwarded while no firewall is blocking the requests
yes
and did you enter the right ip address and port for the DBL webhook settings?
there is no ip adress parameter, is there?
Do you think you can just enter some random numbers and make it work
Get your external IP address and use it in the webhook URL
the URL on top.gg needs to be something like http://mydomain.com:5000/webhook or http://123.123.12.12:5000/webhook
wait now I'm getting TypeError: domain.enter is not a function at DBLAPI.EventEmitter.emit (domain.js:498:10)
ah ok
and if I didn't set a path in the code, is it just http://mydomain.com:5000?
I don't exactly know what you need to enter in your JS library because I don't use JS
By default webhookPath is /dblwebhook
oh ok, thanks
And I think DBL only accepts http webhooks, so no https
But I might be wrong
oh
What
I am wrong?
I highly doubt that
ok, ignore what I said ๐
But then again, you'd better ask a website admin
and how do I change that?
by hosting a webserver manually or sticking to http
I don't recall there being an option to be able to use https unless express server has that
I don't think my site works with http, lets see
show your dbl code
const dbl = new DBL(config.DBLToken, {
webhookPort: config.port,
webhookAuth: config.auth,
webhookServer: server
}, bot)
dbl.on('error', err => {
console.error(err)
});
dbl.webhook.on('ready', hook => {
console.log(chalk.green(`[SYSTEM] - Webhook running at http://${hook.hostname}:${hook.port}`))
});
dbl.webhook.on('vote', vote => {
bot.createMessage('666712304431136769', `<@!${vote.user}> Upvoted for us on DBL! Thanks :heart: \n<https://deltabot.tech/dbl>`)
});
and it's running on port 6719
your server is an express server?
yes
is it configured with ssl?
yes
if you're already running your own server object
you dont need a port
it will use the same port as the server
so remove the port configuration, and change your url to yourwebsite.org/dblwebhook
How can i post my shards from my bot with the JS DBL api
or is it possible?
Yes its possible
and how?
ahh k thx
Example :
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});```
thx
You welcome
hey, so my vote webhooks stopped working after i added my site to cloudfare, any idea how to fix?
you probably need to whitelist something in the cloudflare settings
hmm like what? and where?
anyone?
hi
you are looking for #commands or #265156322012561408
Hi, I got a short question:
In you're Doc you are saying that any bot with over 1000 votes per moth can not use /bots/{bot.id?}/votes, but need to use webhooks instead.
Where does the moth came from? And what will happend with the 1001st voter within a moth?
webhooks are a lot easier than asking the DBL server every time if someone has voted
Depends on the system and I'm realy just courious what will happen to the 1001st voter, scince I couldn't find anything in the Docs for that.
well, the docs say in big red letters that you cannot use it
so its possible that it returns an error if your bot has over 1000 votes
I guess there is no hard limit, but the admins might take action if you go over the limit
Or maybe there is a hard limit, I never tried it
there probably is a hard limit
you have to limit a potentially limitless json response
It's funny that the Java library has marked it deprecated without having the option to use websockets
what if the bot has like 20k votes? does it return all 20k or does it limit the output to 1k?
limits to 1k
Hi for the revocation link token it is : https://discordapp.com/api/oauth2/token/revoke?access_token=TOKEN ?
Oh xuse me dude ๐
so I'm trying to setup webbooks, but not receiving tests at all. (firewall is not an issue)
I think someone in #general said that there is an 18 minute delay on receiving votes through webhook right now
question about the api, I have a cog listener event using the python DBL library, and when receiving POST requests i get this:
127.0.0.1 [18/Jan/2020:12:58:04 +0000] "POST /dblwebhook HTTP/1.1" 401 178 "-" "DBL"
but it doesn't call the function
but it doesn't call the function
The authorization key isn't the same DBL sends
Make sure webhook_auth is the same as the Authorization field value on top.gg
Ah fuck you Discor
Make sure webhook_auth is the same as the Authorization field value on top.gg
Getting anything?
im getting it, just function isn't beinmg called
the authorization is the same in top.gg as it is in my bot
no im recieving it
in my bot i see the request
Economote [INFO] | 127.0.0.1 [18/Jan/2020:13:18:02 +0000] "POST /dblwebhook HTTP/1.1" 200 168 "-" "DBL"
in my bot i see the request
fuck I'm being blind
Would you be sure that the event is actually registered on the bot?
the event function is not being called
but I see the logs spout that out every time I test
(the delay I think is gone)
Are you sending a test request?
yes
And you got on_dbl_test event?
oh.. alright yeah that's what i was missing.
haha
im jealous of the JS people with their really detailed docs lol
and I pity the GO/Java/C# devs XD
Don't you dare call my docs useless, they're just not finished! :(
i will admit they are way better than like a year ago ๐
I would really appreciate some detailed feedback ngl
or some kinda explanation how to do proper documentation at this point
hit: 34 examples for each possible scenario and each possible command/function combination
and whatever other fuckery some idiot will eventually try
At this point that doesn't sound like an exaggerating
documentation is literally one of those "for dummies" books lmao
True
Hi. My bot has only just been approved. I'm not sure how to use the API, so could somebody please provide me with a code snippet on how to DM a user when they've voted, or just tell me how to do this. Thx :)
which library do you use
sorry I can't help for py. I'm using js
sry
@restive otter https://dblpy.readthedocs.io/en/latest/api.html
Well, rather... https://dblpy.readthedocs.io/en/latest/api.html#event-reference
ok ty
@sullen nymph i have another question. how could i make it so the ip the server is on is 0.0.0.0, as im using gcloud and that's the only way i can think of being able to use the external ip.
on the webhook*
Uhh
mainly because i cant use the internal ip
dblpy hosts the webhook on 0.0.0.0
If you are unsure, you're free to to dig around the internal code
ok, tysm c:
๐
last question, is there anyway to test the upvote thing without having to wait 12 hours each time?
I'd show the button itself as a joke but I don't have a bot listed so
There's a Test button on your bot's Edit page
You just save your settings and test the webhook there
ok ty
u
Is there a test bot token I can use to see if my code for posting the server count works? I'm currently rewriting my bot so I'd rather not use my real bots token since it's currently used by the production version. Or is it okay to create a bot just for testing purposes?
There is no test bot, but what's the risk in sending a server count?
During testing I first checked the nr of servers for my real bot and then I used that number plus or minus a few as a static value in the test version of my bot
Don't forget to disable or remove the test code after testing
thank you
Can not obtain ownership information
TCP 0.0.0.0:5000 license:0 LISTENING```
my port
is opened?
but test thing no work
What does your URL look like
What about port
5000
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='epicgamerauthotokenthing', webhook_port=5000, autopost=True)
Well did you specify the port in the URL
yes
Are you sure your firewall isn't blocking stuff
I made 4 rules for it saying don't block port 5000
2 of them inbound tcp and udp, and 2 outbound tcp and udp
Ports currently open on all network interfaces:
Port Protocol Version Program
-------------------------------------------------------------------
5000 UDP Any (null)
5000 TCP Any (null)
25565 TCP Any (null)```
@sullen nymph is there a way I could test if it blocking things
I don't honestly remember if dblpy webhook outputs anything in console on request but you should probably check it out just in case
I have a cog listener for the vote thing
is there anything being output in your terminal when you send a request to the webhook?
nope
are you listening to the test event?
i think so, but can you give me the name
dblpy has different events for normal votes and test votes, for some reason
ยฏ_(ใ)_/ยฏ
well I added it, and tested the vote again, it's a nope
what could also prevent this
then besides router ports and firewall idk
you can try running a simple http server to test
can you give me the code bc I don't know shit about that
i dont use python, so... not really
No
We are not gonna spoonfeed you
Also use a port tester to check if port is open on your public ip
I have
and it says no open
also @green mantle I fucking looked up the shit, and told me some complicated shit
Because bots can and are complicated?
Idfk what you were expecting when you're intersecting with different web servers and socket layers
port testers do nothing, every single time i use them, they say my ports are closed, even though my shit works
ยฏ_(ใ)_/ยฏ
windows says the port is open
but my portchecker says
ok, i have an idea @vapid cape how does one host my code on aws
install python in there, install all your libs, upload your files, and run
idk how to use aws
@austere pumice do you use a portchecker that is installed on your pc or do you use an online one?
the installed portscanner probably doesn't work while your bot is running because the scanner tries to use port 5000 while checking if it is usable
ok
if you want to use it then you will have to stop your bot first and make sure no other program is using port 5000 while running the port scan
ok
what is this channel for?
dbl api
im trying to make a request to https://top.gg/api/users/ID_HERE and get the json data but it appears i am doing something wrong because embed i put the data in doesn't show up.
I have looked over the code and double checked but i can't find anything wrong with my code.
If it helps, i'm using a website to code and host my bot (https://glitch.com) which runs on nodejs and uses the request package to make the request.
this is big confusion to me indeed.
idk if im an idiot or smth but yh
I m use Bot designer for discord
Is this bots allowed? @dense basalt
nope.
Interesting
This is place where you making bot commands
@restive otter you're using bot designer for your bot(s)?
Yea
DMs
You cannot post stats with bot designer
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
take a look at https://top.gg/api/docs
Click the language that you're using
This?
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
@restive otter you just leaked most of your dbl token
Yeah
I am having a problem with webhooks. Cannot read property 'on' of undefined
that doesn't give us context of the problem
show us code so we can give you a step by step of how to fix it
dbl.webhook is undefined
do you have code supported
Well, first I tried dbl.webhook.on but it threw error, so I tried to make dbl.on('vote') and put it in my event handler
Events.forEach(e => {
e = e.split('.');
if (e[0] === 'dbl') {
let event = new (require(`./events/${e[0]}.${e[1]}`))(client);
dbl.on(e[1], (...args) => event.run(...args));
} else {
let event = new (require(`./events/${e[0]}`))(client);
client.on(e[0], (...args) => event.run(...args));
}
});
well
discord.js events work correctly
but I think dbl's don't
did you setup the dbl client correctly
let readdir = require('util').promisify(require('fs').readdir),
client = new (require('./base/Client'))(),
dbl = new (require('dblapi.js'))(client.config.dblKey, client)
well
it's undefined because you didn't setup an object for the webhook
you have to add an object with webhookPort and the path
@scarlet cobalt
Iirc dbd uses js
no no and no... it uses Golang and DiscordGo
it's a custom token you set
@tame kindle I keep trying but it still doesn't work
Yes
event
module.exports = class event {
constructor(client) {
this.client = client;
}
async run(vote) {
let client = this.client;
try {
let hook = await client.channels.get('651532735185420288').fetchWebhooks();
hook = await hook.first();
let user = await client.users.fetch(vote.user),
bot = await client.users.fetch(vote.bot),
embed = new (require('discord.js')).MessageEmbed()
.setColor(client.selectColor('green'))
.setTitle(' | ยกHan votado por ' + bot.username + '!')
.setDescription('ยกTรบ tambiรฉn vota por ' + bot.username + ' [haciendo clic aquรญ](https://top.gg/bot/' + bot.id + '/vote)!')
.addField('โข Usuario', user.tag)
.setTimestamp();
//if (vote.type === 'test') embed.setFooter('(Voto de prueba)');
hook.send(embed);
} catch (e) {
client.err({
type: 'event',
name: 'voteDBL',
error: e
});
}
}
};
command & event handler
let readdir = require('util').promisify(require('fs').readdir),
client = new (require('./base/Client'))(),
dbl = new (require('dblapi.js'))(client.config.dblKey, { webhookPort: 5000, webhookAuth: client.config.dblSkey }, client),
init = async () => {
try {
let Commands = await readdir('./commands'),
Events = await readdir('./events');
Commands.forEach(async cmds => {
let commands = await readdir('./commands/' + cmds + '/');
commands
.filter(cmd => cmd.split('.').pop() === 'js')
.forEach(cmd => {
let response = client.loadCommands('./commands/' + cmds, cmd);
if (response) console.log(response);
});
});
Events.forEach(e => {
e = e.split('.');
if (e[0] === 'dbl') {
let event = new (require(`./events/${e[0]}.${e[1]}`))(client);
dbl.on(e[1], (...args) => event.run(...args));
} else {
let event = new (require(`./events/${e[0]}`))(client);
client.on(e[0], (...args) => event.run(...args));
}
});
let login = await client.login(client.config.token),
connect = await require('mongoose').connect(client.config.mongo, { useNewUrlParser: true, useUnifiedTopology: true });
if (login) console.log('ยกIniciando sesiรณn!');
else console.log('Ha ocurrido un error iniciando sesiรณn');
if (connect) console.log('ยกConectando con la base de datos!');
else console.log('Ha ocurrido un error conectando con la base de datos');
client.dbl = dbl;
} catch (e) {
console.error(e);
}
};
init();
Try to execute the event code with eval and it works, what doesn't work is the webhook, I think.
One message removed from a suspended account.
@elfin maple did you add it to your bots page
I don't know what you mean by that, sorry
Here is the project for you to see https://glitch.com/edit/#!/yuiiiii
ah yes I did that
yes
But, I don't have a page in my bot, I don't know how to use it either
it works with glitch
But I would need to create routes, and that's what I don't know how to do.
the url is your glitch project url + /dblwebhook
and in your webhook port, you need to use process.env.PORT
and there is no dbl.on("vote"), it has to be dbl.webhook.on("vote")
what did you put in the url?
- /dblwebhook
๐

Botdaki verileri dbl ye nasฤฑl aktarฤฑrฤฑm
@commands.Cog.listener()
async def on_dbl_vote(self, payload):
print(payload)
``` Not sure why, but the on_dbl_vote in dblpy never fires
@restive otter english only
1 sec
it might be to do with how I init the DBLClient
Ok no it didnt fix it
@vapid cape this is my dbl page
Right so i realised that dbl says you cant POST directly to a channel
your URL should be the IP or domain of your bot, not discord itself
@wintry kernel I recommend changing your webhook now.
Yeah but prevention is better than cure.

so uh how would I make my raspberry pi have a static IP without making the entire internet router static
this is related to dbl API
some routers like Asus allow you to set specific devices to be static
also your router should be static anyway
this is referring to local IP btw ^^
I think almost every router/modem has an option to link a local IP to a mac address
your external IP is controlled by your internet provider and it depends on them if you have a static or changing public IP
That's is technically wrong
They can be stati
Static
Most loca IPs are static if you have any decent router
Public IPs are often dynamic but can be static if you ISP allows it like mine
In the Netherlands most public IPs are static in practice, your modem can be disconnected from the internet for a few hours and you will still have the same IP
The ISP can give you a new IP, but they usually dont
Local IPs are based on computer connection time
and are decided by the computer itself, if available
Or at least that's how I've set it up
Most routers have a DHCP server that assigns IP addresses on the local network
It's extremely common practices for isps to give you a static public ip
Post your server count
How?
wot
OSError: [Errno 10048] error while attempting to bind on address ('0.0.0.0', 5000): only one usage of each socket address (protocol/network address/port) is normally permitted
Unclosed client session
is your bot running twice?
I'd use a unique port
eg for my webservers I use :5644
and we need the code to help
!help
if you are playing online game they uses 57xx port
(on windows, idk on linux)
(and i mean the client, not the server, and its not choiced by game dev)
(and yeha this is off topic)
when i want to but a bot he is aying to me you have to varify your e-mail adress in order to enter a bot to a server somthing like that how i cant find any thing in my email , even how to resend it
What makes you think this is the correct channel
hey can anyone give me some guidance on creating a webhook from top.gg to my bot so it can see when a user has upvoted it
language and library?
javascript, discord.js
have you checked this?
yep. I am still a bit unsure how it all works.
well, install the library and configure it
your dbl token can be found in your bot's edit page
the webhook port depends on how your machine is set up. if you're on a vps without a reverse proxy, using 3000 or 5000 is fine, if you're on glitch/heroku you have to use process.env.PORT, if you have another webserver running such as express, omit the port and pass your server instance to the options instead, if you have a reverse proxy such as nginx, use whatever you configured the nginx proxy to use
the webhookauth password is a password you create. it must match what you put in the authentication field in your bot edit page
the URL field in your bot's edit page also depends on your system's configuration, if its a vps without a reverse proxy, use your.vps.ip.address:port/dblwebhook, if youre on glitch/heroku, use yourprojecturl.glitch/heroku.com/dblwebhook (or whatever is the correct project url)
ok thanks a lot i will try this out now
thank you so much for the support i really appreciate it
i have now got it working so thanks
i have something else also using the port. i am using glitch. is there any way to have both this webhook and the other thing to use the same port?
yes
pass your server instance in the options
then it will use the existing server instead of creating a new one
ah ok ty
Does anyone share a code for my bot that I will create from raid?
Raids are not allowed and can get you banned
I think he means to counteract raids but that english is broken asf also wrong channel
Maybe
@flat comet
Does your bot needs to be approved to use the API?
you dont get an api token until it is so yes
Might explain why I can't update my status and It just throw an error.
I have setup a wehook url but, however I'm not getting any response from the test button and wireshark confirms that nothing is coming in (port is open and firewall is not blocking anything)
nvm maybe I'm just being stupid
I'll ask again if there's still a problem
Alright I do need help
whats your url? where is your bot hosted?
[removed]
is endercrypt.network a domain you own?
do you have a webserver running on that domain?
no, my co developer, he is in a call rn with me
does he have a webserver running on it?
"possibly, but on different ports"
what kind of server? nginx? node? apache?
Wireshark does not get any incoming packages when we press the test button
Custom java based server
When we send a request to that URL using a browser, wireshark is detecting packages, but when we press the test button nothing is happening
hmm
i cant think of anything that could cause this. did you save before pressing test?
I guess I'm too retarded to press a button. I'm sorry for wasting your time heh...
lul it happens
The issue is fixed, that's all that matters 
could I get help with binding a port to to a PM2 docker container. Everywhere i've looked says to use docker run -p but we don't use that when running the container instead we use docker-compose up -d to update and restart the container and within the Dockerfile we use pm2-runtime, I am asking because I am trying to get the upvote post webhook working but the container is bound to IP 0.0.0.0 and doesn't have a port bound to it currently afaik right now.
btw, the bot is being hosted on a VM, and the docker containers are being routed using a nginx container.
if this should be asked in #development feel free to let me know. I wasn't sure if it should be here or that channel.
also no i'm not asking for help with everything. Just a few things to help get my started with this.
@lilac falcon
- dont ping the mods online
- you make a post request to
https://top.gg/api/bots/{BOT_ID}/statswith ```json
{
"server_count": <number>
}
no
you have to hit the request manually
I would recommend using an official library if you have no idea how to hit the request
how can i get the username of the user voted?
Can I get help with youtube database api v3
read the channel topic
I installed dblapi.js and set the token
however it still shows n/a
is it normal
post stats
did you add it to your code?
yes
im a noob so I just installed it and put the code including token
Cannot find module 'dblapi.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/app/server.js:15:13)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
npm i
show your code
One message removed from a suspended account.
Hello, I'm trying to get my bot to work with the API and I cant seem to get it to work, it would help if I just got a rundown of what I need to do in order to get it to work properly. I'm currently running my bot using discord.py.
Are you using dblpy?
Does anyone know why webhooks arent working? It says it will test it within a few seconds but nothing is happening
if its not working, then your configuration is wrong
@sullen nymph Yes I am using dblpy.
Make sure your needed port is open and you're using public IP address
DBLClient has webhook_x kwargs, when you specify webhook_port, the webhook will run
I cant get the webhook to work. Can someone send me an example, because I think im doing something wrong?
Which lib?
dblPY, python
I have it specified
Make sure your needed port is open and you're using public IP address
It is open
Are you sure your webhook is running?
Well when I go to the url from my browser it says Method not allowed
I sent it
Yes
Alright so I'm trying to pull the votes from the website. I created a webhook within Discord and added that to the https://top.gg/bot/:ID/edit page.
I'm using discord.py rewrite
I don't have an idea of what to do next lol
discord webhooks have nothing to do with dbl webhooks
you run the dbl.py module in your code, configure it with as a webserver (give it a port and an auth password)
then in the edit page you put the auth password you configured, and in the url you put whatever address will make dbl find your bot
this can be your.vps.ip.address:port/dblwebhook or your project url if you're using glitch/heroku
basically, dbl sends the webhooks directly to your machine, which is listening to them through a mini-server created by dbl.py
it has nothing to do with discord webhooks
ooo
In the docs it shows async def update_stats(self): """This function runs every 30 minutes to automatically update your server count"""
Do we have to call this first? Or does it start itself?
You call it somewhere in your code
Or set autopost kwarg to True when declaring DBLClient
๐
@sullen nymph where do you see autopost?
Yeah ive noticed that, some things arent there
Yeah I've been going through them for a little while now lol
Anyone having issues with webhooks?
Whats your issue?
that it's not working and so i'd like to compare it with someone who may or may not be having a problem, i know how webhooks work
Have you saved the changes before testing?
jesus
I- lmao he wasn't trying to figure out how to save the page, he was asking if webhooks were being glitchy
lol
lmao
so under the edit page on dbl, for the url, I put your.vps.ip.address:port/dblwebhook?
or is dblwebhook something else?
Depends on what you set webhook_auth to
that's the password right?
Would there be any point in changing it?
Preferences really
Gotcha
Alright so I've got everything setup I believe. Opened the port on my vps and I'm not getting the test from the edit page on TopGG

hey guys, which url i need to check if someone have voted for my bot
have catch it
thanks
I'm trying to use the webhook to detect when someone upvotes my bot. The updated server count works fine and I think I've got everything webhook wise setup correctly. I opened the port on my host and added the test listener but it isn't recognizing the test from the edit page.
Is there something else I need to do for the webhook to work?
I have the same problem; https://glitch.com/edit/#!/noa-discord
What is the problem? All your dbl code is commented out
Also, what did you put in your top.gg edit page?
Console.log q.body
Yoire probably getting it as a string
Add content-type json or json.parse it
Or console.log body itself, and see what youre actually receiving. The payload might not be in body
@eternal sundial and yohr top.gg config?
Did you check the vps control panel for any port opening? Some hosts require that, like google's GCE
Check your hosting company
They might require you to do something in their control panel
Alrighty
req.body
Contains key-value pairs of data submitted in the request body. By default, it is undefined, and is populated when you use body-parsing middleware such as express.json() or express.urlencoded().
Tim I can't find anything
Whats your host?
DigitalOcean
You did this? sudo ufw allow 5000/tcp
@vapid cape
Then idk
Can you try running a small webserver and test if it works?
Im not famliar with python webservers so i cant help you there, but you should find your way
Simple Flask script or straight up copy dblpy's internal code
Dbl webhook libs should have a test that listens to get requests
so you can try it in your browser
Maybe check what response you get if you try to connect to that URL with a browser
@sullen nymph Which part?
You mean the webhook dblpy uses?
for the webserver, I think that's what I'm missing cause if I type vps.id.address:port into my web browser nothing happens
Tried visiting ip:port/dblwebhook?
Does dblpy listen to get requests?
@vapid cape nop, only POST
@eternal sundial a pure poke on the ground but have you tried adding http:// before the ip
@sullen nymph Nothing, well, it says it took too long to respond
Hi
I'm trying to use dblapi.js in my project but i can't run webhookevents
I'm running an express.js server in port 3000 and webhook in port 5000, everything is running fine but when i trying to catch ready event of the package ain't receive anything
Show your code
yep, wait
@eternal sundial 
All code is in init(), hmm i guess that is the error because when i put dbl.webhook.on("ready") out of that function works fine.
@sullen nymph
That's the only code I have in regards to dbl
I think I'm missing the webserver part
@elfin maple glitch only supports port 3000
You can add your existing server to dblapi.js: scroll down to last example https://top.gg/api/docs#jslib
You are running the webhook just fine if when visiting http://ip:port/dblwebhook webhook gices you "Method Not Allowed"
Then wtf lol
Did you save your settings 
I just redid it
Lemme test
So when I hit test
Does it just print in console?
by default yes but I can't access your URL 
Are you sure that cog is loading
Also why are you using autopost AND making a loop for update_stats 
Cause I grabbed the manual example and then you mentioned the autopost here.
lol
So I can delete the whole task?
and the cogs load
Fun, I typed 42 instead of 142
kek
Webhook is working fine, make sure your Authorization values are the same in your code and on top.gg, re-save and test again
Well, if all else fails, just setup your own webserver
I wouldn't even know where to get started lol
Send your webhook URL in my DMs
Hello
HELLO
What should I do at top.gg/api/docs to fix the servers undefined error
@indigo ice The docs page explains what you have to do
No they shouldn't
i'm trying to install dblpy in my venv and it's erroring (https://hastebin.com/oxofowitow.md for logs)
specifically this pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches aiohttp<3.6.0,<3.7.0,>=3.3.0,>=3.6.0
it's trying to install a version <3.6.0 and >=3.6.0
looking at the pipenv graph:
yeah lol i just realized
@sullen nymph yes it did, that did get noted in 1.3.1
I didn't read changelogs soz
Does "query": "?reminderClicked" mean the user just clicked "Remind me"? (Im talking about when a user votes)
it means the user clicked on a vote reminder notification and then voted
Ok cool, thanks!
For discord.py
async def on_dbl_vote(self, data):
how do I get the user that upvoted?
What's the full scope of data?
What's the full scope of
data?
Isn't it explained on that page
Well yeah but that's not how you access dict keys in Python
uh
wait how
data[user]?
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print(f'Received an upvote from {data[user]}')```
make a user a string there and you're good
Add quotation marks
It's a string actually
Yup
user Snowflake ID of the user who voted
Snowflakes are usually saved as strings
Well technically they are unsigned int64 but top.gg sends them as strings and so does Discord /shrug
@commands.Cog.listener()
async def on_dbl_vote(self, data):
userid = int(data[user])
print(f'Received an upvote from {userid}')```
coolio
Im still a bit confused on how to vote-lock commands
@sullen nymph
Have a database, store the user's ID in there and probably timestamp
ok
and on command usage, fetch that data from database and compare current timestamp to saved timestamp
It's an API call which kinda defeats the purpose of webhooks
oh
- it's ratelimited
sometimes it has delays
ratelimiting seems to not be too bad
ah
ok
its for a minor commands
ill use that for now
but im migrating to MySQL soon
so ill keep that in mind
thank you!

CSS
@sullen nymph please elaborate. WHERE do I put the CSS. HOW do I put the CSS?
HTML
<style> tag in long description
so i want to work with discord api ,where can i start i am completely new to discord
i do not want to use an already made api
Which port does dbl send webhook requests to?
and is the documentation outdated cause I'm getting this error when trying to use dbl.webhook.on:
Property 'webhook' does not exist on type 'DBLAPI'.
You need to configure the port in the dbl options
Then it will enable the webhook receiver
Check the webhook examples in the docs
If i type body {
Background-color: black;
}
Will it work or is it only html?
@night creek it'll work
Can anyone let me know why webhooks aren't working for me?
const dbl = new DBL(topGGAPIKey, {
webhookPort: 5000,
webhookAuth: animuAPIKey,
});
what kind of arent working
property webhook is missing?
are you using typescript probably not
How to change long description transparency??
not the right channel for that @hallow dew ask in #development

2 things
- The image is cached, you might want to add a cache breaker
- Your server count is sent once every 30 minutes by default, so unless you change it (not recommended) it will always be up to 30 minutes outdated
When I try to send a GET request to thehttps://top.gg/api/bots/:id/check/?userId=user id here it seems to sometimes give me a 401 error even though I am providing the correct token. I am doing it like this
const did_vote = (await axios.get(`https://top.gg/api/bots/602406235848835073/check/?userId=${user_id}`, { headers: { 'Authorization': 'token here' } }))
it seems to give the 401 most of the time but not always.
Question
I know there's a way to check if a user voted for your bot or not
But is there a way to check if a user spent their vote, or if they haven't voted yet?
In the python lib :)
I mean it's as simple as checking for a false return if they're voted or not..?
@topaz wyvern
?
@topaz wyvern I know that
I would like to know if there's a way to discriminate if they have voted for my bot, another bot, or no bot at all
That's not possible afaik
Why should it matter if they're voted for another bot anyways?
Well, I want to make a vote locked command, BUT give them a different option if they already voted so they wouldn't have to suffer
@topaz wyvern
Wdym already voted?
Let's say a user wants to use a vote locked command, and they have not voted for my bot yet.
I want to make voting their only option if they have not yet used their vote.
I want to do something else if they already spent their vote.
Idk how to make this simpler @topaz wyvern
Spent their vote?
Eh
That is spending a vote
Since when
Since when
lol
I need help with widgets
my widget is not getting updated idk why ๐
it still says 62 guilds but its in 64 guilds and 60 votes but it has 2 votes ๐
feel free to ping me
Widgets are cached
You can add a cache breaker
widgeturl?whatever=somerandomthingthatalwayschangeslikeatimestamp
oo okay thanks
.
dont do that here @cold marlin
const { stringify } = require('querystring');
const { request } = require('https');
const update = () => {
const data = stringify({ server_count: client.guilds.size });
const req = request({
host: 'discordbots.org',
path: `/api/bots/${client.user.id}/stats`,
method: 'POST',
headers: {
'Authorization': 'API TOKEN',
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(data)
}
});
req.write(data);
req.end();
};
client.on('ready', update);
client.on('guildCreate', update);
client.on('guildRemove', update);
added to my bot but still not showing me the server count
Did you even change 'API TOKEN'?
'Authorization': 'API TOKEN',
also there's an easier way to do it...
https://top.gg/api/docs#jslib
@radiant basin
A) you're not being helpful. He obviously wrote that by the looks of it. And hid the token as to not post it here
B) some people prefer not to use a lib.
@restive otter what response do you get
In console
@radiant basin yes i have changed
1|alphaold | message: 'Unknown Webhook',
1|alphaold | path: '/api/v7/webhooks/645531624737603595/G5cMG-WkEJJMYQvOphD1dExbMYNM_QsdkFwOxhjyU?wait=true',
1|alphaold | code: 10015,
1|alphaold | method: 'POST'
1|alphaold | }``` @dapper copper
That's a discord error
means
Saying it can't find the webhook it's posting too
means i am not getting the error on this code
Hi I need help with top.gg widgets
//ps I tried to delete cache!
widgets don't reload idk why ๐
Why is Top.gg showing that my bot is in 2 servers?
When it's in ~90 servers
new DBL(topGGAPIKey, this.client);
Hello. I setup the vote event. And my friend voted for my bot.
But the console didn't log anything.
You can test your webhook with the Test button
Is it correct like this?
Webhook running at http://0.0.0.0:5000/dblwebhook
Or what im missing?
I pressed test and said this may take seconds. No thing else.
I cant really help you with any details, im sure someone else can help
Thanks brother
If I pressed the test button what should i see in the console??
The console only logs that server count posted. But don't log votings
The url is blank in my bot's config
Which url should I give.?
Make a url in discord or what?
in your bot config you need to have the ip of the server where your bot is hosted
should be something like http://123.123.123.123:5000/dblwebhook
I made a webhook in my server and also provided the authentication password. But it loges
Webhook running at http://0.0.0.0:5000/dblwebhook
Error: listen EADDRINUSE: address already in use :::5000
Error while trying hasvoted
port 5000 is already taken
Whats up with this webhook? A website that i can read over on how to set one up and such?
@rustic burrow webhooks are basically a term for post requests that you use for pushing updates/notifications of some sort
can anyone give me a crash course in webhooks
webhooks allow servers to send you requests and data. If you connect a webhook to top.gg sends you vote data including the user id and some other stuff.
i know what they do but i want to know how to set them up
everywhere ive looked just says what they are but not much on how to use them besides some screenshots of javascript
Well, you make a http server that accepts requests and make a handler for whatever it is you're using it for
I personally use node's built in http module and fastify because that's what I know, but I believe express works
i dont know any js
only py
and cant find any guides on making the server and handler part
i want to have it both do votes and manage some paypal donations for me if i can
But I can tell you, generally, how it would work but I wouldnt be able to help with any code because I use js
Shivaco, the maker of dblpy, might be able to help better
i mean general is better than nothing
So my top.gg webhook that I used to use that I made is just an http server waiting (or listening) for requests then when it got one it sent the request to the method I made. dbl sends data as json (I would think that JSON is the most common, but url encoded is a possibility) so first you parse whatever it is that was sent, usually if it's an application/json it's in the body of the request. then you can use the data it sent as normal object or map (idk what python calls it) you'll also want to send a response code so the server knows its request was verified (some websites will send it until it is accepted or until it caps out, like twitch) so you just send a response code (200 is OK, 401 is Unauthorized which I think are the most common) and message if you want. You'll also want to make sure you set some type of authorization code so not just anyone can send a request and it'll be operated on like normal (alternatively you can use a firewall to only accept requests from specific IP's I think*). I think that's a basic run down of generally how you would make your own, I wish it wasn't 1:09 AM or I would answer questions too, but I really need sleep for tomorrow. I suppose if you do have questions you can ask but I'm hopping off regardless, good luck with them though
@lyric vine do you need a webserver for your votes?
so it doesnt run alongside with your bot?
honestly i dont know what i need
Hey when you pass your client to new DBL() like in this example
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);```
Can you only do it if you aren't sharding? My understanding is that each shard would be creating it's own instance of client correct?
i want to have it both do votes and manage some paypal donations for me if i can
@lyric vine Flask or aiohttp.web sound like what you would need
not even sanic








