#topgg-api
1 messages · Page 112 of 1
Im using py to post my server count ```py
import requests
data = {'server_count': 71}
headers = {'Authorization': 'the CORRECT api key'}
r = requests.post('https://top.gg/api/bot/748670819156099073/stats', data=data, headers=headers)
print(r.json())``` but for some reason, it still returns {error: 'Not Found'}
I got an error: Error: 429 Too Many Requests. How do I fix this?
@restive otter Wait about 1-2 hours, you seem to be ratelimited
ah ok
/api/bots
oh oops\
lol
/api/bots
@sullen nymph ty but that returns this:{}
like no json data
Then it worked, Audit
oh ok
nice
Then it worked, Audit
@sullen nymph ok but this is my main code (i am posting to 3 websites, top.gg is one of them)py webs = ['discord.boats', 'top.gg', 'discordbotlist.com'] data = "" for web in webs: if web == 'discord.boats' or web == 'top.gg': param_name = 'server_count' if web == 'discord.boats': auth = 'Discord Boats Api key' url = 'https://discord.boats/api/bot/748670819156099073' elif web == 'top.gg': auth = 'Top.gg Api key' url = 'https://top.gg/api/bots/748670819156099073/stats/' elif web == 'discordbotlist.com': param_name = 'guilds' auth = 'discordbotlist Api key' url = 'https://discordbotlist.com/api/v1/bots/748670819156099073/stats' body = {param_name: len(client.guilds)} headers = {'Authorization': auth} r = requests.post(url, data=body, headers=headers) await ctx.send(f'Posted server count!')but for some reason, it just returns{'server_count': 66, 'shards': []}and it doesnt update to 71 (the actual server count, 66 was the old one)
i put the whole code, because it might be a small syntax error or something
P.S. use aiohttp with your bot
print length of client.guilds yourself
@sullen nymph wuts that
ok
it makes http requests a lot easier
ok but how does that fix my problem...
well idk how to fix your problem, but you were asking what aiohttp was so I answered it. You can ask someone else to fix your problem ig.
no my actual server count is 71
and when i put my other code in another file to manually update it, then it worked
is there a differance?
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
Where can I get the password?
Webhook auth is set by you on the webhook page @floral orchid
from where exactly?
I could not find the place @rapid kettle
still can't find @rapid kettle
wdym
how do I post bot guild number using dbl.postStats without shard id/total because I dont shard it yet
@rapid kettleAfter entering the top.gg page, I enter the api section, I click the webhook, but the screen does not appear as you did.
@rapid kettleAfter entering the top.gg page, I enter the api section, I click the webhook, but the screen does not appear as you did.
@floral orchid its in bot settings
dbl.getBot("mybot'sid").then(bot => {
console.log(bot.montlyPoints) //
});
@restive otter i've this problem:
(node:4) UnhandledPromiseRejectionWarning: Error: 404 Not Found
wdym, did you enter your bot's id?
Yes
hmm
I send you the screen
is your bot approved on topgg?
is your bot approved on topgg?
@restive otter nope
@rapid kettleAfter entering the top.gg page, I enter the api section, I click the webhook, but the screen does not appear as you did.
@floral orchid go to https://top.gg/bot/yourbotsclientid/webhooks
Do you have ssl setup?
If not dont use https but http
A reverse proxy, or other means of ssl
If you dont know, you probably didn't do it.
Yes
When I try to post the server count I get this error "Error: 429 Too Many Requests", I have tried every way listed in the documentation, but I still get this error
You are being ratelimited for too many api requests.
Stop posting your server count until your unratelimited.
Send less than 60 api requests total per minute.
Thats just an event
I have no post event
That is a post event
Whats your statsInterval set to?
Or any .postStats methods used?
I don't have either, I found this though
WHich means the auto poster limited me
Because that is how I have been recieving the error
The auto poster would be the one getting the ratelimit yes
why would the auto poster be fast enough to limit itself, isn't that really crappy design
Any api request goes to the ratelimit
The autoposter is set to 30 minutes
By default
Is there a list of api requests?
No.
Not that I know of
Its the external ip
Internal can only be used for internal requests
http://ip:5000/dblwebhook correct?
Any firewalls?
Firewalls block connections through specific ports.
There wouldn't be a button. Youd have to use a command.
Depends on the firewall lol
I've never had the issue of not knowing what firewall i had or if I had one. So I am not sure how to help with it.
I would just allow the specific port you require.
Firewalls are a good idea to have enabled.
hi
Does anyone know how we can make it so it post if your bot is online or offline? Because when my bot was offline it still said it was online
hey, bots not giving voter role to people who voted
is this a known issue, or only for my server
ive tried resubmitting my server/updating it, the bots role is above the role it needs to give out
and it has admin perms
how do i authorize myself? didnt understand properly
Ok so I changed my dbl api code hosting to heroku and when I tried changing the webhook URL it doesn't work
Ping me if you have the answer
Ok
Hello
How to listen to bot vote?
JDA
I mean java
So if player votes
He gets a reward
does this remove the role after 12h?
13
Hi
I did this but the function on_guild_post isn't called when I execute update_stats. The server number is well sent.
Thanks
wow so colourful
you don't need to execute it you can use the code in docs it does it automatically
Yes, I think it's easier to understand with colors
you don't need to execute it you can use the code in docs it does it automatically
@restive otter I execute the function when my bot join/leave a server
I prefer manually to update just when it's necessary
and if I do it automatically the function on_guild_post will not be called I think
import dbl
import discord
from discord.ext import commands, tasks
import asyncio
import logging
class TopGG(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.token = 'dbl_token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
@commands.command()
async def update_stats(self):
logger.info('Attempting to post server count')
try:
await self.dblpy.post_guild_count()
logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
except Exception as e:
logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
# if you are not using the tasks extension, put the line below
await asyncio.sleep(1800)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
logger.info('Received an upvote')
print(data)
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))```
@frozen whale
command to update manually
but not a function to call
put this below the event listener member join
Ok so I changed my dbl api code hosting to heroku and when I tried changing the webhook URL it doesn't work
@commands.Cog.listener() I need it ?
async def update_stats(self):
logger.info('Attempting to post server count')
try:
await self.dblpy.post_guild_count()
logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
except Exception as e:
logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
# if you are not using the tasks extension, put the line below
await asyncio.sleep(1800)``` put this below the @commands.Cog .listener() right under async def on_
guild_join()
I put that
The server number is well update but it don't call the function on_guild_post
why you really need to call it? you are doing it manually you can just put the code you want to run below it
My target is to track when a member vote for the bot. The function on_dbl_vote isn't called when I vote and I must wait a few hours to vote again so I try event functions with the on_guild_post. Both functions on_dbl_vote and on_guild_post aren't called
yeah on_dbl_vote doesn't really work I use my own server and webhooks for it
that's what my webhook posts
I don't have any server so I can't track member votes ?
you can
there are services such as pipedream.com
I used it for 2 months now I have all on my own
Thanks I'm going to try it
Hi
I did this but the functionon_guild_postisn't called when I executeupdate_stats. The server number is well sent.
Thanks
@frozen whale It's not called manually, unfortunately
The guild post event is called automatically by the autoposter if you use it
I can call update_stats manually
(You can use self.bot.dispatch("guild_post") yourself)
Yeah, but the event isn't called by any of the methods publicly available to you as a dev
aka post_guild_count doesn't dispatch on_guild_post
hey, bots not giving voter role to people who voted
is this a known issue, or only for my server
ive tried resubmitting my server/updating it, the bots role is above the role it needs to give out
and it has admin perms
how do i setup a webhook for the node.js dblapi
is there any reddit api for memes i can use. (Please ping me when your talking to me)
is it possible to get a webhook sent on a new review?
not as of now, but definitely a good idea to suggest imo
Hey i dont understand how to do this with on_dbl_vote my Code:
# Import
import os
import json
import dbl
# From
from discord.ext.commands import Cog
from discord.ext import commands
from discord.ext import tasks
def create_json():
if not os.path.isfile("json"):
try:
os.mkdir('json')
except:
pass
def get_prefix(bot, message):
create_json()
with open("json/prefixes.json", "r") as f:
prefixes = json.load(f)
return prefixes[str(message.guild.id)]
bot = commands.Bot(command_prefix=get_prefix, case_insensitive=True)
botcolor = 0xffffff
class topgg(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.token = '--------'
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dbl', webhook_auth="------",
webhook_port=1234)
self.update_stats.start()
@Cog.listener()
async def on_dbl_vote(self, data):
"""An event that is called whenever someone votes for the bot on top.gg."""
print("Received an upvote:", "\n", data, sep="")
@Cog.listener()
async def on_dbl_test(self, data):
print("gfvdc")
print(data)
@tasks.loop(hours=1)
async def update_stats(self):
await self.bot.wait_until_ready()
try:
server_count = len(self.bot.guilds)
await self.dblpy.post_guild_count(server_count)
except Exception as e:
print('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
def setup(bot):
bot.add_cog(topgg(bot))```
and it don't works
i don't know anymore how to do it else
https://top.gg/api/docs the javadocs should explain everything
i don't understand the docs thats the problem :/
so I changed my dbl api code hosting to heroku and when I tried changing the webhook URL it doesn't work
hey, bots not giving voter role to people who voted
is this a known issue, or only for my server
ive tried resubmitting my server/updating it, the bots role is above the role it needs to give out
and it has admin perms
asked this like almost 24 hours ago
It isn't api related, that's why you're not getting a response
It isn't api related, that's why you're not getting a response
@rain heart oh so I need to change back then
I mean Apex, not you @hidden wave
Well i definitely think that the dsl role stuff doesn't belong in api, not minimodding though 
How do you make the website display how many members your bots holds?
nvm
I mean servers
@fickle lantern that isn’t dbl webhook
May I ask why doesn't my servers update anymore on my bot page when I added the webhooks to it?
is it possible to use the api to get server count on my website?
yes
Instead of requesting our API to see the users who have voted for your bot, we now have webhooks! Webhooks will send a post request to a URL of your choice when your bot has been voted for.
It’s your own choice throwing your index into a folder or not.
When I used the dbl token by trying with my beta bot, It is showing on the page 5 server, now because it worked I implented the code in my alpha, do i have to generate the token new?
is it possible to use the api to get server count on my website?
@summer tinsel use a webhook
When I used the dbl token by trying with my beta bot, It is showing on the page 5 server, now because it worked I implented the code in my alpha, do i have to generate the token new?
@vocal robin I suggest not using your dbl token on your testbot if your bot doesn't really have users yet. But no you won't need to regenerate it
Hi
Hi
@latent narwhal can you send me your code
@rain heart how long will it take, till it will refresh?
no bots appear in my bots and I already added one
logout and login
logout and login
@rain heart thx
@latent narwhal can you send me your code
@restive otter
I fixed the issue thanks
👍
Okay
how can i do when someone vote to my vote it will show?
i using this
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});```
Hey, I have a question (I'm using the API for python) :
Does event on_dbl_vote necessarily require webhooks server ?
Thank you in advance for the answers
wait what
https://top.gg/api/docs
all the features are listed on the docs.
The main api feature is a webhook for when users vote.
Okay
webhook?
When someone vote a webhook message on a server?
i mean vote a bot
Or something
npnp
they are for sending data to your code specifically, which means making(or using one of the libs with webhook support listed on the docs page) to receive those requests.
no, you can use the public ip.
ah ok
because im trying to create a bot that gives roles as u vote
wait so do i need a express server?
if your making a receiver yourself yes.
reciever?
the webhook is just an http server that receives requests.
ok
any http lib should work.
the offical top.gg lib uses the inbuilt http module
https://top.gg/api/docs#mybots
the webhook doesnt really need the token iirc.
servers being vps/dedi machines?
discord servers*
oh, not directly.
it doesnt work with discord webhooks.
the request has to go to a discord bot for it to interact with discord.
yeim creating a discord bot for it
\but im not exactly sure how to recieve it for servers
i got it for bots but
its exactly the same, just receive the request with the proper auth and handle it any way you want.
yep
it still says i need a token
im just reading a example
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!`);
});```
you can just put an empty string there, it should work fine
okie
T!rank
wait so once im done with my code, i go to the server and put my webhook there?
but whats the url?
http://ip:port/path
but didn't u say the ip , i could use the public one?
yes
your vps's ip, or wherever the code is being run, the public ip of that
oh ok
0.0.0.0 is not your public ip
ah ok
const dbl = new DBL("", { webhookPort: 6500, webhookAuth: 'A23192HASD' });
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!`);
});``` if i do this, it just consoles ``Webhook running at http://0.0.0.0:5000/dblwebhook``
its hardcoded to say 0.0.0.0
no 0.0.0.0 just means "any ip"
http://myip:6500/dblwebhook
your code says 6500 not 5500
oh ye just a example
do you have a firewall blocking requests?
if on a home network did you port forward?
how do i port forward
f
all routers should have their default control username and password changed.
terrible idea to leave it default :p
if you follow the portforward site, they list the default username and password for most routers.
which is why i link it, most routers have a guide specific for that router.
ah ok
yo guys i have a problem. When posting stats i get the unauthorized error even when i have this header: Authorization and Authorization: KEY
nvm i got it
How to use an api key
😅
can i do like when someone vote the bot and the bot give him reward
So h e l p
Anyone
Help
You can indeed send requests to the DBL endpoint to receive informations about your bot or use webhooks for example.
Ok
https://top.gg/api/docs#webhooks
^ webhooks
And yeah you’re allowed to reward users for their votes.
Also written down in the docs.
Which webhook url?
the url will typically look something like this
http://ip:port/path
ip is the public ip of the system the code is running on
port and path are defined in your code.
its seriously just http://publicIP:port/path
just have to fill in the blanks with your info.
yeah, the public ip of where the webhook receiver code is running.
port and path?
port and path will be defined in your code
Ohhh cool ok so how can i see my ip ;_;
hosting on your home network?
Ok
just a heads up, on home networks youll need to port forward aswell.
Okay ty
👋
@robust whale take a look at this https://top.gg/api/docs#jslib
i couldn't
why not?
I can only get server and shard numbers
okay thanks
with the dblapi.js lib you can just use getBot rather than getBots if your just getting one bots votes, the bots object that is returned has points with is the number of total votes, or monthlyPoints for the votes this month
dbl.getBot(client.id).then(bot => {
console.log(bot.points) // 7000000
});
can I have two bots log in to the same dbl client? like for testing and stuff
If it's not at the same time and don't post stats (for example you wouldn't want your testbot that is in 1 server to post)
I'm a total newbie to anything related to webhook APIs, but want to make voting rewards for my Discord.py bot. Is there a good article to get started with?
ummm
Uncaught Promise Error: Error: 404 Not Found
at IncomingMessage.<anonymous> (/home/container/node_modules/dblapi.js/src/index.js:118:25)
at IncomingMessage.emit (events.js:326:22)
at endReadableNT (_stream_readable.js:1223:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
raw: '<!DOCTYPE html>\n' +
'<html lang="en">\n' +
'<head>\n' +
'<meta charset="utf-8">\n' +
'<title>Error</title>\n' +
'</head>\n' +
'<body>\n' +
'<pre>Cannot POST /api/bots/stats</pre>\n' +
'</body>\n' +
'</html>\n',
body: '<!DOCTYPE html>\n' +
'<html lang="en">\n' +
'<head>\n' +
'<meta charset="utf-8">\n' +
'<title>Error</title>\n' +
'</head>\n' +
'<body>\n' +
'<pre>Cannot POST /api/bots/stats</pre>\n' +
'</body>\n' +
'</html>\n',
status: 404,
headers: {
date: 'Mon, 16 Nov 2020 07:17:09 GMT',
'content-type': 'text/html; charset=utf-8',
'transfer-encoding': 'chunked',
connection: 'close',
'set-cookie': [
'__cfduid=d8808f44654c53b72f01fec06cd0dd9b71605511029; expires=Wed, 16-Dec-20 07:17:09 GMT; path=/; domain=.top.gg; HttpOnly; SameSite=Lax; Secure',
'country=US; Path=/'
],
'x-powered-by': 'Express',
'content-security-policy': "default-src 'none'",
'x-content-type-options': 'nosniff',
'cf-cache-status': 'DYNAMIC',
'cf-request-id': '0671833ade0000371d6601c000000001',
'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',
server: 'cloudflare',
'cf-ray': '5f2f6e3e2a3d371d-MIA'
},
ok: false,
statusText: 'Not Found'
}
lol
dbl.postStats(client.quilds.size)
TypeError: Cannot read property 'size' of undefined
how to fix it?
@fallen merlin you've put quilds
You misspelled guilds
dbl.postStats(client.guilds.size)
same code
ahh lmao
its guilds
no worries
How to invite bot??
Asu
how do you do a Server Count on a java bot tagg my
https://top.gg/api/docs#javalib @past crescent
thx
const dbl = new DBL("", { webhookPort: 5500, webhookAuth: 'idk-if-i-can-show-this' });
console.log(dbl)
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!`);
});```
even when i click test webhook nothing logs, can someone help?
@visual brook are you hosting free?
it does log Webhook running at http://0.0.0.0:5500/dblwebhook
Correct hostname and path?
Port 5500 opened?
cuz I couldn't do that with Heroku
yep
I use Pipedream for all my POSTs
@eternal moth try makig a manual request through postman for example
Oh through your computer?
Yeah no wonder why that doesn't work, you need to portforward 5500 if you want to make it work
it is portforwarded
Aye port forwarding in your router
Are you sure? Try pesting the port
And create a rule for your firewall for incoming TCP connections on port 5500 for all apps
If you have no clue how just disable your firewall for a few seconds for the test
That’s faster than explain you how to create the rule
(on mobile)
give me a sec
Btw that port test you run doesn’t say anything about the real status of it
Test the webhook now with a disabled firewall
If it still doesn’t work the port isn’t open
no there's no other console
the thing is i personally called my isp and they told me its open
/bots/{bot.id?}/check
@sullen nymph this has rate limit?
The ISP doesn’t block ports but your router does
Oh! Ok
Well google the routers name and/or type
It should usually not block incoming connections to your device but that’s the last barrier if your firewall is disabled
That’s easier since there’s nothing which blocks your connections by default if you haven’t set it up manually
ye
huh? I don’t understand the question.
ye nvm
The router of the hoster doesn’t block connections only your servers firewall does if set up
Use something like ngrok for testing maybe

just do netstat smh
Where to do coding?
waat
in ur bots code/ main file
in your main file, see https://top.gg/api/docs for further information
the webhook isn't working for me
const dbl = new DBL("", { webhookPort: 5500, webhookAuth: 'aaaaaaa' });
console.log(dbl)
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!`);
});``` im running this on a vps but it still does not console anything when i click test webhook on top.gg
How top.gg/servers Webhook url works theres no Auth
there is an auth?
Where
Im seeing no Auth
I mean Token*
This thing for top.gg/servers/ID/edit is not there
@visual brook ^
How will i do webhooks without the Token
@plucky lance if ur online can u help me with this
Can someone please help me with this problem?
I'm trying to install dblapi.js with npm
but this happens Could not install from "dblapi.js" as it does not contain a package.json file.
Please Help
at IncomingMessage.<anonymous> (/home/runner/my-sr2-bot-1/node_modules/dblapi.js/src/index.js:118:25)
at IncomingMessage.emit (events.js:327:22)
at IncomingMessage.EventEmitter.emit (domain.js:483:12)
at endReadableNT (_stream_readable.js:1220:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:351) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:351) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Wrong dbl token presumably
How will i do webhooks without the Token
@maiden dock
Wrong dbl token presumably
@rain heart wut? i only wanna install dblapi
Wrong dbl token presumably
@rain heart me?
my code is
const dbl = new DBL(process.env.TOKEN, client);```
and error is
```(node:351) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized
at IncomingMessage.<anonymous> (/home/runner/my-sr2-bot-1/node_modules/dblapi.js/src/index.js:118:25)
at IncomingMessage.emit (events.js:327:22)
at IncomingMessage.EventEmitter.emit (domain.js:483:12)
at endReadableNT (_stream_readable.js:1220:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:351) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:351) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
Nvm my prblm fixed
mine isnt
@restive otter check the top.gg docs for the correct package
@rain heart I'm doingnpm install dblapi.jsbut it isnt working
same error
Could not install from "dblapi.js" as it does not contain a package.json file.
thanks 😄
can someone please help me?
Sure
Can someone please help me with this problem?
I'm trying to install dblapi.js with npm
but this happens
Could not install from "dblapi.js" as it does not contain a package.json file.
@jovial kiln Any idea?
Do you have a package.json
nice rank up @jovial kiln
@visual brook Yo I'm back. What's up?
@plucky lance the bot with the same code doesn't work on the vos too
What's a 1006 error code mean?
1006 with the api?
1006 is abnormal closure.
https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent
no bots appear in my bots and I already added one
they don't appear anyway in this page https://top.gg/api/docs#mybots
oh
I dont remember if bots show in the api page until approved or not.
yeah, they dont show on that page until approved. you can see your bots on here.
https://top.gg/me
what where you saying about prefixes before i interrupted @pallid forge
oh gg @jaunty plank
oh wrong chat 
@visual brook oh lol did u try the webhook for a non-approved bot?
Don’t think that will work without any bot.
The webhook will post requests to your endpoint only if an event got triggered for your bot.
For example a vote
The api docs has all the info on the various endpoints.
ty
Is the dblapi.js still depreciated?
how do i make that my bot will say how many servers he is in on the web
me?
ye
okay ty
If there are any problems ping me ;)
const dbl = new DBL("", { webhookPort: 5500, webhookAuth: 'aaaaaaa' });
console.log(dbl)
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!`);
});``` im running this on my vps but when i click test webhook nada
@restive otter
i downloaded that, now look,
ot.on('ready', () =>{
console.log("this bot is online!");
setInterval(() => {
bot.user.setActivity(`a!help | ${bot.guilds.cache.size} Servers.`, {type: "PLAYING"});
}, 60000);
setInterval(() => {
dbl.postStats(bot.guilds.size, bot.shards.total);
}, 1800000);
})
i added that to ready event
Yes
is it like that?
?
the first time it will post is in 180000 ms
its 30m
No
or it will do the same thing with that as well
okay
so you may would like to set it in the ready event aswell, to let the stats instant posted
okay.
o and
look
i always need to refresh it
so it will show that he is approved
ye, its the cache
yes
and so do the votes?
Idk, it seems to take a few hours on my bot
Aswell
Yes
N/A will be the server count
and do you have shards?
not yet
Then you have to limit stats posting to only the serverd
i did
i already removed it
then you only have to wait 30 minutes and it should work ;)
wow you should get promoted lol
let me know if they did
good luck
I will ;)
hello i have a question. How toes the top.gg api work? this is my code (Discord is also defined):
const DBL = require("dblapi.js");
const dbl = new
DBL(`my token here (its a correct token)
`, bot);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})```
And i get this error:
``Oops! TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["authorization"]``
change
DBL(`my token here (its a correct token)
`, bot);
to
DBL(`my token here (its a correct token)`, bot);
You shouldn't leave the trailing new line at the end as its an invalid header field value character
@agile moat ^
k
what is webhook?
its been 2h since i added the server count thing
@sour sequoia please show the code
bot.on('ready', () =>{
console.log("this bot is online!");
setInterval(() => {
bot.user.setActivity(`a!help | ${bot.guilds.cache.size} Servers.`, {type: "PLAYING"});
}, 60000);
setInterval(() => {
dbl.postStats(bot.guilds.size);
}, 1800000);
})
@tiny heart
bot.on('ready', () =>{ console.log("this bot is online!"); setInterval(() => { bot.user.setActivity(`a!help | ${bot.guilds.cache.size} Servers.`, {type: "PLAYING"}); }, 60000); setInterval(() => { dbl.postStats(bot.guilds.size); }, 1800000); })
@sour sequoia not this
give server count one
@sour sequoia
Add this
const dbl = new DBL('Your top.gg token', client);```
i did
show that
const DBL = require("dblapi.js");
const dbl = new DBL('jauhgahguahngmuajguagujuajguagj', bot);
fake token btw
just spammed buttons
any error?
how did you defined bot
i found a erorr
i found a erorr
@sour sequoia show
Error: 401 Unauthorized
your token is incorrect
did you used your top.gg bot token? or Discord Developer Portal one?
@sour sequoia
Discord Developer Portal
@sour sequoia Did you got an error?
Error: 401 Unauthorized
did you used your top.gg bot token? or Discord Developer Portal one?
@tiny heart
Discord Developer Portal
1 min
k
@sour sequoia go to https://top.gg/api/
And then go to My bots
???
np 😄
Whats your code rn (Remove your token)
wow thats a really long token
can i do
const dbltoken = 'long a$$ token'
and then
const dbl = new DBL(dbltoken, bot);
Yes
yes i think so
okay
Thats correct
i have done like
const dbl = new DBL(process.env.TOPGG, client);```
and still it works
em
k
guys
not bot
but im talking to broken tooth
guys
@sour sequoia any error?
bot.on('ready', () =>{
console.log("this bot is online!");
setInterval(() => {
bot.user.setActivity(`a!help | ${bot.guilds.cache.size} Servers.`, {type: "PLAYING"});
}, 60000);
setInterval(() => {
dbl.postStats(bot.guilds.size);
}, 1000);
})```
i forgot what to put instead of the 1000
i changed it so it will send the error
forgot the number
k ty
np
what is the minimum i can put the number on?
with out the bot crashing
Y E S @tiny heart @restive otter
ty for the help
and omg @restive otter get promoted already
@sour sequoia Lol, nice that it works!
hello i have another API question
const waah = `token`
const DBL = require("dblapi.js");
const dbl = new DBL(waah, bot);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
the console error is
Oops! Error: 401 Unauthorized
Discord is also defined
ok nvm the token was wrong lol
may someone help me to set up the vote webhook?
does this work?
Nope
It’s not supposed to send requests to Discord webhooks but to your own endpoint.
is something like this ok?
and if yes, where can i find an ip to use for free? is the one of my home wifi good? Since i cannot use heroku one...
Take a look at the docs pinned in here
Yes, but dblapi.js package has been deprecated
It's still working and has no alternative for now
yep
Hm,
@buoyant geode U replaced 0.0.0.0 with your IP?
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!`);
});```
const dbl = new DBL(process.env.dbl,
{ webhookPort: 5002, webhookAuth: 'haha no' });
dbl.on('posted', () => {
hook.send("DBL posted");
})
dbl.on('error', e => {
return require('../../tools/error')(e, undefined);
})
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', async vote => {
const user = client.users.cache.fetch(vote.user);
if(user){
hook.send(`${user.username} just voted ${client.user.username}`);
}
});
look
so i have to set this on my index and then use the "has voted" on the vote command?
My console is getting spammed by this
{ Error: 401 Unauthorized
at IncomingMessage.res.on (/root/xx/node_modules/dblapi.js/src/index.js:118:25)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
raw: '{"error":"Unauthorized"}',
body: { error: 'Unauthorized' },
status: 401,
headers:
{ date: 'Mon, 16 Nov 2020 15:14:07 GMT',
'content-type': 'application/json; charset=utf-8',
'content-length': '24',
connection: 'close',
'set-cookie':
[ '__cfduid=d5da86113247a78exxb1c102db91605539647; expires=Wed, 16-Dec-20 15:14:07 GMT; path=/; domain=.top.gg; HttpOnly; SameSite=Lax; Secure',
'country=GB; Path=/' ],
'x-powered-by': 'Express',
'access-control-allow-origin': '*',
'access-control-allow-headers': 'Authorization',
etag: 'W/"18-XPDxxMk4yY1/PADG4jYM4rSI"',
'cf-cache-status': 'DYNAMIC',
'cf-request-id': '067337e76e000xx1000000001',
'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': '5f322xx065a-LHR' },
ok: false,
statusText: 'Unauthorized' }
it might be a stupid question
how can I make the bot to perform something when someone vote ?
am currently trying to make it so when the user votes for the bot they receive a item
same here 
dbl.webhook.on('vote', async (vote) => {
const user = bot.users.cache.fetch(vote.user);
if(user){
hook.send(`${user.username} just voted ${bot.user.username}`);
}
const findItem = data.items.find(i => i.name.toLowerCase() == 'key');
let userInv = data.items.filter(i => i.name.toLowerCase() !== 'key');
if (findItem) {
userInv.push({ name: 'key', amount: 1, description: 'Vote key.' });
data.items = userInv;
await data.save();
}
})
not sure if it will work
Hey can anyone help me dbl api I'm getting error on heroku dbl not found
And i had installed dblpy
cuz hook is not defined in that event
@restive otterhookis a Webhook from Discord
and if it is not defined, node.js will tell me
Hey can anyone help me dbl api I'm getting error on heroku
dbl not found?
what should I write here ? 
https://top.gg/api/docs take a look at how you can use the top.gg api
@rain heart hey can you help me with dblpy api
K
How do I change this from N/A to how many servers my bot is in??
https://top.gg/api/docs take a look at how you can use the top.gg api
I copied the msg of H so credits to him
🤣

