#topgg-api
1 messages Β· Page 26 of 1
still didnt fix it
hmm
OH
I see
You should be declaring variables in the init function
but put self. before them
so dbltoken = should become self.dbltoken =
then put self. before every time one of those variables is used
self is not defined
then you aren't writing the code in the class
I said write it in the init function
which is in the class
your code looks very normal to me, so the only problem I see is indentation error, if you have defined a class it's better to keep every event and command in that class
I thought someone was making a bot in lua for a second
he has to declare the variables in the init function
not just somewhere random in the class
hmm
well I have mine defined in on_ready event, where I'm doing that API call loop, try my way if that will work
or define the variables in the init function, which is much easier
oh wait, you are using the dbl library?
he is not
then I don't think defining it in init fuction will do anything
I can show you my code how I did it, if that helps
@tidal burrow if you define a variable in the init function, it's available throughout your entire class
if you just put it somewhere random, it doesn't work
it isn't lib-specific
that's just how classes work
@tidal burrow yes i want to switch to the dbl library side xd
@bot.event
async def on_ready():
print('Logged in as: ' + str(bot.user.name))
print('Bot ID: ' + str(bot.user.id))
print('------------------------')
await bot.change_presence(game = discord.Game(name = '-help'))
dbltoken = 'not_for_your_eyes.baka'
headers = {'Authorization' : dbltoken}
while True:
urlbot = 'https://discordbots.org/api/bots/' + str(bot.user.id) + '/stats'
payload = {'server_count': len(bot.guilds)}
async with aiohttp.ClientSession() as session:
async with session.post(urlbot, data = payload, headers = headers) as r:
if r.status == 200:
pass
await session.close()
await asyncio.sleep(30)
that's how I did it
I'm doing it as a background task tho
calling the API every 30 seconds
and btw, I'm not using the dbl lib as well
this this aiohttp
Hey, i've been looking around on the profiles of well-known bots (such as @echo surge) and i'm wondering what "shards" are.
they're a way to split your connections to the discord gateway
to lower the load on discord's end
and allow you to split your bot in multiple processes or even machines
ahhhhh, OK....wayyyyy beyond me for now....anyway thanks for explaining it to me π
What problem are you running into
tbh just too lazy to use webhooks and ya know, spammy command usage

