#topgg-api
1 messages · Page 73 of 1
Скинь свой полный URL и webhookAuth мне в лс
ну так это же секрет..
Брандмауэр не блочит, порт открыт в настройках роутера, т.д
Что
ты айпи спалил
Как ты не знаешь, открыт ли порт? 
is that the current IP of the webhook server
yup
whenever i use the button test
sometimes it work
sometime it don't
and produce this
are all your ssl things in order
'running test rn in case'
const dbl = new DBL('токен',{webhookPort:1024, webhookAuth:'пароль'})
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
console.log(hook);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
это все
Я бы попробовал порт выще 1024
Tonkku were you sure suggesting port 1024 was a good idea 
Я готов уйти в запой
it would error otherwise
В настройках роутера 
о гспд
is this getting off topic
?
A bit
are you talking about the api or not
он открыт? 
По стандарту для хттп открыт
Нам стоит переместиться в #memes-and-media если мы будем говорить о портах
ну ок
@little ice are you using letsencrypt with nginx?
is nginx your primary webserver?
yes
how did you configure SSL for it?
i mean it's from some times ago but by looking though tutorial and all and manipulating nginx.conf
i bought a certificate and configured it
ah you bought it
yeah
where did you buy it from?
name.com if i remember correctly
but using https://www.ssllabs.com
Bringing you the best SSL/TLS and PKI testing tools and documentation.
my certificate is fine
i do have 2 "issues"
but there not errors
what are the issues?
Who is Russian?
@sullen nymph @frigid shore are you Russian +
щас, я просто делаю
Просто опиши свою проблему
Я занят + советую прочитать тему этого канала
Кто может помочь с Dashboard?
@little ice show your nginx ssl configuration
ДАААААААААААААААААААААА
А что за библиотека?
@little ice the only thing i see different from my config is that you dont have TLSv1.3
but that shouldnt matter, as most people still use TLSv1.2
does your cypher list contain all of these?
ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES
i did try the test button 3 times waiting 5 minutes between in case
only one passed
other just vanished
nothing logged in error.log
and the same problem doesn't happen with service like zapier/twitch for example
first no because i still had Tlsv 1.1
but after removing it i do have the same error
but it shouldn't be a problem
this affect only old browser basically
check this
to use older TLS versions, you need to enable the older cyhpers as well: ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA;
another thing you could do is update your openssl and your nginx
and enable tls 1.3 while you're at it
well idk which cyphers the client sends
then set it up with their "intermediate" profile
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;```
this basically lets the client chose their preferred cypher
instead of the server enforcing it
mozilla posted an article about it, saying that its better for the server to decide with old protocols, but better for the client to decide with newer ones
because newer ones are all secure enough that you can let the client decide based on performance instead of security
yeah your nginx doesnt support 1.3
thats why update
or remove it and keep it on 1.2 only
will do that for now
test button are working for now
i will wait for an actual vote
thanks a lot for your patience and help
really appreciated
i hope it works lol
i hope too ..
so I'm now looking at the logs
seems like most requests work
but I did see a few status code 500 responses
and now there's a few 301 responses because it was http (webhook wont follow redirects)
and 3 requests that got no response because you mistyped https as htpps
but otherwise it's all successful around
you need to post server count yourself
where
read the link
you need to send a POST request to the top.gg API
using your bot's top.gg token
you can do that manually with any HTTP library, or you can do that with one of top.gg's libraries
Help me, I have my API so the link: https://top.gg/api/widget/675734854901694492.svg how i can make it work
your bot is accepted?
No
So that can't work
wait till someone accept your bot
Ok, then if it doesn't show that it is online, it's also because it hasn't been accepted yet?
that don't work because @abstract moth is watching top.gg
and your bot is in approval
at me was the same error
OK thanks for the information
https://shenu.please-fuck.me/2KzoNe @restive otter
sxcu.net free ShareX uploader
You know this API is ONLY FOR TOPGG not discordbots.org
https://tenor.com/6Zdg.gif
oh no no no
@green mantle you know
the top.gg api is the same as discordbots.org api tight
lol
pls meme
i keep hitting 429
just checking user has voted or not
on command having cooldown of 10 seconds
Someone can help me when someone vote the bot to send in a specific channel with webhooks?
DBL webhooks iirc don't support that directly, you would have to use your own webhook system for sending to discord
just checking user has voted or not
... if anyone knows why?
you shouldnt be flooding the API with requests to get votes
it would be better having a temp file or db for storing votes
@ionic flame are you the only one who uses it? or is it a public command?
if its public, are there multiple people using it at the same time?
@vapid cape it is public. But afaik 60 requests are allowed/min
And i don't think 60 ppl run cmd at sane time
are you checking if they have voted every single time they use a command?
regardless of rate limits, this is a very bad solution
you should at least use caching
or switch to webhooks
How can i use webhook to check whether they have voted?
store it
seconds
@ionic flame make sure you log every request so you can get a visual on how many requests your bot is actually making
but yes, the ideal solution would be to use a database, and store votes as you receive them via webhooks
and then check if a user has voted in your database
you can use a database that supports storing data with timeouts, so it automatically deletes them after 12 hours
Thanks for suggestions!
you can use a database that supports storing data with timeouts, so it automatically deletes them after 12 hours
@vapid cape do you know any?
there are many
depends if you prefer a sql, or a nosql one
a file based or a server based
I have tried both. Anything is fine
caller.utils.createMessage(command.msg.channel.id, {
embed: {
color: caller.color.blue,
description: lang.commands.vote.description.replace('@link', `https://top.gg/bot/668481980547072007/vote${command.guild ? `?guild=${command.guild.id}` : ''}`),
},
});
};
exports.Settings = {
command: 'link',
category: 3,
show: true,
permissions: [],
dm: true,
};```
why no work
Not hape help command
have*
@restive otter
exports.Run = async function Run(caller, command, guild, lang) {
caller.utils.createMessage(command.msg.channel.id, {
embed: {
color: caller.color.blue,
description: lang.commands.vote.description.replace('@vote', `https://top.gg/bot/668481980547072007/vote${command.guild ? `?guild=${command.guild.id}` : ''}`),
},
});
};
module.exports.help = {
name:"vote",
aliases: ["v"]
}
@restive otter don't work..
😤
mate
u miss put now settings
its need look like that
if u want lemme give u the command u edit it?
@restive otter please give me vote command )
u gonna edit it
are u from turkey ?
nah
romania
k
oh
deleted ?
wait
?
look dm
if u need it send me dm
how can i get the Json from the api?
(Python)
What
@unreal pilot https://nmw03.is-inside.me/8TlfnvEN.png
webhooks, read the links CF8 posted
where can i get link?
yeah i will read that
@vapid cape https://shenu.please-fuck.me/GbsORX
sxcu.net free ShareX uploader
sxcu.net free ShareX uploader
is correct?
dbl sends webhooks to YOU, not to DISCORD
you have to put a url where YOU can receive them
your server, your vps, your bot's host
how to get your server ip:port/dblwebhook
server ip is ip of your vds
where is your bot hosted?
how to get
your server ip:port/dblwebhook
@restive otter if you are using glitch:
https://your-project-name.glitch.me/dblwebhook
const DBL = require('dblapi.js');
const dbl = new DBL("mysecrettoken", { webhookPort: 5000, webhookAuth: 'mysecretpassword' });
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!`);
});
right?
or i am super idiot
no
now go to the bot edit page and press the test button
ok i pressed
did it work?
then you did something wrong
make sure the url is correct, and the authentication is correct
i think url
also, your token should be your DBL/top.gg token, not your discord token
the url is correct
because the webhook is not GET, the webhook is POST
its normal that GET doesnt work
so that i want when somenone vote to show in a channel
i can show you my dbltoken and authorization?
ok
dm or here
your authorization is not your token
your authorization is a password you create, and then put the same password in the Authorization in the edit page
it doesnt matter what it is as long as its the same in your code and in the website
yes
save and test again
send me what you put now, and what you put in the website
webhookPort
is not 5000
its process.env.PORT
webhookPort: process.env.PORT
and it should be dbl.webhook.on("vote")
not dbl.on("vote")
ok
done
but at webhookport
console.log(`Webhook running at http://${hook.hostname}:webhookPort: process.env.PORT:${hook.path}`);
sorry if i am super idiot
ye
Use the same server as your uptime robot
ye
const http = require("http");
const express = require("express");
const app = express();
app.get("/", (request, response) => {
response.sendStatus(200);
});
app.listen(process.env.PORT);
setInterval(() => {
http.get(`http://redwebhooks.glitch.me/`);
}, 280000);
so the webhook cant create a server, because you cannot have 2 servers
so you need to put the server in the dbl config instead of webhookport
where?
webhookServer:app
instead of webhookPort
if it doesnt work, then you need to put the server in its own variable: const server = app.listen(...) webhookServer: server
ok
if app doesnt work
then do what i said
change app.listen() to const server = app.listen()
and then put server instead of app in webhookServer
wow so that is so hard to make..
@vapid cape so
in app.listen() put webhooksServer:app
no
dont change anything in app.listen
put it the way it was before
the only thing is that instead of app.listen you do const server = app.listen
you just add const server in the front
then in the webhook options, where you put your top.gg token and the webhook password, you put server instead of app
i delete
the whole
app
its to hard
and i don't understand
anything
@vapid cape sorry if i lose your time 
https://nmw03.is-inside.me/UYXAsQsb.png
is this normal?
dont rlly matter
but ports 0 - 80 are protected
so its not necessarily advised imo
https://oliy.is-just-a.dev/8kljb_2821.png linux stuff
Yeah the 1024-49151 are good ones to use
No, in fact you cant. You cant have 2 servers on the same port
if node is directly exposed, the port should be the same
if node is behind a reverse proxy or similar, then no
if you have an existing server, you can attach it to the dbl library
let srv = server.listen(...)
let dbl = new DBL({token:token,webhookServer:srv})```
https://nmw03.is-inside.me/CEplJwKC.png
what is wrong?
I get this https://nmw03.is-inside.me/uQE1tCwS.png
When a port is not provided, the library sets it to 0 so that's normal because you gave it a server
idk if you need it to start listening after you create it tho
@vapid cape might know
aaaa ateam
it just needs to be a valid http server object, doesnt matter when it starts listening
Well I didnt know that, learned something new
i am confused
should I use http.createServer ? (i dont know anything about servers)
I just started using VDS
@ me if you can help
@willow spindle
I was having same error but I got the solution
var server = app.listen(process.env.PORT)
That's it
or you can also do
var server = app.listen(4000, function() { console.log("listening to port 4000")});
@hexed pivot Should the port on the site be the same as the port in the code?
@pale flint
Please do not mention (ping) more than one or two moderators for help, unless there is an emergency.
Here are some examples of emergencies:
- Raids / Multiple members mass spamming.
- Severe disruption of Discord's ToS (NSFW content, etc)
- Anything that requires more than 2 moderators to handle.
Ok
also this isnt the channel for that question
Sorry
Move in #general or #memes-and-media if needed, keep this channel clean
I need help i used this
const DBL = require('dblapi.js');
const dbl = new DBL("top.ggtokentoo", { webhookPort: 30009, webhookAuth: 'mypasswordhere' });
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!`);
});
i get reply Webhook running at http://0.0.0.0:30009/dblwebhook
and when i click test nothing happend
same problem 😔
@rotund dune do you set webhook url and password?
url is a your server ip:port/dblwebhook
server's ip?
@willow spindle still nothing
The code is put in the link below
https://hastebin.com/ijaziqiyap.js
The bot responds with http://0.0.0.0:57668/dblwebhook
Ive tried other ways still same results
where is your bot hosted?
is heroku the answer youre looking for?
ye
then your url is YOURPROJECTNAME.herokuapp.com/dblwebhook
or whatever heroku uses for the project url
how do you know
all heroku projects have a public url
since they are meant to run small websites and web systems
@vapid cape i have some error and can't fix it
like all work but when i test nothing happend
Done
idk its my mate server
then you need to ask him
because you are opening that port in the same machine, but that doesnt mean the machine is exposing the port
if the website is behind a reverse proxy for example, that port will never be reached
we use apache
so you need to make an internal redirect or a reverse proxy
because yourwebsite.com will connect to apache, and apache doesnt know what to do with port 30009, its not configured for it
you need to tell apache to send that port to your node program
how can i do it lol
he is offline rn
how do i find trhat on linux
@vapid cape i am trying to test it on my pc but still cant
its no reply
the hosting company should have that info
check the hosting company's control panel or something
What's this?
UnhandledPromiseRejectionWarning: Error: 401 Unauthorized
is this a good sign?
your token is invalid
oh did i missclick "regen token" 
its been a while and i came nowhere
CODE HERE{ https://hastebin.com/luzuliteme.js }
still getting an invaild link
http://0.0.0.0:16981/dblwebhook
and it wont respond with anything when clicking on test
Why are you saying that's imvalid
0.0.0.0 is all ipson the machine
It's just different with heroku
Theres a special url you need to use that I dont know
its different with heroku?
okay lets say that the link to check the application is
https://dashboard.heroku.com/apps/cowboish-bot
or to make it more clear
https://dashboard.heroku.com/apps/application-name
YOURPROJECTNAME.herokuapp.com/dblwebhook I believe
and your port should be your process.env.PORT
i dont think it is
if i do cowboish-bot.herokuapp.com just like this it takes me to
Yes because there's nothing running on it and if the dbl webhook was it's only listening for POST requests
the url is as steven said
and dont forget the /dblwebhook part
the url will not work in the browser, only for POST requests. browsers make GET requests by default
so the url is not reachable
not by a browser's default way of accessing websites
aight
you dont need two instances of DBL, make just one
if you access yourprojectname.herokuapp.com in your browser, does it show "hello?"
what do the logs show?
did you run heroku ps:scale web=1?
whats this?
yes
show the error
wait
nope
still nothing
oh shit
omg thank you so much Tim <3
and now because i had two dynos on the bot duplicated
but it fixes itself if i turn "worker" off and keep web on
:)
👍
oof why is it so?
all free hosts have limitations
@elder sandal
dont randomly @ admins
Hi
I'm having an issue about the website. Everytime I login, it logins my other, useless account
How to promote server quickly
Or how to get member quickly
How to bump in top.gg
Like disboard
Did you read this channel's topic?
Me ??
yes
Reason
hi, if i add my bot to top.gg, do i also have to include the gg api in my bot?
also: what would be the benefits in adding the api other than being able to give bot users vote rewards
@jagged escarp clarification: no
not only ip port or domain
you can also put domains
Thanks, I was able to get things working thankfully
It was working all along I just hadn't caught the issue yet so I blamed the webhook lol
should the api be added to bot before or after it has been approved?
!stop
Just stuck with a minor thing, How to get the Author ID once someone vote? I am not really able to make it work. Any help would be appreciated.
Yes
webhooks 🙂
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!`);
});```
PY 😋
😛
.hasVoted isn't working
for some reason
Ill wait a few minutes cause maybe it needs to update
but it takes awhile
nvm it works
just takes a long time
It's recommended to use webhooks
Umm
Requiem PnW tells me I should receive a message shortly, but I never do
and then it's always on cooldown
for registering
wrong channel, and possibly wrong server
F
Hi, I'm still having an issue with dblapi.js.
It's currently using 365MB of RAM and 10% CPU on a good server. And it is just listening to the vote event then send a message
Just listening to the vote event? how many guilds, servers, channels, messages, emojis, roles and presences are cached?
I'm using Eris. The bot is in 100 guilds and has about 200k users
this guild by itself has almost 100k lol
^
So... I don't really get the purpose of the whole API, and I don't think it's written anywhere. Why should I use it in the first place?
the api is not required, so use it if you want to
the goal of the api is to give bots access to top.gg's voting platform and create applications around it
as well as to post server counts to be displayed in the website
What is API mean and do?
it can give u information
and u can use it in a bot or whatever u want
for more info go read what a rest/json api does
It was not returning this error yesterday
That name is kinda redundant
Traceback purposes be like
Hi, how i can do functions but for donators or see if the person vote the bot
I see that a lot of bots have that function
which language are you using?
Js
have you tried using dblapi.js?
I installed it, but im asking for how i can do that
oh
I can't say on that, I am unfamiliar with js
Does anyone know why this doesn't work (as in top.gg doesn't update my server count when I send this):
dbltoken = "[REDACTED]"
servers = {'server_count': util.get_server_count()}
headers = {"Authorization": dbltoken, "Content-Type": "application/json"}
async with aiohttp.ClientSession() as session:
async with session.post(url="https://top.gg/api/bots/496480755728384002/stats", data=json.dumps(servers), headers=json.dumps(headers)):
await util.say(ctx.channel, "Done!")
This doesn't give me any error, so I have no clue what the problem is. This is written in Python 3.5.2, and dblpy requires 3.5.3+ to install so I can't use the library.
cache problem is most likely
dbl caches the server counts (reason one to have it send like every 5 mins) and updates eventually.
i've updated multiple times over multiple days
also
you're trying to dump the server
do len(servers)

