#topgg-api
1 messages · Page 42 of 1
@humble bison this is why I hated fetch on the client side.
I had to manually check whether or not the response was correct
ow
How do I use Discord Webhooks to see if someone voted?
setup a web server that accepts POST requests
How do i get the guild of a vote user?
vote.user.guild
doesnt work
as user doesnt have .guild
votes aren't tied to guilds
ik
@coarse seal since votes aren't associated with guilds naturally you can't get the guild of a vote
i got
i iterated through every guild the bot is in, iterated through the members in them, compared the id to vote.user.id and then gave rewards
smart huh
it'll give it to the first guild it finds it in
after all economy isn't global
its per-server on my bot
What do you give for voting
You could provide a link to the vote page with the server id as a query parameter
It sends query params in the post request
the votes come from api
don't you need like multipart (or whatever enctype webhooks use) middleware
well the webhook sends the user id who voted and what not in res.body
1 sec and ill make a quick app and test it
however you want to store it :D
sec
@azure pollen ya here?
ew
organized code
what kind of person does that, i just put all my 3k lines of code in 1 file with bad indenting and no commenting
lol
yeah if my code isn't documented i would die
the most organization i have is grouping commands by perms
so like the code for administrator commands are all in the same spot
A manually coded webhook example. (NODE.JS)
const express = require('express');
// creates a new express app
const app = express();
// does the dirty work for us and parses the request body
const bodyParser = require("body-parser");
// the port the express app will run on
const port = 3333;
// the super secret authorization token so nobody can cheat the system
const token = "here is some super secret token!!!!";
// just sets the bodyParser stuff, nothing to worry about
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// these are just examples of the content you may receive!
const EXAMPLE_MESSAGE = {
bot: '00021412412414',
user: '00021412412414',
type: 'test',
query: '?test=data¬RandomNumber=8',
isWeekend: false
};
const EXAMPLE_HEADER = {
'user-agent': 'DBL',
authorization: 'some lit auth token here',
host: 'this.should.be.your.IP:andPORT',
accept: 'application/json',
'content-type': 'application/json',
'content-length': '???',
connection: 'close'
};
// catches a post request with the specified URL
app.post('/webhook/url', (req, res) => {
// put the request body in a variable for use after we respond
const message = req.body;
const headers = req.headers;
// check if the headers exist (good practice) and check if the authorization in the headers match the token we have saved as "token"
if (headers && headers.authorization === token) {
// tells the sender that the webhook sent successfully
res.status(200).send();
// do whatever you want with "message" here
} else {
// tells the sender they are forbidden because their authorization token is incorrect!
res.status(403).send();
// do nothing
}
});
// this starts the express app and begins listening to the port we asked it to
app.listen(port, () => {
console.log("Webhook server is listening on port: " + port);
});
that blur should have something like
324.242.242.242:3333 (the IP and PORT to your webhook catcher)

🤷
i can specify the url
i dont see what wont work about glitch
its just a subdomain
i mean i'm a certified by website administrator great coder so i know what im talking about
nice
glitch is great for small test apps
i'd just hire a server for a couple hours if i was doing a test app
and ok for free "hosting" (aka shit)
yeah
there was this study done
where people analyzed how people react to free vs a couple cents
who could have guessed, its a strong difference to the human mind
so a lot of people aren't prepared to pay 4 cents for a server
lmao
ken
yo
also a lot of people might not even have means to pay because they're like 13
yeah we need more info

