#topgg-api
1 messages Β· Page 34 of 1
open the port 5000 in your router so requests can be sent through it
can someone help me with setting up the webhook thing?
i'm just googling how to port forward
will this work once i upload it to Heroku?
what will I have to change to make it work on Heroku
Heroku should open a port for you
Should i make a PR for dblapi.js for the weekend doubler support
I'm working on it
i care much more about getting it to work on Heroku than my laptop. Does that mean that I don't need to bother with this port forwarding stuff if I only care about Heroku?
its good to learn
upload it to Heroku and then start it. It will tell you the port
you can also type heroku open to open the webhook page
I think so
k
can you help me with setting up the webhook server?
I have it installed on my vps, I just don't know how to use it
POST http://IP:5000
what do you have installed on your vps
@arctic arch isn't it accutally better to use destructuring like
const {body} = await this._request('get', `weekend`);
return body;```
I got the stuff from here
https://github.com/thousandeyes/simple-webhook-server
@median cedar
I got this back
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /</pre>
</body>
</html>```
why destruct tho
i'm afraid i can't help you with that one, i'm new to this today π
are you able to send a POST request to yours?
how do I find the IP of my Heroku application? it's just saying http://127.0.0.1:5000/
https://discordbots.org/api/docs#bots
Individual User Id Voting Check for the past 24 hours.
Will that change to 12 hours?
probably
Even though the endpoint doesn't even work
it works for me
Always returns 0 for me
at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=smileybot-webhook.herokuapp.com request_id=a87ba71d-da5d-44c6-9a8c-d9deebd1a952 fwd="92.234.80.47" dyno= connect= service= status=503 bytes= protocol=https
what does this mean?
this was in the logs after typing heroku open and being confronted by an error
This channel is for DBL API only go to #development
this is about the DBL API