and you dont wanna json.dumps the headers
just use headers=dblheaders
oh ok
Nevermind, I was wrong. But yeah you do len(servers) and keep the token the same
ah ok
the bot class is defined in another file and I can't import it into the files with the commands, so I use util.get_server_count(), which is basically just
sum(len(client.servers) for client in shard_clients)
you can get the bot class
from (where the bot class is) import (the bot class) as bot
yeah the problem is importing the file causes a weird chain of errors
lemme try and find them
ok
ok this is a more normal error, but sometimes i get weirder errors:
from . import run
ImportError: cannot import name 'run'
(it's trying to import run.py, which is where the bot class is)
or from run import bot
yeah, lemme head over to the testing channel
unless you start your bot from a __init__ file
i think you have it switched around, all the files in my bot are imported with from . import <>, and modules are imported like import time
0.16.12
i made a rewrite to 1.3 but i haven't implemented it yet
i have 3.5.2 because that's what came installed on my vps
i don't remember anymore, the last time i tried was many months ago
I remember using async with 3.6 just fine
rip
if it was a OS based error, that was an issue with python 3.6.0 and got patched with 3.6.1
i would advise upgrading D.py version and upgrading python to 3.7.x
^
i think it isn't an OS based error because it is able to send get, post, and patch to other websites
I had used python 3.6.9 I believe
@green mantle
I may also do a big bug fixing thing when Python 3.9 comes out
What is api?
How would I get the number of votes my bot has in javascript
Hello people. I have a Python discord bot hosted on Heroku. In the last 3 days, sometimes (low frequency) I get this KeyError: 'content-type' when sending embedded messages.
Why is this happening? And why does it happen only rarely?
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.7/site-packages/discord/ext/commands/core.py", line 83, in wrapped
ret = await coro(*args, **kwargs)
File "Ve7s.py", line 227, in play
await Play.go(ctx=ctx, args=args, client=client, partidas=playing, admin=ve7sadmin, vets=VeTs, db=ve7sdb)
File "/app/Ve7sGame/Play.py", line 141, in go
await game.task
File "/app/Ve7sGame/Play.py", line 114, in match
await gameloop(game, partidas, client)
File "/app/Ve7sGame/Play.py", line 44, in gameloop
await game.canal.send(file=File(data, f'hazzu.{ext}'), embed=embeder)
File "/app/.heroku/python/lib/python3.7/site-packages/discord/abc.py", line 839, in send
content=content, tts=tts, embed=embed, nonce=nonce)
File "/app/.heroku/python/lib/python3.7/site-packages/discord/http.py", line 164, in request
data = await json_or_text(r)
File "/app/.heroku/python/lib/python3.7/site-packages/discord/http.py", line 43, in json_or_text
if response.headers['content-type'] == 'application/json':
KeyError: 'content-type'```
How would I get the number of votes my bot has in javascript
@steady granite happened to me when discord was having ssues yesterday
Worse, there seems to be no improvement. I may have to ignore this exception and try to send the message again ...
It was a cloudflare issue
guys, is there an api that serves to show the number of servers where is my bot? (my english is bad)
Example image:
look on the site
where?
c l i c k t h e l i n k
read the docs
I don't understand what to do
read what it actually says
yes
Yes. If you confirm your account with credit card, you get 1000 hours free / month. My bot stay 24/7 online with this
@fierce field what is your coding language and library?
JavaScript
I still do not understand... 
@fierce field then learn
What kind of "developer" doesn't know how ro read the docs
it literally says how to install and how to use
Yes
where to run the installation? I only ask
DiScOrD bOt mAkEr
@fierce field which lib do you use
javascript?
javascript is not a lib
You should be a white name tbh
do you using a discord bot maker?
^
yes
lol
@dense compass
Dbm is, sadly, allowed
allowed?
🤦♂️
They removed it
@fierce field if you install DBM-MODS you can use the action send stats do dbl
otherwise you have to code it yourself as a custom script
ask in the discord bot maker server for help
Okay
@abstract moth
I am sending {"server_count": count, "shard_count": shard_count, "shard_no": shard_id}, from all my shards, however it's not updating on the bot page. How often does the server count updates on the page?
shard_count would be 6
server_count varies between shards
shard_no would be 0 to 5
Are you getting any errors?
Hey, I have a Problem. I used this code, but If someone votes for my Bot, nothing happend in the Console:
const Discord = require('discord.js')
const DBL = require('dblapi.js');
const client = new Discord.Client();
const http = require('http');
const dbl = new DBL('"mytoken"', { 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!`);
});```
Were ist the Problem?
Do I have to open the Port on my Router?
Or were do I get the Password?
Port must be open, password is created by you
did you configure the url and auth in your bot's edit page?
The server count still fails to update when I send the post. I use this code, and it gives no error, but doesn't update even after waiting over an hour.
payload = {'server_count': util.get_server_count()}
dbltoken = "[REDACTED]"
dblheaders = {"Authorization": dbltoken, "Content-Type": "application/json"}
dblurl = "https://top.gg/api/bots/496480755728384002/stats"
async with aiohttp.ClientSession() as session:
async with session.post(url=dblurl, data=payload, headers=dblheaders):
await util.say(ctx.channel, "Done!")
The main bot is in discord.py 0.16.12, but when I use the same code and correct token on a copy in discord.py 1.3.1, it still fails.
@vapid cape Yes I did
@sullen nymph how can I create the password? Is it my PCs password or something like that?
dont do that lmao
Anything you come up with
it can be anything
just dont use the same password for everything
tends to be a bad idea
Ok
Because it is still not working lmao
Were can I set this password
Sorry If I'm asking silly things, but I'm new in javascript
Authorization field on your bot's top,gg edit page
Yup
Ok thank you
does anyone have an answer to my question a bit farther up? (i can repost it if you want)
What is util.get_server_count's type
save the response for .post and see the response code
What's your current server count
5573 Servers```

