#topgg-api
1 messages · Page 23 of 1
no thats my end cause you didnt call the HTTP directly
@golden wind does your lib use f strings?
ye
👀
4jr made a fork and fixed a few of the things you mentioned yesterday, i havent had a chance to test it today but it looks good (apart from the docstrings)
i also redid the example but wanted to double check it through you first
Oh cool if he’s forked I’ll take a look later
Am I the only one who has to JSON.parse(Object(response)) the API call response
yes
😦
Pro tip for fellow Java devs: the library uses retrofit which requires gson version 2.6.2 and I was getting methodnotfound errors with 2.8.2
rip
am i misunderstanding this or can the C# library really only target .NET 2.0? 
Oh that's annoying if that's the case

@cobalt ruin Do you collect stats on API keys?
I get this error when trying to do a server count:
ValueError: data and json parameters can not be used at the same time
@queen dagger which lib?
Can a "voted_at" be added to the API's json return on api/bots/:{bot.id}/votes ?
If it's possible
@restive otter you probably have the wrong version of node
what version of node do you have
try and update your node version

you can make suggestions to the api in here
Okay it would be nice to have an api endpoint for checking how many calls your token has made in the last minute, to check if its close to 60 and if it is lockdown all dbl api command until it resets to 0
Something like https://discordbots.org/api/token/<yourtoken>
it would be on a header
Thats the most retarded ratelimit system ive ever seen then if you allow me to say 
why not put the ratelimit in your own api code and not cloudflare 
because we can
TBH rate limiting by IP is very restrictive, for example what if multiple bots are hosted on the same server?
That's the entire server rate limited
Lets just make this easy, react with
if you want per token ratelimit and
if you dont want/dont care. Majority wins.
you can't make everything into a vote
keep in mind some endpoints do not require a token as well
which ones
Ultimately it's your call, and I understand why it's rate limited, I'm just thinking by IP imo is a tad overkill and rather restrictive over per-token
anything but POST /stats and GET /votes
we had to ratelimit because of assholes putting stat posts in while loops or some shit
I was going no ratelimits as long as it's not abused
there was someone who got the idea of making the token use "possible" but not required, so you could base the ratelimit per-token if its provided
either ip or whole api locked
Pls token rate limits for authed endpoints
I put my post stats in async loops what wrong with it 
tbh lock the whole api with tokens, there is no need for an not bot developer to interact with it anyways
token rate-limit would be pretty much the best deal here
@thin vessel you actually wanna know whats wrong with that? you spam the api for no reason, instead of looping shit just update on demand (server count changed due any event) and you would spam less 
I poll the votes endpoint once every minute for my voter rewards
But my loop only fires every 15 mins and the ratelimit is 60 request per min 
hmm thats pretty high tho
Because Up To Date server count 
unless you have rythm's growth i don't think your server count will be off that much in 1 hour
lmfao
but why does up to date server count matter that much anyways
once per hour isnt much to ask 
guess you could even prevent cached request and don't post if the latest post was already that count 
that is so smart im gonna add that to my bot
or you just update on demand and dont waste any requests 👏
automation yukine
But making guildCreet and guilDelet events ish too hard 
@elfin solstice what if you have a rapid growth spurt, boom rate limited
you dont join/leave 60 servers in 1 minute
keep on dreaming york
rythm does
well yea for big bots likey Rythm thats completly fine, but not for smaller bots > 5k servers
And I never said me I'm speaking in a general sense
I'm quite surprised and shocked Misaki has as many guilds as she does
aslong as your bot isn't on 20k servers this shouldn't really happen
THIS CHANNEL IS ONLY FOR SUGGESTIONS/HELP/BUGS TO DO WITH OFFICIAL API LIBRARIES AND API DOCS FOUND AT HTTPS://DISCORDBOTS.ORG/API/DOCS
yours is not any of that
keep in mind that posting on guild join/leave events might spam the api a lot
if there's an outage
it's not rare to get guild joins for all your bot's guilds when discord has an outage
at once
most libs filter that but that's not the case for all 
hmm thats actuall a valid point
^
i think JDA doesn't (atleast it was like that last time i used it) but most JS libs do that
it's simple to filter
but people who never got it have no idea that it might happen
tru
That's why he's asking for it
we're not a user listing site
U have an api thay could benefit from it tho
@arctic arch the only usage case I can think of, is he wants to list bots the user may own
you can do that from the /bots/ endpoint
that's the only usage I can think of for users
I found a workaround using the bots endpointing with the ?search=owners:ID thing
Nailed the perms™
Hey you wanna unmute me in shitpost? I did nothing but say what was true and you didn't like it.
discord pls
Wanna unmute me?
uh ohs
this the api channel
yupp
congrats on shitposting general and getting muted
sence ™
hello @restive otter are you seeing this
hello @thin vessel i am seeing t his
webhook for votes?
What? why?
probably would end up overloading our servers
true on that part
/bots
A vote webhook would be actually really cool, I think
That way, bots aren't forced to repeatably call the votes endpoint to update their list of users that have voted
I could very easily reduce how many times I call the API if I knew when it changed. I'm already caching the results so it'd be really easy to implement.
Yes I've implemented caching and in web dashboard for user to click when voted so there is no periodic checks.
Webhook is going live tomorrow or Thursday, sorry for the wait guys ❤
Even better then
Sorry for the wait guys 😛
@robust olive pls
¯_(ツ)_/¯
Can't please everyone, even if I tried I would be wasting my time
ok Oliy-sama
Why do we need a websocket for DBL. That's pointless af
your pointless
@tame kindle last warning
also, it's you're
novus, I'd imagine because people don't have to keep making new requests and they can maintain their own cache
@vagrant kayak So people don't have to request API every x seconds/minutes
That's why I initially suggested the webhook system
Websocket would be a pointless server running
(node:10320) UnhandledPromiseRejectionWarning: Error: 400 Bad Request
at _response.transport.finalizeRequest.call.then (C:\Users\Admin\Desktop\Hikari\node_modules\snekfetch\src\index.js:195:23)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:160:7)
this started happening after attempting to implement the api in djs
and it looks like it has nothing to do with me :/
OOF i've been getting that ToO
I checked all of my files and it wasn't caused by my code
i have no way of checking whether or not it actually worked eee
Well I use d.js too and I dont get that
it all started after I put the api
const dbl = require('dblapi.js');
const dblAPI = new dbl('don't steal token pls', client);
i assume client is our instance of the djs client
api docs inaccurate reeeeeeeeeeeeeeeeeeee
const DBLapi = require("dblapi.js");
const dbl = new DBLapi('nope m8 u not getting it');
that's straight from the docs
docs are gay then
gae
when will @arctic arch stop using discord.js client for it's api.
even if it's from the docs it's bad practive
I can make an api w/o discord.js instance
practice*
I can make an api with ur face
Hot
t!t credits
wrong channel #commands or #265156322012561408
I get this error when trying to do a server count in discord.py:
ValueError: data and json parameters can not be used at the same time
What’s your code
await dbl.post_stats(jsonObject={
"server_count": len(client.guilds)
})
Python 🤢
^
I keep getting the same error as this sc:
https://cdn.discordapp.com/attachments/412006692125933568/412882078905008181/unknown.png
:S
when will tonkku test his bullshit
welp
someone ping me when they have solution
:C
@junior goblet do u know solution 
what version of node do you have?
3.10.10
what in tarnation
try and download the latest node version from nodejs website
👀
I got it
@shy vessel
👀
sorry i didnt respond but yeah either way you had to update node 
#development not here
ok
can you see if a specific user has upvoted your bot, or do you just get the list and check from that

@restive otter the latter
thanks
I like how you can do days=0.1 to get who voted in last 2**.**4h
My bot has eveything accessable through the client, I don't feel all that good sharing the client object.
what?
Ooo what is this channel for
discussing the api/api libs
newly overhauled api for DBL
also
channel topc
THIS CHANNEL IS ONLY FOR SUGGESTIONS/HELP/BUGS TO DO WITH OFFICIAL API LIBRARIES AND API DOCS FOUND AT HTTPS://DISCORDBOTS.ORG/API/DOCS
I'm on a phone sorry lol
i'm having trouble with installing the python API
Collecting aiohttp>=2.3.9 (from dblpy)
Using cached aiohttp-3.0.1-cp36-cp36m-win32.whl
Requirement already satisfied: multidict<5.0,>=4.0 in c:\users\user\appdata\local\programs\python\python36-32\lib\site-packages (from aiohttp>=2.3.9->dblpy)
Requirement already satisfied: idna-ssl>=1.0 in c:\users\user\appdata\local\programs\python\python36-32\lib\site-packages (from aiohttp>=2.3.9->dblpy)
Requirement already satisfied: attrs>=17.4.0 in c:\users\user\appdata\local\programs\python\python36-32\lib\site-packages (from aiohttp>=2.3.9->dblpy)
Requirement already satisfied: chardet<4.0,>=2.0 in c:\users\user\appdata\local\programs\python\python36-32\lib\site-packages (from aiohttp>=2.3.9->dblpy)
Requirement already satisfied: yarl<2.0,>=1.0 in c:\users\user\appdata\local\programs\python\python36-32\lib\site-packages (from aiohttp>=2.3.9->dblpy)
Requirement already satisfied: async-timeout<3.0,>=1.2 in c:\users\user\appdata\local\programs\python\python36-32\lib\site-packages (from aiohttp>=2.3.9->dblpy)
Requirement already satisfied: idna>=2.0 in c:\users\user\appdata\local\programs\python\python36-32\lib\site-packages (from idna-ssl>=1.0->aiohttp>=2.3.9->dblpy)
Installing collected packages: aiohttp, dblpy
Found existing installation: aiohttp 2.2.5
Uninstalling aiohttp-2.2.5:
Successfully uninstalled aiohttp-2.2.5```
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\shutil.py", line 387, in _rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\user\\AppData\\Local\\Temp\\pip-bfbr6dwe-uninstall\\users\\user\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\\aiohttp\\_http_parser.cp36-win32.pyd'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\commands\install.py", line 342, in run
prefix=options.prefix_path,
File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\req\req_set.py", line 795, in install
requirement.commit_uninstall()
File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\req\req_install.py", line 767, in commit_uninstall
self.uninstalled.commit()
File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\req\req_uninstall.py", line 142, in commit```
File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_vendor\retrying.py", line 49, in wrapped_f
return Retrying(*dargs, **dkw).call(f, *args, **kw)
File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_vendor\retrying.py", line 212, in call
raise attempt.get()
File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_vendor\retrying.py", line 247, in get
six.reraise(self.value[0], self.value[1], self.value[2])
File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_vendor\six.py", line 686, in reraise
raise value
File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\_vendor\retrying.py", line 200, in call
attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\utils\__init__.py", line 102, in rmtree
onerror=rmtree_errorhandler)
File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\shutil.py", line 494, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\shutil.py", line 384, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
_rmtree_unsafe(fullname, onerror)
File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\shutil.py", line 384, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
[Previous line repeated 6 more times]
File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\shutil.py", line 389, in _rmtree_unsafe
onerror(os.unlink, fullname, sys.exc_info())
File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pip\utils\__init__.py", line 114, in rmtree_errorhandler
func(path)
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\user\\AppData\\Local\\Temp\\pip-bfbr6dwe-uninstall\\users\\user\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\\aiohttp\\_http_parser.cp36-win32.pyd'```
sorry i just spammed the channel :P
i'd be very grateful if someone could help. thank you
temporal solution: run console as administrator and then install
(this is probably for #development )
What link would I send the DBL webhook to if I want it to post on my discord server
I don't think you fully understand webhooks
I dont have mony to buy a webserver for a heckin webhook 
Are you hosting the bot on your pc
it doesn't say in the documentation how to find out if a user has upvoted your bot on a specific day. anyone know?
i'm using python
i want to know whether a certain user has upvoted today
@median cedar. Grab the list of users with a limit of 1 days and then see if it contains the user you're looking for
do i just add a limit=1 parameter to it then cuz that's not on the docs
nope that doesn't work
🤔
@inner venture that doesn't work
^
nope
it works
what did you just put in...?
I think it had his token in it lol
i'm using await dbl.get_upvote_info(id=id, token=token, onlyids=True)
oooh the library
yes
sec gonna take a look at the library
can i add a manual request into my bot?
ofc
can you explain how to do a 'manual request' plz
basic GET request with the aiohttp library
Perhaps you should do a bit of googling
this is a place to start: https://aiohttp.readthedocs.io/en/stable/client_quickstart.html#make-a-request
Can someone make a DBL webhook working on JS I cant get mine to work
I mean a tutorial for one*
I succ at http
so we have to provide the webhook yes?
this is what i get from the aiohttp request:
<CIMultiDictProxy('Date': 'Wed, 14 Feb 2018 20:24:39 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '24', 'Connection': 'keep-alive', 'Set-Cookie': '__cfduid=a_long_number_that_might_need_to_be_secret_idrk; expires=Thu, 14-Feb-19 20:24:39 GMT; path=/; domain=.discordbots.org; HttpOnly; Secure', 'X-Powered-By': 'Express', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Headers': 'Authorization', 'ETag': 'W/"18-XPDV80vbMk4yY1/PADG4jYM4rSI"', 'X-Varnish': '96503185', 'Age': '0', 'Via': '1.1 varnish-v4', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains; preload', 'X-Content-Type-Options': 'nosniff', 'Expect-CT': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', 'Server': 'cloudflare', 'CF-RAY': '3ed2c0900d513536-LHR')>```
boo, does not appear to be discord webhook friendly
i have to go now, if anyone knows anything that could help me complete this then please ping me. i'll be back in ~20 mins
It's intended to be send to a server you own, so your bot can immediately respond on a vote
But you could generate the Discord webhook yourself by parsing the data on your backend
hell yeah plz
@median cedar you have to put token in headers not in params
async with session.get(url, params=params, headers=headers) as resp:
Thx
i am still getting unauthorized error
@reef apex
sorry to keep bothering you, if you are busy doing something else feel free to say
DM me your code
for future askers: ```python
import aiohttp
async def has_user_voted(user_id, bot_id=None, days=1, token=None):
async with aiohttp.ClientSession() as session:
async with session.get("https://discordbots.org/api/bots/{}/votes".format(bot_id), params={
"onlyids": True,
"days": days
}, headers={
"Authorization": token
}) as resp:
return str(user_id) in resp.json()
JS now plez
but to what http server 
The webhook doesn't work? >.>
I'm listening for upvotes on my "bot" (currently a dummy to test the listening process), and it's not receiving any POST requests.
Are you sure the webhook URL is set?
Yes, I've set it four different times.
@median cedar try my fork of the wrapper pip install -U git+https://www.github.com/fourjr/DBL-Python-Library
Thanks for your help but I’ve got it to work with aiohttp

@cobalt ruin maybe look into "test webhook" functionality to send example payload for developers to verify the data they get etc
Okay! Thanks for your suggestion
Will the library packages ever emit an event of upvotes? Also, is there any way to prevent users from voting and un-voting repeatedly? That would screw up my auto rewards system.
Kek
Is there any way of verifying that the webhook request to the bot's HTTP server is valid?
In that it has been sent from discordbots.org?
maybe have in the Authorization header a token
the bot token
so we can verify on our ends
yeah I guess if the POST request had an authorization header matching the bot's DBL token that would be enough
btw if anyone wants i wrote (in go) a basic http server that redirects data to a redis pubsub
for best security I have the packets of the webhook request sent on an encrypted flash chip in a locked container carried by a carrier pidgeon
OR if you wanna get really fancy you could encrypt the entire request body using a SHA hash signed with the DBL token
might be excessive for what it is
again, #memes-and-media
I think just a header with that info would be fine
that's not a shitpost.
but yeah I agree
I was just thinking about this protocol
https://www.w3.org/TR/websub/
You could also have your library verify if the post is coming from a host
I know for sure sanic (Python) has this, but check your library's docs for others
coming from a host being you check what?
What could you possibly check that makes sure it came from a specific host
(without the host giving you something)
in sanic, request.host gives you whatever host the request is coming from
in production/real use it'd be discordbots.org
¯_(ツ)_/¯
I mean you can just obfuscate the endpoint
call it server.address.com/4j20q9f904q2jf09j24q0 or something
lmao
@calm torrent have you tested your fork yet?
i did minor testing, definitely not enough testing tho
ye i noticed lol
but at least it works :^)
well
File "/usr/local/lib/python3.6/dist-packages/discord/ext/commands/core.py", line 62, in wrapped
ret = yield from coro(*args, **kwargs)
File "/root/github/test/modules/Cmds.py", line 26, in gs
await self.dblpy.get_server_count(self.bot)
File "/usr/local/lib/python3.6/dist-packages/dbl/client.py", line 121, in get_server_count
self.bot_user_init()
File "/usr/local/lib/python3.6/dist-packages/dbl/client.py", line 67, in bot_user_init
if not self.bot.is_ready():
AttributeError: 'str' object has no attribute 'is_ready'
@calm torrent "works"
uh.. what did u parse in?
self.bot
send code
class Cmds:
def __init__(self, bot):
self.bot = bot
self.token = 'no u' # set this to your DBL token
self.dblpy = dbl.Client(self.bot, self.token)
@commands.command()
async def gs(self, ctx):
await self.dblpy.get_server_count()
def setup(bot):
bot.add_cog(Cmds(bot))
also tried parsing self.bot into get_server_count
lol rip
try updatin now
hmm ye
Traceback (most recent call last):
File "bot.py", line 120, in on_ready
bot.load_extension(extension)
File "/usr/local/lib/python3.6/dist-packages/discord/ext/commands/bot.py", line 704, in load_extension
lib.setup(self)
File "/root/github/test/modules/DiscordBotsOrgAPI.py", line 39, in setup
bot.add_cog(DiscordBotsOrgAPI(bot))
File "/root/github/test/modules/DiscordBotsOrgAPI.py", line 10, in __init__
self.dblpy = dbl.Client(self.bot, self.token)
File "/usr/local/lib/python3.6/dist-packages/dbl/client.py", line 59, in __init__
self.loop = kwargs.get('loop') or bot.loop
@calm torrent in the client init, replace bot.loop with asyncio.get_event_loop()
def __init__(self, token, bot, **kwargs):
self.bot = bot
self.bot_id = None
self.loop = kwargs.get('loop') or asyncio.get_event_loop() # <------
class Cmds:
def __init__(self, bot):
self.bot = bot
self.token = ' ' # set this to your DBL token
self.dblpy = dbl.Client(self.bot, self.token)
im passing self.bot into it
@golden wind does it work?
posting and getting server count work
im looking at the rest atm
i'll update the examples once im done and work out the best way to implement stats every 30 mins
isn't it already in the thing?
oh wait.. ahh it's in my test bot/example
#def __init__
self.bot.loop.create_task(self.update_stats())
async def update_stats(self):
while not self.bot.is_closed:
await self.dblpy.update_thing()
await asyncio.sleep(30 minutes in seconds)
something like that @golden wind
1800