rip
express is an http server...
i tried lmao
tried googling
it's probably because there's specific ports you're allowed to use and not allowed to use
or smthing
make another express application
if you want different ports
and if you mean for glitch, then idk just uh like... don't use glitch or something
from what i've heard
i'd bite the bullet and pull together a couple dollars a month
if (server && !(server instanceof Server)) throw Error('The server is not an instance of http.Server');
dblapi.js
meh
ok just run require("http").createServer iirc
i did
and it worked
dbots.webhook.on('ready', hook => {
console.log(`[WEBHOOK] Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});```
why this not firing?
because the webhook isn't ready
yeah but why isn't it?
const dbots = new DBL(process.env.DBL, { webhookAuth: process.env.authToken, webhookServer: server }, client);
is there
should i remove webhookAuth?
as it does check it in app?
you either use the dbl api example
or you use the manually coded example
you don't use both
THATS WHY IT WAS FUCKED up

stilll fucked up
lmao
it doesnt take 5 mins for such a small express app to initilize
well
the server initializes but
the webhook doesnt
fucc
huh
atleast now i know the ip of uptime robot lmao
@restive otter
in the url thingy on dbl
i would out:
does test use your own ip to POST the bot?
@coarse seal no it sends it from dbls server
test button
const message = req.body;
const headers = req.headers;
console.log(message + '\n\n' + headers)
for the request from DBL
Output:
meh, why is it empty?
Cause its an object, inspect it
Kek
help pls
@arctic arch
IncomingMessage.res.on (/rbd/pnpm-volume/c841a381-532c-47ce-b09f-dd3a3ad13c6d/node_modules/.registry.npmjs.org/dblapi.js/2.2.0/node_modules/dblapi.js/src/index.js:115:25)
...?
dblapi.js/src/index.js
that doesnt tell anything
Error: 403 Forbidden
(node:8736) UnhandledPromiseRejectionWarning: Error: 403 Forbidden
at IncomingMessage.res.on (/rbd/pnpm-volume/c841a381-532c-47ce-b09f-dd3a3ad13c6d/node_modules/.registry.npmjs.org/dblapi.js/2.2.0/node_modules/dblapi.js/src/index.js:115:25)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:139:11)
at process._tickCallback (internal/process/next_tick.js:181:9)
(node:8736) 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)
(node:8736) [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.
so your token is wrong
what function are you calling
So I have this
const DBL = require("dblapi.js");
const dbl = new DBL('token', {webhookPort: 5000, webhookAuth: 'password'}, bot); // "bot" is just the Discord.js Client
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`Vote registered - User: ${bot.users.get(vote.user).tag}`)
});
And I have no idea what to put in these two boxes, or what to put where 'password' is, I've tried a few things and read the entirety of the API section on the website and the "vote" event never seems to trigger.
url prints in console
password in the code
still has no clue what the url or authorization areon the page
classic dbl 
ok thats it for today folks im off to bed
Thanks...?
@restive otter the url is the IP or domain with the port and path, dblapi.js should log it to the console but if it says 0.0.0.0 you need to change that to the domain/IP
And the authorization is whatever you set as webhookAuth in the code
That's what I thought - Thanks for the help
Damn..
the webhook api worked fine
till a few weeks ago..
no requests are coming in from the site either
even test fails
Help?
I havent changed anything either..
Webhooks work for me
^
the router can assign u a different one
Wait, you have to replace 0.0.0.0 to your IP?
I wish I knew that earlier
0.0.0.0 is a special IP address signifying all open network interfaces or some shit like that
so yeah don't use that in your webhooks
0.0.0.0 is localhost?
0.0.0.0 is used to bind to all local interfaces
eg you have x.y.z.1 and z.y.z.2 ips
0.0.0.0 would bind to both
@arctic arch Hey, how is the ratelimit on the DBL API implemented? It says 60/m, but is it 1/s, or like it's total in a minute
Alright, thanks
how to put a background image?
@glass wyvern you need to be certified
oohh, okey, What do you need to get certified? @restive otter
ahh, all right, thanks
@restive otter
np
Im using dblapi.js, and cant get any requests to come through to my code at all (all that fires is the ready function). I tried many things, even like above changing the hostname to my Ip but still cant get the vote function to fire. Any Ideas?
const DBL = require('dblapi.js');
const dbl = new DBL(dbltoken, { webhookPort: 5000, webhookAuth: 'passpass', webhookPath: '/test' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`--- VOTE ---`);
});
dbl.webhook.on('test', test => {
console.log(`--- TEST ---`);
});
with that port + path
it'd be http://your.ip:5000/test or https://your.ip:5000/test if you have SSL configured
yea thas what I have, and nothing happens when I vote, or test
Hmm..I just thought of an idea:
dblapi.js should be in the form of an express middleware
it would integrate so much better with express-based http frameworks
you literally do
const dl = require('dblapi.js');
const dbl = new dl(token);
const app = require('express')():
app.use(dbl())```
and boom, your route is configured
so uhm... hey everyone! I've been wrapping my head around this for a few minutes now. My test button does absolutely nothing, I can successfully make http posts to my webserver, but putting the url and hitting test just doesn't do anything. I even created a url on https://webhook.site to see if the test button sends anything, but didn't work. Any one can shed some light? I'm using flask and python to catch the http posts
When placing the IP into the URL for the webhook, is it public Ip, or local Ip?
public
It does not seem to respond to anything but the ready event. Is there anything I'm missing?
const DBL = require('dblapi.js');
const dbl = new DBL(dbltoken, { webhookPort: 5000, webhookAuth: 'passpass', webhookPath: '/test' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://(my public ip):5000/test`);
});
dbl.webhook.on('vote', vote => {
console.log(`--- VOTE ---`);
console.log(vote)
});
dbl.webhook.on('test', test => {
console.log(`--- TEST ---`);
console.log(test)
});
@indigo trout have you tried the test thing
@shut ibex the router ITSELF assigned a new ip
not the device where my webhooks are coming in
Cuz that ones static
but ig router isnt
how can you even get a token
on ur bot's edit page at the webhook section @restive otter
Yeah i got it
Thank you
np
@humble bison yea I have voted on it, pressed the test, no response
Also sorry, I was sleeping
Wat
Wut, I didn’t mention you
@indigo trout U did
and wym no response?
So I hit test, nothin, I hit vote on my own, nothing responds in the codes end. The webhook only responds to the ready event and that’s all
Lol
@indigo trout Where do u host ur bot (where the webhook is supposed to send to) on?
pc? vps?
You need to get the router's IP
so like 0.0.0.0:FORWARDED PORT/dblwebhook for it to work if its hosted inside ur house
on a vps idk
Heyo, I'm having this issue.
I regenerated the token several time
and copy pasted the code of the documentation
I set the asyncio.sleep at 10sec for testing purposes
@restive otter I’ll try that. Thanks for the help!
@marble urchin Does that happen when the bot is starting?
Wrong DBL token, it seems
is the token for the same bot
Yeah
Well here is the situation
I have 2 bots
and the one i'm having issues with
is destined to replace the old one
I stopped using DBL with the old bot
so it should work
since I removed the code part for DBL
on the old bot
Yeah ok
But then
why do I have this
(sorry for paint mouse skills tho)
how do I do this ?
teach me senpai
As you can see here. I added the wait_until_ready()
and still having the error
@sudden rampart
Why do people use dblpy at all? Using aiohttp manually is better 🤔
L a z i n e s s
at this point I think i'm going to do it the old way
coding a python package is nice. It's better if it's working
And now It works
thanks for the help
For webhooks, do you need a custom router forwarded port, or can you use like port 80?
Can you have two bots use the same IP and port for their individual votes?
@indigo trout I'm pretty sure as long as the port is forwarded in your router, you can use any port you like. However 80 is a common port used for things like Http so unless you're really not using it setting it to port 80 might be a bad idea
What can you do with the API except updating your bot's guilds count ?
take a look at the docs and see for yourself
@distant dove updating shard count, if the bot uses shards, and seeing who's voted for your bot - but as Deivedux said, you should check out the API page: https://discordbots.org/api/docs
did webhooks break again or did something change?
altough it might be me switching from apache to nginx
idk
yhe I forgot I was using apache_request_headers
What are shards?
@opal hollow wrong channel, #development 
ok
Umm...
This doesn't respond to both ready and vote events.
Although, When I use the TEST button.
Did you try reloading
yes i have
still doesnt work ;/
am i doing something wrong?
i can press the save button
but not the test
shows nothing after i clicked the test button
@azure pollen can u help me?
have you looked at the pinnged messages and made sure it's coded right
yes i have
most likely a problem with your code and not with the test button itself
do i have to put exactly as EXAMPLE_HEADERS?
oops srry
im still confused on y its not working
what happens if ur hosting on glitch? what do i need to put for host? @azure pollen
AHH
http://project-name.glitch.me/webhook and use port 3000
glitch host?
i got
Cannot GET /
mmhm
🤔
because there is no get routes
which means?
you need to do a post request to the correct path
are u out of ur fuckin mind?