you mean 120/minute?
""raising"" to 120 seconds would make it 30/minute instead of 60/minute
I meant minute, but I meant 120/minute yes
that's too much lol
:feelslazyman:
you can pull upvoters/post stats on an interval
so spammy command usage wouldn't affect it
gonna add something like that to the js module at some point unless someone wants to do that and PR lol
i just block requests until ratelimit is done on mine
also ratelimit handling needs to be made
How do I get this to work for the bot? (python) I just get the error urllib.error.URLError: <urlopen error [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:777)>
votes = "https://discordbots.org/api/bots/386333909362933772/votes?onlyids=false?days=0"
with urllib.request.urlopen(votes) as response:
html = response.read()
print(html)```
are you on rewrite or async?
async
but anyway is better if you do requests with aiohttp lib because urllib is not async
ok
pip install aiohttp
https://aiohttp.readthedocs.io/en/stable/
bad idea, because it locks up your bot (urllib)
oh ok
you have an example here: https://aiohttp.readthedocs.io/en/stable/client_quickstart.html
so is py r = yield from aiohttp.request('get', 'https://discordbots.org/api/bots/386333909362933772/votes?onlyids=false&days=1')
supposed to work or am i doing it wrong?
oh its py async with aiohttp.ClientSession() as session: async with session.get('https://discordbots.org/api/bots/386333909362933772/votes?onlyids=false&days=1') as resp: print(resp.status) print(await resp.text())
k
Now i get aiohttp.client_exceptions.ClientConnectorSSLError: Cannot connect to host discordbots.org:443 ssl:True [[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:777)]
and the library supports parameters sooo:
async with aiohttp.ClientSession() as session:
async with session.get('https://discordbots.org/api/bots/386333909362933772/votes', params={
"onlyids": "false",
"days": 1
}) as resp:
print(resp.status)
print(await resp.text())
huh that's interesting are you on linux?
maybe is your ssl or openssl lib outdated
isn't it because I need to sign in to get the users?
no and you should have an Authorization header
oh
read the docs pls
these docs have like literally nothing and i put py headers = {"Authorization" : 'mytoken'} at the beginning of my code but i get the exact same error
so... where do i use it?
oh ok
url = 'http://example.com/image'
payload = b'GIF89a\x01\x00\x01\x00\x00\xff\x00,\x00\x00'
b'\x00\x00\x01\x00\x01\x00\x00\x02\x00;'
headers = {'content-type': 'image/gif'}
await session.post(url,
data=payload,
headers=headers)```
Can I reget ratelimited if I pull/get if someone has upvoted too many times?
yes
:/
use an existing lib because they have examples that wont get you ratelimited
So, if a command that checks if the person has voted everytime they use it, and they use it 61 times in a minute. I will get ratelimited?
basically post every Xtime
uh.. i dont think there are ratelimits for that but you should store it in dbs with webhooks
I want to keep things simple. So would I get ratelimited if I did that?
Quote: So, if a command that checks if the person has voted everytime they use it, and they use it 61 times in a minute. I will get ratelimited?
yes
well, they can't use it 61 times in a minute
oh nvm
they'd need 2 people
yeah
youd get blocked for an hour if it happens
2 people could ratelimit it
or 61 people requesting at once
:/
use webhooks and store in database
The only thing is that if your bot is down when a webhook would be sent, it'd be pretty riperoni
Maybe also do a once in 24 hour rest call to double check
mine's been running basically non-stop since webhooks were added
did one or two updates
but those take ~10s
Last Month I had the 400 Bad Request when trying to post my Server Count
1 Month later of not doing it, it still says it.
show code
I use this
https://www.npmjs.com/package/dblposter
DBLPoster.bind(bot);
we don't support unofficial libraries
any what?
official libraries
And I can't access the website until I fix my Modem
what
There's an issue with Telstra, where some website become unaccessable and I have to turn off my Modem for 2-3mins to reset the IP
is there an endpoint for retrieving the number of servers for a bot?
yes
no
i mean this is human communicating
can we change the rl to 3600 per hour because im lazy and 60 per min then 1h block is hard to code /s
Anyone have a cleverbot code?
@slim cradle "THIS CHANNEL IS ONLY FOR SUGGESTIONS/HELP/BUGS TO DO WITH OFFICIAL API LIBRARIES AND API DOCS FOUND AT https://discordbots.org/api/docs "
@golden wind I still get a 403: Forbidden error when using the example from https://discordbots.org/api/docs#pylib
do u need my code? π€
is this a bug from your API side?
my bot says it is in 45 servers
but your site says 42

