#topgg-api
1 messages ยท Page 25 of 1
A web hook is like a text message
You don't just check every time it there is a new message
Your phone will just tell you that there is a new one the moment it arrives
So dbl is the equivalent of that text message, all you need is a cell phone and a number to receive it on
Good analogy +1
lol
@sudden rampart 60/minute man.
And yes I do one for my guildsize but not more
@arctic arch why not? I do a request every 3 seconds for my checkforvotes function
It checks if a user that uses the bot has voted up
I know I could use a webhook but i am to dump for it
Thats no spamming lol
every 3 seconds is spam
why am i even discussing lmao have fun getting banned by Tonkku
idc about you tbh
Why should I get banned lol
even if it's not blocked it's still technically spam
cya ๐
I thought it's 60/min ๐
When you dont care about me why are you even answering
I have a while loop with 60 seconds cooldown, is that ok?
@arctic arch why you dont update your api to a function that allows you to give you an array of all ids that have votet up the bot
.................................................................
Sorry but i have not the time to set up a webhook nodejs server
No the mod says no @tidal burrow
isn't that what the api is

I was first recommended to do a while loop, and now they aren't allowed? ๐
What function does that?
@tidal burrow i would recommend using an webhook there it doesn't loop request at all and is more precisios
No its technical spam ^^
I mean it's just a background task, that sends the server count every minute, I think I'll stick to it
You made a good webhook but it would ve much simplier if you would host it
request every 60 seconds is better than every 3 seconds
Hosting a webhook 
...
i remember why i stopped helping now
hosting a webhook lol wut
xD
I mean you could host the webhook on one of ur servers
do you know what webhooks are?
That this server sends a callback to the webhook of the bot
so you don't understand webhooks
Okay so I read again about it, thx
Is there a js function that allows you to get a list of all ids that upvoted the bot?

how are you doing it now if not a js function?
ohmy 