@restive otter ummm....
No, my mind is in body.
How to get an API token ?
@coarse seal don't mention admins
how do I run it @mystic wing With like node index.js
it will startup when you run the file
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});``` ok so I have this running but every time someone votes nothing pops up
You probably arn't running the webhook properly
var sender = message.author.id;
dbl.hasVoted(sender).then(voted => {
if (voted) return message.channel.send("Thou has perks (coming soon near you)");
else return message.channel.send("Thou is not worthy of such perks. Vote here to get perks: http://bit.ly/vote_botty");
});
}```
I also have that
and it works perfectly
@latent sparrow did you set the webhook info in ur bots edit page
@solid owl this is for questions about the DBL API as it says in the channel topic, for bot development questions go to #development
sry
For some reason people say they voted but my bot didnt say anything about them voting
@last cedar same with me
why i can't click that two buttons
cuz ur browser sucks?
No but srsly it depends what browser u use lol
the code behind the button isn't supported on every browser
Funny enough I can't click either of those on chrome
Works for me in chrome
Lol
Okie dokie, so I have a thing set up in Nerdcore Radio, that checks for the vote of a message sender(JavaScript library on discord.js), and it returns a 401 Unauthorized error. I have regenerated the API token of the bot and saved it too, but it seems like I keep getting the same error. I'll share some of the code here.
const yt = require('ytdl-core');
const stripIndents = require('common-tags').stripIndents;
const DBL = require('dblapi.js');
const utils = require('../utils');
const dbl = new DBL(process.env.DBL_TOKEN);
dbl.hasVoted(message.author.id).then(voted => {
if(voted === false) {
message.channel.send({
embed: utils.embed(`Error!`, `You didn't unlock this radio! Please [vote for the bot](URL) to unlock this radio!`, [], {
color: "#ff0000"
})
});
} else {
// Do Stuff
}
}
Any idea how this is possible?
Oh?
try console.log(process.env.DBL_TOKEN)
Sure, hold on.
does dblapi.js take in client also?
thats for autoposting
ah okay
its optional
The bot says undefined, yet the console logs it perfectly fine.
It also seems like the bot only does this in the command file itself, instead of everywhere, because server count and such are posted to the DBL without any trouble.
are you using the latest version of dblapi.js?
Oof, I gotta check, hold on.
Yep, latest version is installed.
OH WAIT--
It works now!
oof
console.log doesnt have a return value
so ofc it will log to console but eval will return undefined
most likely wrong token
Can somebody tell me how can I prevent users getting multiple perks after voting?
like doing to vote command multiple times and get multiple perks
That's your own problem.
boi
just get the channel u want a message to be sent to
and put that in the vote event
Can someone tell me the .hasVoted thing test if the person has voted for the bot past 12 hours or 24 hours?
read the docs
ok then
@restive otter iirc it's actually 12 hours and the docs are wrong
But an admin needs to confirm that
Yea i guess the docs havent been updated yet
cuz since they announced the 12h voting it was changed in the hasVoted too
How can I get on vote function that will post who voted for bot in Python?
Anyone know why my bot can't mention everyone? bot.channels.get("***INSERTCHANNELID****").send(" This is a test to see if I can announce @everyone ")
I'm using discord.js and I cant seem to find anything about this issue.. They say you just type @everyone for it to work
Also I've checked permissions on the server and they are all set properly 🤔
yup didn't see I had disableEveryone set to true on my client options 🤦
you can just do <@guildId>
Post your server count to our API. How do you do that?
read the api documentation
I've read http://www.thereal.tk/e7zz1.png so??
Ah ok ty.
np
fix your GET apis for those of us who dont use webhooks
😡 😡 😡 😡 😡 😡
@restive otter its in api docs and your bot's edit page
@terse nebula what's the issue
Thanks
How long does .hasVoted take to update the fact that someone has voted
ping me if u have the answer n ill see when i get back
@restive otter probably instant but it only checks the last 12 hours
in the api is there something that has a timestamp for every person?
yes
ok
fellas, is it just me or are vanity and legacy no longer returned in a /bots/id call?
Hm I'll validate
i dont see it so im wondering
yeah idk who's maintaining the api atm
api docs are really outdated rn
ye
lol
dang epic bot ok back to the nitty gritty does discriminator not show # anymore?
cuz u are
yes u just noticed
yeah I love this theme
sorry its hard for me to notice cancer when i see it

wait did you make dbl go?
i thought u were referring to vscode when u said this lol
I made go-dbl
its unofficial
but there really out here being one already
I requested a replacement of dblgo, but I haven't gotten a response yet
turtlegamingftw made the official dblgo
i requested my beautiful library to be added and they responded to my initial email but not my 2nd one
didn tthey not respond to ur first one
to be fair it was 5:13 am when they responded
the official dbl go lib atm is unmaintained and exits fatally
there's 2
ooof
how long was Go library existed?
@shut ibex 
what
Yeah I've talked to him
yes how long was it existed
Fishy!Today at 7:12 PM
the official dbl go lib atm is unmaintained and exits fatally
3 months ago?
thought that said exists
it existed for 4 months and was added 1 couple days ago
I stopped maintaining it because they never added it to the site
so
¯_(ツ)_/¯
shouldn't tools be renamed libraries
oof
they did 4 months late
r u gonna fix it?
and the actual API doc is outdated
inb4 library merge
oof
and fishys will take over
is that y u lost the pink role
me and fishy talked about this
and cert
rip cert
dont even get me started about cert
I doubt my will even be imported for another couple months

My lib was created in need of my bot
1 result = 1 star on my library repo
ok
is there anyway of finding out everyone who has voted for ur bot?
(ping me if you know)
@urban pawn you can either use \/ or webhooks
ok ty
im making a request to get the votes on my bot is the header like this Authorization:{api token}
yes
wdym
im getting sent
because youre the only voter (i think)
I can decipher that token
Someone has an better example of Webhooks?
what example are you trying now
is there an alt to the dblgo lib? or is it still maintained
^ that
thx, any reason why the official one is not being updated
Yep, the dev waited 4 months and it never got marked as official until a few days ago, so he abandoned it, and fishy (rumblefrog) made his own, so they're working together to replace the old, dead one with that new one
sounds good, it's just that the official one randomly quits my bot
may I know who's in charge of maintaining the api libraries
it's various people
it's scary that no issue exist on that repo regarding that problem and it's been approved as an official lib
well as i said, it was fine 4 months ago when he applied for it to be official
I think it's mainly the percentage of the devs that uses golang at all, and I don't think any admin is familiar with it
I've talked to Tonkku about it, just matter of time now.
well i hope @arctic arch will fix this before another bot randomly quits, i thought it was my code's issue
i'll go fix my code now, thx guys
@arctic arch log.Fatal quits the process
^
it's similar to process.exit() in js
it's ok, you'll learn eventually
my room is my office so
yo how do I add so it shows how many servers the bot is on
like on the web
What language are you using?
JS
ty
How can i send server count to api?
Please don't invisible ping me
Use an official DBL library for your language if there's one, otherwise do manual HTTP requests
Can I get help on using the api on upvote and then rewarding the upvoter after?
const fetch = require('node-fetch');
fetch(`https://discordbots.org/api/bots/YourBotID/stats`, {
method: 'POST',
body: JSON.stringify({ 'server_count': guilds?, 'shard_count': shards? }),
headers: { 'Content-Type': 'application/json', 'Authorization': urQtToken }
}).catch(console.error);
here is an example using nodefetch
I feel like I need to point out the obvious
that has to be in an async function
or if you prefer superagent for readability
const req = require('superagent');
(async () => {
await req
.post(`https://discordbots.org/api/bots/YOUR_BOT_ID/stats`)
.set('Authorization', 'YOUR_TOKEN')
.send({ 'server_count': GUILDS, 'shard_count': SHARDS})
.catch(e => console.error(e));
})()
thought they would know that, but anyways, changed it™
hello
@chrome canyon Lol. is that even how you call an anonymous function
yeah. its not
if you're going to write an anonymous function like that, you have to wrap it in () and actually call it
People copy paste that and expect it to work. lol
Please, spoonfeed me more code
fetch engines?
You mean http clients? lol
axios all the way.
oh, why?
hmmm I decided for superagent because of speed
and because I like the api
http.request GET request x 14,176 ops/sec ±7.08% (64 runs sampled)
http.request POST request x 17,465 ops/sec ±9.97% (68 runs sampled)
superagent GET request x 7,778 ops/sec ±11.02% (58 runs sampled)
superagent POST request x 9,754 ops/sec ±8.94% (72 runs sampled)
snekfetch GET request x 6,656 ops/sec ±10.64% (60 runs sampled)
snekfetch POST request x 6,274 ops/sec ±7.05% (63 runs sampled)
node-fetch GET request x 5,327 ops/sec ±13.20% (60 runs sampled)
node-fetch POST request x 4,960 ops/sec ±11.07% (55 runs sampled)
axios GET request x 3,307 ops/sec ±12.19% (65 runs sampled)
axios POST request x 3,483 ops/sec ±11.82% (64 runs sampled)
Request GET request x 2,784 ops/sec ±7.77% (58 runs sampled)
Request POST request x 4,103 ops/sec ±16.06% (67 runs sampled)
got GET request x 2,223 ops/sec ±4.62% (70 runs sampled)
got POST request x 2,509 ops/sec ±3.51% (74 runs sampled)
this my last bench
and well
yeah.
Hmm, these numbers are good and all, but I can't say that they make enough of a difference for me to care much
if I really cared about speed, I'd use http.request
you wouldn't
that's a pain in the ass
but thing is
axios and superagent have a similar api
but it's a third of the delay
does superagent reject on non-200 error codes?
does the api supports voting?
why wouldnt it
idk 'cause I never used it.
support voting?
this I mean, like I want to put a command for my bot so that any user can just vote inside discord.
That's not possible afaik
impossible
oh thanks for letting me know.
Np
does the api supports typescript?
@jade pebble you can use an api in any language if there is a way to make a http request
you have to make your own webhook server
damn.
You can make ur own webhook server and trigger the discord webhook your self
how? I'm lazy right now.
Set up an http server, with a route that accepts POST requests
handle the response as you wish
lol, that's it?
yes
It's simple really
What is the "bot" passed into the _init_ meant to be? Is it a user object of the bot?
An instance of a discord.py Bot or Client object
So a discord.Client object will do?
Alright, thanks
okay so I recently added so that it shows servers on the website
but it only shows if I click view.
does it take time to show outside of that or?
wdym
Nvm I got it
@last cedar can you explain?
like if someone upvoted
u get their username
not the id
also u dont ping him using @
U get their id lmao
not username
But if u want to get their username then just call client.users.get('the id') then get their username
guys, I need help with webhooks
I have this code
const express = require('express');
const http = require('http');
const app = express();
const server = http.createServer(app);
const DBL = require('dblapi.js');
const dbl = new DBL(`Bot token here`, { webhookAuth: 'my password here' ,webhookServer: server});
dbl.webhook.on('ready', hook => {
console.log(`Succes, webbhook running on http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
app.get('/', (req, res) => {
res.sendStatus(200);
});
server.listen(5000, () => {
console.log('Listening');
});
I just don't know what to put in the webhook hurl in the dbl bot page
url*
where do u host ur bot on
on a vps in digitalocean
then get that vps's IP, (make sure port 5000 is open)
http://
ok np
hmmm not working
maybe I'm missing something
is enough with that code and having the ip and port or I must do something more
ah wait
I have wrong token in config


look at the api docs
Dw man, got it working, just a typo in the link
i get 403 forbidden when attempting to get/check votes https://discordbots.org/api/bots/510114241307607051/votes (this isnt my bot btw this is just a bot with less than 1000 votes to see what "simple user" means)
getting just the bot works fine tho
only the owner of the bot can get the votes
o.... how is that authorized?
or i should check
found it
thx mighty tonku, ur rust bindings be dun soon
Thanks!
how come some of the api is snake case, like bot stats, while the rest is camelcase
Any example on how to use webhooks in Python?
How can i create embeds like this?
if you're using discord.js
i'm using JDa Java
What is a discord bot server
Without a bot commands channel
what is u blind
Hey don't blame me if I didn't see it

don't blame us if we blame you.
Okay thats enough
what does posted mean?
when it posts server count
Any example on how to use webhooks in Python?
@mighty glacier you'll need to set up a webserver to receive post requests
and you can make a web server using python. other options are php, nodejs, ruby on rails, etc.
But python http servers suck
Idk how, still new at coding 😕
and python web server tutorial would be fine
you just need to listen for a post request, nothing difficult
It would be much easier if the Dbl could post through discord webhooks
I'm not gonna try to make web server
can i use dbl.webhook.emit("vote", message.author);
to make an fake vote event ?
well, yes
thanks
@arctic arch why cant we use discord webhooks tbh?
All you'd have to do is send the correct payload to the discord webhook endpoint
thats not the purpose
I'm not sure I understand
The webhooks are supposed to notify when a user has voted for the bot
Giving people the option to send to a discord channel may be just enough for most
just catch the webhook and send the user a DM
or better yet, send it to a channel yourself
it's so you can retrieve the data from the upvote and reward accordingly
🇹🇷
🇦🇿
🥚
Neii
@alpine fox @sly pivot those emotes do not belong here and do not contribute to the conversation, please refrain
Why
because those emotes do not belong here and do not contribute to the conversation
Does the votes reset every month?
Monthly votes reset but all-time votes don't, in the API points is all time and monthlyPoints is monthly
https://i.imgur.com/7DvUU6G.png
Shit code, I did it for testing ONLY, but can anyone explain why in the right mind it doesn't get user on webhook request? It's hitting the URL when the vote is done, but NO get or post is given by DiscordBots..
DBL webhook posts a url
Well yeah.. hence my code lol..
@surreal barn what do you mean it's hitting the URL but there's no post 🤔
@plain timber as in I can see its calling my url as it inserts into the DB but all post data ie the user id is not coming in
maybe you should log the data
@restive otter webhooks aren't specifically for telling you someone voted
Yes I know that.
they're designed to let you know so you can do that, as well as/or reward users and such
then supporting discord webhooks is dumb
personally
this isn't anything new though
I see a lot of people here who don't even reward users, they just want to send a message to a channel
then they can do that via their bot
if I support discord webhooks, lots of newbies are likely to never figure out what the webhooks are really for
newbies seem to be intimidated by HTTP servers 🤷
that's true but it's a learning opportunity
dblapi.js does most of the work for you, I hope other libs do something similar
Oh, you're right
Then why do so many people complain 
Its mainly the js guys
now it seems like laziness on their part
newbies seem to be intimidated by HTTP servers
rightly so
i bet 95% of users are setting their servers up insecurely
ew what
also
its doesnt really matter if your discord bot gets rekt by an insecure setup no harm is done and best case ppl will learn something
can someone give me a example of like a webhook where when you vote it sends a message
because im confused on how to do it
What lang
javscript
javascript*
node.js
no.
sorry ill look up a video on all of this
im %100 new to webhooks :b
never mind i dont know how to use webhooks its confusing

@tepid garden https://discordbots.org/api/docs#jslib
can someone help with setting up reaction role
im constantly getting an error on the fetched message
@kindred ocean go to the reaction role server
Oh the owner is here lol

i been at this for hours
Fishy u can send the link
thank you
🤷🏾♂️
did you read #6 
funky fresh pc

to set up the console.log when someone votes do i set it up like this (it also has the post servers in it)```
const DBL = require("dblapi.js");
const dbl = new DBL('token', { webhookPort: 5000, webhookAuth: 'pass' }, bot);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(Oops! ${e});
})
dbl.webhook.on('ready', hook => {
console.log(Webhook running at http://${hook.hostname}:${hook.port}${hook.path});
});
dbl.webhook.on('vote', vote => {
console.log(User with ID ${vote.user} just voted!);
});
?
looks correct
its not saying when someone votes or when i test it
have you configured your webhook correctly on the website
if you're running locally, are ports open
dont you go into the bot and set up the webhooks then gen a token
the post server count is working
just not the votes
server count:
You send a request to our server
Your bot -- HTTP Request --> DBL server
webhooks:
We send a request to a server your bot (dblapi.js) is hosting
Your bot <-- HTTP Request -- DBL server
If you haven't configured your webhooks correctly on the edit page, the webhook request arrow doesn't know where to go
Your bot? ?----|
Your bot? ?----| --- DBL server
Your bot? ?----|
If you don't have the required port open, the webhook request arrow gets cut off before it reaches your bot
Your bot |---- DBL server
how do i get it open
I assume you are self hosting it on your computer?
in that case you're gonna have to check your router's model and search google for how to do it
this step is mostly unnecessary if you're hosting on a VPS
if i put a url param on the vote url, will the webhook provide it?
aka if i put ?ref=674 on /bot/:id/vote, will the webhook provide it to me or not
@humble bison well there's a query key in the post body so I assume so
alright, thanks
My bot is now failing to post server count to DBL.
Any error?
ok
it would be nice if the dbl python module had a http vote thing
Tonkku thought all the libs support webhooks but afaik only the js one does
I'll add one to the the go lib
TBH we should have webhook examples form more languages
It would be best if support is added to the libs tho
@plain timber I said I hope other libs will add support smh
webhook is available in go-dbl now
@arctic arch it sounded like "I hope other libs already do" instead of "I hope other libs will do"
how dare you tonku why does this matter
<DBL>.getVotes() sometimes returns the votes for my other bots, other than the one who’s token is in the constructor. Is there any way to fix this server side? Or would receiving webhooks be the only way
ae you sure it's using the right token
Yes, because it returns the correct bot’s data initially, then when I run the command again a few seconds later the data changes
are you hotswapping tokens
I’m not sure what that is
You can see it here when it randomly switches from 5 votes to 11 votes found in the same interval loop
I’ve even tried changing the token but it still sends another bot’s data
You do know you don't need to do dbl = this.dbl right?
I was just using it for the interval example
Hi, I would like to add a bot, but I'm kinda new to this. Can someone please help me?
Okay, I will try that. Thanks
@lyric coyote just to make sure, you made a bot and want to add it to the website?
or you want to add someone else's bot to your server
I was looking to add a dice roll bot
to your server?
Yeah
oh
Yeah, I am trying to set up an rp server
also go to #general or #memes-and-media
Thank you so much
yw
For the Python DBL API, is there a way to track if the user has voted.
If so can an example be provided xD
Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}
Traceback (most recent call last):
File "/home/uniquebot/cogs/discordapi.py", line 25, in update_stats
await self.dblpy.post_server_count()
File "/usr/local/lib/python3.5/dist-packages/dbl/client.py", line 100, in post_server_count
await self.http.post_server_count(self.bot_id, self.guild_count(), shard_count, shard_no)
File "/usr/local/lib/python3.5/dist-packages/dbl/http.py", line 189, in post_server_count
await self.request('POST', '{}/bots/{}/stats'.format(self.BASE, bot_id), json=payload)
File "/usr/local/lib/python3.5/dist-packages/dbl/http.py", line 160, in request
raise Forbidden(resp, data)
dbl.errors.Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}
what this
saying something about forbidden on
line 25 what is : await self.dblpy.post_server_count()
code? @restive otter
import dbl
import discord
from discord.ext import commands
import aiohttp
import asyncio
import logging
class DiscordBotsOrgAPI:
"""Handles interactions with the discordbots.org API"""
def __init__(self, bot):
self.bot = bot
self.token = 'token here' # set this to your DBL token
self.dblpy = dbl.Client(self.bot, self.token)
self.bot.loop.create_task(self.update_stats())
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count"""
while True:
logger.info('attempting to post server count')
try:
await self.dblpy.post_server_count()
logger.info('posted server count ({})'.format(len(self.bot.guilds)))
except Exception as e:
logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
await asyncio.sleep(1800)
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(DiscordBotsOrgAPI(bot))
just updating to python 3.5.3
The error is here > "await self.dblpy.post_server_count()"
And it looks like it can't connect
Because the website responds with 403
weird
weird
should the dbl files be installed there
wait it shows that error but it works lol
this is why I don't use libs
- they aren't always error-free
- they must always be up to date by their creator
do you lurk here or something

hey can someone help me with the servers count in the page?
im trying since 1 day but nothing happens
no error no result
Which lib
dsicord.js
Oh welp, I'll pass
:/
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL(`My token`
, client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
whats wrong? 🤔
Either token being wrong
are you even posting server count is the question, or are you just waiting until it will be magically posted
or you putting a bot one instead of DBL one
If you pass Client into DBL params, it will autopost every 30 mins
that's dbl lib?
Look at my first 2 messages
which ones
nice
Failed to post server count
Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}
Traceback (most recent call last):
File "/home/uniquebot/cogs/discordapi.py", line 25, in update_stats
await self.dblpy.post_server_count()
File "/usr/local/lib/python3.5/site-packages/dbl/client.py", line 100, in post_server_count
await self.http.post_server_count(self.bot_id, self.guild_count(), shard_count, shard_no)
File "/usr/local/lib/python3.5/site-packages/dbl/http.py", line 189, in post_server_count
await self.request('POST', '{}/bots/{}/stats'.format(self.BASE, bot_id), json=payload)
File "/usr/local/lib/python3.5/site-packages/dbl/http.py", line 160, in request
raise Forbidden(resp, data)
dbl.errors.Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}
so i tested it and the error seems to still be there every time it updates the counter idk what it is but it works but the error is still there
i see it says 403 error but that ant on my end ive tried everything
403 would happen when the ID doesn't match with the token
but what is weird tho i see that but it works just fine like it updates the server count but it gives that error what i would of thort it would not work but it does