^
@golden wind what 1800?
soz
@calm torrent 30m in sec
oh ok
i can't find my bot (sorry if this is dumb) will it be added later for testing?
kk
@calm torrent all works 👍
👍
I'll make bot the first parameter first 
👍 i'll sort out the docs later
wth my bot is in like 5/6 servers and it wont show it on widget
@proven hedge because you need to post server count, you can try out our library for JavaScript here https://discordbots.org/api/docs#jslib
If the webhook fails? will it try to send again?
btw, should i replcae the "client" to my bot client?
Yes
@proven hedge, nodejs?
@cobalt ruin is the webhook sending out POST or PUT?
post
can someone tell me where do i put "dbl.getStats("ID)"?
Welp, I've been catching any requests to my port, and it's not sending anything.
it works for me
iirc you do have to specify the URL + port
Mk, well I've still done that...
then pray
I have sold my soul to get this to work..
I've used postman to send a POST request to the url:port
And it works,
but when I try and vote. It doesn't send it.
do i put dbl.getStats("ID) below dbl.postStats?
you don't have to get stats
what about the server count?
but it doesnt show the server count on the website
btw is this okay or should i reinstall
it's fine
So I want to use a webhook to see who upvotes my bot. I already defined a discord webhook but idk how to continue. Which event triggers that someone upvoted my bot, can someone help me pls? Its for javascript btw
That's not how webhooks work
A webhook in web development is a method of augmenting or altering the behaviour of a web page, or web application, with custom callbacks. These callbacks may be maintained, modified, and managed by third-party users and developers who may not ne...
I imagine it's possible to write a webhook handler that emits a d.js event
most likely
i have a go http server forwarding the webhook events to a redis pubsub channel
cba to run an http server on my bot process
Except in the docs, DBL has a webhook for posting when a user upvotes..
(Albeit it doesn't seem to want to work..)
Updates
- Fixed some webhooks documentation
- Added documentation about small widgets and querystrings
jesus idk how to make this webhook work
is there a tutorial how to make a simple node.js webhook?
We are trying to get one out on how to use webhooks on our site 😄
Okay that's very nice. Ty. I wonder how Nadeko could forgive the Flowers for upvoting their bot before the relase of the Webhook.
they polled the votes endpoint every set time
and checked for new people
probably
But they have soooooo many users and the api allows just 60 requests per hour
I wonder how a big bot can forgive the users when there is just a limit of 60.
Since when
No
Well get outta here then
it's been 60/min for a decent time
lol I swear there was written per hour
iirc at least a month
okay so i am sorry ^^
Yeah, your API doesn't send any data to my webhook...
it's working for me
Okay, what port do you have your webhook going to
this is my code https://github.com/natanbc/dbl-upvote-redis/blob/master/main.go
i have on 23456
but i reverse proxy with nginx
so it ends up on 443
then proxied to localhost 23456
Mk, on my router. I have port 8000 open to my IP.
I've gone into my DNS and forwarded my domain on the subdomain w to go to the IP address
i couldn't get it to work when pointing to my ip
on the edit page I have it going to my website to the ip 8000
That's the thing, I had a friend in a different country send a POST request to the website+port and it sent through
@steady sundial I stole this from @hardy valley
const http = require("http");
const querystring = require("querystring");
const server = http.createServer().listen(6669);
console.log("Listening on port 6669");
server.on("request", function (req, res) {
var body = "";
req.on("data", function (data) {
body += data;
});
req.on("end", function () {
var post = querystring.parse(body);
console.log(post);
res.writeHead(200, {
"Content-Type": "text/plain"
});
res.end("Hello World\n");
});
});
Works perfectly for me
@severe mist thx york. I appreciate it!
all native node, no additional modules
now I'm just working on a way to constitute that into my bot to award upvotes now
i'm just waiting for a way of verifying if the webhook request actually came from dbots.org
yeah, that is a very very good point
oof
maybe keep the webhook URL a secret?
its easily verifiable
cache the webhooks
and every 20 seconds
check with the votes api
pls no
i'd rather have a way of verifying the request as extra safety
this kills their purpose tho
would be just a single extra case for the if https://this-is.definitely-not-a-sketchy.host/21a4a2a239.png
@cobalt ruin can you update your bot's description with http post?
No, why would you do that?
like a command count or something
do it manually
okay
if you really want something like that, build your own website and link to it from your bot page
<iframe>
OR, have the server send a token?
If it matches the correct one accept it, otherwise.
that's what was suggested yesterday
btw for people wanting to verify it's dbl, you can use the Cf-Connecting-Ip header if you have cloudflare
Can someone confirm Ratelimit is for token rather than IP?
im pretty sure for ip
since they ip ban for an 1 hour after to many requests
@inner rune
Oh hey, how are server counts calculated with sharding? Because before the update w/ api they had it so I had to update it per shard but now I only need to add the shards up and send it?
I am really confused whether I am supposed to send it per shard or just in one shard.
(AKA @earnest lintel 's shard count is incorrect)
you can do either, still
@inner rune There are still the 3 different ways you can post your stats
total server count
server count for a shard
and all the shard server counts in an array
So how would I setup a webhook with discord.js, just want a msg whenever someone upvotes
Dont see it. Is it the querystring one?
const http = require("http");
const querystring = require("querystring");
const server = http.createServer().listen(6669);
console.log("Listening on port 6669");
server.on("request", function (req, res) {
var body = "";
req.on("data", function (data) {
body += data;
});
req.on("end", function () {
var post = querystring.parse(body);
console.log(post);
res.writeHead(200, {
"Content-Type": "text/plain"
});
res.end("Hello World\n");
});
});
@solid scarab
Thank you
probably a common question: can you put a discord webhook link in the webhook for the votes?
or how would you format it if you can
figured id try ¯_(ツ)_/¯
¯_(ツ)_/¯ what is this ?
help with the dbl api
Wow nice question tho
Is there a delay in how long it takes the server count to update for a bot?
no
if (!dbl.hasVoted(message.author.id)) return message.channel.send("You must vote to use the music commands. You can do so here: https://discordbots.org/bot/332971222897786892/vote");
this does not work?
never tried but im psure the method is asynchronous
yes it is
therefore you have to await it
i have some code for it ill see if i can find it
dbl.hasVoted(message.author.id).then(result => {
if(!result)
return message.channel.send("You must vote to use the music commands. You can do so here: https://discordbots.org/bot/332971222897786892/vote");
}
//command
try this
okay]
if it doesnt work try removing the return and slapping an else after the message
e.g.
dbl.hasVoted(message.author.id).then(result => {
if(!result) {
message.channel.send("You must vote to use the music commands. You can do so here:
https://discordbots.org/bot/332971222897786892/vote");
} else {
//command
}
}
ugh
dbl.hasVoted(msg.author.id).then((res) => {
if (!res) { return; }
// commands here
});
why would you put the return; into brackets 
ban
why would you use .then
I'm not able to udpate the server count for my bot. I've verified I'm getting a 200ok header response from the API endpoint, but it doesn't update.
$response = $guzzle->post(self::DISCORD_BOTS_URL.'/bots/'.env('DISCORD_BOT_ID').'/stats', [
RequestOptions::FORM_PARAMS => [
'server_count' => $guildCount,
'shards' => 1
]
]);
dd($response->getStatusCode());
shows "200" as the response code
How long ago was your 200?
200 is ok tho?
Yes 200 is ok
Yes, it is. But I've harded coded the server count of 2018
So it should be indicating that number. the 200ok was about 5 mins ago

@gleaming dragon so you only have one shard?
Yeah
I believe it should be an array?
Yep, that fixed it.
Thanks
Seems strange for that to have to be an array though
Not sure @arctic arch designed the API
just remove the shards from your post
if you want to send a total server count and the amount of shards you have use shard_count
k
sure
Where do I have to insert the API?
?
DiscordBotListAPI api = new DiscordBotListAPI.Builder()
.token("token")
.build();```
Do not I have to insert the API somewhere?
save it in a field
?
I don't understand your question
How should I paste the API into Eclipse so that I can use it?
In Maven? I need more information
DBL-Java-Library - An API wrapper for https://discordbots.org/api/docs that works in Java
thx
bintray easier https://this-is.definitely-not-a-sketchy.host/90aa754a6f.png
just click the button
hmm
and get the copy paste stuff
do i have to push the builds to it?
yes
see thats harder 😩
if you use gradle it's as easy as 2 clicks
make a custom gradle task for bot git push and bintray upload
ez
jda is on bintray right?
task pushAndPublish {
dependsOn bintrayUpload
Runtime.getRuntime().exec("git push").waitFor()
}```
yes
👏
is there a problem or why is it returning a STATUS CODE: 503 Backend fetch failed whenever I try to make a post request
we're aware of the issues on the service, it's being worked on
oh okay 
- multiple grammar (capitalization) mistakes in docs
- didn't find any documentation on manually POSTing server count, is that supposed to be a thing
- are there any headers that return # of requests remaining before a ratelimit? if not why not?
- no, only when you get ratelimit
then there is the retry-after header
you have to handle ratelimits yourself
Bots
So, do we have to actually use the webhooks and track ourselves how many times a user voted? Doing a GET to /votes just returned the users not how many times they voted. Only other way I can see doing it is by adding &days=1 and tracking the changes there.
Well, can't you just give a reward each time they vote? Why would you want to store about many times they voted?
It's good information to have
Uhm @arctic arch ?
Track it yourself @restive otter, the API doesn't, and shouldn't cover every little thing for edge cases like this, I mean depending on your setup you can store it in a db
Is the webhook triggered with type none after 24h when the daily vote gets removed by DBL?
no
Bad. Then I must use the old endpoint.
Why do i always find york in every server im in
not appropriate for this channel @foggy lava
didnt notice i was in the api channel, sorry
Why am I receiving this error? https://www.hastebin.com/afuzojadib
@viral herald did you read the error?
knowning nothing about the lib but is server_count undefined
@viral herald https://discordbots.org/api/docs#pylib
@viral herald What bot ID are you using
my guess is that youre trying to get the server count of a bot that does nto have a posted server count
so the lib tries to get at "server_count" but it doesnt exist, so error
@golden wind just tagging you because this might be an issue on your end
I got it
Traceback (most recent call last):
File "bot.py", line 278, in _eval
ret = await func()
File "<string>", line 8, in func
File "/usr/local/lib/python3.6/site-packages/dbl/client.py", line 77, in post_server_count
await self.http.post_server_count(id, token, guild_count, shard_count, shard_no)
File "/usr/local/lib/python3.6/site-packages/dbl/http.py", line 114, in post_server_count
await self.request('POST', f'{self.BASE}/bots/{id}/stats', json=payload)
File "/usr/local/lib/python3.6/site-packages/dbl/http.py", line 78, in request
raise Unauthorized(data.pop('message', 'unknown'))
TypeError: __init__() missing 1 required positional argument: 'message'
Is this a mistake in the lib?
yep, fixed in latest version
@arctic arch retry_after for ratelimits in ms or s?
seconds
👍
@golden wind if it was fixed in the latest version then why is it still giving me the error Bc I just installed it today
Ah ok
I'm having a small issue with sending stats. I've sent it multiple times, but it won't reach the actual server count. https://hypercoder.me/aa8721.png vs https://hypercoder.me/e1950f.png ( https://hypercoder.me/00fc74.png )
from there you can probably see that shards like 2 (3rd one) are null which means their stats haven't been sent
I sent a eval to all shards to send them, along with the fact that any time the shard gains a server, which I’m sure all have by time I checked last, it updates.
That's a bad idea to update on guild join/leave
^^ lol , yes
Just join. That’s what I was told to do because an interval is apparently stupid.
I was told that was wrong by people in Discord Bots. 
They're stupid
For the webhooks, how would i prove that the requests are coming from DBL, not some rando request?
Github uses a X-Hub-Signature header.
has been suggested before with an Authorization header with the bot token
ah
hey with the API dbl.getVotes(true) function I get a 401 error like. How am I supposed to use it exactly?
did you give it the token?
did you use the right token
yes
did you give it the correct token
do not give it your bot token
give it the discordbots.org token
bot page -> edit -> scroll down
O yea i just found it, sorry
I've been grinding this all day. I'm working with komada and trying to make an upvote inhibitor. using the api in code i can't get true/false, yet in eval i can.
I've tried some of the above options.
Is it possible to get the top voters of a bot?
no
@gray root unless you track the stats yourself, no
@wanton matrix I don't quite understand your problem, can you try and elaborate on your problem?
ok so with
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
the 2nd and 3rd arguments do not work this is what it gives me
TypeError: Cannot read property 'Id' of undefined
which is the Id value in the 2nd argument, and in the 3rd argument it just flat out does not work for me. only way I can get the current shard id the bot is currently on is with client.shard.id and to get the total shards I have to use client.shard.count but if I change them to these working values only the server_count updates
{ server_count: bot_server_count_here, shards: [] }
like so but where is says bot_server_count_here is the number of guilds the bot is in. any idea why client.shards.total and client.shards.Id isn't working?
I'm trying to use hasVoted to get a true/false value, yet it returns a promise, in code. But when i so the same line in an EVAL it returns the true/false
@cobalt ruin
I have done that in an async function yet the returned value is another promise
I think this might be what you need? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then
if you're using js
yes, but see again i've tried that. I need the value to be outside of the promise so i can access it
And komada don't like async funcs, they break if uses as the run
@fallow nymph the client.shards.Id, client.shards.total is a placeholder, they won't work by default
oh ok.
will this api support net framework 4.6 soon?
i cant implement this in my bot because it requires net standard amd my bot doesn't use it
do you support post requests?
yes, i use some of them so i can use the api for my vps actually
so you can also use the api directly without the need for a lib
@vital anvil read this
@gray root In the request context you may have some sort of host variable. Check your server library docs for info
like request.host
?
@amber junco the API works on 4.6.1 afaik
https://docs.microsoft.com/en-us/dotnet/standard/net-standard the library is built in net standard 1.6
It has a compatability table inside
With the API and posting stats, is it better to do it on guild join/leave or on a interval such as every 10-30 mins
depends how big your bot is
with an guild count of 10k+ i would recommend do it in interval everything under that can be done on request (join/leave)
Yeah, I'm below the 2500 server limit. So I guess the join/leave will be fine for now
yea
im not able to install it because it only specifies net standard 2.0 on the nuget page @vital anvil
Shouldn't the API return like an x-ratelimit-remaining and x-ratelimit-reset headers?
This would make devs life's easier
it's cloudflare ratelimits iirc
Yes hopefully we will be able to have custom ratelimits etc soon, but at the moment, cloudflare handles our ratelimits, which limits what we can do with it
This should never be the case honestly, coding a ratelimit system yourself gives so much more possibilitites
The API is written in node?
And it can't be that hard
we need to do things in order to have the ratelimit have any efficiency
sure we can block your access but it doesn't help us in any way
because you might still be spamming like hell
and shit
Odd, @amber junco I'll check it out
@cunning forum writing a ratelimiter is hard
Hmmm
I think that's a cloudflare thing in this particular case
yep
how can I catch a dbl connection error? every once in a while ill get a 521 error, and so nobody can use the voter command
which language?
try {} catch {}
im dumb lol
i guess
then if (!r.response_code === 200) {console.log("Something went wrong")}
try {
dbl.hasVoted('${id}').then((x) => {console.log(x)})
} catch (err) {}
not sure if it is response code but it's a concept
after the request?
yea
that is a different story
lol
let me take a look
this is the api chat lol
oh wait do you have a link to js dbl client?
hm?
github
idk
it is all correct tho
it just has connection issues some of the time
most of the time it works tho
not the point
oh
you probably can't check for status codes
it's the library issue
so try pinging the dev
@arctic arch could you help with this issue above?
the dev not the owner xd
who tf is the dev lol
i take it back
Js?
yea
Tonk made the js one
ok so i'm right
hello
Why is this page still wrong? https://discordbots.org/api/docs#pylib
how's it wrong?
The code is completely wrong 😃
I notified the dev of the python api and he said he will change it. But that was one week ago 😕
@vital anvil
@primal lark updated the readme, idk how long it'll take for the site to update (if it updates automatically)
OK thx 👍 
@golden wind I think they were manually pulled and made into the sites style
👀
@amber junco Uploading now, give it ~30 minutes to show
ok
Also, if you're using Discord.Net, I'm uploading the first release of the adapter project
which allows you to do
Discord.DiscordSocketClient.CreateDblApi(token);
and some extra routes for ease of use.
i'll have to mess with that when it comes out because i use discord.net
It's a seperate nuget package, to avoid dependency hell in the main package
It should pop up with DiscordBotsList.Api
ok so how do you catch an error, uploading to dbl using the api
no, try catch does not work
can the webhook post without a vote happening? like for a test
javascript
just upvote the bot yourself to test 
wow i'm smart

can I get some help please?
@vital anvil I still can't install it
it needs something on there that says its compatable with net framework4.6+
.
@sacred horizon .catch
users can dm bots and they can chat in dm
my bot uses 4.6.1 and I can't download it because it isn't specified as a requirement on the nuget page still @vital anvil
@amber junco It should work on 4.6.1 based on this https://docs.microsoft.com/en-us/dotnet/standard/net-standard
the only issue is that I can't install it because net framework 4.6.1 isn't part of the requirements. my bot is based solely on the main net framework api and not any net standard or core apis
Will the webhook fire multiple times if a user votes/unvotes and repeats?
Does DBL always use the same IP to post to the web hook?
Ah thanks, I want to make sure that users could not fake a vote by posting to my web server
it does for now but possibly not in the future
In that case, will it be possible to add something like an authorization code, which in this case we devs can set?
@snow fiber Didn't think of that. Heh.
@vital anvil .NET Framework 4.6.1 implements .NET Standard 1.4 apparently. is there a way to backport the api to that?

That seems weird
I'd prefer to keep it on a more modern version to make sure people keep out of dotnet 1.x versions :shudder: that was hell
1.6 should do, just update to a more recent .Net framework, nothing bad will happen to your code other than having either more language features or performance improvements 👍
I'd also highly recommend dotnet core for bots, as it is designed for lasting microservices instead of desktop clients
@snow fiber you can add the authorization code in the query parameters. (e.g.)
my.domain.com/webhooks/dbl?auth=198234ijifewwef
Hmm would be neater tho to have DBL send it as a header
How often is /bots/id/votes updated btw?
No other webhook does that I guess
As their function is to send from server to server
🤔
No idea about the update
As long as it is not every request
What is the value "legacy" in getting information on a bot?
tonkker does the API sorry fren
reee
Does the API ever in any case send anything with any "expires" tag?
how do i show servercount
What language are you uding
js
Try the js lib :p
k
Does this channel also count bugs with the API docs website?
yes
Okay.
actually if its a bug on the docs page itself i'd put it in #267327844357636097 because i think by "SUGGESTIONS/HELP/BUGS" in the topic it means bugs with the api itself
it does but oliy told someone to put a bug within the docs page on #267327844357636097 so ¯_(ツ)_/¯
i suppose it doesn't really matter
idk
@ashen hull legacy: true if hasn't edited since beta was announced may disappear at some point
@short forge Little late, but if you still have the json issue, ' isn't a valid character, it must be "
Can someone give me an example of discord.js dbl
look on the api docs
it has everything there
I couldn't find there
@normal sleet Yup
@cobalt ruin I want to server count with teh api, I have done making const but after I am not getting help from api.
true if hasn't edited since beta was announced may disappear at some point
again, Does the API ever in any case send anything with any "expires" tag?
i really need that information
It doesn't because fuck CloudFlare
? because ONLY when sending stuff to the list, it does not work. i dont have the exact error, but i remember it being about some "expires" tag being unknown
Well if anything is weird you can blame CloudFlare in all honesty
Unless you mean a different type of "Expires" (not Ratelimit) then it might be the cache
why cloudflare, if its being hated?
because it allows dbl to not be ddosed and prevent access to certain sensitive data
more easily than if oliy were to code it himself
we are hoping to move away from cloudflare for our ratelimiting service soon.
hey guys, why is this happening when i try updating my server count?
0|givaway | { Error: Cannot find module 'discordbots-api'
0|givaway | at Function.Module._resolveFilename (module.js:538:15)
0|givaway | at Function.Module._load (module.js:468:25)
0|givaway | at Module.require (module.js:587:17)
0|givaway | at require (internal/module.js:11:18)
0|givaway | at Object.exports.run (/home/tony/Givaway/commands/usc.js:8:33)
0|givaway | at Client.client.on.message (/home/tony/Givaway/givaway.js:22:17)
0|givaway | at emitOne (events.js:116:13)
0|givaway | at Client.emit (events.js:211:7)
0|givaway | at MessageCreateHandler.handle (/home/tony/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
0|givaway | at WebSocketPacketManager.handle (/home/tony/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:103:65) code: 'MODULE_NOT_FOUND' }
i'm using https://www.npmjs.com/package/discordbots-api ^
DiscordBots-API | A API Wrapper for DiscordBots (bots.discord.pw and discordbots.org)
That's not our official library, you should use https://www.npmjs.com/package/dblapi.js for better support in this chat
alright, i'll switch over

changed over now, i got another error haha but i'll put it in #development since its a handler error, thanks though 
i've ended up manually updating my count for now ^^
@humble bison that's my npm package 
oh
for the js api, since it returns true or false in the promise, how do I check whether it is true or false?
for hasvoted
await is a thing
(async()=>{await thing()})()
Is there a python API
prob





_
