Closed SpectrixDev closed 6 years ago
probably using an outdated token tbh
o shit hello
i'd just like to confirm it's not an outdated token
Broh the dbl api won't just accidentally fuck up up your token, fix that shit. Also coding your tokens straight into the code is a bad idea cus you have to change it then change it back every single time you push to GitHub.
I know, that's why I'm changing that. I'm busy doing it all in the new branch Spectrum-main. But I'm afraid it's not a broken token. Token matches the website exactly.
There's a way to publish without using the dbl api. Just use aiohttp.ClientSession()
to get it from the actual source.
import aiohttp
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)}
async with aiohttp.ClientSession() as aioclient:
await aioclient.post(url, data=payload, headers=headers)
async def on_server_join(server):
payload = {"server_count" : len(bot.servers)}
async with aiohttp.ClientSession() as aioclient:
await aioclient.post(url, data=payload, headers=headers)
async def on_server_remove(server):
payload = {"server_count" : len(bot.servers)}
async with aiohttp.ClientSession() as aioclient:
await aioclient.post(url, data=payload, headers=headers)
I'll try that soon. I've tried something similar before
Ok so after 27 days I actually tried it. Thanks.
And here's the code (I changed it to rewrite) if anyone has the same problem
It never works and I'm still getting errors now
Failed to post server count Unauthorized: Unauthorized (status code: 401): {"error":"Unauthorized"} Traceback (most recent call last): File "/home/Spectrix/cogs/dblUpdater.py", line 25, in update_stats await self.dblpy.post_server_count() File "/home/Spectrix/.local/lib/python3.6/site-packages/dbl/client.py", line 100, in post_server_count Unauthorized: Unauthorized (status code: 401): {"error":"Unauthorized"} await self.http.post_server_count(self.bot_id, self.guild_count(), shard_count, shard_no) File "/home/Spectrix/.local/lib/python3.6/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 "/home/Spectrix/.local/lib/python3.6/site-packages/dbl/http.py", line 158, in request raise Unauthorized(resp, data) dbl.errors.Unauthorized: Unauthorized (status code: 401): {"error":"Unauthorized"}
Basically, it's saying it's unauthorized, and i checked the api on github https://github.com/DiscordBotList/DBL-Python-Library/issues/5 So apparently it's a bug
Any other ways of posting to the discord bot list api that actually work?