Okay so my loop is really really dump cd
for every user.id? lol you'd be checking millions of users xD
and for the future know your facts before saying someone should read the docs kthxbye
No for every user id that the bot has fetched......
@steady sundial and if you have more than 60 you're ratelimited
on the first execution
๐ค
I've set a while loop to send to API the number of servers every 5 minutes, and every time it does it, it prints/spams this into the console, here's the code if necessary:
import aiohttp
@bot.event
async def on_ready():
dbltoken = 'CENSORED'
url = 'https://discordbots.org/api/bots/' + str(bot.user.id) + '/stats'
headers = {'Authorization' : dbltoken}
while True:
payload = {'server_count': len(bot.guilds)}
async with aiohttp.ClientSession() as aioclient:
await aioclient.post(url, data = payload, headers = headers)
await asyncio.sleep(300)
I'll be gone for the next ~30 minutes so please mention me with the reply, thanks
you never close anything
I've never worked with APIs before, how do you close a session?
๐
If I remember correctly it's better to do
async with aiohttp.post() as r:
log status code here or type pass or whatever
also why create a new session every time instead of reusing a single one?
@tidal burrow obligatory mention
@snow fiber I think thats deprecated
That's literally how I got it from the docs if I remember
Yeah
That's what she the docs said
nm lol
Nah I think they say that making the request directly is deprecated
Not making a session and using that for your web requests
Yeah just realized 
I think I finally made it close it, await aioclient.close() I think it is, at least it stopped spamming my console
nope, it's still spamming...
@tidal burrow Than use the example of Queen of Banne
async with aiohttp.ClientSession() as session:
async with session.post(dastuff) as r:
print(r.status)
hm
And then you could also do like
async with aiohttp.ClientSession() as session:
async with session.post(dastuff) as dbl:
print(dbl.status + 'DBL POSTED')
async with session.post(daotherstuff) as botspw:
print(botspw.status + 'bots.pw POSTED')
Say you are posting to multiple lists or anything or doing some custom stats with your site whatevs
Which will reuse the session and use less resources
well it's been 5 minutes without the spam, I think it worked, thanks
I need to learn about API, cause I have no idea how to use them lol
hola
wrong channel for greetings
my bot was declined for api abuse and I'm just wondering what classes as abusing the API?
Bot Description:
My bot is used to cleanup messages that being with the most common command prefixes... Useful for cleaning up chats full of commands.
Workflow:
Command Sent with common symbol as first letter !help, ]help, .help, etc... > > > Message with command deleted automatically after 2 seconds.
I don't think this has anything to do with the DBL API. Also would recommend talking the moderator who declined you
that's what I'm wondering... If it's something to do with the DBL API then I'm confused since I don't even have DBL API setup for this bot...
I believe the mod is referring to abuse of the Discord API
But please, lets take this discussion elsewhere
Is there a way to like make the bot do something on_upvote (py)
webhooks can do that, i guess
If I'm not using any sharding, what should I be using for the 2nd and 3rd arguments?
or are the latter two optional?
not sure about that, but if there isnt a way to post w/o sharding, you could always just use 0 for the shardId and 1 for the shardCount
I'm doing it right now, trying to make sure everything's correct since I have to put it on the live bot (test bot isn't on the DBL :P)
Looks like it worked with just the first param ๐
๐
if(dbl.hasVoted(message.author.id)) return message.channel.send(`**ERROR**: You must vote at https://discordbots.org/bot/409538753997307915 to use this command.`);```
will that work @arctic arch
nope
hmm
dbl.hasVoted(message.author.id) return message.channel.send(`**ERROR**: You must vote at https://discordbots.org/bot/409538753997307915 to use this command.`);```
will that? @arctic arch
what
will that code work
im catching before one command if the person voted
how do u return with this api
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});
Found that in the API Docs.
Well, client.shards.id is undefined. What should you replace this parameter with?
client.shard.id ?
mhm
I'm just wondering why you would post a single shard id ๐ค
if your bot isn't sharded just sent the guild count
if you sent the guild count for individual shards dbl adds them together
it's got to know the shard id to know which to update
or you can total the guild count for all shards yourself and just send that
IDk much about API
How can i set up clash ip to a self hosed bot
I wanna add a donation logger
Erm
Um
Anyone Here Can Help Me With Checking Over My Discord.py Code
Need An Experienced Discord.py User To Check It Over 
Oh
@vast junco you want the sleep function outside the exception
no idea why this happens
that's not the error
I havn't even started coding anything, just trying to import it into my code
import dbl
is where it dies
try python 3.6
yeah ok im on python 3.5.2
@tough stream i have no idea whats causing that error
i have tried finding it, someone else had it above
did you say you were on py3.5?
lol yeet time to install all my tensorflow libraries again yaaaaaaaaaaaay
rip sorry ๐ฆ
๐
Nos amamos EUA
@vast junco i'm not too sure about that
in the try exception block
the indentation for your sleep is in the exception part
so it'll only sleep when something goes wrong
@golden wind maybe consider not using fstrings and instead use .format for this
bc yknow fstrings are 3.6
or use the future-fstring thing
ye
@Francis#2517 @Francis#2517
How do I get my bot to print the uids that have voted for it as mentions?
I'm assuming that you already have the user IDs, but the format for mentions in discord is <@userId>
@inner venture
You dont really have to include the !
You don't have to include ! at all. That's just something Discord does for nicknames.. idk why
So for loop it?
dbl.getVotes(true).then(vote => {dio.sendMessage({to:channelID,message:'<@' + vote[+1] + '>'})})
yeah
but i dont relly know how to use a 'for' loop
oh dear that's going to send a new message for EVERY voter
yeah
You need to concat them into a string
I'm trying to use the DBL API to check if a user has voted for my bot, then give him or her access to a command.
This is the code I'm using, and it isn't working.
if (dbl.hasVoted(message.author.id) || message.author.id === '250811963334983683')
it's a promise
I'm not familiar with those.
dbl.hasVoted(message.author.id).then(voted => {
if (voted)
})
or
// In an async function
const voted = await dbl.hasVoted(message.author.id)
Ohh, ok.
I've used those before, I just never knew they were called promises, sorry!
This should work to post a message for each use who has upvoted my bot as a mention right? ```js
for (i = 0; i < 5; i++) {
dbl.getVotes(true).then(vote => {dio.sendMessage({to:channelID,message:dio.fixMessage('<@'+ vote[i] + '>')})})}
๐
theres only five people
and where should i place the loop?
oh wait a minute
yeah where should I put it then?
would it be too spammy if my bot will be checking if a user has upvoted it after each, limited by votes, command?
@tidal burrow yes
Either keep a global list of the users who have voted
And update it like
Every 30 seconds or something (?)
Or use the webhook
Which sends you a post req everytime someone votes / unvotes
it's limited to 60 requests per minute, right?
the entire api, yeah
sounds like a good idea, thanks
hmmm
so im trying to retrieve info on a bot using the id and i keep getting an error json unexpected token u in position 0
huh
How long does it take for a vote to register?
Because a friend of mine voted for my bot and I had to manually add him.
how are you getting the vote data?
through a webhook?
or are you periodically callaing the votes endpoint
@unique flax
dbl.hasVoted(message.author.id).then(voted => {
if (voted) {}
});
This was written up by Tonkku.
That's what I thought, but it isn't working.
how will I be going around getting a list of all upvoters with discord.py with only one request? I was thinking of calling the GET on users instead of users/{user.id}, but idk if it's the correct way, or will it even work
GET /bots/:bot-id/votes
oh, I guess I was on a bit of wrong track lol
so that will basically return a list of all upvoters?
upvoters..? @sudden rampart
Isnt there a py dbl lib?
i wrote the code to handle that months ago lul
so to clarify, onlyids will return the discord user ids, right?
yes
@violet crane I don't know if you're still having the unexpected token u in position 0 error, but whenever I get that same error, it's because something is trying to use JSON.parse on undefined
@uncut crystal Why did you delete my bot?
again, #topgg-api isn't the appropriate channel for this, DM me
I'm pretty bad at APIs, so can someone tell me if I'm doing this right? ๐
headers = {'Authorization' : dbltoken}
urlvoters = 'https://discordbots.org/api/bots/' + str(bot.user.id) + '/votes'
voters = []
payload_2 = {'onlyids': True, 'days': 7}
async with aiohttp.ClientSession() as session:
async with session.get(urlvoters, data = payload_2, headers = headers) as r:
for x in r:
voters.append(x)
await session.close()
@tidal burrow kinda unrelated, but why arent you using the dbl py lib? ๐ค
it pretty much works without it, yet I'm still learning how APIs work, so maybe later I'll consider taking a look into it
hm
any way to retrive information like on reddit using discord.py
wrong channel
cough cough I still kinda need help with my code above haha ๐
hey guys, my bots growing pretty quick so, will i get in trouble if i update my guild count too much? right now it does it on ready and when it joins/leaves a guild, but its starting to join/leave a lot of guilds and quite fast
you should turn it into a background task
make it update on it's own with some interval
so like update it every 15 minutes or something instead?
well, the actual limit is 60 API requests per minute, but I personally have it set to 30 seconds
just don't go close to the ratelimit and you'll be fine
i run mine each 30m
yeah... and I still need help as well... ๐
okay
Is the JS library still bad?
Should I migrate to it from my own snekfetch implementation?
I can make 1 request per second?
That seems high.
How I Use DBLDAPI?
DISCORD BOTS LIST API?
PLS
??
PLS
How To I Run With Discordbot-api?
@open minnow
GROOVY????
GROOVY
@open minnow have you read the docs?
@tidal burrow why are you copying r to voters when r is everyone who voted?
might want to create a static session
^
What's wrong withif(dbl.hasVoted(String(sender.id)))?
I have js const DBL = require("dblapi.js"); const dbl = new DBL(`TOKEN`); to initiate
It's a promise, so
dbl.hasVoted(message.author.id).then(voted => {
if (voted)
})
or
// In an async function
const voted = await dbl.hasVoted(message.author.id)
if (voted)
Oh ok
didn't realise it was a promise
cant make a bot....
wrong channel
......
ok
@restive otter henlo 
https://elon-musk.is-fi.re/b31796.png
with this, does it autopost when a new guild is joined?
no
does DBLPoster do that?
kk
so run this in a guild joined or leave event
global.dbl = new DBL(auth.dbltoken, bot);
dbl.postStats(bot.guilds.size).catch(err => {console.log(`Error ${err.code}: Error uploading guild count to DBL`)});
thank you!
np
autoposter posts every 30 minutes
@golden wind that was basically my idea, I intentionally want to get a list of all user ids who voted on the bot, I just need to know if I'm doing it right
@tidal burrow ye but the api returns that list as r, so why copy it when it already exists?
and you should probably use the client session that you should have already created when starting the bot
as 4jr said
well I did mention that I'm new to API stuff, idk what or how would be a better way of doing it ๐ค
can i do can i do if(!dbl.voted(id))?
@golden wind you should create a start_vote_post() function in the wrapper
that just does what's in the example
anyone knows how to set config vars in heroku with python and github
bot.run(BOT_TOKEN) doesnt seem to work
pls help
wrong channel
how i use Dbl api?! And How I Run?! I Run Node bot.js Is Not Work
@zealous dagger bot.run(process.env.BOT_TOKEN)
doesnt work too xD
still wrong channel
my discord server isn't on the "select a server" whenever i add a bot D:
how to fix?
wrong channel to ask in 
oh rip
i saw it said "help" in the
top
;|
its says this channel is only for suggestions/HELP/bugs....
i guess i post in general?
read the full desc before posting but yea u can ask in #general or #development or #memes-and-media 
this channel is only for the api libraries
its okay!
hey guys, dunno really how webhooks or the api works, but is there a way to post to a channel in my bots server when someone votes, with their username and id?
You need to have a webserver catch the webhook first to do that
oh
you could always point the web hook to a web hook on discord
um
yeah no
I use dbl.hasVoted(message.author.id)
but how do i check when the upvote was?
so have they upvoted in the last 24 hourse?
*hours
you'd have to use getVotes(onlyids, days)
but now that I think of it, I should include the days part
oh ok...
in hasvoted
yeah...
so would it be:
dbl.getVotes(true, 1).then(result => {
if (result.includes(message.author.id)) {/*DO STUFF*/}
})```
?
@arctic arch ?
ok
@restive otter released 1.2.0
ok
ok im having an issue with the dbl api where it wont let me make an api key
what
my bot is on the list and everything but each time i click generate token it doesnt
csan you screenshot what it looks like for you ๐ค
if(dbl.hasVoted(message.author.id) === false)
can someone tell me why
this isn't working bc i thought it would
nvm we good
On the latest version of the dblpy lib get_upvote_info() returns NotFound: Not Found (status code: 404): {"error":"Not Found"} I looked through the previous messages here and saw others also having this problem but no solution
@brave pond what version is your dblpy lib?
0.1.5
hmm
I'm using
self.dblpy = dbl.Client(self.bot, self.token)
and
await self.dblpy.get_upvote_info()
can you send me the full traceback?
1 sec
Traceback (most recent call last):
File "C:\Users\Giraffe\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 62, in wrapped
ret = yield from coro(*args, **kwargs)
File "C:\BotsLock&Key\cogs\ServerCount.py", line 90, in votedhere
voted = await self.dblpy.get_upvote_info()
File "C:\Users\Giraffe\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dbl\client.py", line 150, in get_upvote_info
return await self.http.get_upvote_info(bot_id, onlyids, days)
File "C:\Users\Giraffe\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dbl\http.py", line 255, in get_upvote_info
return await self.request('GET', f'{self.BASE}/bots/{bot_id}/votes' + urlencode(params))
File "C:\Users\Giraffe\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dbl\http.py", line 207, in request
raise NotFound(resp, data)
dbl.errors.NotFound: Not Found (status code: 404): {"error":"Not Found"}
and your code being used?
This was a test to see if it worked
@commands.command()
async def voted(self, ctx):
voted = await self.dblpy.get_upvote_info()
print(voted)
I set self.dblpy = dbl.Client(self.bot, self.token) in the init function
1 second
Traceback (most recent call last):
File "C:\Users\Giraffe\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 62, in wrapped
ret = yield from coro(*args, **kwargs)
File "C:\Users\Giraffe\Desktop\GiraffeBot2\Lock&KeyTest\cogs\ServerCount.py", line 90, in voted
voted = await self.dblpy.get_upvote_info(self.bot.user.id)
TypeError: get_upvote_info() takes 1 positional argument but 2 were given
what python version are you using?
3.6.4
hm
wait 3.6.2 apparently
I am on the latest version of the dblpy lib and I am using Python 3.6.4.post_server_count() returns a Forbidden: Forbidden (status code: 403): {"error":"Forbidden"} error.
@opal zealot I wouldn't use the lib and just use aiohttp
check your token
You could be ratelimited
ratelimited is 429
o
token is correct, still getting forbidden error
make sure its a token from discordbots.org and not your discord bot token
i got the token from https://discordbots.org/api/docs#mybots
so its not my discord bot token
iirc there's a different token you can take from a different place of dbl
oh no wait, that's the one I'm talking about lol
Are you sure it's a string and not a number or something
it cant be in '' can it -.-
lol ofc it must be a string
put it inside quotes
Python can use either ' or " doesn't matter
Aslong as it is enclosed with same chars
It's recommend to stick to one style tho
" > '
another question, are you sure you copied the whole token? for example, my monitor is small enough to hide the last bit of the token, so you know...
I had to zoom out to get the rest of it ๐
I like the way you hide your token xd
yes xd
I'm not exactly sure what the issue is tho
@arctic arch you probably dont want to be pinged but do you have an idea of the issue?