the "test" webhooks seem to arrive at my bot okay, but the real vote webhooks seem to not arrive?
nvm it did work
just delayed
@arctic arch isnt the vote cooldown 12h now
+ * Returns true if a user has voted for your bot in the last 24h.
or did i miss understand that part
thats the cooldown ye
Hey, can anyone tell me the timezone that the API uses for monthly vote-tracking? Want to make sure my bots' code is lined up
London
Quick thing - doesn't seem like the double votes gets registered properly. When I run a get request, it doesn't take into account the double votes.
My vote count should be at 6 if it was.
Also noticed due to a discrepency between my calculated value and the value on the site - my code calculates 48 votes, while the site displays 56
how does your code calculate it
@arctic arch Throws a call to getVoters, which returns a list of users. Loop through the users, adds 1 to a total amount, and adds 1 to a hash where the key is the users' id, and the value is the users' total votes
Hasn't been wrong until the double vote
multiplied votes aren't in the list twice
Tonkku is everywhere ._.
i need help
how to send my bot guilds size on the shard
i get error
Which language are you using?
What's the error youre getting?
Something is already using port 5000
Use a different port?
i fix it
I just tried the API and used UpdateStatsAsync and set it to my current guild count. Does it take time to reflect in the webSite ot I messed something up
C# api btw
how can i request from the bots api with python?
i mean can someone give me and example of a request url?
@restive otter https://discordbots.org/api/docs#pylib
The example is here
...
How long does it take to reflect the changes in the website?
google does not help
@uncut crystal Firstly sorry for ping but I really need help on https://discordapp.com/channels/264445053596991498/412006692125933568/469946640741171240 and not because I want to get it working but because I messed something up from the examples on the website and now it shows that my bot is in 2133 servers which is just not true. I'd really like not to get banned for doing this as it is againt the rules. So how to corrct or completely remove it? π€
Again sorry for ping.
just send another request setting it to the proper value
await Global.MeBot.UpdateStatsAsync(21);```
Ive been doing this for like 10 times
Stll doesnt work
Has anyone made a new bot?(like just now?) Cause I wanna test it lol
not really appropriate for this channel
@gray dove I'm not familiar with the C# lib API but just making the request manually will always work
Well sadly it still shows 2133 servers desite the updates and i have this feeling that imma get rekt for this
nah
2133 isn't a very extreme number + you've warned us and you're trying to fix it
Do you have access to curl?
Nope
Anyways thanks for help. Ill wait for some c# dev to read this n fix. just happy that i wont get banned xD
yeah, don't worry about that
π
@gray dove
- #development
- did you use authorization properly? I mean ID and API token.
- by breakpoint you can see exactly what's wrong with HTTP request, like "404 not found" "bad request" or "unauthorized" etc
so i was wondering is voting kinda broken? I have some users that are having issues voting with the new 12 hour vote system
@honest root ey boi
...
so I don't quite know how to contribute (or commit to a open pull request of someone else) but the library already automatically serializes json
Keep it on topic please
hi im ok, u having questions on discordapis?
yo
Which library?
.net
Can u help me make a bot?
π π library developer role
Just wanted to make it clear who I was talking to π
@vital anvil I only make the java lib kek
-_-
I made the .net lib π
do you know how to push to a uh
pull request from someone else
do I fork their repo and PR there?
Nay nay
oof
go to the Pr and scroll all the way down
I had to learn how to do this today too hahah dw
I felt like what I have done does not looks pretty nice, but wasn't sure what to do, so you saying I have to get rid of dynamic object and use existing Deserialize?
and... me? I have contributed it.... I guess...
Sure thing
π
Nice pinkish
tbh i cant tell the diff between the lib dev color and teh mod color
With veld's small name, I mean
π
π€
π
So no matter what my .hasVoted() check returns false?
Which lib?
i'd assume js lib
js yep
does the weekend multiplier apply to GTM or the voter's local date ?
I think UTC
okay thx :)
if (isWeekend(gmdate())) { ```
something like that I gues
function isWeekend($date) {
return (date('N', strtotime($date)) >= 6);
}```
I think it doesnt take Date
isWeekend returning true or false here: https://discordbots.org/api/weekend
oh thx
function boolean isWeekend() {
$r = new HttpRequest('https://discordbots.org/api/weekend', HttpRequest::METH_GET);
try {
$r->send();
if ($r->getResponseCode() == 200) {
$json = json_decode($r->getResponseBody()), true);
return $json["is_weekend"];
}
} catch (HttpException $ex) {
echo $ex;
}
return false;
}```
like this then?
I'm not so good in requests in php
so im trying to run my voter only command and it says i didnt vote even though i did? im using .hasVoted() function for dblapi.js
try again
I've added the DBL dependency and repository to my maven project, now I'm kind of stuck on what to do next. The instructions are really confusing
<dependency>
<groupId>com.github.DiscordBotList</groupId>
<artifactId>DBL-Java-Wrapper</artifactId>
<version>1.0</version>
</dependency>
still says i didnt
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
I need help π idk if I'm stupid or not but I tried at 4 in the morning to do it, and I wasted an hour with no progress
please ping me if u can help
@austere crescent yo yo yo
The current lib is really old
I'm remaking it on the rewrite branch
Here, let me get you a dep that'll build that one for you
Here -- use this as the version: e592e99
Once there, follow the readme in the rewrite branch
DBL-Java-Library - An API wrapper for https://discordbots.org/api/docs that works in Java
Thanks heaps
@inner venture Ooh. I'm liking the changes you've done to it.
Thanks for taking a look at my changes, by the way! 
Hahaha
They served their purpose 
I cloned the master repo and built ontop of that
until I got responses from the API
lmfao
Never used retrofit. Seemed fun Β―_(γ)_/Β―
Yeah, it's nice for making simple api clietns
but any more complex than that, it's not so great
thats why I ended up ditching it for more control
Yeah. I've just basically switched to webhooks now. Streamlined my copy of the library to the basics
Tbh
I kinda wanna add webhook support for the lib
but i kinda feel like its an overreach
I dont know
It'd be a pain for the enduser to setup
Maybe
I've really badly cheated w/ my webhooks
the webhook goes to my website, which parses it and sends a message to a channel on my Discord that my bot can see, which then it sees, and parses the data.