thats just a url to the widget
Yes so where should I put the url??
wherever you want the widget to show.
Umm like 😅
anyone here that can kindly explain me how to setup the webhook 
insert what, insert the widget link?
i use python 
Yes @jaunty plank
you insert it where ever you want the widget to show
theres not any reason to put it there imo, since the stats the widget shows is already on your bots page.
the widget is pretty much just an image with your current bot info.
Because you cant
Then how will I put this?? https://top.gg/api/widget/:ID.svg
you dont.
you put that, where you want your widget to be shown
if you for example, have a website, you can put your widget there
if you want it to show in a command a user can do, you put it in the response there.
I don't have any website for bot
the widget isnt mandatory, its just an optional visual thing.
@restive otter
hookis a Webhook from Discord
@buoyant geode k
if you have no use for it, you dont need to do anything with it.
But I wanna remove that N/A
widgets have nothing to do with posting server counts.
under the tools section of the docs, you can view the various libraries which can post your server count for you, or you can use the api endpoints.
for the manual api endpoint https://top.gg/api/docs#bots
what is your goal? interacting with the api, correct?
widgets do nothing for you posting server count
My goal is to remove N/A and put the no. of servers my bot is in..
I actually didn't start coding in JavaScript cuz my pc is gone... So currently I'm doing it through bdfd
At winters I'll start with javascript
Kk tellme for javascript only..
hi my ports are all open and this is my code
const dbl = new DBL("", { webhookPort: 5500, webhookAuth: 'A23192HASD' });
console.log(dbl)
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!`);
});``` but even when i input this on my top.gg server and click test webhook nothing logs can someone help
Read the tool section for your corresponding programming language then
am i supposed to add the discord bot of it rn??
Did you follow the webhook tutorials on the apidocs correctly?
yes
did you fill in the webhook url and auth on the bots edit page?
https://top.gg/me
the url will look something like
http://ip:5500/dblwebhook
yep
ip not being 0.0.0.0
sorry if this all seems basic to you, lots of people learning these things.
ah ok np
im running it on my vps so all ports are forwared
i clarified that again with my provider
I think it may be
const DBL = require('top.gg');
needing to be
const DBL = require('dblapi.js');
unless top.gg is a clone of dblapi.js
oh intresting, can you link to it?
as far as i can tell, it should work.
ye this is just the sampel
its supposed to work haha
but for some rerason its not
potentially might be beneficial to use something like postman to test it manually
im not sure how to use postman
anyone getting ```
long error code brr
@leaden obsidian try in #development if that's not api-related
i see thanks
its really weird its not llo
postman just makes http requests so you can test things.
for example heres a postman test to my webhook.
ok just give me a sec
yeah, just gives more control/info
ye i hate my internet
isn['t allowing me to even login lmao
imma do it tommorow its really late here
okay!
postman just makes http requests so you can test things.
for example heres a postman test to my webhook.
@jaunty plank where is this page ?
how to get this password
that's just the password you can use in order to authorize the requests
it has to match the one on your bot page
I downloaded the postman application for windows since I use it a lot @restive otter.
https://www.postman.com/downloads/
postman useful indeed
but how can i get this password?
@restive otter you make it
on your bot page
then webhooks
on my bot's page it doesn't have this password, just a key api
@restive otter
thanks
👍
@jaunty plank how are you getting the port ?
The port can be any available port.
You define it in your code.
const dbl = new DBL(process.env.dbl, { webhookPort: 5002, webhookAuth: 'password' });
just have that atm
Then the port is 5002
The webhookPort: 5002 is what sets the port.
You fill in the url that points to your webhook receiver.
In most cases the structure is.
http://publicIP:port/path
is that your ip ?
Can anyone help me with dblpy api?
@jaunty plank is there a video on the api on how to set the webhook up so am not taking up your time ?
I don't know how it works, what would the path be?
Nope. The webhook is seriously just an http server which receives post requests on a single endpoint.
Most libs set the default path to dblwebhook
Woo would you put public ip as my public ip ?
Yeah where ever the code is running, the public ip of that.
const bot = new Discord.Client();
const waah = `hiddentoken`
const DBL = require("dblapi.js");
const dbl = new DBL(waah, bot);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})```
this not work, why? 🤔
Hello, any idea on why dblpy lib auto guild posting is not posting the shardcount too?
this not work, why?
@grizzled gate uh i think its client, not bot
it can be called bot, depending on the users definition.
it can be called bot, depending on the users definition.
@jaunty plank isnt client the built-in topgg module?
the client/bot needs to be your actual bot(logged in)
no, client is discordsjs or eris client
it can be called whatever, it just needs to be the actual client for the autoposter
this not work, why?
@grizzled gate uh i think its client, not bot
@restive otter thank you ❤️
@restive otter thank you ❤️
@grizzled gate no read what @jaunty plank said above, I suggest taking the waah variable out and replacing it with your token directly, and seeing if it works.
is this correct? py self.dblpy = dbl.DBLClient(self.bot, self.token)?
its working on my pc but not on server?
I would need help with one thing
How do I build my Webhook https address?
Forgot which parts belong where
https://ip:port?/dblwebhook
My entire ip address when I google it? (Hosting on device)
i still suggest using ngrok for testing it out
for production, use the servers ip
so you don't have to go through the hassle (and presumably security) of portforwarding
If i am using heroku to host the bot, the webhook url will be something like this right?https://git.heroku.com/RepoName.git/dblwebhook
so i have to use an ip?
from heroku?
no, my only experience is hosting my bot...
Send the heroku application name
@fair herald
dogmahost
discord.js
https://dogmahost.herokuapp.com:5000/dblwebhook
Yes
alright thanks a lot, let me try
ah okay, i just tried the request from webhook but nothing from console
Try without the port in the url.
Use the PORT environment variable in your code.
i dont know how to use this PORT environment variable
you mean to just remove the port thing from the code?
Nope, using the port environment variable. The specific way to use it depends on the language.
i am using discord.js
process.env.PORT rather than 5000
okay will try immediatly
Cannot read property 'on' of undefined
i am using this:
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!`);
});```
instead of 5000 i put : process.env.PORT
probably returns undefined if you didn't specify a valid token.
i used the correct token tho, the one from the site
The webhook doesn't require a token anyway.
I mean that's literally the exact example from the docs
did you change it in any way?
yes yes ofc i changed the things, just dont wanted to share token ecc
const dbl = new DBL(`very long token`, { webhookPort: process.env.PORT, webhookAuth: 'blanknamepassword' });
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!`);
});```
looks like this
and the url is : https://dogmahost.herokuapp.com/dblwebhook
So, the webhook should exist if port is set to something.
https://github.com/top-gg/dblapi.js/blob/master/src/index.js#L67
Which you are doing.
Maybe heroku uses a diffrent env variable.
Well, it says its PORT
The port to bind to is assigned by Heroku as the PORT environment variable.
maybe i should specify the port in the url too?
The error is specific to the code
yes it says : Cannot read property 'on' of undefined
ah, i am testing it not on heroku