wew i get to ask the dev of discord.py xd
owat
the api lib
i am using that example from https://discordbots.org/api/docs#pylib
xd
@golden wind
@golden wind i need help ;-;
can you not post whatever this is here >_<
How I Use DBLapi When I Run node bot.js or node . Is Not Woring
cancer please
?
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Nubs');
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size);
}, 1800000);
});```
I Add This
yeah and whats the error it produces?
Nothing
also did you install dblapi.js
yep
yep
show? it should do something ๐
wait
my bot says started successfully
Token Discordbot?
?
Your discordbots.org token?
hm hold on
const DBL = require("dblapi.js");
const dbl = new DBL(` YOUR TOKEN FOR DISCORDBOTS.ORG HERE `);
setInterval(() => {
dbl.postStats(client.guilds.size);
}, 1800000);
see ^
you set it up like that and add the interval into ready
Where I GOt Token?
on your bot's edit page
just put your token in and thats it
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('o');
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size);
}, 1800000);
});```
CANT xD
HELP
you might wanna blank out ur token
?
How?
DONE
K
K
(node:6964) UnhandledPromiseRejectionWarning: Error: postStats requires 1 argument at DBLAPI.postStats (C:\Users\user\Documents\ZTzHex\node_modules\dblapi.js\index.js:49:45) at Timeout.setInterval [as _onTimeout] (C:\Users\user\Documents\ZTzHex\bot.js:7:13) at ontimeout (timers.js:458:11) at tryOnTimeout (timers.js:296:5) at Timer.listOnTimeout (timers.js:259:5) (node:6964) 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)
WHY?
help
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL(`? `, client);
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});```
HOW?
When I Run Node . Nothing Happend
oh my god
hi
Ye
@opal zealot server count is giving you a 403? ๐
your token too
@golden wind yes ;-;
Dont really know if this should go here, it seems like Github cached my widget. It's not updating on my readme and is now stuck at offline.
Anyone else that has had this issue?
browser cache
Oh really? K i'll try that out
No, not a fix
K sorry, fixed it by removing the cookie from discordbots, not by clearing cache. Thanks
github likes caching images
@arctic arch Ye, but with the right headers you can force it not to cache badges. It was actually when I found a cookie in the headers from discordbots that I found out how to fix it
set-cookie: __cfduid=d4619aac4b1ac607f6f8177baa49dd1471520890074; expires=Tue, 1
It's not a big issue though, it has an expiredate
that's irrelevant to caching
That's what I thought, but when I removed that cookie that's when I was able to see it being online again.
But now I think about it
probably a coincidence
That shouldnt have worked so ye maybe a coincidence
Do we have a way of inputting HTML code?
wat
.... Anyways.... is there any way of inputting HTML tags.....
where?
in messages?
yes
Thanks
@golden wind Do you know why im getting a 403? 
@opal zealot wrong token?
no
im getting a 403: Forbidden error
the token is correct
from the discordbots.org api docs
what are you trying to do
Im trying to post server count
how sure are you that you have the rigth token
i got it from here
and
my bots edit list
they are both same
discordbots edit list
list?
i mean edit the bot watever
u get the point xd
@opal zealot triple check you haven't accidentally missed letter off the token
otherwise send me the full traceback
k
hey guys, im getting 404 error with the url https://discordbots.org/api/bots/{id} Got my header with params key Authorization and value the token from my edit page. Any idea what im doing wrong?>
also get this Could not get any response There was an error connecting to https://discordbots.org/api/bots/281874979191259136. Why this might have happened: The server couldn't send a response: Ensure that the backend is working properly Self-signed SSL certificates are being blocked: Fix this by turning off 'SSL certificate verification' in Settings > General Client certificates are required for this server: Fix this by adding client certificates in Settings > Certificates Proxy configured incorrectly Ensure that proxy is configured correctly in Settings > Proxy Request timeout: Change request timeout in Settings > General
Are you using the right method? @scarlet cobalt
trying to use any other method besides GET will return a 404
because that isn't a valid user id 
on that endpoint, i mean
oh yeah, thatll also return a 404
Are you trying to do this in a browser? ๐ค
here, @inner venture and @robust olive
then the bot ID is invalid
ohh blurp -,- i though it was discord snowflake, but discordbots has its own id

thx anyways ๐
it is the discord id
arent user ids snowflakes
yeah, they are
So mass pinging or giving a pingable role (those anyone can mention) to those that didn't upvote are officially not allowed?
You can ping like say in an announcement channel or something asking people to vote, but don't abuse it ?
re: emote servers that spam the shit out of those that don't upvote
ok
Hello, how Can my bot get accepted :D ?
Submit it, and wait
not this channel anyway
you need to learn how to use promises
promise is a special kind of object in javascript
which represents a value after some time
when the underlying method executes
you have 2 ways to get values out of promises
- Using async funtions/await
- Using Promise.then
so what you want to do
is
apicall(whatever).then(function(returnValue) {
// Do stuff with return Value
});
Ok
@cunning forum its time to change ur profile pic to the new scary android turtle
Do vote webhooks fire on each daily vote, or just one time?
Also does it set the Content-Type header correctly?
b/c some web frameworks are weird and will interpret a POST as application/x-www-form-urlencoded unless Content-Type is explicitly set to application/json
afaik it has the correct content type
I can confirm
Thank
Webhooks are a general term
Discord webhooks do not work
You must setup your own webserver of some kind to fetch the webhook they send
do you know how to interact with rest apis
Nope
perhaps you should read up on that ^^
Okay
discord.js
Lol
memes
is there an easy way to get all upvotes for the month
or do I have to do ?days=numberofdayssincereset
Hello, i'm curious on how to post my server count to the DBL API, I have tried the example code, however, I get an error message stating: Forbidden: Forbidden (status code: 403): {"error":"Forbidden"} Traceback (most recent call last): File "C:\Users\jackg\Desktop\My Bot\Post.py", line 32, in update_stats await self.dblpy.post_server_count() File "C:\Users\jackg\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\jackg\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\jackg\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"} it might be useful for you to know that I am using async as a pose to rewrite
@ocean sky are you using the right token
yeah
ok
with the correct bot, right?
yes
youre 200% sure?
201% sure
wait one time some of my token was hidden offscreen
hmmmm
thats all i got ๐คท
I just checked the token in my code and the token on the API, and they are both identical....
can i see the code you're using to call the client?
"""Handles interactions with the discordbots.org API"""
def __init__(self, bot):
self.bot = bot
self.token = 'Tis a secret' # 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))``` is anything wrong with my code?
there it is lol ๐
That is within a cog BTW
hmmm
๐ change len(self.bot.guilds) to len(self.bot.servers)
oh yea....
ooohh
nope, same error message
really?
yes
I know in the lib it tries servers then guilds
what version of dblpy are you using?
0.1.6?
I believe so
and py?
0.16.12
and dblpy is different to discord.py
Oh hey Francis 0.1.6 fixed getting votes
rip
ooh that'd be awesome, I was looking into web servers today to handle them myself
I'm still confused at why it says i'm forbidden to post the server count
should
are you triply sure its the correct token?
I still think your token is wrong but you just didn't notice
Maybe try regenerating it
yep, I even regened and replaced it
no secret spaces or anything?
nope
trailing whitespace?
what?
spaces at the beginning or end
nope...not like that
hmm
Got the right bot token right
yep
what bot id is it?
no I meant on dbl, you picked the right bot from the list right
yes
idk how many bots you have so might as well cover all ground
I have 2....there both very much distinguishable between each other
the only reason that a 403 would be sent back is that your token is incorrect
hmmm
I'll try it again....and possibly agin....
I've regened and replaced it once...still doesn't work...
hmmmf
quick check, the token is found under the My bots section correct?
yes
ok, I was just making sure I got it from the right place lol
Does anyone else know why I get a 403 error when I try to post my server count to the DBL API?? (I must have regened and replaced my DBL 50 times now BTW)
what can the Webhooks do?
can it like, for example, send a message into a guild when I edit the bot's page
No
https://hannah.is-pretty.cool/67ed94.png @loud harbor
wrong chat
no?
Ok
I would though
How do I start the bot
Does anyone know how to receive only IDs when sending a get request to https://discordbots.org/api/bots/346353957029019648/votes? I remember there was a way but I forgot how and I cant be bothered to download a library
onlyids=true
Do I add that as a header or? Sorry Im not very familiar with http xd
add it on to the end of your url
Oh I see, thanks!
I've never actually used a webhook before and i'm trying to figure this out, how do I just make a simple thing where it prints the id of a user that votes? (python)
@restive otter You have to setup a webserver to receive the post request that DBL sends to your url
aand how do I make a webserver? I don't have my own website.
Tutorials. Just don't copy and actually change some things.
hm ok I'll keep looking then
oh so you do need to make a website guess i'm not doing this then
@restive otter no, you dont
hi
@golden wind The api is working just fine on windows, but Im still getting this error on Debian 9: ```Python
Traceback (most recent call last):
File "run.py", line 9, in <module>
from stats import dbl_stats
File "../stats/dbl_stats.py", line 1, in <module>
import dbl
File "/usr/local/lib/python3.5/dist-packages/dbl/init.py", line 19, in <module>
from .client import Client
File "/usr/local/lib/python3.5/dist-packages/dbl/client.py", line 31, in <module>
from .http import HTTPClient
File "/usr/local/lib/python3.5/dist-packages/dbl/http.py", line 234
await self.request('POST', f'{self.BASE}/bots/{bot_id}/stats', json=payload)
^
SyntaxError: invalid syntax
Python 3.5.3
@primal lark update to python 3.6; that type of string formatting is only supported in 3.6
Lol
INFO:discord.client:logging in using static token
ERROR:bot:Failed to post server count
Unauthorized: Unauthorized (status code: 401): {"error":"Unauthorized"}
Traceback (most recent call last):
File "C:\Users\jackg\Desktop\My Bot\post.py", line 33, in update_stats
await self.dblpy.post_server_count()
File "C:\Users\jackg\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\jackg\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\jackg\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dbl\http.py", line 158, in request
raise Unauthorized(resp, data)
dbl.errors.Unauthorized: Unauthorized (status code: 401): {"error":"Unauthorized"}``` Does anyone know why I get this error message when I attempt to post my server count to the DBL API?
I don't even get an error message xd ```py
class DiscordBotsOrgAPI:
"""Handles interactions with the discordbots.org API"""
def __init__(self, bot):
self.bot = bot
self.token = 'asdf' # 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.servers)))
except Exception as e:
logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
await asyncio.sleep(1800)
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(DiscordBotsOrgAPI(bot))```
just nothing happens
hmmm
yeah this api thing is broken i'm just gonna give up on it
nothing is working for me
yeah...
@primal lark update the library i fixed that
@restive otter its not broken, it just wont post anything to your console if you haven't set up logging correctly
Thanks man ๐ค
@ocean sky it isn't broken. you just don't send authorization
In the header you have to set authorization with your discordbotsapi token
recommend that you look for scripts that use aiohttp if you're going for manually because using requests or urllib will make your bot slower
oh ok
why u ping me 
ohhhhhh, I pinged the worng user.....i'm really sorry...I meant to ping someone else
When I run: dbltoken = "Tis a secret" url = "https://discordbots.org/api/bots/" + bot.user.id + "/stats" headers = {"Authorization" : dbltoken} I get the error message url = "https://discordbots.org/api/bots/" + bot.user.id + "/stats" AttributeError: 'NoneType' object has no attribute 'id'
Is your client named bot?
yes
hmm
(also make it a string)
Well there is something wrong with your client. I think. User should not be none
so should I just replace bot.user.id with a string that is my bots id?
If you want.
ok
client_response: <ClientResponse(https://discordbots.org/api/bots/423889279630966787/stats) [401 Unauthorized]>
<CIMultiDictProxy('Date': 'Sat, 17 Mar 2018 16:35:12 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '24', 'Connection': 'keep-alive', 'Set-Cookie': '__cfduid=d96b13d2d772f5ea230dc624995631db41521304512; expires=Sun, 17-Mar-19 16:35:12 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-Cacheable': 'NO', 'X-Varnish': '890733437', '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': '3fd0df100ea4353c-LHR')>``` WTF???
Have you entered your token
yes
May I see the full script without tokens?
url = "https://discordbots.org/api/bots/" + '423889279630966787' + "/stats"
headers = {"Authorization" : dbltoken}``` It goes where `tis a secret` is right?
But show me the actual aiohttp code you're using
dbltoken = "token"
url = "https://discordbots.org/api/bots/" + bot.user.id + "/stats"
headers = {"Authorization" : dbltoken}
async def on_ready():
payload = {"server_count" : len(bot.servers)}
requests.post(url, data=payload, headers=headers)
async def on_server_join(server):
payload = {"server_count" : len(bot.servers)}
requests.post(url, data=payload, headers=headers)
async def on_server_remove(server):
payload = {"server_count" : len(bot.servers)}
requests.post(url, data=payload, headers=headers)``` That's the example that I copied
Ah
Wouldn't recommend for every server join and remove
Yeah but it's fine for now
hmmm
import requests
import json
dbltoken = "token"
url = "https://discordbots.org/api/bots/" + bot.user.id + "/stats"
headers = {"Authorization" : dbltoken, "Content-Type" : "application/json"}
async def on_ready():
payload = {"server_count" : len(bot.servers)}
requests.post(url, data=json.dumps(payload), headers=headers)
async def on_server_join(server):
payload = {"server_count" : len(bot.servers)}
requests.post(url, data=json.dumps(payload) headers=headers)
async def on_server_remove(server):
payload = {"server_count" : len(bot.servers)}
requests.post(url, data=json.dumps(payload), headers=headers)
should I try that instead?
Yeah just try it
ok
It's similiar to what I use
Also while I'm at it I want to recommend looking into discord.py rewrite
It has better support for sharding, categories and uses cleaner code https://discordpy.readthedocs.io/en/rewrite/
LOL
pip3 install discord-rewrite
oo
But that's getting a bit offtopic
requests.post(url, data=json.dumps(payload) headers=headers)
^
SyntaxError: invalid syntax``` doesn't work...
shouldn't there be a comma after data?
idk
Yea
Sorry my bad
so, where does the comma go?
after data=json.dumps(payload)
u need to install it
i think
yea, just tried it lol
ok...my bot actually loaded this time...
no error has been logged
Is your count getting posted
how many servers do you have?
-bots @ocean sky
@vivid moth
@keen flume
cause it says 4
ik
when I checked this morning it magically said 4
I recently added the ot to another server tho
r = requests.post(url, data=json.dumps(payload), headers=headers)
print(r.status_code)
print(r.text)
where do I put that?
Replace requests.post with that
under on_ready & on_server_join etc?
It'll show you the HTTP status code
oh ok
Just on_ready for now
ok
You'll only need it to show you if it's being send
If it's 200 it's ok
If it's 404 or 401 or something there is a mistake
https://cdn.discordapp.com/attachments/264445053596991498/307272430047461377/unknown.png is a great cheat sheet
It shows nothing what so ever...
hmm
hmm
really weird
never mind, i placed it in on_server_join
lole
lol
my bad..lemme fix that
{"error":"Unauthorized"}```....am I banned from posting the server count or something?
ahh ok
it's a 401 BTW
No, are you sure you have copied your token in full?
Are you using the DiscordBotsAPI token?
YES!
wtf
hmmmm? ๐ค
Are you sure you are using the correct bot ID and not the ID of your other bot?
Do I need to change "Authorization"????
No that is correct
ok
what about it?
That's how it should work
ok...
but afaik your code has that correctly
"Content-Type" : "application/json" what about this?
You post your stats as a json object
How did you post it before
This tells DBL that you are actually sending JSON
I didn't @inner venture ...idk how I did
OK
maybe something is borked on dbl's side
It's not working for me either
Im guessing cos that token is incorrect tho
hmmm....
i'll regen the token, send it to you again (and try myself) if not then dbl is broen
https://discordbots.org/api/docs#mybots the token for your bot is located here
ik where my dbtoken is
user tokens anyone? 
hmmm
yea, @sudden rampart i'm sending my token in DM as a last desperate attempt....i'll regen my token if it doesn't work anyway
OK, it worked
I got a 200 message
nice
ik
YES!
My bot actually has a chance to get certified...it just depends on how popular it becomes...
Only problem now is that my bot responds to commands twice per command....
....I do actually...come to think of it
yea, I did
ty for all of your help everyone ๐
did someone here invite my bot into their server....cos in my dev server I just got a mod log stating that the bot joined it's 6th server?
well it's on the list so someone probably added it from there 
unless you have the bot role from another bot in which case idk lol
you were probably right the first time...I was just curious that was all ๐
I need some help. I have been trying to figure out the problem and i dont know what is wrong.
I am using Python 3.6.4 and the discord.py rewrite. Here is my code:
import discord
from discord.ext import commands
import aiohttp
class zdblapi:
def __init__(self, bot):
self.bot = bot
import aiohttp
dbltoken = "no token for you"
url = "https://discordbots.org/api/bots/no id for you/stats"
headers = {"Authorization" : dbltoken}
async def on_ready(self, guild):
payload = {"server_count" : len(self.bot.guilds)}
async with aiohttp.ClientSession() as aioclient:
await aioclient.post(url, data=payload, headers=headers)
async def on_server_join(self, guild):
payload = {"server_count" : len(self.bot.guilds)}
async with aiohttp.ClientSession() as aioclient:
await aioclient.post(url, data=payload, headers=headers)
async def on_guild_remove(self, guild):
payload = {"server_count" : len(self.bot.guilds)}
async with aiohttp.ClientSession() as aioclient:
await aioclient.post(url, data=payload, headers=headers)
def setup(bot):
bot.add_cog(zdblapi(bot))
The server count just doesn't update. So, I made a little server count updater in discord.js
and it worked, it updated the server count. To test if the python one worked, I set the discord.js counter to 3, started and ended the process. My bot is in 13 servers, and the server count didnt update.
Add a 'Content-Type': 'application/json' header
Try import json
and do data=json.dumps(payload)
import discord
from discord.ext import commands
import json
import aiohttp
class zdblapi:
def __init__(self, bot):
self.bot = bot
import aiohttp
dbltoken = "no token for you"
url = "https://discordbots.org/api/bots/422019359603556362/stats"
headers = {'Content-Type': 'application/json', "Authorization" : dbltoken}
async def on_ready(self, guild):
payload = {"server_count" : len(self.bot.guilds)}
async with aiohttp.ClientSession() as aioclient:
await aioclient.post(url, data=payload, headers=headers)
async def on_server_join(self, guild):
payload = {"server_count" : len(self.bot.guilds)}
async with aiohttp.ClientSession() as aioclient:
await aioclient.post(url, data=payload, headers=headers)
async def on_guild_remove(self, guild):
payload = {"server_count" : len(self.bot.guilds)}
async with aiohttp.ClientSession() as aioclient:
await aioclient.post(url, data=payload, headers=headers)
def setup(bot):
bot.add_cog(zdblapi(bot))
i probably did something wrong, because it still doesnt work