did you post stats
it does it every 30 seconds
you can see for yourself, the -stats will show it's current server count, but the page will show otherwise
dbltoken = 'not_for_your_eyes'
headers = {'Authorization' : dbltoken}
while True:
urlbot = 'https://discordbots.org/api/bots/' + str(bot.user.id) + '/stats'
payload = {'server_count': len(bot.guilds)}
async with aiohttp.ClientSession() as session:
async with session.post(urlbot, data = payload, headers = headers) as r:
if r.status == 200:
pass
await session.close()
await asyncio.sleep(30)
just to show that it does it by itself
many minutes have passed and the count did not update, and I can't scroll up in the console to see if anything happened cause putty doesn't allow that
doing it every 30 seconds is bad
you'll hit the ratelimit and get blocked for an hour
no
the limit is 60 requests/minute
doing it every 30s is 2/minute
a bit overkill tho
oh, woops
how is that an overkill? 
well anyway, should I try restarting the bot at this point? or would there be any solutions?
ok, restarting fixed it, now the site is showing the correct server count, so there was some mistake that happened while I was sleeping π€
your guild count is unlikely to change in 30s
well I'm saying that I woke up seing the site and the bot showing different results, and I waited several minutes before even coming to this channel addressing this issue
If i POST to /bots/stats with server_count and shards, will it be smart and show shards and servers on the website?
np
@opal zealot i cant fix an invalid token
are you sure you have the correct token, the most up to date version of the api library, and python 3.5 or above?
yes
The token is correct
I put the exact same token from the api docs into it
then i even put it in a little discord.js environment to test it
it worked
hmm
i got the api directly from pip
open an issue on github
and im using Python 3.6.4
i will look into it π
@tidal burrow have you set up logging to retrieve the logs from the module? if so, could you send me them?
nvm you dont use the module
sorry for pinging
^
It isnt like my bot's server count will change 60 times in a minute
What's the hex colour of the Certified badge?
center colour
f9e3ae and fff8f8
thanks
code?
we are not mind readers, so we can't see your code straight from discord
lol
you have to post your code :p
I just copied and pasted whatever the bot said
but we cant guess why it error with out context
I'd guess that the library has a faulty success code checker
@latent glade just send the code, tell us which library you are using
uh.... Even I don't know the answer to that
How would I post the bot status on the website?
@charred portal what language are you using
Javascript
use the js wrapper @charred portal
How do I send the server count to the website? (I use JDA)
I've found an example in #312614469819826177 , so I don't need help anymore
you can't edit a bot you don't own
^
then this is definitely not the place to look for, join bot's support server or contact dev
Currently using dblapi.js to postStats, how would I allow it to show that I am sharding?
@inner rune I dunno how the JS api handles it, but simply posting stats with shard info allows you to show your shard count on the page
So then what would be the best way because I currently do my things like this.
setInterval(() => {
this.client.dbl.postStats(this.client.guilds.size, this.client.shard.id, this.client.shard.count);
}, 1800000);
and this no longer works
It just spams this to me now:
Uncaught Promise Error:
Error: postStats requires 1 argument
at DBLAPI.postStats (E:\Desktop\Discord Bots\SistineBot\node_modules\dblapi.js\index.js:49:45)
at Timeout.setInterval [as _onTimeout] (E:\Desktop\Discord Bots\SistineBot\events\ready.js:8:20)
at ontimeout (timers.js:475:11)
at tryOnTimeout (timers.js:310:5)
at Timer.listOnTimeout (timers.js:270:5)
lemme take a look at the coderino
of the lib, i mean
im not so sure, huh π€
welp, i gotta hand this off to someone else
This is technically what this.client.dbl is inside a constructor: this.dbl = new DBL(dBotsORG, Client);
this.client.guilds.size is undefined or 0
hmm simple youtube api get some songs on yt as undefined but some songs are not
@clever rock this isn't the correct channel to ask, try #development
also try not to spam the chat too much with text-walls
@junior goblet I thought its here sorry, because its an api related problem I think
can we have the voting redirect to a specific URL with results? e.g
on vote, redirect to: website.com/?vote=1&by=userid
use webhook?
@clever rock this channel is for DBL API
yep sorry for that π
Question about dbl.hasVoted, is 0 = the remaining time or 24 hours?
remaining time of the day*
what 0?
dbl.hasVoted(user.id, [0 - 31])
It says something about it
Error: Days parameter out of bounds (0-31)
^
Hello guys, i have a problem
the code
const { body } = await snekfetch.get(`https://discordbots.org/api/bots/${user.id}`);```
/api/bot
actually nvm
@sudden rampart https://discordbots.org/api/bot/340315829264711700
{"error":"Not Found"}
that url works for me https://this-is.definitely-not-a-sketchy.host/ee484355e9.png
I need use the API token?
discord hates me
is points the equivalent of upvotes
english only also that isnt related to api
@junior goblet help
sorry for late response i was eating
Anyone having an issue when trying to post server_count to https://discordbots.org/api/bots/botidhere/
@junior goblet Able to assist?
@restive otter Please don't ping random people, anyone who can answer will
Understood, @uncut crystal
Server count is currently functioning fine on our end. What issues are you experiencing?
I cannot seem to post to https://discordbots.org/api/bots/botid/stats
Isn't returning an error either so I cannot investigate the issue.
What's the HTTP status code?
After posting to the previously mentioned URL - It's returning {"shards":[]}
You seme to be GET'ing, not POSTing.
Definitely posting
If I post to https://discordbots.org/api/bots/botid/stats - It will attempt to post, then return the data which is on the page.
Wouldn't be so sure. How are you making the request?
Post the code you used here
Sent in direct messages.
pls
How am I supposed to correctly post data to the discordbots api?
https://discordbots.org/api/bots/botid/stats
I'm posting to server_count with json data though it doesn't seem to return the updated result.
/api/bots/stats
I believe it's missing an API key, if so, how am I supposed to implement this?
Can we see your code? (excluding any tokens)
Sorry, I'm using /stats as well.
go to the bottom of your edit page for the api key
I'm posting through PHP
The rest of the code is just sending it off and returning a response which doesn't need to be displayed here.
why not send through bot?
You need to get a token
Because the bot is fully managed through the web panel.
they can be found here
Authorization header
How am I to post the token?
Authorization headerΒ²
Any docs for that?
https://pear.php.net/manual/en/package.http.http-request.headers.php https://stackoverflow.com/questions/3032643/php-get-request-sending-headers
As well as https://discordbots.org/api/docs#reference
@restive otter what does it respond with
{"shards":[]}
API doesn't even return errors or missing params, which is quite inconvenient.
i dont know if youre constructing the body correctly
it kinda looks like youre creating something like
{"server_count": {"server_count": 11}}
I'll return the data and I'll see what it outputs.
{"server_count":11}
It's returning that
?
Which is definitely fine.
What do you mean?
Though the shards are still {"shards":[]}
The form of the json content which I'm creating looks like {"server_count":11}
oh
i see it now
hmm
Are you sure?
What bit are you printlning?
jsoncontent?
or data
I'm encoding $jsoncontent then printing it.
I've used this method of posting to other API's all the time - never had an issue.
I'm quite surprised with this one..
Im just concerned about the fact that you have typed "server_count" twice
Im not exactly familiar with whatever language youre coding in
Those terms dont really make sense together
I agree, though I don't believe the API was made for PHP
As states the docs, it has JS, Python and C#
RESTful APIs are accessable in any lanugage
I'm aware, though there isn't any docs for PHP
As long as it can make simple http requests
That's because no one has made a dedicated library for it
so there isnt anything to document
for a bot? - impossible
I dont think anyone has created a PHP library for implementing the DBL API
Do you think you could try setting data to json_encode($jsoncontent)
instead of wrapping it in an array
Iβll have to go through the discord bots api later and translate it to PHP to get everything working
@cobalt ruin Mind if I can have a chat with you through direct messages?
How do I setup the webhook? It isn't very clear to me.
@graceful musk Do you know how to setup a webserver?
@inner venture As in a linux or web hosting?
@graceful musk Just a generic one in your language of chocie
its not to host any actual web content
its to receive the post request that DBl will send you
do I look like a PHP guy
but the api returns {shards:[]}?
that means your thing is sending a get request
even if you have set the method to post
something's wrong
and idk what
How do I make it so that people can see how many servers my bots on the website.....
.
.
.
.
Donβt spam.
@restive otter post server count?
?
@restive otter https://discordbots.org/api/docs
wrong screenshot, suppose to be this one instead https://puu.sh/zOxQv/fa56f00d92.png
ok
Hope you're not using a Discord webhook
I'm not
What did you try / what's failing?
So, I'm using an app written in Flask, although that has nothing to do with the issue
This works completely fine (python)
but when someone actually upvotes
they don't get added as an upvoter
I can show the webhook's code, if you want
make sure your webhook url has a http or https
It has an https in the above snippet of code and in the webhook url
How do I make it so that the website can know how many servers my bots on? I use discord.js
#312614469819826177 @restive otter
find a discord.js one
ok
gotchu fam
@restive otter you were already told to read #312614469819826177 why you DMing me ;-;
Because none of them are working for me!
But they have been tested to work so they should work
You must be doing something wrong

...
do you even know how to code
@restive otter that only means that you may not use async on it
Discard, I have resolved the issue.
k
Thank you for the assistance though, @ashen hull
sa
@restive otter that's not what this channel is really for
well, there goes trying to be helpful
appreciate the thought, but yeah, we're not looking for server count examples anymore
how do i get the bot to post wether or not its online
its online but on dbl it shows ??? on status
that means the bot is not in this server
check modlog for why it was kicked
ok
thank you for the help
it does not appear to be on the modlog
as for why it would have been kicked or anything
-bots @hazy coral
@neon dagger
@undone geyser
do Your Webhooks work with Discord?
no
k
-bots @restive otter
@real stone
@restive otter you can do -bots for your own and you don't need to do that command here π
@queen merlin
-bots @dull silo
@nocturne mortar
this is a wrong channel for commands
^^
hey people i used ```const dbl = require("dblposter");
const DBLPoster = new dbl(API KEY);
// Then, depending on what you called your client
DBLPoster.bind(bot);```
but i get RangeError: You need to provide a client to bind to! at DBLPoster.bind when using my client ( var bot = new Discord.Client({ autoReconnect: true }); )
any ideas?
discord.js
the code snippet used is from #312614469819826177
@woeful grove u need
const Discord = require("discord.js")
var bot = new Discord.Client()
//the rest of the code here
cause bot is undefiend
@opal zealot you still getting 403s?
no bot works fine the code runs and i use bot for all my stuff
it just doesn't get accepted as client for those paramteres @restive otter
i just didnt paste all my code here bc i thought that'd be uneccessary
try to do
DBLPoster.bind(bot);
after 10 seconds from your bot starting
I will try that , thanks
Does the Client need to be online? Because i set that after everything else that Happens in startup
@golden wind I havent tried it yet
@opal zealot i havent actually pushed changes, just wondering if they're still popping up
or if its some firewall/proxy related thing on windows
so could you post the full traceback when it occurs?
!playmusic
How to get upvotes using dlbapi.js??
I'll get docs 1 sec
if the site ever loads...
seriously...
dbl.getVotes(<boolean only ids>)
and dbl.hasVoted(id)
session.get('https://discordbots.org/api/bots/{}/votes'.format(387322914183184384), params={'onlyids':'true'}, headers={'authorization':'token'}) is only returning 4 IDs when it now has 9 upvotes
it also doesn't save the fact that you voted on the website
so there's probably an issue with DBL
i'll report it in #267327844357636097 cuz it's definitely a bug
@median cedar those. 4 IDs would be the people who voted in the past 30 days
message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8'
π
what?
url = "https://discordbots.org/api/bots/310039170792030211/votes"
async with aiohttp.ClientSession(headers={"Authorization": config.dbots.key}) as cs:
async with cs.get(url) as r:
res = await r.json()```
will sometimes return `message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8'`