It works
eww
I needed a quick and dirty way of setting up the webhooks 
I mean - it's not horrible. When the bot goes down and comes back up, it scans through the channel and parses the votes that are there
So
Β―_(γ)_/Β―
Oh that's even more eww
How can I request from the api with python?
I think someone made a python lib for this
I wish
Only thing I need is the url format
Like example url
Oh and
I have another problem
My widget does not update
Tho I have the loggin setup
There is a Python lib
https://discordbots.org/api/docs#pylib
https://github.com/DiscordBotList/DBL-Python-Library
http://dblpy.rtfd.io/
DBL-Python-Library - A simple API wrapper for discordbots.org written in Python
alright
Tbh it's an interesting way of creating messaging
Why run a message queue if discord can be your message queue 
i cant get the webhook part of dbl to work
Whats up alek?
i think i need to put the address to my webhook in the edit page 
nevermind, that wasn't the problem
and im pretty sure i have everything declared correctly
i was typing webook instead of webhook in the events
works now?
well, the bot is connecting but still no response from the servers
though i dont know how to use http servers
though im not super sure this is what its supposed to be displaying
port forward and all that stuff?
port 0?
i did, i even tested it with my app that i made for things like this and i got an ERRREFUSED
no response from the webhook of course
port is 0 when the webhook is attached to an existing server
whatever that server is listening to is the port but I can't really tell what it is
i have http.createServer(app) listening on 5000
idk if this is the right way to arrange this stuff
i give up
that is correct
Wait why is he trying to listen again on the same port?
That would create an exception, wouldn't it?
I dont see listening twice
I mean, the lib listens when you first create the object according to the docs. But again he has server.listen which listens on what I assume is the same port
if you look at the options, they have attached that server to the webhook
Ah gotcha. My bad
yes kef
What lang did you write your bot in?
js with eris
Are you using the python lib?
ye
i used the codes for server-count from #312614469819826177
it loaded the module without any error so far
but doesn't seem to work
it's outdated
Use the code here
if i dont use something like express will that work too?
No idea honestly
just puting in webhookPort: 5000, webhookPath: '/dblwebhook' into the args
planning to put this onto my linux later yeah, why
Try running it as admin
I was trying the same thing but in another lang and it only worked when I ran it as admin
Visual Studio Code is already running as admin, and it asked me if node was allowed to run through the network
and i allowed it
i really just followed https://discordbots.org/api/docs#webhooks that
Why is there a global in https://discordbots.org/api/docs#pylib ???
you need admin for ports lower than 1000
well i am using 5000 so idk
are you sure you set up port forwarding right
it is
try requesting 127.0.0.1:5000 with postman or something
i dont have postman
@full socket ty got it
hang on im grabbing postman
@restive otter no problem
going to get a response from the webhook at the 127.0.0.1:5000/dblwebhook gives me
switching just the api gives a blank response
still no response from anything like the test button
would the api be considered a public network?
did you switch away from express?
i did and it left an empty response
wait, cannot post was with express
a blank response with some 400 should be the webhook itself in action
they all are 404
ok i have express commented out and node allowed to work on a public network
yeah, all 404 not found
that's odd
OOH i got a bad request
i went through 127.0.0.1:5000/dblwebhook instead of just 127.0.0.1:5000
yeah
though, instead of it actually doing anything, the website didnt do anything still
no vote confirmation or anything
A stupid question but are you sure you're using your public ip address on the website instead of your local network address?
im using my public on the website
Because it's either that or your firewall is blocking something
lemme try on my linux machine
make sure it has http://
btw
it would also help if i install the api to my linux machine
@full socket i was trynna code a page in html
and it said malicious code
π€
tho there wasn't any
I think if you're not certified you can't use JS. Wait for Tonkku to reply though, I'm not entirely sure
k i got a 400 from public netork
Okay that's good
oh
I think
yeah you have to be certified
is it okay if i mention tonkku
π€·
or big moderator mentions are bad too
@arctic arch i was trynna code a page in html on discordbots.org for my bots description but it said malicious code and didn't let me use it, what is the possible reasons for that cause i am sure there wasn't any malicious code. Please ping me if you are able to reply anytime soon
yeah you have to be cert
do you have any onclicks or anything like that in your html
or maybe you have meta tags
yes to change the commands tab
@snow sky any luck?
I still need to sign into my other alt
how do I do that?
they already sent you the answer in #development
shouldn't this say 12 hours instead of 24?
I've been trying to do this for a while, but it's consistently not working. I've added these to my pom ```
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.DiscordBotList</groupId>
<artifactId>DBL-Java-Library</artifactId>
<version>e592e99</version>
</dependency>
</dependencies>
But my maven project still says this when I look at the dependencies: Incomplete result, processing indices
And when I try to do java DiscordBotListAPI api = new DiscordBotListAPI.Builder() .token("token") .botId("botId") .build();
it says create class DiscordBotListAPI
please ping me if you can help
@austere crescent I ended up making my own library from scratch because I couldn't get the official one working. It only works for updating server count though π€·, but if that's what you want to do I can send it to you
the library wasnt the problem
oops
its just that they didn't update the number 24
wrong person π€¦
exdee
@austere crescent
yes?
scroll up 5-10 messages
kk I'll DM you when I have access to my dev computer
okay tysm
this is what i have for mine
im not sure if the botID matters
also im using branch 4b27930a63 instead of e592e99 if that helps
yea, it might xd
also whats the exact error?
Well, when I try to create a DiscordBotListAPI object it's as if I don't even have the dependency
pretty much
ouch
yea lol
did you rebuild the project with the version i recomended?
yea
still nothing?
π
Incomplete result, still processing indices lol
wait there we go
I think it might be working
Finally
ok the import popped up
It's working now, thank you @amber dune
Just in case, here's my code anyway
public static boolean updateStats(int payload) {
try {
URL url = new URL("https://discordbots.org/api/bots/<YOUR BOT ID>/stats");
StringBuilder postData = new StringBuilder();
postData.append("{\n\"server_count\": " + payload + "\n}");
byte[] postDataBytes = postData.toString().getBytes("UTF-8");
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
conn.setRequestProperty("Authorization", dblToken);
conn.setDoOutput(true);
conn.getOutputStream().write(postDataBytes);
// Everything after this is old debug stuffs
Reader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
StringBuilder sb = new StringBuilder();
for (int c; (c = in.read()) >= 0;)
sb.append((char)c);
//System.out.println(sb);
return true;
}
catch(Exception e) {System.out.println(e);}
return false;
}
no problem!
guys
this doesn't work
#1 Posts the server count for the whole bot.
int serverCount = ...; // the total amount of servers across all shards
api.setStats(serverCount);
did you try my code?
no π
try it π
ok
so the dbl token is https://discordbots.org/bot/467976293166874634 <-- right?
no, it's the api key
no
I just called them tokens in my code for some reason
https://discordbots.org/api/docs#mybots go here and then click on the bot you want to get the api token of @austere crescent
okay thanks again for helping π
no problem!
dblapi.js doesn't seem to work with the internal sharding build of d.js ;;n;;
hey @cobalt ruin, do you think to add TimeVoted or TimeLeft into isVoted request? it would be pretty nice for developers, to show how much time left for the new vote
P.s. I suspect that you thought about it, and most likely you do have reasons not to do so, but still wanted to ask ._.
Yeah true, that's a good question :D
At what guild count is it also displayed at the site?
you need to post your guild count yourself
I am, but it's currently 15, so I thoght there might be a minimum limit before it's shown on the site
though if your bot drops to 0.. 

