#topgg-api
1 messages · Page 43 of 1
like do i need to open something to let it not forbid the domain or something
@arctic arch is there anything i should change on my end or is it something on the website i need to change
yes everytime
the bot or the dbl
ima go test
no i dont only one
wait lol i fixed it somehow#
my brain kicked in better
had to install dbl in to lib file in my bot not from the python3.5 site packages
Ok, I'm still pretty confused on how to use the DBL Python API. Can I be show like an example.
there is
@zinc lintel there is a server count example here https://github.com/DiscordBotList/DBL-Python-Library#example
A simple API wrapper for discordbots.org written in Python - DiscordBotList/DBL-Python-Library
oh yeah @arctic arch api/docs#golib is still pointing to the old one
I shall delet
ive come back again about this error
Failed to post server count
Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}
Traceback (most recent call last):
File "/home/uniquebot/cogs/discordapi.py", line 24, in update_stats
await self.dblpy.post_server_count()
File "/usr/local/lib/python3.5/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 "/usr/local/lib/python3.5/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 "/usr/local/lib/python3.5/site-packages/dbl/http.py", line 160, in request
raise Forbidden(resp, data)
dbl.errors.Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}
Isnt that incorrect/no token provided?
the token is there it works but it shows that error when i load the bot and then every 30 mins it shows some other error
it'll be helpful if you print the payload and the url endpoint
i dont get what you mean show what like
sorry kinda new to putting api stuff on a bot
and that error up there is the only error i see
then print debug info
humm i dont see that weird
what
i dont see the debug info
your code where you passed the parameters
class DiscordBotsOrgAPI:
"""Handles interactions with the discordbots.org API"""
def __init__(self, bot):
self.bot = bot
self.token = my token'
self.dblpy = dbl.Client(self.bot, self.token)
self.bot.loop.create_task(self.update_stats())
async def update_stats(self): # error is from this line
"""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)
that ??
wait @sand hazel do i need to open a port
as i can do that
the dbl or the discordapi file
if discordapi file that is in my cogs file
loaded in its own cog
fyi 403 means wrong token
403 is forbidden
this is wrong token btw
raise UnauthorizedDetected('Unauthorized (status code: 401): No TOKEN provided')
mine is a different error
should i test the api on my pc and see if it works
lmao it might be the library's issue
can you goto L189 in http.py and print the endpoint and the payload
it's most likely malformed request, so you'll need to add debug lines
wait one sec lol ant even loaded the api
im dumb
nope i was wrong i should ive looked before i typed lol
ok ima go to that line you said
@sand hazel here
await self.request('POST', '{}/bots/{}/stats'.format(self.BASE, bot_id), json=payload)
thats on line 189
alright print the formatted endpoint and the payload
... lost could you be able to ring me and help me over call as im getting lost
man I don't even use python 
oh i see you use .go my bad
print '{}/bots/{}/stats'.format(self.BASE, bot_id)
print payload
prob want to redact payload part when you show other people
am i adding the
print '{}/bots/{}/stats'.format(self.BASE, bot_id)
print payload
in the discordapi file
that look good
what line
24
and that line content is?
print '{}/bots/{}/stats'.format(self.BASE, bot_id)
print()
i thought print alone also works 
print thing is 2.x syntax
does it need "" not ''
there's also an open issue regarding the forbidden error
use parenthesis with print
i forgot py3 is different

try
^
print payload
^
SyntaxError: Missing parentheses in call to 'print'
the same thing
^
ok it loaded
{}/bots/{}/stats
Failed to post server count
AttributeError: 'NoneType' object has no attribute 'format'
Traceback (most recent call last):
File "/home/uniquebot/cogs/discordapi.py", line 24, in update_stats
print ('{}/bots/{}/stats').format(self.BASE, bot_id)
AttributeError: 'NoneType' object has no attribute 'format'
yer sorry about this im still learning little things but il get there
print ('{}/bots/{}/stats').format(self.BASE, bot_id) suppose be print ('{}/bots/{}/stats'.format(self.BASE, bot_id))
is it?
print func does not have format to it
ok this is only the error now
Failed to post server count
AttributeError: 'DiscordBotsOrgAPI' object has no attribute 'BASE'
Traceback (most recent call last):
File "/home/uniquebot/cogs/discordapi.py", line 24, in update_stats
print ('{}/bots/{}/stats'.format(self.BASE, bot_id))
AttributeError: 'DiscordBotsOrgAPI' object has no attribute 'BASE'

oh you are suppose to put that in the http.py
prior to await self.request
L188
async def post_server_count(self, bot_id, guild_count, shard_count, shard_no):
if shard_count:
payload = {
'server_count': guild_count,
'shard_count': shard_count,
'shard_no': shard_no
}
else:
payload = {
'server_count': guild_count
}
'''Some debug stuff'''
print('{}/bots/{}/stats'.format(self.BASE, bot_id))
print(payload)
await self.request('POST', '{}/bots/{}/stats'.format(self.BASE, bot_id), json=payload)
rip discord indentation
but you get the point
you have some small screen
welp
https://discordbots.org/api/bots/None/stats
{'server_count': 0}
Failed to post server count
Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}
Traceback (most recent call last):
File "/home/uniquebot/cogs/discordapi.py", line 24, in update_stats
await self.dblpy.post_server_count()
File "/usr/local/lib/python3.5/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 "/usr/local/lib/python3.5/site-packages/dbl/http.py", line 193, in post_server_count
await self.request('POST', '{}/bots/{}/stats'.format(self.BASE, bot_id), json=payload)
File "/usr/local/lib/python3.5/site-packages/dbl/http.py", line 160, in request
raise Forbidden(resp, data)
dbl.errors.Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}
and there you go
why is it /bots/None/stats tho
looks like the library's fault
should i change something
looks like it's None when the user isn't logged in?
looks like its posting to None
make a pr and fix it
do I look like I know python
is it ok to use or should i disable for now
you could try manually POSTing stats with aiohttp
^
ive never messed with this stuff lol
or just use https://pypi.org/project/discordlists.py
A simple API wrapper for botblock.org providing server count posting to all bot lists and fetching bot information from all.
it's prob easier to do it yourself
isnt that for some other discord list thing
it works with all lists including DBL
so all i need to do is install and bam should work
ye
^^ something like that
im trash at adding this stuff lol
How do i tell that my bot can have a custom prefix on the website ?
-play sad
could get banned
to some commands?
uh wait wrong page hold on
so you can use the /bots/{bot.id?}/votes endpoint if your bot has low upvotes, otherwise you have to use a webhook
yea thats not working
the endpoint?
you send an API GET request to https://discordbots.org/api/bots/012345/votes and it'll respond with some json, can't remember exactly what it is but it's some array (with 012345 obviously being your bot's ID)
For some reason I can't post my guild count with the API using node.js. I copied the code from the docs
It won't even give me the error console log
did you wait 30 minutes?
there might be instances where your bot isn't sharded and you also copied all the code including the code for shard size, try removing it if so
Where i can set my bot state to online with
dbl.on('posted', () => {
console.log('Server count posted!');
})
event ?
^
and the exception is?
Failed to post server count
Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}
Traceback (most recent call last):
File "C:\Users\hamza_000.HAMZA.000\Desktop\discord bot python\ChatManager\Chat Manager 5\DiscordBotsOrgAPI.py", line 25, in update_stats
await self.dblpy.post_server_count()
File "C:\Users\hamza_000.HAMZA.000\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\hamza_000.HAMZA.000\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\hamza_000.HAMZA.000\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"}
got anything?
import dbl
import discord
from discord.ext import commands
import aiohttp
import asyncio
import logging
class DiscordBotsOrgAPI:
"""Handles interactions with the discordbots.org API"""
def __init__(self, client):
self.client = client
self.token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjUxMTYwNDMzODI5Mjk0OTAxNCIsImJvdCI6dHJ1ZSwiaWF0IjoxNTQyNTYzODIxfQ.9Ttr7uFhY9-tBIjsbuscmERw2UNwy9O6gwkt7kpc8rQ'
self.dblpy = dbl.Client(self.client, self.token)
self.client.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(client.servers)}))
except Exception as e:
logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
await asyncio.sleep(1800)
def setup(client):
global logger
logger = logging.getLogger('client')
client.add_cog(DiscordBotsOrgAPI(client))
my code
i regenerated it
alright
yeah i think that's a known bug in the py library
I am having an issue. When I attempt to post server count from the example from https://discordbots.org/api/docs#pylib I get a 403: Forbidden error. The token is correct. I used the token from http...
Giving the author time to fix it, before I dive into it myself
how can i fix this?
Ensure the user state exist before trying to post
It's None when the client is not logged in yet
how do i do that
im not that good with coding so i dont understand 😅
how long is that gonna take
¯_(ツ)_/¯
try Node.js
i use python
just wait or you can create the payload yourself
aiohttp to the endpoint
upon bot ready
then just set a timer
!info-server
@sand hazel How i can invite it here if i just kick him (i want to test something 🤐)
Possible to reinvite my bot (sorry for pinging 😋)
Here is my bot : https://discordbots.org/bot/457184443308965900
you can create a server, then use that to test it, btw information about terrestrial objects, heavenly bodies, might be good feature for spacebots
nevermind, my discordapp lagged for a bit noticing that the problem was already solved
@hexed glade why are you chatting in #topgg-api
In offtopic so?
this channel is only for help with the dbl api
okay
Hello some vote for my bot are not send on the webhook and it's all the time the same people who yet following a verification we vote well but it works for all other people I wonder where it can come
English
@restive otter english only
can I send the weebhook to a channel?
what do you mean?
like
dbl.webhook.on('vote', vote => {
bot.channels.get('id').send(`User with ID ${vote.user} just voted!`)
});
How do I even make a webhook url and stuff
You deploy a http server
like in glitch?
sure
So i host on glitch
and
do I make another website that gets pinged if someone is on it?
then do somtin crazy
w h a t
idk
@digital linden do you use express
you can either
- use dblapi.js and connect it to your express server, or
- just make a post route in express
use the webhookServer option in dblapi.js
?????
ok
for example
const DBL = require('dblapi.js');
const dbl = new DBL(yourDBLTokenHere, { webhookServer: app, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
assuming your server is app
then your webhook URL will be https://projectname.glitch.me/dblwebhook
yw
doesnt matter
ok
and dont mention random people
actually its better to put your token in a different file
ok
like your .env file
you dont need webhookPort
you need webhookServer though
i already said its your express server
o
if you have const app = express() then the webhookServer should be app
if (server && !(server instanceof Server)) throw Error('The server is not an instance of http.Server');
^
Error: The server is not an instance of http.Server
at new DBLWebhook (/rbd/pnpm-volume/0bf93457-01e6-4b5a-ab05-cd0ed5739e31/node_modules/.registry.npmjs.org/dblapi.js/2.3.0/node_modules/dblapi.js/src/webhook.js:23:54)
at new DBLAPI (/rbd/pnpm-volume/0bf93457-01e6-4b5a-ab05-cd0ed5739e31/node_modules/.registry.npmjs.org/dblapi.js/2.3.0/node_modules/dblapi.js/src/index.js:69:22)
at Object.<anonymous> (/app/discordbots.js:4:13)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
ummmmmmmmmm
@plain timber PLS HELP
also what the authorization thing
goodbye children
@humble bison oh yeah I found some pseudocode for that permission check as well
def compute_base_permissions(member, guild):
if guild.is_owner(member):
return ALL
role_everyone = guild.get_role(guild.id) # get @everyone role
permissions = role_everyone.permissions
for role in member.roles:
permissions |= role.permissions
if permissions & ADMINISTRATOR == ADMINISTRATOR:
return ALL
return permissions
def compute_overwrites(base_permissions, member, channel):
# ADMINISTRATOR overrides any potential permission overwrites, so there is nothing to do here.
if base_permissions & ADMINISTRATOR == ADMINISTRATOR:
return ALL
permissions = base_permissions
overwrite_everyone = overwrites.get(channel.guild_id) # Find (@everyone) role overwrite and apply it.
if overwrite_everyone:
permissions &= ~overwrite_everyone.deny
permissions |= overwrite_everyone.allow
# Apply role specific overwrites.
overwrites = channel.permission_overwrites
allow = NONE
deny = NONE
for role_id in member.roles:
overwrite_role = overwrites.get(role_id)
if overwrite_role:
allow |= overwrite_role.allow
deny |= overwrite_role.deny
permissions &= ~deny
permissions |= allow
# Apply member specific overwrite if it exist.
overwrite_member = overwrites.get(member.user_id)
if overwrite_member:
permissions &= ~overwrite_member.deny
permissions |= overwrite_member.allow
return permissions
def compute_permissions(member, channel):
base_permissions = compute_base_permissions(member, channel.guild)
return compute_overwrites(base_permissions, member, channel)
@digital linden hm, do you have an app.listen line?
no
wait
@plain timber I have this in another js file
const express = require("express");
const app = express();
app.get("/", (request, response) => {
console.log("Ping received!");
response.sendStatus(200);
});
// listen for requests :)
const listener = app.listen(process.env.PORT, function() {
console.log('Your app is listening on port ' + listener.address().port);
});
wdym
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});```
that
you don't really need that
no it cant run
because of the error
/rbd/pnpm-volume/0bf93457-01e6-4b5a-ab05-cd0ed5739e31/node_modules/.registry.npmjs.org/dblapi.js/2.3.0/node_modules/dblapi.js/src/webhook.js:23
if (server && !(server instanceof Server)) throw Error('The server is not an instance of http.Server');
^
Error: The server is not an instance of http.Server
at new DBLWebhook (/rbd/pnpm-volume/0bf93457-01e6-4b5a-ab05-cd0ed5739e31/node_modules/.registry.npmjs.org/dblapi.js/2.3.0/node_modules/dblapi.js/src/webhook.js:23:54)
at new DBLAPI (/rbd/pnpm-volume/0bf93457-01e6-4b5a-ab05-cd0ed5739e31/node_modules/.registry.npmjs.org/dblapi.js/2.3.0/node_modules/dblapi.js/src/index.js:69:22)
at Object.<anonymous> (/app/discordbots.js:5:13)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)```
what error
that
did you put the console.log code before or after your dbl code
ifk
idk
its not there anymore
wait
@plain timber it spams 🚘🌇 Your app is listening on port 3000
and Bot is online
and Ping Recived
what
idk
what if you comment out the dbl code and put console.log(app)
so we can see what app is
ok
you said the express code was in a different file right
yea
but I copy and pasted in const express = require("express");
const app = express();
no dont do that
Here just take my code
10x easier to read
either put your dblapi.js code in the server file, or export app from the server file
ok
or just move the server code to the discordbots file and delete the server file
delete the discordbots.js file
ok
ok
also what is an authorization
on the dbl
the Authorization
You can use this value to verify the requests are coming from us.
just set webhookAuth to the same thing as Authorization in the edit page
its to prevent someone else from pretending to be dbl and making fake votes
I dont have a Authorization
wdym
like it just says abcdefghijklmnopqrstuv
🤔
Yes, you need to choose an authorization code
how?
Just pick something and type it into both the edit page and your code
ok
And remember the URL is https://projectname.glitch.me/dblwebhook
jeez this is still going 
me
yeah
XD
how do yall read this
no?
ok
DBL fires post requests
ok
Is there any resources on how to work with the webhooks here?
I'm new to webhooks and I'm not sure how I'll make them work
and it doesn't seem to be any webhook features in the python lib 
Yeah, things don't even run in the right order when posting in that lib, so I had to change some stuff
don't have anything to check the status if a member has voted within 24h by sending the user_id
so I had to add that too
I've read some history in this chat, and I assume one way to do it could be creating a webhook URL in discord, for a channel in my support server, and have all the votes go to that channel, and then my bot just picks up and checks / rewards the user
For webhooks, DBL will send a post request to the specified url with the vote data
or maybe I'm wrong
So you just need to receive the post request
it was maintained by francis
is he in here
tho I think they left the server
Yeah I know is sends a post request with data
dem activity tho: https://github.com/FishyFing
@cobalt ruin wanna contact francis?
if he's leaving it unmaintained the position is open
It's mainly this issue: https://github.com/DiscordBotList/DBL-Python-Library/issues/5
I am having an issue. When I attempt to post server count from the example from https://discordbots.org/api/docs#pylib I get a 403: Forbidden error. The token is correct. I used the token from http...
There were several people in here that had this
phew, make a pr
the thing is, there is only 1 line of code that fixes it
the example used on the github should be correct and working
do tell
but the example on the website is not
o
let me see if it's still the same
yeah it's different
await self.bot.is_ready()
this line
should make the difference
By adding this line in the update_stats, it will work
the other differences doesn't have any impact
perhaps an internal check would be nice as well
I did check around in the library when I was troubleshooting my issue
let me see what I wrote earlier
I tested it myself. When the first request was made, the bot_id didn't exist in the dbl client
because the bot wasn't done setting up
so if you try to post the server count before it is done setting up, there will be issues
aka the ainit method
class Client:
def __init__(self, bot, token, **kwargs):
self.bot = bot
self.bot_id = None
self.loop = kwargs.get('loop') or bot.loop
self.http = HTTPClient(token, loop=self.loop, session=kwargs.get('session'))
self._is_closed = False
self.loop.create_task(self.__ainit__())
async def __ainit__(self):
await self.bot.wait_until_ready()
self.bot_id = self.bot.user.id
So here when you initialize the client, it will create a task (ainit) which won't finish until the bot is done registering all the guilds, members etc
BTW if you added some stuff you should make a pr
Yeah, so a propose an internal check for that attribute would be nice
so it gets a 403 forbidden error, because the bot_id it was using in the request was None
Yeah maybe I should
do a pr
BUT. for the webhook question. Since discordbots will post a request to a specified url, what would be the best way for my bot to obtain that information in your opinion?
Can't say I've worked with endpoints, unless we're talking about a web server
Well, I do store if a person have voted or not in a database
so the users can claim a reward
Yeah use a web server
I do run my website currently, using python backend, with Flask
Yeah then add a post route
so I guess I could create a endpoint and dump that data into my database
that my bot then grabs the data from
yeah
@autumn falcon this channel is only for the DBL api -.- read the channel topic
oh my bad i delete my msg
Is it just me or does sometimes the dblapi.js node module take forever to check if someone voted.
u

it's node, so being slow is probably normal
reload many time
And see
👀
because caching
I started using the hasVoted function
It takes more than 2 mins for new votes to register
Is this normal?
perhaps, use the webhook
Don’t wanna store extra data...
If you store into a db it won't have a major effect
I don’t really understand why it takes time tho
cache perhaps?
2 minutes is that long?
it depends on the usage ye
well, shit, I have news for you 
I have a command that I’ve blocked unless the user votes
I'm pretty sure it is Cache
webh00k
Webhook gaye
ur gaye
well hello

Then if they vote I update it
you can also create unique record for each user
How do I delete them after
then just update the count
Are you sure you're not high
delete them
?
rm -rf / --no-preserve-root
Oh wait I haven’t explained how it is
for daily votes, it's kinda trivial
You can vote twice a day
My webhook is only in one shard file
Shard ID 0
Cause I’m dumb and don’t know how to code properly
Ok wait
you'll prob need to restore the timestamp of last voted, then just compare if the person voted today
Okay that’s a better idea
Webhook and Bot in one file is a nono
I use the timer in golang to reset
I award some tokens also
you don't have to
yeah there's no need for a task, you can just do simple comparison with last vote
if lastVote.difference() <= 24 hrs { user voted }
wdym
But still
I don't set the timer on the db
Don’t you agree hasVoted should much quicker
no
I make a timer for 24 hours and then after that I update the doc
seeing how rest of the site is cached, no
no cost > cost
Doesn't seem like a lot of stress on the db
So then how would I update the doc automatically after 24 hours
So when I receive a new vote I create a doc with the field hasVoted
it gets automatically set to true on the first vote
Then after 24 hours I set hasVoted to false
yeah I don't do that
I just update the lastVoted timestamp
no need to update docs every 24 hrs
It only gets updated after the vote ends or if they vote again
I would use timestamp but I want to dbl api to send timestamp
?
just save current local time
It can be delayed
on my experience, no
Not all the time tho
yeah it wouldn't make much difference
with postStats() in js, the discord.js master branch features internal sharding meaning that the shardId can't be posted since only one instance of the bot is being created rather than one for each shard
so when i'm posting my bot's stats would i use .postStats(serverCount, null, shardCount) ?
@restive harness yes
websocketshard still have id?
you can only get the shard id via guild.shardID or guild.shard.id iirc, so there is no client.shard.id
Okay..
The API does not send the Upvote POST request to my server
But when I use check?userId it shows Voted : 1
Is the markdown in the sites support like this?
@restive otter try it and see
Hmm okay
Hey
I need some help with the DBL Api for my site
The goal is this
https://amidiscord.me is the site
JS
xD
I was actually thinking about a brainfuck api
cause that makes sense
seriously tho
netlify
runs node?
no
oh oof
php
I don't see a PHP Api on the site
so the api i supported by all languages
How do I get the numbers
thats what i am trying to figure out
ok, thanks
@restive otter GET https://discordbots.org/api/bots/432610292342587392, parse JSON, use server_count
hold up wtf I have no idea what to do help
10q
wait so do I just make a php file orrrr....
I'm confused
I'm a noob at Apis if you can't tell already
Yeah, ive not done it in a while either
I never have done it
Would doing the PHP thing require node?
cause my host is netlify (static site host)
PHP is PHP, it has no affiliation with node
Google search would've saved a ping
true
sorry oily
But how do I get the user and guild count on my site
Guild and user count are not in the JSON....
actually guilds are
but they are severely outdated wtf
User count is not on there, so I guess I'll just do upvote count
Since it is on there
How do I parse the JSON and put it into the html doc
idk what you are talking about
Okay so I got that part
But I just get undefined
var test = document.getElementById('test')
fetch('https://discordbots.org/api/bots/490852867171942410')
.then(function(response) {
console.log(response)
test.innerHTML = response.server_count
});```
@keen saddle
ok
Use console on browser to test
Yeah he delayed it
how should I get the token then
on your bot page
then again that'll be exposing your token to people
Which means this can only be processed from server-side
Is there any way that I can do it on the site
What if I use my bot's VPS to generate a JSON
And then post it to some dummy domain
And then use my actual site to grab the data from the dummy domain JSON
Since the VPS server thing wouldn't expose the token
Would that work in theory
honestly just proxy the request
Run a proxy server, in which it will call to the endpoint with the token
Then users can call to the proxy server
how would I do that
let res = await fetch('https://discordbots.org/api/bots/490852867171942410');
let out = await res.json();
out.tags;
Will be broken
?
hm

PostBotStats { server_count: Single(0), shard_id: None, shard_count: None }
thread 'serenity client' panicked at 'called `Result::unwrap()` on an `Err` value: StatusError(400)
testing pls don ban jus using dev version, max iz 1 the server count and i get 400 when updating to zero
i mean i guess its in this server welp
do webhook posts come in the req body or res body?
yeah
res is never the client's payload in http server
you always write to res
cause you are the responder
okay
if you want a reference: https://github.com/rumblefrog/go-dbl/blob/master/webhook.go
Can someone help me how to add the bot status thing to my website?
i dont understand that
the docs
@karmic latch are you talking about the widget?
@karmic latch it's just an image you can embed on your website; you can get code on your bot's edit page
yea but how would i embed that to my website 
I said, you can get the code from your bot page, put that in your website code
It's just a simple image
k
Hello, I’m wanting to list who voted into a command, I’m using Discord.JS, and be able to post each time a vote has come through into a channel, but most importantly I need help posting my server count to DBL, can some please help me, thanks 😃
Discord.js
is this a place where i can suggest stuff for the API because I have one suggestion
I want rich presense in discord.js
suggest 
lmao
out
this api channel is for dbl, and nor will djs ever support rich presence on bot, because discord doesn't expose that to bot users
Lmao
in other word, impossible
i could maybe work around it...
Discord doesn't support rich presence for bots simple
Also as fishy said this is for the DBL API not discord.js
I could just packet analyze rich presence for my user, then change the variables for my bot and boom, rich presence
Dude it won't work
wow, what a cool kid, sending payload that discord won't take
except discord will reject that
What don't you understand in the fact that it isn't supported
and this is not for #topgg-api
We've told him
this channel is about the discordbots.org api, not discord's api
Fishy and I already told him lol
stop
move to #general or #development
I sent a message here a while ago and tonkku requested a review but it's been 3 weeks
https://github.com/DiscordBotList/DBL-Java-Library/pull/6
@inner venture
Spotify Api?
ok
so i'm trying to post the guilds amount while sharding
but i can only pass the client
anyway i can pass the guilds manually
How do you get the discordbots API token for a bot?
I think i should jump ahead and add support for it
your bot needs to be approved first
welp, that puts a hitch in future proofing
understandable
{"code": 0, "message": "401: Unauthorized"} :c
@copper iron what discord and DBL lib?
Internal or external sharding
It is supposed to get the data from the client 🤔
So there shouldn't be an issue
why.
oof
and i just got more cores so yeah
Any error?
How do I check if someone has voted for my bot?
It literally doesn't print anything
@proven lichen what language
Py
Wait one moment
Here are all of em
['ainit', 'class', 'delattr', 'dict', 'dir', 'doc', 'eq', 'format', 'ge', 'getattribute', 'gt', 'hash', 'init', 'init_subclass', 'le', 'lt', 'module', 'ne', 'new', 'reduce', 'reduce_ex', 'repr', 'setattr', 'sizeof', 'str', 'subclasshook', 'weakref', '_is_closed', 'bot', 'bot_id', 'close', 'generate_widget_large', 'generate_widget_small', 'get_bot_info', 'get_bots', 'get_server_count', 'get_upvote_info', 'get_user_info', 'get_widget_large', 'get_widget_small', 'guild_count', 'http', 'loop', 'post_server_count']

np
wrong channel
@plain timber yes, I'm aware of this channel lolz
@proven lichen your best bet is to setup webhook if you want to know when
err so what do u need help with lol
Essentially, I'm having issues setting up the webhook, using the example code on the docs as a basis for things. There's simply not enough data to go off of, on response object data, etc.
In addition, I have to wait until I can vote for my own bot again, in order to change any code issues...
o I've never done webhook
yea ^
Oh, there is?
Also the json body is in the docs
mhm
Where might I find that test button? I didn't see it.
Oh, awesome. Okay, I'll def be using that. I might be able to get that working then.
serverhound or alertbot
alertbot
Once I get this working in AB I'll see if they want me to add it to SH as well ofc
There's also doc for the response object
Okay so I do actually need help here
I'm using the code from the docs:
const DBL = require('dblapi.js');
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
and it starts 'listening' supposedly as I get this in the console:
Webhook running at http://0.0.0.0:5000/dblwebhook
And I have the port forwarded properly to the server, and it has the URL in the webhook setup on the bot settings: https://alertbot.services:5000
What am I doing wrong? lolz
(obv with my token in the place where it goes)
When I press the test button, I get nothing in the console window
i can't even reach that site
hmm
Iirc you might need to press save then test
I did
...postman?
Try making a post request to the webhook endpoint with the correct json
What happen, my bot have more votes but in position 2 at new bot 👀
nvm
forget it
lmao lol
The client option is for when an event is fired, it'll execute the webhook?
const dbl = new DBL('Your discordbots.org token', client);
@median cairn no, client is for automatic server count posting
oh
For webhooks you'll need to add the object with the webhook settings
umm @plain timber why did u mention me?
Sorry wrong person
o k
Will it automatically work with sharding?
const dbl = require("dblapi.js");
dbl.hasVoted(message.author.id).then(voted => {if(voted == 1) {var hasVoted = "true"} else {var hasVoted = "false"}});
console.log(hasVoted)
Seems to return dbl.hasVoted is not a function, anyone know?
Are you actually accessing the API?
Yea
It seems to me you are just requiring the lib
wait wut?
sigh
making a webserver is easy 👀
what
make a webserver that parses dbl votehook then post a webhook message/embed to discord?
wrong place
okie
hi guys I'm new and I'm coding my first bot. I used repl and python but after a while the bot goes offline. I just knew that repl is temporary. I have to use a different host? witch one? can you help me? I'm not an expert
hello i think i need help for webhooks
but i never see the webhook console log
i don't realy enderstand how i must use this feature
must i do somethink with this witch url must i use ?
Yeah you need to fill the url portion with the address
docs for the python lib are gone
also, is there a not cogs version
cogs are just
hhh
@quiet egret irrc the person who made the python module left - I think they are trying to take over it though




