#topgg-api
1 messages Β· Page 33 of 1
who came up with the idea of using JSON instead of post parameters. Just a question
post parameters dont exist
no because you make no sensd
"post parameters" aren't really a thing
the data a post request generally carries is the post body.. which is exactly what JSON is in this scenario
JSON doesn't replace the post parameters, JSON is what the post parameters are already in
what would password be?
nevermind, ive decided not to include dblapi.js
I'm still having an issue using the API. I'm getting a 400 error whenever I send a request.
private static boolean updateStats(int payload, boolean disabled) {
if(disabled) {
return false;
}
try {
URL url = new URL("https://discordbots.org/api/bots/461938818627665940/stats");
StringBuilder postData = new StringBuilder();
postData.append("{\nserver_count: " + payload + "\n}");
byte[] postDataBytes = postData.toString().getBytes("UTF-8");
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
conn.setRequestProperty("Authorization", dblToken);
conn.setDoOutput(true);
conn.getOutputStream().write(postDataBytes);
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;
}
I recorded the POST request:
POST / HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Authorization: (TOKEN CENSORED)
User-Agent: Java/1.8.0_171
Host: https://discordbots.org
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-Length: 20
{
server_count: 21
}
I assume I'm doing something wrong, but I'm not sure what
ah, it might be my Content-Type header
nope
I think the content-type needs to be application/json and server_count needs double quotes around it
I changed the content type and it still doesn't work. I'll try the quotes now
didn't work
Try the dbl java library then https://discordbots.org/api/docs#javalib
I can't get it to work, but I can look at their code
that lib is broken af, last i tried to use it
from what the code looks like it (or some parts of it) were never really working in the first place
@summer oracle do you code java?
I do but I cba to implement the full thing 
i also have my own kinda thing already that works with several lists
would have PRd already otherwise π
I see
how do you make a bot
you don't
@bitter jay #development
@fast tapir that's invalid json
json requires quotes around the keys
also content-type should be application/json
Idk, I'm high on laughing gas rn
and what does that have to do with #topgg-api
hello!
is it possible to do batch vote checks? my voting mechanism is cached and I want to see if they've voted within 24hours...
and dbl doesnt provide a timestamp so the only possible way I know right now is to check individually with the check endpoint.
webhooks

anyone got a webhook URL Example in full, Thanks π
for me I just used this PHP script:
<?php
$headers = apache_request_headers();
if(isset($headers['Authorization'])){
if($headers['Authorization'] == "Auth 'password' thing"){
$data = json_decode(file_get_contents('php://input'), true);
$conn = new mysqli("127.0.0.1", "username", "password", "databasename");
if (!$conn->connect_error) {
$user = $data['user'];
$conn->query("INSERT INTO `voter`(`user_id`, `date`) VALUES ('$user', UTC_TIMESTAMP())");
$conn->close();
}
}
}
hosted it on:
https://somedomain.xyz/somepath/DBLvoteWebhook.php
and used the url where I hosted it on as the webhook url (obv. xd)
anyone got suggested apis to use for game stats?
@latent pebble
Not the best person for php, Could you explain what to change in your example π
you need the change the password to the "password" you set on DBL
then the mysql auth info
and the query
I just use this for MC server stats π€
API service for game servers.
i set a password? π when xD
wait I thought you knew more about DBL than me
I know everything apart from the Webhook side of things. not really focused on it tbh.
this is on the bottom of the edit page of your bot
yeah

quick learner π
well it just needs common sense xD
but webhooks are part of the API
^
not webhook, the chat part
that'd make the topic irrelevant
it was 4 replys xD
How do I make a webhook send a message when they voted for my BOT? π
since I'm using a PHP webhook, i just add it to db, check the DB and the local voter cache of my bot, then get if a new voter gets added.... do stuff.
http://bit.ly/2MUyvER
is this where the Webhook URL for the channel i want goes?
no that part is for inserting it into the MySQL DB
you do the bot stuff on the bot's side
Is there a way to check top upvoters per month?
Like storing who upvoted and make them on a leaderboard
Get the webhook into action, save the data you reviece from the webhook for a month into a DB, and at the end of the month check it.
How do I make a webhook say someone voted in a channel
I am trying to create my bot, but it is not being confirmed, i keeps saying "Please enter at least 300 characters excluding special characters in your detailed description. If you use iframes, you need to use at least 300 more characters.." but i have 315. COuld i get some help?
spaces are ignored
I have 315 characters
Nevermind
I hade 263
had*
its not able to fetch my application
did you create a bot account?
creating an application and a bot are different things
on the https://discordapp.com/developers/applications/me page, select the application you want to have your bot in
after that, scroll down and click on "Create bot user"
How do i get my bot confirmed?
You wait?
!help
Are webhooks working fine?
@restive otter
make a webhook in discord, and send it to that webhook when webhook.on(vote) fires
Oof, ok
If someone is already voted for first time does DBL send request to webhook we define after first vote?
Like after 24h which user can vote again
Ah yes it does
@uncut crystal Is it against rules to have users vote every 24h?
no
Thanks
hello, quick question. I doubt it, but is there any way for a webhook to be able to use emojis from other servers?
quick question: if i'll setup a webhook, it will send a message to a chanel when somebody votes the bot?
@crimson adder DBL webhooks aren't the same as Discord webhooks
unless you specifically configured it so your bot would send a message to a channel on a vote, it won't do that
@daring night what do you mean?
oh :C
@junior goblet When a user invoke the embed using a command, there is no problem. But when the bot sends a webhook notification about the same embed, emojis are messed up.
I guess it's because webhook is specific to a channel and can't see emojis from other servers unlike the actual bot
is this a Discord webhook?
the first image yes. The second one is a normal bot with commands
can you give me a bit more detail on what your bot does possibly? i was going to suggest that your bot sends the message to a pre-determined channel (through the bot account, not a webhook) but i don't know if this would be possible in your case
also, do you use the dblapi.js package?
It's a Java bot using Discord4J
ah okay
what i would recommend is to maybe make a HTTP server within your bot (or at least a HTTP server that can send messages to your bot) to which then the bot can send messages to a pre-determined channel
the HTTP server listens for the webhook, and once it receives it, it will send the message to the channel
does that make sense
Basically this is a bot for a video game called Geometry Dash. It has commands to get data from the game's servers (levels, users, etc), so for example when I do u?level XXX it will display info for the level named XXX, with an embed containing custom emojis.
The bot also has another major feature, which is sending notifications when an event happens in the game (new levels, etc). So when this kind of event happens, it will send a message to all servers that are "subscribed to event notifications" (server admins can choose a channel where notifications are sent), and the notification contains an embed of the level concerned by the event.
When I first developed the bot I didn't use webhooks at all, the bot was just reading the database to get the list of channels where to send the notification, and then the bot sends a message individually in each channel. The problem is that my bot is in 2500 servers, including ~1000 subscribed to notifications, and because of rate limits it's getting really slow to send notifications to all channels, and also causes CPU spikes on the VM where it's hosted (sometimes it even crashes completely). That's why I wanted to switch to webhooks so I could just send one request to each webhook of subscribed channels, and this way I could get rid of rate limits and save my system resources. But since webhook don't seem to support custom emojis, embeds in notification messages don't look good at all...
ah okay i see
so you originally did have it so the bot would send the message, but you switched to Discord webhooks
does the bot create a new webhook for each server it's in?
It checks for each channel if a webhook already exists, if not it creates one. If the bot doesn't have manage webhooks perms it will just ignore the channel
yeah, unfortunately webhooks don't have nitro features like normal bot applications so you wouldn't be able to use custom emoji
other solutions you could try is drawing to an image and posting the image, but you already mentioned that your CPU usage was high so that doesn't work well
can i just ask, in what ways were you hitting ratelimits on your bot? bots can post 5 messages a second per channel, so it doesn't make sense that it would hit the ratelimit that quickly
I don't know what's the ratelimit for sending one message to X channels. What I observe is that it's getting much slower as the bot joins more servers
I think I'll try again without webhooks because it might also be an optimization problem within my code
I'm believing that using webhooks would solve my performance issues, but it might not even be true
best of luck to you and the bot, hopefully you get the performance issues fixed
if you have any more questions or concerns don't hesitate to ask in #development 

https://discordbots.org/api/docs#bots What does avatar hash mean?
its the hash code of the bots avatar
I'm trying to use the dblapi.js webhook system, but I get an error on this.dbl.webhook.on (cannot read property on of undefined). I tried use await to wait everything, but it did not work too 
remove the this..?
this.dbl = await new dblapi(process.env.DBLTOKEN, { statsInterval: 900000, webhookAuth: process.env.DBLHOOKPASS, webhookServer: app }, client)```  no
Why do you await the constructor?
@restive otter
Also can you send the code?
Like full code, I am not sure what dblapi is
don't need what?
Hi
Is this ok?
const dbl = new DBL('<token>', {options: statsInterval=900000}, client);```
@restive otter remove the await in front of new
It might be because app is not an instance of http.Server
@restive otter change the = in the options to :
@arctic arch i forgot a .app lol, thx
ok
why do you have options:
How do you get a bot online?

you do you
Got it
is there a way to vote throught a command?
no
π
I don't see a status field in the API, yet bot pages show an online status
How can I get that?
you shouldn't need that since the bot is in here and you can get that from your lib via the id
@elfin solstice I'm trying to use it outside of my bot's program
you don't have to worry about the status, it's not related to api anyway
the status on the page updates whenever your bot changes it's own status
i think he wants to access the status
going to post this again...
/bots/:id/check seems less-than ideal because it doesn't tell during which period that vote is valid
So you have no real way of distinguishing one vote from another
providing the timestamp at which the vote occurred is a good idea
well for the exact date you should use the webhook anyway
since you can handle that yourself then (caching the date)
Hey I reseted my token and since then, I'm getting Unauthorized when I try to post my stats ...
Ok I tested the old one and that one is working 
there is an unfinished undocumented api endpoint
If the bot is on the site, itβs in this server (if it got accepted). Just get the bot ID and retrieve its status from Discord
I have alt accounts and the bots website thinks I'm getting the bots on my alt account and not my main account
what
@bright lake head to https://discordapp.com/channels/@me, click User Settings, click Logout in the sidebar, then login with your main account. Then go back to https://discordbots.org and sign in again.
clear your cookies
how
Have you signed in with your main account on discordapp.com?
let me check
DBL gets its account info off the main Discord account your logged into on the website.
there we go
How would one use the api in discord.net?
Individual User Id Voting Check for the past 24 hours.
returns{voted: 1} or {voted: 0}
Could someone tell me what the difference between the 1 and 0 is? I've tried User IDs who haven't upvoted and who have upvoted and it always returns 0
0 is false, 1 is true
Doesn't explain it returns 0 regardless if they've upvoted or not
is the vote in the last 24 hours?
Yes
Why does DBL not check that my bot is sharde? What I do wrong (https://github.com/Rubicon-Bot/Rubicon/tree/Rework-1.0.0/src/main/java/fun/rubicon/util/BotListHandler.java)
Any mod here who could help me
DK why but two shards gets an Unauthorized responsed and the third one not
All of them use the same config WHY?
because you post shard count with the poast stats request
@restive otter you should change all your authentication keys
Just looking at implementing the API for discordbots.org. It appears they don't have any verification as far as the count of servers that is sent up to the API. Is this known?
not sure if they have any validation, but I guess when your manipulate the server number by intent it might be considered a violation of tos
@pseudo plinth thats true but we monitor guild count updates and if there is something strange about the growth we reserve us to delete the bot from our page. So if someone is faking server count his bot will get deleted the first time and if he does it again he get banned from this server.
That is interesting and noted. Have you considered having the API send up the guild ids its apart of? That would be a lot more difficult to fake.
yea but that would make the api way more complicated and for big bots would probaly overload the api
that'd be really heavy on resource usage
1.7 million
damn
which would be around 35MB in a single request
just keep the server count and trust people...there is no point in faking the number...it doesnt make your bot in any way better
Hello
https://big.animetitti.es/i/QAD.png And use #general for that please :^)

Quick question why does my bot suddenly crash after being up for like 10-15 days saying incorrect login details, nothing changed (did not change anything on my part)
Probably its session expired
@coarse heath this channel is only for questions related to the DBL api, not the Discord API
i would also agree with what @fast tapir said
it's not discord api, since it is logged in
either way it's not related to DBL
Itβs not DBL API either
it crashes after logging in with the token and going on with the DBL plgun
You can go to the Discord API server and ask there
π
I need help
It won't show the discord acount I want to log into on the website
I have multiple accounts
go to discordapp.com/login and then click the cog wheel and click log out. Then log in with the right account @umbral wigeon
Thank you
np
GET /bots/{bot.id?}/check
Is there a reason why "voted" always returns 0.
I've checked the UserID if they had Voted or Not in the past 24 hours. Yet is always returns 0.
show code
with dblapi.js a webhook is running on the port given, you do need to open the port
but how would this be triggered? will it just auto Post threw webhook when someone votes?
idk
this channel is about DBLβs api not discord
We could if we knew what went wrong
I know what it is, Iβm just not sure about the no error. Are you sure itβs not working?
Stop tagging me Iβm already here
Try clearing your cache
@orchid sparrow do you have it on a setinterval/timeout?
Remember you have to wait the time before it runs
https://i.imgur.com/xSKAG2x.png Wich Method I should use instead of bot.add_cog(), because in discord.py [rewrite] this Method don't exists.
are you sure?
i use add_cog no problem
also this is the wrong channel
use #development for things like this
ok I solve the problem. I use discord.Client() instead of Bot()
anyone got the Files required for DBL Votes Webhook.
you dont need any files, you just need a htto webserver which accepts post requests
@mystic wing there is no interval
can you get information about bots that are not verified yet?
I don't think so 
@elfin solstice could you explain more? or someone.
https://discordbots.org/api/bots/:id/check seems to have broken and now only returns {"voted": 0}
@snow fiber
https://discordbots.org/api/bots/247134460024193027/check?userId=247741991310327810 returned {"voted": 1} free upvote for ya :^)
@sullen nymph It worked the first time but now it's no longer working so I'm assuming it only affects users that aren't first time voters
OR my vote was bad somehow
just tried on an alt that had voted before and the same issue happens
so it's not just me
Looks like it was just taking a long time to update the cache or something
Hey, I'm working on a rewrite for the Java lib
I need a second set of eyes to help me look it over for dumb stuff I've missed
@inner venture you can pong me
@summer oracle Hi napster chan
The code is under the rewrite branch of the repo if you wanna take a look
theres no rush ^^
did you also remove the deprecated method of getting votes? π or marked it as deprecated?
ah kk
wait
do you mean the one that gets the last 1000 users or wahtever
@elfin solstice
yea
Oh, didn't realize
before it returned all users
I'll mark it as deprecated
not only last 1000
is that completely deprecated?
ive been using it as my backup way to notify users of upvotes when webhooks are down 
no but it won't work if you have more than 1k votes and to test if someone has voted you should use the new endpoint or webhooks
by doing diffs between the polls
i guess you missed it, that endpoint is there since idk maybe 2 months
yeah missed it
I'm using the DBL-Java-Library and want to run some tests of posting my server count to my bot. However, I don't want to be accused of faking my server count. I didn't see any protocol for conducting tests. Am I missing something or am I fine doing this?
no we dont have any protocol to test this see this https://i.imgur.com/pqEGq6V.png
we monitor it and see if something strange happens
Alright. I'm going to jump from like ~5 to around ~11k.
jesus
Well I have a debug bot that's in a few servers. So I'm going to test sending my server count with that. But then I'm going to push the update to my actual bot which has around that many servers
Awesome. Thank you!
hey how do you test to make sure that your bot is actually posting it's server count i use the discord.js dbl api
I'd imagine you can look at the response or go check your bot's page on the site
well either way it shows it's server count there.
But idk if the .js api lets you look at the site's responses
So you're probs good then π
yes it does, it returns a Promise if you manuall post stats, for autoposting it will show logs if the response errored
oh i'm dumb af
nvm i know why it isn't logging the post. I updated my bot and my local bot.js didn't have the api post request smh
So I had a comment about your "code of conduct" for your /votes endpoint. This is at least true for the Java library, but have you considered implementing a cache in your API libraries that keeps voters for 24 hours? That could dramatically reduce the number of hits you get.
thats why we recommend using the webhook over the /votes endpoint
so you can have your own cache of people who voted
shards start at 0
Just wanted to make sure. Thanks!

alright everything works
Aurora is online on 21 servers!
-_-_-_- commands folder loading... -_-_-_-
loaded!
-_-_-_- moderation folder loading... -_-_-_-
ban.js loaded from moderation!
kick.js loaded from moderation!
mute.js loaded from moderation!
report.js loaded from moderation!
unban.js loaded from moderation!
-_-_-_- wip folder loading... -_-_-_-
deletecounter.js loaded from wip!
membercount.js loaded from wip!
-_-_-_- Util folder loading... -_-_-_-
restart.js loaded from Util!
stop.js loaded from Util!
>(node:13147) ExperimentalWarning: The http2 module is an experimental API.
>Server count posted!
π
yay lol alright i think i am done for today seeya
I'm using the DBL-Java-Library, and I can't seem to hit the /stats endpoint. I keep getting this error
ERROR org.discordbots.api.client.retrofit.GenericCallAdapterFactory - Error while executing request to https://discordbots.org/api/bots/<clientID>/stats
I verified that my token is correct. I cannot seem to get any requests from the API to work on this endpoint.
what's your code?
DiscordBotsListAPI dblClient = new DiscordBotListAPI.Builder()
.token(authToken)
.build();
...
dblClient.setStats(discordClient.getApplicationClientID(), discordClient.getGuilds().size(), shardID, totalShards);
@sand pumice Can you try using the rewrite branch?
Sure, I'll give that a shot
f069984
This is the latest commit of that branch
Just put that in the artifact ID spot
wouldn't it go in the version with jitpack?
oh yeah
sorry
I mixed up the two
When I was writing it, I was like, hey, that doesnt sound right
So it would be
<dependency>
<groupId>com.github.DiscordBotList</groupId>
<artifactId>DBL-Java-Library</artifactId>
<version>f069984</version>
</dependency>
Alright, I have the branch. I'll tackle this when I get home from church.
@sand pumice alright π The syntax is a bit different but it should be pretty easy to switch
whats up
the api reference doesn't actually show what i have to post anympore?
just tells me how to auth
wdym?
lmao
didn't notice this: https://i.thedevfreak.tk/images/12eec8d9.png
forgot you had to scroll down there
π
sigh
π
hi tonkku
hi groovy
{
'server_count': 4,
'shard_count': 2
}```
single line json is a thing, right?
{ 'server_count': 4, 'shard_count': 2 }```
yeah
if youre posting like that though
wait, are you able to post like that?
im not sure anymore
dunno.
try it man
wait what do you mean
"post like that"
i currently just post my counts like
{
'server_count': 4,
'shard_count': 2
}```
The formatting of the json doesnt matter omg
I'm pretty sure you need " instead of '
cant see why one-lineifying would be bad.
I was wondering if DBL would accept it
for valid json
double quotes instead of single quotes
{ "server_count": 4, "shard_count": 2 }```
FWIW i'm writing a program for my bots to POST to that will then POST out to other services.
so that my bots only need to deal with POSTing to one place.
thats nice
rofl
Alright, so I'm trying out the newest version (49690ab) of the rewrite branch of the DBL-Java-Library, and I'm getting this whenever I try to send a request
@sand pumice you want to talk with @inner venture about that, he is the dev for the java library
My code:
DiscordBotListAPI dblClient = new DiscordBotListAPI.Builder()
.token(authToken)
.botId(clientID)
.build();
...
dblClient.setStats(discordClient.getGuilds().size(), shardID, totalShards);```
Ah, alright. Thank you Yukine
Groovy, I see you've been actively working on the API. I'm looking through the code and I don't see how the token can be null.
hmmm
I've triple checked that the value of authToken is my token from the DBL website
yeah, its not a problem with you
It's adef a problem with the code
Can you try the latest version?
3b14ad9?
yeah
it might just be jitpack taking a bit to build it
Alright. I'll look through your code and see if I can find anything.
Hey @inner venture , I think I found something.
private CompletionStage<Void> setStats(JSONObject jsonBody) {
HttpUrl url = baseUrl.newBuilder()
.addPathSegment("bots")
.addPathSegment(botId)
.addPathSegment("votes")
.build();
return post(url, jsonBody, Void.class);
}
Shouldn't it be .addPathSegment("stats");?
Oh yeah, my bad
Does that solve the issue? It doesn't look like that has much to do with the header field being null
Did it fix the setStats(int,int,int) method throwing the NPE?
Honestly, I'm not sure
It works by my tseting
Are you sure that the token you put in there wasnt null to begin with
Only a little, haha
It's because I'm using an abstract class and set some data members out of order
ahh, okay
Here, I'll add some checks to the builder to make sure it isn't null when building
Saving future fools from their folly. Good call
π
Alright, we got rid of the NPE! surprise surprise
π
So I'll go ahead and grab the latest commit once it's available and try it out.
It should be available now
It looks like it ran. Looking at the website to see if it shows up there
Does it usually take a bit for the site to update?
Still nothing
can i check?
Yeah, what info do you need?
yeah im not seein any hahah
RIP
hmm, you could check the callback
to see if its throwing an error
api.setStats(whatever).whenComplete((v, e) -> {
if(e != null) e.printStackTrace();
});```
something like that
Sure, I'll give it a shot
it might just not print anything at all
I'll put an else in there for good measure
I'm unfamiliar with Voids
Don't worry about it
It hit my else

If you pass over your creds to me I could give it a try
i promise i wont mess it up hahahhah
Hmmm, I think that'll be better as a last ditch effort
Yeah
I understand
I got it to work on my end, though
Could you double check that the token and bot ID belong together
But you said the setStats works for you?
yeah
What if you use setStats(int, int, int) and specify only one shard?
I initially did that
let me tryerino
Ah, I got the order of the parameters wrong
So I said the total shards was 0
I hope I didn't mess something up internally on the site
I'm having trouble getting that one to work as well @sand pumice
let me investigate
Alright, cool. I also tried the setStats(int) and that didn't work
but that was after I got the total shards wrong
That one seems to work for me
Oh hey, I got setStats(int) to work
The bot id in the discordbots url is different from my bot's client id from Discord
lol how does that work?
i didnt think your bot was that old hahahh
rn
discord uses the bot id for the client id
or the other way around
basically, theyre the sdame
but they used to be different when you made bots ages ago
Oh, so the bot's account has a different ID from the client ID
yeah
the bots user ID and the bots client ID are differnet from old bots, basically
lol wow, that's a little silly. Took me for a ride
yeah hahhaha
I think that means that my code won't work for newer bots
How so?
Unless I include that data in a config file
So Discord4J has this DiscordClient object that keeps track of my client ID
However, it looks like I need the bot's user ID when building the DiscordBitListAPI
shouldn't your lib have your ClientUser somewhere where you can get the id of that?
Let me check
Ah, yes I can
The setStats(int,int,int) didn't work with the correct id, so it's not just you
What's the issue?
I had a parameter messed up
but it also kinda exposes a messed up thing with the error handling
so π
its quite easy, just setup a small webserver what accepts post requests and in there you handle the logic for your webhook to add it do cache, a database or something
Oh boy. Sounds like an adventure is unfolding. I'll be on the lookout for the next commit
@sand pumice the issue is like a two second fix hahaha im just figuring out the best way to handle thsi
so im leaving it unfixed so i can test out if my error handling works okie doke
I have no idea on how to do that
Gotcha
then you want use google and do [Your choosen langauge here] http web server library tutorial
I might make a tutorial or example for one using node.js 
ah
hmm, maybe I should add webhook support for the java lib
@sand pumice Seems like I've fixed that now :)
Web hook stuff would be amazing!
Do you think you'd cash voters in the library or let the developer? I use a library called EHCache that is pretty robust. Pretty simple to use too
we would let the dev do that, we just forward the response from the webhook to the dev himself
setStats(int,int,int) worked for me!
the lib itself would never cache it itself
That makes sense
Hmmm, but if you do webhook stuff in the Java API, wouldn't that create an HTTP server for every bot process? So if a dev was running a bunch of instances on the same machine, it would spawn a bunch of servers
Thanks so much for the help, groovy! Super appreciate your time and patience for my folly
@sand pumice Yeah, it would make a bunch of http servers. It's still up in the air thuogh. Thank you for helping me test out the rewrite hahaha π
Sure thing! Thanks for making the API!
Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}
Traceback (most recent call last):
File "<ipython-input-6-7b2a7524067c>", line 16, in update_stats
await self.dblpy.post_server_count()
File "/usr/local/lib/python3.6/dist-packages/dbl/client.py", line 100, in post_server_count
await self.http.post_server_count(self.bot_id, self.guild_count(), shard_count, shard_no)
File "/usr/local/lib/python3.6/dist-packages/dbl/http.py", line 189, in post_server_count
await self.request('POST', '{}/bots/{}/stats'.format(self.BASE, bot_id), json=payload)
File "/usr/local/lib/python3.6/dist-packages/dbl/http.py", line 160, in request
raise Forbidden(resp, data)
dbl.errors.Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}```
i have no idea why, but every time i try posting my server count this happens
d.py btw, i just copied the example on dbl
Is your token correct?
it's the one generated on the dbl site, right?
ok i'll try again just to be sure
yep i reset the token and put the new one in, but same error
Are you trying to post the stats to the bot that token is attached to?
yes
hm, i dont know what to say then
might wanna ping python lib dev to see whats up
who's that?
@golden wind
thanks, couldnt tag him for some reason
oh cool
Been having a few issues binding my client to the dblposter
const dbl = require("dblposter");
const poster = new dbl(Auth.dbl_key);
//inside a client.once("ready");
poster.bind(client);
This throws:
RangeError: You need to provide a client to bind to, either in the constructor of dblposter or in the bind function!
Not sure what the issue is as I looked at #312614469819826177
actually. I suppose I'll take a look at dblapi.js
dblposter isn't supported by us
That's what I figured as the api page doesnt say to install it. I suppose it was my mistake to look at an old channel
at _response.transport.request.then (/app/node_modules/snekfetch/src/index.js:193:21)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
(node:13633) 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: 2)
(node:13633) [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.```
get this error when I do a command to send bot stats
can you send your code?
seems like a snekfetch bug
what makes you think that
Or an api bug
Nevermind, I fixed it
I have another problem D:
at _response.transport.request.then (/app/node_modules/snekfetch/src/index.js:193:21)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
(node:23032) 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: 2)
(node:23032) [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.```
keep getting that in my console every time my bot reloads
Are you providing the correct token?
It would really help if you can show us parts of the code, it'll help narrow down the problem
const Discord = require("discord.js");
const fs = require("fs");
const bot = new Discord.Client({disableEveryone: true});
const DBL = require("dblapi.js");
const dbl = new DBL(-snip', bot);
bot.commands = new Discord.Collection();
fs.readdir("./commands/", (err, files) => {
if(err) console.log(err);
let jsfile = files.filter(f => f.split(".").pop() === "js")
if(jsfile.length <= 0){
console.log("Couldn't find commands.");
return;
}
jsfile.forEach((f, i) =>{
let props = require(`./commands/${f}`);
console.log(`${f} loaded!`);
bot.commands.set(props.help.name, props);
});
});
console.log(`${bot.user.username} is online on ${bot.guilds.size} servers!`);
bot.user.setActivity(`for +help | on ${bot.guilds.size} servers`, {type: "WATCHING"})
});
bot.on("message", async message => {
if(message.author.bot) return;
if(message.channel.type === "dm") return;
let prefix = botconfig.prefix;
if(!message.content.startsWith(prefix)) return;
let messageArray = message.content.split(" ");
let cmd = messageArray[0];
let args = messageArray.slice(1);
let commandFile = bot.commands.get(cmd.slice(prefix.length));
if(commandFile) commandFile.run(bot,message,args);
});
// Client join and leave Discord
bot.on("guildCreate", async guild => {
let guildCreateChannel = bot.channels.get("468656742088048640");
let general = guild.channels.find('name', 'general');
guild.channels.get(general.id).createInvite().then(invite => {
let joinEmbed = new Discord.RichEmbed()
.setTitle('Guild Joined')
.setThumbnail(guild.iconURL)
.setURL(invite.url)
.setDescription('Join the new Guild')
.addField('Guild Info', `Name: **${guild.name}** \nID: **${guild.id}**`)
guildCreateChannel.send(joinEmbed);
});
});
bot.on("guildDelete", async guild => {
let guildCreateDelete = bot.channels.get("468656742088048640");
let leaveEmbed = new Discord.RichEmbed()
.setTitle('Guild Left')
.setThumbnail(guild.iconURL)
.addField('Guild Info', `Name: **${guild.name}** \nID: **${guild.id}**`)
guildCreateDelete.send(leaveEmbed);
});
bot.login(process.env.SECRET);```
@austere swallow
It might've been the token, just re-pasted it. But I had 11 and It turned to 12 before I replaced it
Yeah always double-check the token
(Assuming this is the right channel) Okay so, I've properly set up my webhook, it's up and running, I've even tested it on my own with curl and some "apitester" website to make sure it's usable. However, when I test the webhook in discordbots, nothing seems to be happening, the bot doesn't react (not even with some debug lines of code that print stuff to console when the post request is received). I'm not exactly sure if it's something I'm doing wrong or not, since nothing seems to be happening at all 
Could you post the link you have in there @tacit forge ?
Remember it has to have the port included
Is the Get Bot's Last 1000 Votes endpoint considered deprecated?
kinda since it won't work anymore if you have over 1k votes, you should use the check endpoint for votes instead or use webhook
should i just remove it from the java lib honestly
well the C# one marked it as deprecated
guess you could add and mark as deprecated or remove, what you like more
yeah, but im rewriting the entire thing so breaking changes galore anyways
yea remove then
that simplifies my code a bit, hmm
thats the only place simple user objs are returned right?
kinda since it won't work anymore if you have over 1k votes
not true π
or at least it doesnt fail in a hard way
Yo. Is there a way to check if user have voted for my bot using .net library?
@summer oracle what do you mean "fail the had way"?

and if i got upvote, the endpoint will include my vote after a few minutes
i did this on aki a few weeks back
when webhooks broke
how much votes does it give you?
oh maybe it discards old votes and include the new ones
yeah
thats what i figured
i didnt see the user vote check route lol
which im about to deploy now so i wont have to rely on the 1k endpoint hack when webhooks are borked
@arctic arch could you explain how the endpoint works in that case later π
which endpoint?
the last 1000 votes oen
π
@mystic wing
@tacit forge put the webook port after the domain
http://saddy.iscool:5000/test/test
that doesn't seem to be working either
@tacit forge does it work when you press the test button
Nothing seems to happen when I press the test button
as if it can't communicate with the webhook or something
Why does dbl.getVotes() return me 1000 random votes
Users can currently vote every 24 hours for each bot. The /votes endpoint for your bot (the one you use via getVotes) only indexes the last 1000 votes. Please implement the webhook instead if you plan to process over 1000 votes.
@plain timber my probmel is i get 999 random votes as my bot only has 1 vote on the page atm
IS there any use of puting client into the .js api
( const dbl = new DBL(process.env.dbl, bot ( Discord.JS Client) ); )
wh
client.shards is undefined and I am using shards. How can I post the server count to the bot then?
I am using discord.js
@grim beacon client.shards.id
client.shards is undefined
yeah
it exists
but it gives me 400 Bad Request
(node:30748) UnhandledPromiseRejectionWarning: Error: 400 Bad Request
at _response.transport.request.then (bot directory\node_modules\dblapi.js\node_modules\snekfetch\src\index.js:193:21)
ahh
what's the value?
.id is 0, .total is 1
id is the number of the shard that is on the server

const DBL = require('dblapi.js');
const dbl = new DBL(process.env.dblkey, { webhookPort: 5000 });
does not make a webhook
you have to go to the bot page and insert the link and port + password
yeah but i do not even see the webhook running
add dbl.webhook.on('ready', () => console.log('webhook running, yay!'))
that logs it but pressing the test button still doesn't do shit
okay
problem changed
is your configuration on the DBL website correct and can you receive http requests on your machine and connection
If you host it on your machine you will need to port forward.
how can I show if my bot is online on DBL website?
have it added here
does .hasVoted(id) reset after 24h
it resets when the user is able to vote again
What happens when I don't specify webhookPort?
I feel like I should use JS for this API, as .NET library very weak. it does not have .hasVoted(id) function, all it shows its all votes. even though it should return only amount of votes for day I entered, as a parameter, but it always returns all voters
Webhooks
Oh
Ok
@arctic arch I still never figured out what to put my port as
And test doesn't seem to be working
I set it to 5000 but still nothing
Do I need to port forward? @mystic wing
It no woooork D:
const DBL = require("dblapi.js"), dbl = new DBL(Token Here, {
"webhookPort": 5000
});
dbl.webhook.on("ready", (hook) => {
console.log(hook);
});
dbl.webhook.on("vote", (vote) => {
console.log(vote);
});```
That's what I have
yea you need to port forward
Ok
@arctic arch https://i.imgur.com/7mCI23U.png ?
It still hasn't worked
hook = { hostname: '0.0.0.0', port: 5000, path: '/dblwebhook' }
whats the url you set on the edit page
you're runnign this in your house right
Yes, but soon I'm going to upload it to my host
Thanks
should I edit your api for .net and pr?
yes that would be nice
I will add at least "has voted" and fix some redundant data there
ππ»
After some intense google searches, I'm still not understanding why clicking test on the edit page doesn't do anything to my webhook. I know it works cause I've tested it multiple times in multiple areas and PCs, but in the one place I need it to work, it doesn't seem to. Is there something specific I need to do with the webhook for it to work...?
It is
@noble iron My 2nd bot was approved
@dense sinew ping
...
Wat
@dense sinew ping
M-Missing permissions?
What permissions?
wat
This isnt testing
Oh crap
I thought I was in testing-1
Sorry
s my h
S MY H
D:
smh
Anyway, the port is forwarded, the webhook works, clicking test doesn't seem to do anything and my webhook doesn't seem to be receiving the post request at all.
@tacit forge One thing I noticed is that you have https in dbl but all the curl screenshots you posted use http
I was using cloudflare at one point, but when I used curl on my PC it got in the way and didn't work, so I turned it off just to see if that would change anything. I tried http earlier today and it didn't make much of a difference (despite it working on my PC)
What language are you using?
Not sure what DBM is
but i'd take a look at this\
oh
well uh
I have no idea how that would work
just made a PR for .net lib, should I notify anyone?
@honest root i think pinging the .net lib dev would be acceptable
who is he? 

velddev another person who developed this lib 5 month ago
what is his nickname on this server?
well, I will wait for few days, in worst case will ping admins or something
@honest root you did not submit the PR to the right repo
._.
submit the PR https://github.com/DiscordBotList/DBL-dotnet-Library
there
Discord bot maker
when you follow a tutorial and later on ask billion questions
#memes-and-media
when you dont move there
ok
@restive otter this channel is only for the DBL api, check the channel topic
My pr merged 
are all http request I can see in documentation, or there is something not added yet?
theyre all documented afaik
can i receive vote-webhooks without a URL? just to my bot-servers IP perhaps?
Yes.
URL can contain IP ex. http://1.2.3.4:1234/test
i dont know why i expected that url to work
Lol
Can webhooks get a attribute to see if it is a weekend? I don't want to ping the weekend endpoint for every vote that comes in.
This is in no way shitting on how dbl did it. But wouldn't it make alot more sense to include whenever the vote counted double in the weebhook payload rather than making a whole endpoint just for the purpose of checking it?
The inconsistent naming in this API kinda bothers me, tbh
What do you mean?
Some fields use snakecase
Some fields use all lowercase
Some fields use camelcase
Some boolean fields have the is prefix
So, is this going to be changed to the past 12 hours after the change?
some boolean fields dont have it
I would honestly appreciate a standardization effort but it's more effort than its worth at this point
Imo 1 person should take charge to update the API and the 24 hour thing
meh
It would be great to receive the amount of time (maybe in seconds but doesn't matter) that the user has to wait for the next upvote.
Correct me if I'm wrong but wouldn't that always be 12 hours?
Oh my gob
Even more naming inconsistencies

@cobalt ruin Oliy this is out of control
I don't think that is what the multiplier is @restive otter
what
oh nevermind
I misread
@cobalt ruin The naming inconsistencies within dbl are insnae
You literally just added a feature and named the same value two different things
or atleast, used two different naming schemes
in the REST api, is_weekend, in webhooks, isWeekend
lol seriously
Yes

Even within the Bot object, 3 different naming schemes are present
maybe each admin uses a different naming scheme or something
The actual bot object returned by DBL is also woefully different from the one in the documentation
@inner venture yes it's quite bad at the minute but we're going through a rewrite so all of this will be fixed
yea something like that, we haven't reach the api yet
I sure hope, Oliy
I sure hope
What is the date returned in the bot object?
@cobalt ruin
Last modified?
or is it creation date
what timezone does "weekend" use?
GMT
OΓ― is someone still online ?
thx
I'm not sure where to ask this question, but it sorta relates to the API and it's not in the FAQ. Do I need a website to get certified, or can my commands be documented on discordbots/a help command?
I saw someone get denied certification because of a poorly constructed website (or something along those lines)
Made another PR related to weekend update + fixing a bug where you can send a HTTP request even if you have more than 1000 votes
P.s. maybe this time I will get the role!
@sand pumice Full documentation of commands, either in a help commands or external site.
is one of the requirements
OR
so
if your help command shows EVERY command
like it should
then you're fine on that front
also #development is a better place
its not really related to the API
Thatβs not the right endpoint, check #announcements
π
Hi there! Could anyone help me out setting up webhooks in Python? I donβt have a website so it might not be possible. I simply want some code to be triggered every time someone votes so I can put the voting stuff in there
im trying to get a webhook sent to my bots' server when someone votes, what am i doing wrong? I have the URL set to the server IP with the port (I tried without the port too)
in my code i have the webhookPort set to 5000, with the right auth and token
Hey the generate token button on the website isnt working
it isnt actually a button
@arctic arch /path?
does anyone know anything about webhooks in python? i'm struggling to find anything online that works
try looking into http://flask.pocoo.org/
thx
@arctic arch im testing it locally and in my console it says its running at http://0.0.0.0:80/dblwebhook - & on the website I have http://{{MY_IP}}:80/dblwebhook but i dont seem to be receiving them?
have you port forwarded
i thought I wouldnt have to because i set it to port 80 π€ ill try it on the server
it says running on http://127.0.0.1:5000, but this isn't my IP address. Should I use this or my actual IP?
what can't connect
when i try and send a webhook, it just gives me a connection error
how are you sending a webhook
try using 127.0.0.1 when testing in postman
that worked
okay so you need to port forward as well