ive gotten over like 1k errors from this lol
in like 2 days π
you're probably getting cloudflare ratelimited
Oof~
-bots @ebon crow
@lofty isle
-bots @candid scarab
@lone karma
owo
@ebon solar
π
@median cedar if they had voted at all in the past month they won't show up
k
@lean delta wrong chat π³
i can only get my token when my bot is accepted?
I'm a bit confused as to how the webhooks work... can I like, make the voted webhook post something in a Discord channel, like a Discord webhook?
alright thanks
DBL just sends a POST request to the URL of your chocie whenever someone votes/unvotes on your bot
So you'd need to be ready to receive that requesy
But the api endpoint is still available for bots with under 100 votes per month?
Where can we see if this is the case? Or what will be the output if the request was rejected
Im working on a Go library rn so π would be useful to know
(also @ me plz coz ill be asleep)
Slightly contradicts what the announcement says, but thanks ^^
Not really
The announcement says the /votes endpoint will be deprecated for bots with over 100 votes per month
This screenie says that itll simply limit it to the last 100 votes
@inner venture
Right?
we use the word deprecated because we want to discourage developers from using the endpoint because we see it as pointless when developers can use webhooks which work better for everyone
Okay that much makes sense
Cheers
Should libraries add support for the webhook or no?
I'm not really sure how they could...?
Might be language dependant
And would need some outside help from lib users perhaps
libaries cant really do that, sure there can be a lib that creates the server for you, unlikely tho. But since it's a request you are receiving and not once you send its a bit harder lol
@frail meadow You can't really do that with webhooks..? But we are hoping to get some tutorials so it's easier to set up for inexperienced users
Was thinking of channels in Go. But i should probably think about it when its not almost 2am
it's out of scope for a wrapper to add webhooks
because it'd end up forcing a specific webserver
without bundling a webserver there isn't much a wrapper could help with besides parsing json
But i get the idea anyways, that it should be excluded
Thats as far as i was thinking
Hence i said "would need some outside help from lib users"
Bundling a web server is an obvious no
webhook is a general term, Discord webhook won't work
no
Did it will save data of old users?
webhooks don't save data
if you tell it to do such
you need to save it yourself
Hmm?
ok for starters install nginx or apache on your vps if you have one
I use heroku/glitch
oh no
i'm not sure, but that may work?
ok so no installing apache or nginx
i believe they easily support flask
so what i would do is learn python then read the docs for flask
then you could easily make a webhook
I use discord.js
that has nothing to do with the webhook
Ok
your bot and your webhook are 2 seperate things
Oh
you can have both on a single process
I'm genuinely surprised how many people are confused by this concept
if you want to do that, take a look at express (i wouldn't recommend it tho)
i never used either of those Β―_(γ)_/Β―
So what i do
but i don't recommend running the webserver on the same process as your bot
Learn what webhooks are first
when i try to get something from dbl and i get
Error: 500 Internal Server Error
does that mean im requesting too much
mmk
ratelimited is 429
500+ errors are the server not you
YES
Perfect example and I love that meme
The only 1** though is the websocket right? π
idk
I mean it makes sense in that case but I'm just curious
informational
2** = here you go, but what if 204 
It technically can't say "Here you go" 
anyways I think this is more #development stuff π€·
204 is here you don't go
wait but i can post, so i cant get but i can post stats 
well i can too if i go on the site, but like it wont work for me when i eval and try to get it rn
works for me https://i.atalanta.site/2dbb3bcd90.png
hold oh yeah i got that to work
but now when i try to get anything about voting it doesnt work
stop
π€ π€ π€ π€ π€
ok it was the dblapi.js issue so mk
How do you see up the webhooks?
wtf is a snowflake
Discord uses it to generate IDs
SO dumb
do webhooks work with actual discord webhooks?
No

Any ideas: I use the test webhook I can see the request just fine, but when I try voting for my bot I get nothing. Is voting webhook disabled right now since that announcement?
Works fine for us
hmmmm
@restive otter possible that you already voted?
And thatβs why youβre not getting it?
It only counts once every 24 h
I have voted, but it should still show, at least before this announcement, it would show voted/unvoted unlimited times per day
would be weird if webhook only fired for a person every 24h, since it includes the "type" in the webhook data
type String The type of the vote (either "upvote" or "none", none means unvoting)
ooooooooooooooooooohhh
It only shows if the vote is successful
so no more unvotes, and successful votes every 24h?
Yh
How do I set up a webhook to sync my voters to a role on my server?
another thing, since they dont include unvotes in webhooks anymore, is the data format for the webhook still the same apart from that?
happy birthday @spice jacinth
Hello guys
hoi
I have an webhook nodejs server now and that one works but how can I give credits to a user that uses my discord bot
You get the user id in the web hook
Is it possible that my webhook server sends a discord message that a user got credits?
uhhh, something is going on with dblapi.js I think... was working before the announcement. I am getting votes and adding them to an enmap like this:
dbl.getVotes(true).then(function (voterIDs) {
console.log(voterIDs.length) // => prints 1890 -- I DEFINITELY dont have 1890 votes. /votes endpoint is just me :p
voterIDs.forEach(function (voterID) {
votes.set(voterID, true)
});
});
Any ideas?
the api changed a bit
Yeah I got that. So should I just grab from the /votes endpoint for now (i have < 1000 votes) and wait for the lib to get updated?
updating the lib soonβ’
how soon is soon?
π sounds good
cause i want to lock all my commands behind upvote cause i need to add some perks when people upvote
updating the lib soonβ’
quite lost on how too use the webhook stuff
already set my url and authentication on the edit page
basically that url needs to be a living page?
or I just need to use that url to link it into the script
That face when you have a due date and suddenly someone emails you "I'm sorry to tell you, but your deadline moved one week further away"
Feels good man
Haha, there will always be someone upset about these things π
Oh, wrong chat btw. #general :S
does the webhook still send type="upvote"?
apparently it sends type upvote, but never "none" theres no unvotes in webhook anymore
Guys can someone give me a hint about webhooks?
On how it works?
you haven't parsed the json
There's no authorization header on the webhooks anymore?
is it missing for you?
yeah
ive never used a webhook before. can someone help me figure out where to start to set it up?
what lang
python
using discord.py
it says you can check an individual user's votes but i couldn't figure out how to do it with dblpy. i thought maybe get_user_info but that didnt seem to have any information about votes
dblpy is probably not updated yet
ah ok. ive been trying to google about using webhooks in python but i honestly have no idea what im doing
i have this at the moment running on a vps
import web
urls = ("/.*", "hooks")
app = web.application(urls, globals())
class hooks:
def POST(self):
data = web.data()
print(data)
return "OK"
app.run()
i tried using hurl.it to send it a POST request or whatever and it says this
there is already something running on port 8080
Can someone help me setup an if message author voted for the bot check? discord.js
how do i figure out if something is already running on port 8080? i googled it and tried some stuff but it doesnt seem to do anything. and i tried using a different port but it does the same thing
@lost skiff
https://discordbots.org/api/bots/urbotid/check?userId=userid```
if it says 1 then the user has voted
@restive otter thanks this actually solves my problem too because i give up with webhooks now lol
No prob
Outta curiosity, whats the lang used in the backend of the api?
nodejs
Well that probably explains the bottleneck
A scalable language would've been a better choice
Or is there a different bottleneck re. votes endpoint? Db perhaps?
Node is not scalable
lol go study
Compared to something not single threaded, definitely
the problem was that our old vote format was slow to process
what if I told you our backend runs on multiple threads 
Cluster
Doesnt make node not single threaded :p
π€¦
but it does scale
By throwing more into the mix, yea
Its like adding more servers
Sure, it works
But its far from the best way
not really
Enlighten me then, please
feel free to ask in #development, as that's more general programming than API-related
Awaiting reply
how do i put an authorization header when using urllib.request in python? i cant figure it out. i think im just dumb
It uses clustering @frail meadow
#development to continue that conversation
@old wave already been discussed
in other news the js module's master branch now supports the latest API changes
dblpy 
I'm querying https://discordbots.org/api/bots/426537812993638400/check?userId=84117866944663552 and it's showing my voted = 0, even though I just voted right now
import requests
url = "https://discordbots.org/api/bots/413728456942288896/check?userId=71632953322512384"
token = "my token"
r = requests.get(url, headers={"Authorization": token})
print(r.text)
what am i doing wrong here?
i get error: unauthorized
nvm. somehow i had the token wrong
I don't understand this system.
On page 1 of Top Votes this month there are bots with 5 or less votes and on 2nd page there are bots with over 100 votes.
Is this a bug?
(ping pls)
@limpid sorrel check again
maybe it needs some time Β―_(γ)_/Β―
yea they're cached for a while
gy
Yes @patent violet on https://discordbots.org/api/docs#mybots
abb?
about
Does the test webhook send authorization header if you fill it in or am I missing something here? I tried testing my webhook but Authorization header is NULL
Wondering if that's an issue with API or not
it should but it's an issue
mmf
@cobalt ruin pm me the ip so i can ip check webhooks
you can use the auth header π
@golden wind you should not IP check webhooks
2) Webhooks are sent from a different server than before, so if you had an IP check in place, please make sure to revise it
revise it means throw it out the window and use the authorization
Realistically you guys should do what Google does with their google bot. Set the reverse DNS to be on the domain like IP.rdns.discordbots
I mean sure Authorization works but this works too
I mean I guess π€·
You could also do the patreon way
Webhook Public/Secret system where the webhook is sent with headers that have it encrypted from the webhook secret
Or whatever way it was done, I don't remember but it sent an encrypted HMAC which can only be checked via the webhook secret they have
a cryptographic signature is possible to add later
but this way of authorization is the easiest to implement for devs
it's just upvotes π why would you need something like that
cuz its cool
Because you're also sending it to a publicly obtainable API
albeit I doubt anybody will figure it out ..... but you know
open source bots
People can use it to reward users for upvoting but if somehow the URL is known they can fake it
Yours
okay thanks
(afaik)
I didn't actually check it but I saw like 15.... something in mine and that implied it was probably mine since i kind of know my ID
API should return a hash of the payload with concat with the API key
So u can check via bot the payload
Actually I think that's what Patreon does
Guys can anyone give me a hint about how to use webhooks for votes?
Put your webhook in the field in the site.
You will get post requests, listen to it.
I am also not so good at it. Other dev in my team did it.
and there is some code floating in this channel (if you use js) regarding the usage of webhook.
@narrow charm Can you send me those codes
Can't find it
Ok
i have a bot but not registering
let dbt = "api";
const { body } = snekfetch.get(`https://discordbots.org/api/bots/botid/check?userId=user:id`)
.set('Authorization', dbt)
channel.send(Boolean(body));```
Why it returning false i already upvoted my bot

Anyone here want to help an idiot

const snekfetch = require("snekfetch");
let dbt = "api";
const { body } = snekfetch.get(`https://discordbots.org/api/bots/${bot.id}/check?userId=${user.id}`)
// where bot is your client object, and user is you.
.set('Authorization', dbt)
channel.send(Boolean(body));
I directly using my bot and user id
botid is my bot id and user id my id directly @narrow charm
Not included in bot yet
I havent checked how this endPOINT works, let me check for a while.
Ok
I guess its daily vote checks.
with webhooks, its getting and posting but im not getting any info/data and its just weird
hmm no idea then
Question. https://github.com/MattIPv4/DiscordBots.org-API-Examples on here, my lib can handle ALL js libraries... But how do I go about adding it to the repo?
DiscordBots.org-API-Examples - Bot Stats API Examples for DiscordBots.org
Would I just make a file in a javascript folder and call it Example-all.js or
Or??
let dbt = "api";
const { body } = snekfetch.get(`https://discordbots.org/api/bots/botid/check?userId=user:id`)
.set('Authorization', dbt)
channel.send(Boolean(body));```
Why it's returning false
Only those who really know
Help me

first off, the body has a voted property which returns a 1 or 0
secondly, snekfetch.get is a promise, so you need to either await it or do everything in a .then
^

why am i getting a connection from my webhook but no data
they post a json body.. Soo, /shrug
yeah i know the weird thing is that im not even getting body
just everyother bs thing
@distant flare i still don't getting how to do it rip
async function getVoted () {
const { body } = await snekfetch.get(`URL`).set("Authorization", "muh code");
return body.voted || false;
}
// your command
getVoted().then(voted => {
channel.send(`You ${voted ? "voted" : "didn't vote :c"}`);
});```
example.exe
or
snekfetch.get(`url`).set().then(({ body }) => {
channel.send(`body.voted`);
});```
Ok thanks
I was trying body.voted
But i got undefined but i will try with await
It worked hue hue
anyone wanna test webhook support for dblapi.js before I release?
read the link
...
if you try reading that link
it explains how to do exactly what you want
in this case
Do votes reset 24 hours exactly per user vote (timestamps) or something else?
24 hours per user vote
Hmm, I have a suggestion for the webhook, maybe include the voters timestamp?
Released dblapi.js v2.0.0
dblapi.js - An official module for interacting with the discordbots.org API
Webhook example
const DBL = require('dblapi.js');
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(vote);
// Do what you need to do
});
how would i get the server usage on the site for widgets, using api key
by posting your server count onto here?
by code then it will auto change or something like that
like for websites the embeded widgets
the widgets off of discord bot list or somewhere else?
yes
discord bots
is your server count already posted on your bot on discord bot list
no
thats what im trying to do
do that then it will work
im asking how do i use the API key
what lib
Python
async
not rewrite
i dont do discord.py but isnβt there a page on the site
its just examples
have you seen it tho?
There's a library created in Python that implements the dbl api
^
Ic it
thatβs async the examples
and imo its tells you everything on how to use it
i was on the widget section
prop why
is the api being weird it say my bot is offline on the website but its online and running
cookiebot owner person how do I add a bot to the api xD
'
oh
I just login with my discord
OOF
for server count there should be example code on the website
ok... i signed in with discord and now it say my bot is online XD
Any anwer please
Personally I would advise against sticking a http server inside your bot
@severe mist why?
Because it could lead to possible memory issues, and you may run into issues if you shard (discord.js) as it creates additional processes and if they all attempt to open / access the same port can cause problems
Having a separate node process for the http server and using a pub/sub system, or adding to a db is the best solution imo
oh yea
if you shard adding the webhook in the bot code is a no-no
not only because of the http server 
and memory issues just have to be tackled with
I'm currently writing a small bot / http server to handle role rewards for my guild
Why would there be memory issues
And I plan on expanding the functionality for the pub/sub system
You're adding a http server to your bot, that's a memory issue right there lol
I dont get how thats a memory issue :p
If your bot is sharded, problems, if it's not sharded, no problems @tough yoke
How big are http servers in whatever lang you use π€
if it's Eris it's fine
How
but in d.js sharding it wouldnt work
Eris has fancy internal sharding
Try it and see if it works
Δ°snt eris has not sharder and all eris user uses eris-sharder
Eris has a built in sharder
Is sharding for our sake or discords?
bit of both
Eris has they own sharder like d.js?
if you use eris-sharder you should have webhooks on the master
are the talks happening for multiple http server running on same port?
@severe mist ?
hmm?
what is the memory issue you talked aout.
and ignore the typo,keyboard damaged just few momentsago.
y
@calm torrent the topic froosty and I are talking about is very relevant to the topic of the channel, pls don't mini-mod
it was another person who deleted his message and just moved to #development, not related to you @severe mist
fair enough
@narrow charm pretty sure you cant have multiple processes bound to the same port
No clue what the memory issue is that he mentioned
Must be a bad http server
d.js and the api wrapper uses same port?