yeah that's why im updating it
Sorry if Im annoying, but Its still not working. Witch type of Webhock do I need? My current one is http://0.0.0.0:5000/dblwebhook.
this is not api related
oh sorry
help
your dbl token is invalid
oh no
what?
"Required parameter server_count or shards missing"
where i change it?
const dbl = new DBL(config.dblToken, client) dbl.on("posted", () => { console.log("Connected to DBL") })
no why?
i think @arctic arch can help you
k
what's client
i need to change that client to this.client ?
client needs to be your bot's client, however you obtain it
const dbl = new DBL(config.dblToken, this.client)
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
setInterval(() => {
dbl.postStats(this.client.guilds.size, this.client.shards.Id, this.client.shards.total);
}, 1800000);
this is my new code
...
what is client
NMW asked if you had postStats code and you said no
but you clearly have some right there
yes, and i added that
if you want to use the automatic poster, remove your manual interval
if you want to use your own code, remove the client from the DBL constructor
and those events only cover the automatic poster
const dbl = new DBL(config.dblToken, this.client)
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
``` (sorry if i didn't do what do u say, my english is very bad)
const client = new Bot({
fetchAllMembers: true
});
class Bot extends Client {
why are you using open source...
ok I get this long error when trying to post server_count to top.gg with aiohttp (python), I took out the long number/letter sequences because idk if some of them need to be private:
<ClientResponse(https://top.gg/api/bots/496480755728384002/stats) [400 Bad Request]>
<CIMultiDictProxy('Date': 'Fri, 21 Feb 2020 18:37:20 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '52', 'Connection': 'keep-alive', 'Set-Cookie': '__cfduid=[REDACTED]; expires=Sun, 22-Mar-20 18:37:20 GMT; path=/; domain=.top.gg; HttpOnly; SameSite=Lax; Secure', 'X-Powered-By': 'Express', 'Etag': '[REDACTED]"', 'X-Cacheable': 'NO', 'X-Varnish': '449151971', 'Age': '0', 'Via': '1.1 varnish-v4', 'Cf-Cache-Status': 'DYNAMIC', 'Expect-Ct': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains; preload', 'X-Content-Type-Options': 'nosniff', 'Server': 'cloudflare', 'Cf-Ray': '[REDACTED]')>
no clue what the problem is, the json body conforms exactly to the specifications in the api docs
send the json body
also can you get the response body
it will have more info on whats wrong
it's farther up
payload = {'server_count': util.get_server_count()}
dbltoken = "[REDACTED]"
dblheaders = {"Authorization": dbltoken, "Content-Type": "application/json"}
dblurl = "https://top.gg/api/bots/496480755728384002/stats"
async with aiohttp.ClientSession() as session:
async with session.post(url=dblurl, data=payload, headers=dblheaders):
await util.say(ctx.channel, "Done!")
that's just the headers, not the body
how do I get the response body then
idk about python
@sullen nymph
what does it look like then
ah ok
did you log util.get_server_count() to make sure its actually populating server_count with a valid value?
^
400 bad request would mean that you didnt send the right data
int
sometimes
I've seen json=payload instead of data=payload before
json=payload is for requests
ah ok i'll get that
oh that's true
if you're dumb enough to not modify the example from a documentation to your needs you shouldn't be a programmer
just add the as resp and print the response
i am
but... we're not trying to get stats? Or did I miss something
hes trying to post them lol
^
we're trying to get the error response from topgg api to see what the error is
but you arent gonna post anything with aiohttpclient.get

omg bruh why are you getting servercount from github api lol
{'error': 'Unexpected token s in JSON at position 0'}
ok remove the " from the dbl token
your JSON has a syntax error
dbltoken = ["Authorization":"token"]
i don't have an s at position zero
ok I'm just gonna leave at this point
the s in position 0 is server_count
it's probably just server_count=1234
your json is not being serialized
that's weird, I do it the same way when I post to another website and it works fine
ok
and check the error again
{'error': 'Unexpected token " in JSON at position 0'}
that's really weird
indeed
maybe the internal json serializer is broken
was that the sign that you did it
was what the sign?
oh well it works now
yup yup
i think the problem was that the dbltoken was encased in double quotes instead of single quotes
python seems to be weird with json
indeed
that doesnt really make any sense
well when I made it single quotes, it worked
or maybe the json thing is inconsistent
¯_(ツ)_/¯
Let's use XML
so the problem was the headers? then why the unexpected json error lol
I dont think the api supports parsing xml
because content-type was not being set?
content-type was fine
no the content type was set or you wouldnt get the json parsing error
-bots 376166105917554701
Content-Type should be set to application/json by default if you use json= iirc
yeah it was
what was your server count
what was it or what is it now
now
1127
right
ok
I tried looking at the logs
but it turns out it's not logged when there's a json error
was trying to see what the actual body was
response.content to view response body