I'm using d.py
The dbl.Client should really have it's own logger. I'm already saving the root logger so when I didn't see any errors I thought I successfully posted the guild count
nvm, it does have logger, it's just logging only to debug so It was hard to find it
@elfin solstice actually 0 would result in an error
Technically bots can be in 0 servers. When they are so unwanted by their owners that even they haven't invited them
rip

in the js api sending '0' will result server count to be N/A
anyone else here getting GenericCallAdapter factory errors when trying to get votes with the java lib?
Hello everyone !! can you help me please I do not understand how I can post my server account on your API
how can i send a message when a user votes?
ok
I completely forgot about webhooks at the time I asked that question... 
i got a question about rewards for votes.
my bot is using a system where many commands are locked for non supporters and only available for patrons.
https://discordbots.org/api/docs#votes here u are saying that i am not allowed to lock features behind votes.
i would like to make a giveaway for my users, they would have to vote at least 5 times a month to enter. the winner will be able to use all features of the bot for a month without having to be a patron.
is that acceptable?
a small amount of votelocked commands are allowed but you may not lock most of your bot
that sounds acceptable to me
okay thanks
Is it possible to make the bot only usable to people who voted for my bot using the api on javascript
u can use the webhooks and store every user that voted in a database
although i dont think its allowed to make the bot only usable by voters
Is it possible to receive DBL Upvote Webhooks without having to port forward?
API keys are only for people who have bots added to the list
@restive otter Technically, but it is not allowed, see https://discordbots.org/api/docs#votes for our policies on vote locking
Hey, Is there anything else I need to do in order to check whether or not a user voted? Such as add my server count to the dbl website?
Will I still need to Port Forward?
Hey, i just want to search for a bot using user input and get the bots info as an image that my bot can display in a server. Can anyone help me? The api docs are a little bit unclear
You can use GET /bots and use the search parameter
Use a limit of 1 so you get the first result
Alright
Ok thx but how to get the little widget image?
Oh wait
You where not speaking to me Auxim?
@restive otter Use /bots/ID for that
@restive otter Under 1000 votes/month you can use the /check endpoint
https://discordbots.org/api/docs#bots it's on here
how do you install dblapi.js in heroku?
Is there a way to make the votes webhook rerun if it gets some response?
does anyone know the answer to my question?
heroku. Why not just pay that 3$ a month for real vps
cuz i dont have the moeny XD
@restive otter https://discordbots.org/api/docs#widgets these widgets?
Auxim i use snekfetch, and i am not very good with http requests could you build an example querystring with a searchterm of any word and a limit of one bot?
Whats the start of the link with this endpoint? /bots/{bot.id?}/check
https://discordbots.org/api/docs#reference documented in the API reference
You should handle getting 0 bots and stuff like that
You can just get the value of total from the JSON response
@restive otter just like u did with d.js and any other lib
Is it in ya packages.json
he
hey
where do i put
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
?
Thisis how you would do it right?
unirest.get(`https://discordbots.org/api/bots/463384270887452673/check?userId=${message.author.id}`)
.header("Accept", "application/json")
.end(function(result) {
if(!result.voted === 0) return message.channel.send({embed: { color: premiumConfigRow.embedColour, title: `Queue | ${message.author.id}`, description: `[**You must upvote Gamer to get access. Click here!**](${config.upvoteLink})`}}).catch(console.error);
For some reason, oh wait
nvm
whats this?
ok my dbapi works
how do i do the vote to access command?
anyone?
Okay, I am also having trouble with this:
unirest.get(`https://discordbots.org/api/bots/463384270887452673/check?userId=${message.author.id}`)
.header("Accept", "application/json")
.end(function(result) {
if(result.voted === 0) return message.channel.send({embed: { color: premiumConfigRow.embedColour, title: `Queue | ${message.author.id}`, description: `[**You must upvote Gamer to get access. Click here!**](${config.upvoteLink})`}}).catch(console.error);
Thats how it should be, right?
But when people use the command it allows them to use it, even if they have not upvoted.
@restive otter basic node js
hasVoted(id) returns a promise
hm.m..
@sudden depot i really dont know how to do it
Okay, I am also having trouble with this:
unirest.get(`https://discordbots.org/api/bots/463384270887452673/check?userId=${message.author.id}`)
.header("Accept", "application/json")
.end(function(result) {
if(result.voted === 0) return message.channel.send({embed: { color: premiumConfigRow.embedColour, title: `Queue | ${message.author.id}`, description: `[**You must upvote Gamer to get access. Click here!**](${config.upvoteLink})`}}).catch(console.error);
Thats how it should be, right?
But when people use the command it allows them to use it, even if they have not upvoted.
@restive otter can you show me your vote to access command for the command play?
Thats it
does it work
insert it into the play command. No, im trying to find a fix for it
when you do can you show me?
@restive otter tjere is also a lib
But can u log result.voted
I dont want to log it to console. I want to message in chat if they did not upvote
Thats the problem...
I mean u could log it and look at the output but ....
What am I logging? result? or result.voted?
Both
Okay, in the result.body, it says unauthorized... How do I authorize?
Go to your bots edit page and scroll all the way down
Something's not working with what you suggested @snow fiber
My bot just breaks. Stops working completely
And if you console.log results?
i found it with PM2 logs
when bots use /tts is it considered api abuse?
what's the format for the username field when using the search query?
@sinful dune this channel is only for the DBL api
Boi
What
why Boi?
oki then
Traceback (most recent call last):
File "C:\Users\tasty\Desktop\owo bot\cogs\DBL.py", line 25, in update_stats
await self.dblpy.post_server_count()
File "C:\Users\tasty\AppData\Local\Programs\Python\Python36-32\lib\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 "C:\Users\tasty\AppData\Local\Programs\Python\Python36-32\lib\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 "C:\Users\tasty\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dbl\http.py", line 160, in request
raise Forbidden(resp, data)
dbl.errors.Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}``` I get that error when I run my bot
wrong token most likely
do you set the token before you call the post_server_count() method?
"""Handles interactions with the discordbots.org API"""
def __init__(self, bot):
self.bot = bot
self.token = # 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))```
im using that
from the website
!ftn Lezzim
Probably not your issue but just want to say make sure it is dbl's token not discord
It's dbls token
what version is the maven java library or the api
cant seem to find it anywhere
for*
@keen citrus ```py
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count"""
await self.bot.wait_until_ready()
while not self.bot.is_closed():
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)```
try that for your update_stats library
possibly it's trying to post with null data?
"forbidden" isn't the most creative of errors
I only added the wait_until_ready and changed while True to while not self.bot.is_closed(), by the way
got it for anyone else that may have the same question here it is
<dependency>
<groupId>com.github.DiscordBotList</groupId>
<artifactId>DBL-Java-Wrapper</artifactId>
<version>v1.0</version>
</dependency>
Hey so I just recently started getting this error when posting to dbl.. UnhandledPromiseRejectionWarning: Error: 401 Unauthorized
By chances is my API key wrong?
(my server count wont update)
I've tried regenerating the api token and still nothing
Hm.. if you've tried a new API token then dunno.
Is there anything I can do? I've tried removing dblapi and reinstalling with npm install dblapi.js, regening token.. I'm not sure what to do.
can you post your code?
const DBL = require("dblapi.js");
const dbl = new DBL('thetokenforDBL');
//and then in a setinterval:
dbl.postStats(bot.guilds.size, bot.shard.id, bot.shard.count);```
I forgot to mention that I think this started when I moved onto a vps...
Could that somehow be a problem?
The full error:
0|server | (node:31142) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized
0|server | at IncomingMessage.res.on (/home/dark/Arcane/node_modules/dblapi.js/src/index.js:115:25)
0|server | at emitNone (events.js:111:20)
0|server | at IncomingMessage.emit (events.js:208:7)
0|server | at endReadableNT (_stream_readable.js:1064:12)
0|server | at _combinedTickCallback (internal/process/next_tick.js:138:11)
0|server | at process._tickCallback (internal/process/next_tick.js:180:9)
0|server | (node:31142) 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)
0|server | (node:31142) [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.
At this point I've reset the token 2 times now and still nothing
Error: 401 Unauthorized means that you dont put any token in the request
Would it be a problem with the token then? How would I send the token with the request..
in const dbl = new DBL('thetokenforDBL') the token is wrong
i mean
the one in ur code is wrong
but
hmm
well thats the only place you can set the token
That's what I thought. I have no clue what's happening..
I was able to fix it by using dblapi.js@2.1.0...
ok let my try
const client = new Discord.Client(); const DBL = require("dblapi.js"); const dbl = new DBL('Your discordbots.org token', client);
k
That's what they provide on there api docs and it worked for me
same issue
What's the error
401 error. This is on dblapi.js@2.2.0.. on 2.1.0 there is no issue
Uhm kk I guess use the one that works for you. Or wait for a mod or something
Yah Idk.. as soon as I switched back it worked.
I am trying to find a way to hide my DBL token from my github though the bot is hosted on Heroku...
.gitignore or .env, depending on what you wanna use.
ok
env is better
env files can't be accessed by anyone other than you iirc
Wrong channel @celest root, use #development.
@humble bison sorry, thank you!

@humble bison it was a question about the dbl api tho...
and the link on the discordbots.org site is outdated
i have voting benefits but some users are saying that they lose some of their benefits randomly. does the API reset the log of who's voted for the bot at any point?
what are you using
/votes endpoint
this might be your problem then
i only have around 100 votes
ive had an easier time just setting up the webhook
i think ill do that and store it in a DB
what maybe i do have 1000 votes
page only says 136
oh well ill use the webhook then
idk if /votes returns votes of all time
i pulled votes and it was 1000 votes but the website says i have 136 votes
and if i click on the bot then it says i have 90
i assumed one number was the total and one was the weekly or whenever it resets
π²
monthly
so what are the numbers?
did u vote like 40 times for the bot urself?
i think ur own votes dont show on the bot page
i think so
no idea what makes the difference in the numbers, but imo the webhook is way better anyways because u can react to votes instead of having to react to a command and check if that persoon really voted
can i ask what library you're using, and how you've implemented webhooks? python examples seem to use flask but id prefer to try and keep it as one application
im using java (d4j) and used spring boot to setup my endpoint for the webhook
oh okay, thanks
can you not have flask in the same application?
probably but id need to start threading it and the audio library keeps seg faulting so i dont know how itd play
is a webhook just a reversed API request?
basically
ok thanks
bot.dbl.getVotes().then(console.log) gives me 1000 random people
where https://discordbots.org/api/bots/432945787756871696/votes only gives me real people that voted
seems to be a issue with dblapi.js
can you send me the data you get from both
can you also DM the token you used
also does anyone else have the same issue
does the webhook exclusively use https?
no, it can use http as well
something was wrong but ive left it alone for 10 mins and now it seems to be working so thats good i guess
@arctic arch when i get a widget from the api can i get it in PNG format?
yea
how exactly?
just do .png
oki!
instead of .svg
thank you! i was hashing over my conversion options
Thanks @arctic arch i now have a working DBL command!
ππ»
who
What?
ghost pinger 
I hate them
.
channel only for dbl api not jsut chatting
In another server
.
I was talking in #memes-and-media
does the webhook fire if someone upvotes/unvotes/upvotes again, or does it only fire once a day or something for each person
basically so users can't keep unvoting and upvoting every minute to get free premium on my bot
u cant unvote?
oh, you're right, it's not letting me. it used to be possible before
You can only vote every 12 hours now
thanks, that's useful to know
Also voting on the weekends counts double now, but it's still up to you wether to implement that
π
you get the user's object and you do stuff with that
the vote.user is just the user's id
yeah
np
how to setup @sacred tinsel
@ripe linden nothing, if you don't want to
i highly suggest choosing a auth secret though
if you don't set one others can just make requests without you knowing it's actually DBL
ok
It is automatically set
It is in the constructor of dbl.js
Look at the example in the docs
You need to forward a port for that
Google it up
It is too long to write
Hello, does the getVotes () function only return the votes of our bot?
<@&304313580025544704> β¬
It is marked in the documentation "Gets votes from your bot" while the API returns me a lot of votes.
@azure yew i would recommend you to not try pinged all mods for help next time or you get muted, see #460037222331187200
yeah
it gets the last 1000 votes
although I would recommend webhooks as they are easier and less api heavy
@azure yew
But he returns the last 1000 votes on all the bots not only mine? @mystic wing
your bot
actually there seems to be a bug in the API that causes wrong votes to appear when you use the token
@azure yew can you send me what votes you get
@arctic arch
Find the stats of your account with any settings, link your account, match history and many other things
I dont have 1000 votes on my bot x)
can I see the top of the list as well
@arctic arch
because its not discordbots-api its dblapi.js
read up
read up
ugh
For those using the Java lib, I've just pushed an update for it -- 2.0.0
Feel free to give it a spin
meanwhile none of the admins acknowledge my library
@restive otter which one is yours
like a link to it?
sure
I emailed (and pm'd one) the admins because of this
it's been like 3 months and no response, not even a "no thanks" or something
hmm
sure, it's ruby, but still
π€
april 28th, email sent with links to it and "let me know your thoughts"
Why canβt we get the bot online status with a API request?
Thatβs the one thing Iβd like to get, not only server count and such
@restive otter, it'd be cool, but seems pointless to me when its done automatically. Plus, that'd be a LOT more API requests y'know.
No I mean when doing a get request to have the bot info knowing if itβs online or not
Cause Iβd like to use this to display its status on my website with the server count
Oh, that.

I guess it'd be cool, but yeah you can't.
(there is a good workaround that exists, but yeah)
You can get this information directly using discord API
yeah so like
not really
presences are sent thru ws not rest so it'd be a pain to get online status from discord without having an api in ur bot
@restive otter I agree, ruby is pure awesome
It deserves it's own library
yes mine also its*
@wary trench
@rigid zinc
What does that have to do with DBL's API @ruby obsidian
-bots @restive otter
@lean lance
@merry juniper
@tribal harbor
@silent oxide
Please dont do that here
@azure yew could it be that it's returning all unique voters. Like everyone that has votes for your bot, expired or not
soz
-bots @craggy torrent
@jaunty gulch
How can I use webhooks?
I've read the page already
I placed the webhook
and i tested it
but it isn't sending any messages
it's not a discord webhook
What's it then?
its a webhook
The dbl webhook wasnt designed for discord
hey does anyone know how to create a patreon if you pay then get access to a command in heroku?
the way i do this is by granting patrons special roles on my support server. the bot then checks if the user has that role and only lets him use the command if he does. @restive otter
-bots @restive otter
This user has no bots
Oh forgot sorry ;c
I thought I was in #commands
@frank glacier can you help me with it in DM?
sure
ok
(Sorry, I assumed this was testing like Tommie did-though in my case it was because I saw his chat first)
Yeah I don't know how to use this api...
let tde = bot.guilds.get("429995294542004225");
let ch = tde.channels.get("471779437164101652");
ch.send(`User <@${vote.user}> has just voted for Automator! Thanks for voting :smile:`)
})```
Tried that and got the error "Cannot read property 'on' of undefined
const data = new DBL('TOKEN');
And I have that at the top
Is there any steps I am missing?
I just coded it in like this
I made a webhook too
And added the link onto DBL
Still getting the same error
Anyone ._.
const DBL = require('dblapi.js');
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
you need to specify webhookport and webhookauth i guess?
i never used it myself tbh
@karmic veldt you need to define the webhookPort option to start the webhook
and make sure it is a port you are 100% sure will not conflict with some other program
the password is what you enter here
if you leave that empty, you dont need the password
i.e. how some people who use nginx make their website localhost on port 8080. Always gets me like "but whyyyyyy"
(so I set mine to 1337, 2552 and 5225)
Okay it turned on this time I think π
if you are hosting your bot on your home machine you need to do something called port forwarding
Nah its on AWS
aws also has some sort of port trickery
uhh.. quick g oogle.. not sure if accurate https://medium.com/@rakeshkanagaraj1990/aws-nat-instance-port-forwarding-475fbcf2585f
..
@restive otter bcs port website.com:80 and website.com:8080 and website.com are the same
:80 and :8080 aren't the same
Idk what to do
Do I need to do anything now Tonkku?
Or just specify it in code
Orrr
Well in webbrowsers
so you set port 5000 in the code?
Yeah
enter the url on the edit page, save and hit test
if nothing happens (and the url is correct) do the port forwarding bit
The port forwarding tester is a utility used to identify your external IP address and detect open ports on your connection. This tool is useful for finding out if your port forwarding is setup correctly or if your server applications are being blocked by a firewall.
specifying port on my website's address doesn't work even when it's 1337 PLASMA, coz it's not set up that way. In short: DigitalOcean VPS has NGINX running, this has a config for a reverse proxy to localhost:1337 which is a webserver ran by ExpressJS. DigitalOcean is also my Nameserver as configured in my registrar, Namecheap
so it doesn't matter either way in the grand scheme of things
Let me try that
1 sec
Its closed
ffs
Just tried to open it and nothing
._.
@arctic arch You don't know how to Port Forward on AWS/Ubuntu do you?
I am so confused by these yt vids
and none of them open the port
._.
try the medium post linked before
Ok
I only know DigitalOcean Ubuntu / Debian.. those come with ufw (uncompilicated firewall) and would require allowing the ports through there. idk about AWS. The only AWS I use is Lambda for my Alexa skill ...
AWS let's you setup port forwarding via IAM security groups yeah. In DigitalOcean though you just got a basic firewall. You can however setup a reverse proxy (like haproxy or nginx) to do the forwarding instead.
The user id, that is being given by the API, is it also a user id for discord?
yes
@bold oak #development
is DBL constructed
yes
DBL = new blah()
yes
update the module then
thats ooold
...
recent is 2.2.0
did you change the require
that's a good time interval
ok good
the minimum recommended by tonkku is 30 minutes so yeah
i mean it's only got 11 servers and it's very niche so
beautiful
so i just globally installed the npm package for dblapi.js, yet my bot is complaining that that module doesn't exist
everything else is globally installed and recognised fine
this ain't working
also sorry for posting in multiple channels
alright, i fixed it
NODE_PATH was set to nothing, so i pointed it to the right place and it works
but all modules are installed globally, like discordjs, not just dblapi, no idea why that specifically failed, but anyway
@formal lily #development
yeah i wasn't sure if this pertained to dev or api since it had to do with the api but didn't necessarily do with api functions or what have you, sorry
Hey uh... DBL is showing that my bot is on 2 servers, but it's on 164 servers
I mean, I'm posting same way from like 3 months, just giving my bot onbject
But how can I log request? ```js
const dbl = new DBL(bot.config.tokens.dbl, bot);
I'm using this
It always worked
Ok I know the issue
Just version of my d.js isn't supported
gotta modify DBL api then
hmm?
DBL API just doesn't support internal-sharding structure
I don't have client.shard for example
ah
I have client.ws.shards
It's probably better to handle the requests yourself instead of using the lib in that case
is that built in d.js stuff now?
It's one of versions
or your custom stuff




