#topgg-api
1 messages ยท Page 81 of 1
Webhook URL and auth match for sure:
const DBL = require("dblapi.js");
const dbl = new DBL('<token>', { webhookPort: <port>, webhookAuth: '<auth>' }, client);
dbl.webhook.on('vote', vote => {
console.log(vote);
});```
Webhook running at http://0.0.0.0:<port>/dblwebhook
Port is open, going to that link (with proper IP) gets me to an empty page
It doesn't print anything though
test it with reqbin
Hmm, POST with bearer token returns 404
CanYouSeeMe shows the port is open for that IP, what should I check?
if you're hosting in a vps, check if your hosting provider requires firewall unblocking in the admin panel
on the api docs it states that on weekends votes are counted as double the normal amount
but why fridays?
just wondering
how do I setup a webhook for something of my choice?
@heady kindle In some ways Friday is a weekend.
Friday evening/night more specifically, as you can still stay up late and have fun, since you got no work/school the next day.
@open garden i see, but the multiplier is all day friday right?, not just in the night?
I honestly don't know for certain but I believe so yes,
thanks for the help
No problem! ๐
@fiery shadow ??
That was a bit weird, but I wanted to say with that I thought it was weird that you are writing here again. I haven't heard from you for a long time but also didnt read much about you, that's why I'm asking you now How are you? ๐
Good thanks, and yeah this lockdown stuff gives me loads of time.
( #memes-and-media for continuing if you wish )
if you're hosting in a vps, check if your hosting provider requires firewall unblocking in the admin panel
It's not blocked
Trying to make a vote webhook in js
dbl.webhook.on('ready', async (hook) => {
client.log(`Top.gg webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', async (voter) => {
console.log('someone voted');
});```
The ready event is on but the vote event doesn't emit anything
Is my URL wrong?
Replace 0.0.0.0 with your external IPv4
yes
What do you use to host ur bot
Nor do I
any further help ?
or at least a it is broken atm or it is normal with explanation
@tender garnet
I dont think you can actually use the normal check for votes considering Koya gets easily over 1k votes a month
@green mantle
KoyamieYesterday at 3:07 PM
He should, this is only for getting 1000 latest votes
as API said
@green mantle
yes, thanks
but i've seen many people reporting that the check endpoint can be slow, as slow as a few minutes
but this is not working atm, I receive {voted: 0} for every user ID
it is not slow, it is not working
or I am doing it bad but changed nothing for months and it stopped working suddenly
I don't see what's wrong with using the webhooks -> overall better to use it
can you read ?
KoyamieYesterday at 2:56 PM
my website was offline this morning so webhooks stopped working
seriously
If I had a chance to finish:
That could be solved by using a redundancy system and load balancer with kubernceles
yes it could
but this is not my case of use
and this enpoint should work
so I am reporting it
ยฏ_(ใ)_/ยฏ
so, nevermind I found the issue and it was on my side
still surprised that it stopped working without changing anything on my side or I am amnesiac
anyway sorry for disturb
im kinda a novice on all of this but how do you make a weebhook for voting??
What lib?
python
Thats not a lib
well its the language so i hoped you could guide me based on that
dblpy
there is an example here https://top.gg/api/docs#pylib
#alwaysreadthedocsbefore
i have but you need a webhook path for it and i want to know how to make that
Just make it as it is in the doc, /dblwebhook?
hey i keep getting this error upon GETting my bot's page. Is this some sort of ratelimit? aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', url=URL('https://top.gg/bots/572842779374518283')
Because a get to that page returns html not json
^
yea i can't figure it out, i need to know how to make the url that a put in both the webhook_path section and in the webhook URL section on the edit page
i would appreciate it if anyone could help
In the website you put domain.ltd:port/webhook_path
make sure you replace with accurate stuff tho
im not sure how to check if its weekend with /weekend
console.log(`User with ID ${vote.user} just voted!`);
let embed = new MessageEmbed()
.setColor(`#5780cd`)
.setAuthor(`<@${vote.user}> Upvote !`)
.setTimestamp()
.addField(`User ${vote.user} With ID ${vote.user} Just Upvote For my Bot `, `He UpVote in https://top.gg/bot/672883668594720773 `)
.addField(`We Have ${vote.count} UpVotes `, `Thanks You Soo Much`)
let guild = bot.guilds.cache.get(`675254454139748352`)
client.channels.cache.get("694189734146211901").send(embed) });```
why in the embed dont mention the user
and in vote.count it says undefined?
you cant mention a user in author of the embed of the title of the field
Ok
oh
yeah
one moment
Now Work but
idk why it Says Undefined
in vote.count
Vote.count don't exist
and dont are a funtion to show current vote count of my bot?
you can use dbl.getBot
ok
dbl.getBot("264811613708746752").then(bot => {
console.log(bot.username) // "Luca"
});```
change .username to .votes i believe
if not just log bot and check in the json what vote is
nice
console.log(bot.votes) // "Luca"
});
console.log(`User with ID ${vote.user} just voted!`);
let embed = new MessageEmbed()
.setColor(`#5780cd`)
.setTimestamp()
.addField( `New UpVote in https://top.gg/bot/672883668594720773 `, `User <@${vote.user}> With ID ${vote.user} Just Upvote For my Bot `)
.addField(`Thanks You Soo Much`, `We Have ${count} UpVotes `)
let guild = client.guilds.cache.get(`675254454139748352`)
client.channels.cache.get("694189734146211901").send(embed) });```
What's in Console ?
Console.log(bot.votes)
?
@restive otter console.log(bot) and look at bot proprieties to find what you want
Of dblapi.js
Ok
https://lumap.is-inside.me/gQ6NC5Vb.png --> ```js
const count = await dbl.getBot(id).then(bot => { bot.monthlyPoints })
ok
@true talon ?
@restive otter
const count = get.monthlyPoints || 0```
try this
ok
Work!!!!!
thanks
and i cna get total upvotes?
changing monthlyPoints
wait a sec..
ok
Here you go: https://discordbots.org/api/docs#bots
ok
Thanks โค๏ธ
Eh, despite many attempts, I can't connect webhook to my code
(node:2766) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized
This is my first time using a webhook
@bitter crag i checked ksoft's docs
if you chose to use them, then you dont need to use dblapi.js
they are a replacement for running your own webhook server and manage it for you
top.gg will send webhooks to them, they will store it and manage it for you, then you access them via the ksoft api
for example, to check if someone voted: https://api.ksoft.si/webhook/dbl/check
oh, ok. Do you know how to connect it to my code?
I don't know which choice will be the best :v
it doesnt matter really
depends on what you want to do
top.gg sends a webhook when someone votes
do you need to store the vote?
or just execute an action when someone votes?
I want to be notified when someone votes
I don't know. This is my first time using a webhook
are you using ksoft for anything else? did someone tell you to use ksoft?
or did you just randomly find a tutorial that uses ksoft and tried to use it?
I use ban-api which offers ksoft
ah alright
and I tried to connect ksoft with dbl
well its your choice really, if you want to use them for votes too, or just use dblapi.js
if you prefer using them, then you can remove dblapi.js
and then you use their api. do you know how to use their api?
No :v I don't know how to use
how are you using the ban api?
I am a beginner bot developer
yes, but you said you're using the ksoft ban-api
how do you use it?
show a code that uses it
because if you're using the ban-api, their dbl api should be very similar
const ksoft = new KSoftClient('f*79*f71071c5307##40**d3c466##4f96b6aa8');
async function checkBan(id) {
const banned = await ksoft.bans.check(id);
return banned;
}
My ksoft token is naturally different
well, apparently the ksoft.js library does not support the votes endpoint
I read ksoft docs https://docs.ksoft.si/api/dbl-integration and still not working
I don't know what to do to make it work, ehh
the library does not support it
the only way to do it is making the requests yourself
do you know how to make an api request?
using an http library, such as node-fetch, axios, got, etc...
No, I have never used it
making a request is like loading a website inside your code and getting the result from it
there are many different libraries that do that
you would need to chose one to get started with
for example, using got (https://www.npmjs.com/package/got)
you would load a website like this const response = await got('https://websitehere.com');
in your case, you would need to load https://api.ksoft.si/webhook/dbl/check?bot=YOURBOTID&user=USERID to check if someone voted
this is how you would manually make requests to an API
now to receive webhooks its a different story, you need a webserver
and you need to receive it
dblapi.js makes a webserver for you. if you want to use ksoft, then you need to make a webserver for it. an example webserver is express.js
have you ever used express.js?
No :/ I only saw
then i would recommend you give up on ksoft and use dblapi.js
okay
in google cloud
compute engine?
yes
then your URL will look like this YOUR.GOOGLE.IP.ADDRESS:PORT/dblwebhook
PORT can be any number from 1024 to 65550, defaults to 5000
but you need to open this port in your google firewall
your vps's ip
https://
It's been a while, how do I send a simple GET request using my bot tokens?
I'm trying to find out what guilds my bot is in /users/@me/guilds
Oh excuse me, and I found out why my call wasn't working :p
@bitter crag that is correct
My console shows still (node:4685) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized
:v
show your dbl code
const dbl = new DBL('mytoken', {webhookPort: 3389, webhookAuth: 'mysupersecretauthkey'}, Client);
and not working :v
unauthorized has nothing to do with webhooks
more likely your token is wrong, but it only affects posting stats, not the webhook
the URL should indeed being with http:// but not https:// unless you have SSL
did you allow port 3389 in your google firewall?
yes
dm me your ip and your authorization
how can i change the color
you can't

Hello i need some help my DC server not have api kay but i need from Rust DC Core
Who can help me how do i can set
what is Rust DC Core?
Rust (game) Rust Discord Core (for plugin) Comunicate serverside and discord side too
And this game plugin need discord API
but my dc not have
post more info in #development
i rly dont know what i must do it for make API
move #development
does the
DiscordBotListAPI api = new DiscordBotListAPI.Builder()``` need to be in the Launcher or can it be in a difrent class ?
explain your problem
my bot needs to catch when people vote
but I can't use my main bot for webhooks because I don't have a web server
so I get a glitch.com website and use express
and I use that to catch dbl webhooks
what did you put URL option on website
ok
but then
I use a different bot
to post the people who vote
and I use the main bot
to add their coins
but the problem is
that when I use my DBL token for the webhooks, I can't use it for my main bot to post a server count anymore
it complains Error: 401 Unauthorized
did I explain my whole situation?
401 means your token is invalid

Ehhh anyone got any idea why it says on the website my bots only in one server
When its in 600+
you did something wrong when posting
DiscordBotListAPI api = new DiscordBotListAPI.Builder()
.token(config.getString("api.topggToken"))
.botId("bot.ID")
.build();
int serverCount = shards.getShardsTotal();
api.setStats(serverCount);```
Thats what i put
-servercount
To have your bot's server count displayed on DBL, please read the documentation on server/shard posting. Click here to see the docs.. You may also find #312614469819826177 useful; however it is strongly discouraged as most of the examples are extremely outdated.
@floral phoenix arent you posting the shard count instead of the guild count?
Ye
then thats why its 1 lol
But im using Sharts and getShardsTotal() gets every guild in all my shards
are you sure?
you're using JDA right?
im looking at its source code, and from what i understand, it returns the total number of shards
yah @gloomy fractal i have a corona bot. Approved 4 days ago. after it got approved. every hour the bot was beeing added in 30-40 servers or more. We got 3.5k this isnt so easy in 4 days. suddenly, last 6 hours no one added the bot. i doubt on it.
Ya, so it's not updating your server count?
Maybe. cant figure out
Why did people stop inviting the bot? Its not possible
laat 6 hours no one added it. where we were getting 40-50 servers per hour
I doubt people stopped inviting it, probably just isnt updating your server count
Do you have like guild logs in the server?
yah
Also post how you are posting your server count
And you said that isn't right?
and it had 3330 6 hours ago
So topgg says those numbers?
no. my bot says
lemme Chexk
check
wrong emote. accidently
oh its working now
but whats the problem. about the last 6 hours topic
@gloomy fractal
sry for ping
I am not sure, come back if it doesn't start to work again, as long as it's posting your correct stats now that's good ๐
Also no worries about the ping.

@gloomy fractal so you are saying that, it was showing wrong stats that's why it wasnt being added in servers?
I am not 100% sure really
it was shoeing 3335
now showing correct one. 3326
so its about same.
maybe not for this. I checked by inviting the bot. there is lnp
np
even we are having 4 shards,
787
837
811
892
the webhook is instant, the hasVoted will need to run in your code
I just started messing with the api I'm a little confused on how to display monthly/total vote count for my bot
Nevermind I found it
having issues with this
says server count posted
in console log
but doesnt show
what library? also can i see the code?
Wumpus Giveaway?
it shows fine for me
your browser is probably caching the webpage
its discord.js
use Ctrl+F5
okay
The caching of your client / browser isnt up to date. probably just clear your cache
Im mking a bot
but it cannot do more than one process at once
it can only work for 1 channel not more
wrong channel goto -> #development
Anyone here with knowledge for the top.gg webhooks?
I get that the webhook is running on http://0.0.0.0:3010/dblwebhook
I then have this listener:
dbl.webhook.on('voted', (vote) => {
console.log(`User has voted: ${vote.user}`);
});
But nothing gets logged when test voting
click "My Bots" @restive otter
Are there events for new votes?
So I can make like a notification in my Discord server when someone boosts the server
what do you mean by boosting
nitro boosting doesn't have to do with top.gg's API afaik
unless they have some api endpoint that for some reason does involve it
^
some libs provide webservers for you to use with the webhook system i'm sure
if not the docs are here https://top.gg/api/docs#webhooks
What is the response when you use /bots/:bot_id/votes but you have over 1k votes?
judging by the description, it indexes the most recent 1000 votes
Users can currently vote every 12 hours for each bot. The /votes endpoint for your bot (the one you use via getVotes) only indexes the last 1000 votes. Please implement the webhook instead if you plan to process over 1000 votes.
does not indicate that it will stop working past 1,000 votes
@supple river @green mantle I didnt mean boost, I'm talking about upvoting
well then in that case the webhook system is the way to go
depending on what DBL lib you're using, it might include a webserver for you to use to listen to webhook calls
then you can just hook that logic up to announcing in your server ๐
Hey
<groupId>com.github.DiscordBotList</groupId>
<artifactId>DBL-Java-Library</artifactId>
<version>LATEST</version>
@supple river
i haven't used java lib but by the looks of it it does not have a webserver
though i'm sure there's plenty of web server libs on java
if you can find one that works for you, just open a port on your network, let the server listen to it, and you can set up the webhook settings on your bot edit page
once again, this page https://discordbots.org/api/docs#webhooks has information on what the payload looks like
it will POST your webserver webhook with that JSON, to which you can just decode it and see who voted ๐
isnt there an easier way?
i mean technically you could request https://discordbots.org/api/docs#votes
but you shouldn't
This is how I define DBL:
const dbl = new DBL(token, { webhookPort: port, webhookAuth: config.auth });
In the docs it says that options.statsInterval has a default interval of 30 minutes. However, it doesn't update for my Discord bot even though I don't overwrite the variable. Any idea why?
define your bot client in DBL
const dbl = new DBL(token, { webhookPort: port, webhookAuth: config.auth }, client);
```like this ^
I'm using Java tho haha
someone said.....java?
Should I use api#getVoters or api#hasVoted for every user?
you should setup a webhook server
manually checking for votes is a VERY bad solution
you can, but it's not recommended
since it's java, you can easily create one with springboot
I'm not using Spring tho
you don't need to
how do I do it then?
maven
do you use JPA?
ok, just a sec
even*
asked that because there's a different setup if you use JPA with springboot
kk
hey im trying to vote lock a command
this is my code: if(!dbl.hasVoted(message.author.id)) return message.channel.send(Errorembed("You Need To Upvote us to use this command.").setURL(upvote));
and it seems to not work, and idea of how can i fix it?
oh wait i think i got it
its a promise
im dumb nvm
I've got a question,
Does this mean that if server_count is an array, it will act as shards here (as and like can mean different things)
yes
@rotund magnet If your bot has shards, that server_count should be an array. else it'll just be a single number
Do you need API help?
@remote flicker
You need API help? @manic plaza
I need help
You need
@red wasp what do you need help with
What do I keep doing wrong here?
I'm trying to post my bot
I got the invite url in there, and every time I submit-- I get an error
For the discord support server section you are only supposed to put the code
So like: hdjahg
And not discord.gg/ hdjahgjsnsbs
@red wasp That isn't the DBL API, head to that API's support server we don't help with other APIs.
@gloomy fractal I think they mean the support server code
Since he or she didnโt fill that out
Am I suppose to fill it out?
Yes
I don't see the red star on it
Your invite link might be incorrect
@gloomy fractal okay
How to get the server count for my bot, I mean, Luca isn't being friendly.
-servercount
To have your bot's server count displayed on DBL, please read the documentation on server/shard posting. Click here to see the docs.. You may also find #312614469819826177 useful; however it is strongly discouraged as most of the examples are extremely outdated.
@gloomy fractal Thanks.
Np
How am I suppose to get the shard ID in ready event in Js
@jaunty sable better question for #development
Even I pass shard ID in, it's not showing up on top.gg
And when I didnt pass it in it logged 400 bad request
Hey, i want to setup a channel in my discord server that if someone votes it will send like <name> has voted for BOTNAME
how could i co this ?
aah didn't look into that thanks
๐
And the bot id is not that much a secret at all. You can find it easily. The thing which should be hidden is the token of the bot.
And you can't post the server invite to the bot, you need to use /bot/:id/edit and update it via HTML
This is what you can post:
i get 0.0.0.0/0:5000/dblwebhook what should i do next ?
what do you mean?
No
Ohhhh
So how do I get what its asking of me?
go to the website
press generator
then go to
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
and copy the Client ID
then paste it where it says client ID
then done
can someone explain me about .isWeekend() api? does it return true if weekend (sat and sunday) or what?
yes because voting is doubled during the weekend
or something like that
so if isWeekend() is true, that means votes are more valuable than normally
thank you
hello, I have no idea how webhooks work but I want to let my bot send a message when someone voted and I want to know if someone voted for my bot, but I have no idea how this works. I tried it, but I failed
can someone help me please?
language?
js
are you using dblapi.js?
yes
did you set it up like it shows in the webhook example?
yes, I used this example
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!`);
});
but like I said, I have no idea how webhooks work tbh
you put your top.gg token there and make up a password of your choice
depending on where your bot is hosted, the URL might be http://YOUR.BOTS.IP.ADDRESS:PORT/dblwebhook
Hello need help
Have you read this channel's topic
lol
When someone gives a vote to the bot, he will throw it into a channel. How can I do this?
-api @autumn flume
@autumn flume
THIS CHANNEL IS ONLY FOR SUGGESTIONS/HELP/BUGS TO DO WITH OFFICIAL TOP.GG API LIBRARIES AND API DOCS FOUND AT
https://top.gg/api/docs
move over to #development
yes
Ok thanks
that essentially websraping the site to automatically vote
Hey I'm a little confused on the webhooks as well. Let's say I was self hosting for bot testing how would I enter the link for the webhook?
webhook?
@rotund smelt most likely your IP address followed by your webhook port
and you'll likely have to portforward in your router
and configure a webhook handler
-api
That is about the api
You can but it would be obviously unofficial
Hi. How can I use this API to post my server count if the bot has sharding?
iterate through all shards
So, I have the normal codes in my file and it makes 2 shards/
go through both and add the servers to a variable
I want it to show the shards count too. How can I do it?
Should I need to have the codes in a new instance where there's no sharding or should I need to just have the codes in the main bot files where sharding is occurnng?
yo, so i got all of the code to use the api, but i cant find any good apis to use for memes, does anyone have suggestions?
oh sorry didnt read the top
Is this what's supposed to happen with the webhook?
I'm pretty sure i properly set it up
Halp!
Well what's the error
@sullen nymph its glitch.com it just show red dot for errrors it dont show error
I remember people showing errors on Glitch
where can i check error ?
@sullen nymph ohh i find error
it says dbl is not defined
well import it and define the DBL client? 
https://top.gg/api/docs#jslib there's an example
@sullen nymph now it says message is not define
please help me
@sullen nymphare you there ?
Are you sure you have message anywhere within that code
or if you're even putting that code snippet where it's supposed to be
yes i am sure
@sullen nymph now i add blacklits and now it dont shows error but it is working by non voters also
- Make sure you are not hitting ratelimits since your bot could be getting way more than 60 messages per second
- Are you even checking if the returned data says "true" or "false"
per second 60+ message ?
minute, not second
@sullen nymph const Discord = require("discord.js"); const client = new Discord.Client(); const DBL = require("dblapi.js"); const dbl = new DBL('', client); dbl.hasVoted(`message.author.id`).then(voted => { `Please vote for the bot to use this command` }) see where is mistake
i removed bot dbl token
Ask in #development
That's a discord.js question from here
Also...
`message.author.id`
That won't work
U hover over the dot @restive otter
O wow late response
I got bumbed up like 20 msgs
Hello!
@hasty lagoon Feel free to chat in #memes-and-media or #general ๐
This channel is for top.gg api support only.
how do I fix a 401 error, Not Authorized
this only happens when the dbl package is mentioned
@strange wraith check if your DBL API token is correct.
guys my api is not posting the amount of guilds what can it be? I also don't get any errors on the console
You'll have to provide some extra information.
Eg code (no tokens pls)
@haughty tundra
onst DBL = require("dblapi.js");
const dbl = new DBL('', bot);// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})dbl.on('error', e => {
console.log(Oops! ${e});
})
Sorry can't help with that, currenly I've only "mastered" python
Did you look at the docs?
@fast mirage Send your code without the token
How do I know if the token is correct? I got the string of numbers from the URL, the code is directly from the docs
@gloomy fractal it says const I missed the c
@gloomy fractal ```py
import dbl
import discord
from discord.ext import commands, tasks
import asyncio
import logging
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
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)
# The decorator below will work only on discord.py 1.1.0+
# In case your discord.py version is below that, you can use self.bot.loop.create_task(self.update_stats())
@tasks.loop(minutes=30.0)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count"""
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))
@strange wraith Where did you get your bot's token from?
@strange wraith did you get your token from here?
Where is that??
ok
@fast mirage Looks like you just copied and pasted the code from the docs. Did you change anything that would need to do with your bot? Add your token and such? the example is to help you
replace the YOURBOTID with ur bot id
Or go to my bots>edit>scrol down
@fast mirage did you fill in your credentials and did you load the COG ?
yes
Weird, you said that it didn't raise any errors right?
I'm sorry but I'm unable to replicate this. :3
Task exception was never retrieved
future: <Task finished coro=<DBLClient.webhook() done, defined at /usr/local/lib/python3.7/dist-packages/dbl/client.py:417> exception=OSError(98, "error while attempting to bind on address ('0.0.0.0', 5000): address already in use")>
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/dbl/client.py", line 436, in webhook
await self._webserver.start()
File "/usr/local/lib/python3.7/dist-packages/aiohttp/web_runner.py", line 104, in start
reuse_port=self._reuse_port)
File "/usr/lib/python3.7/asyncio/base_events.py", line 1378, in create_server
% (sa, err.strerror.lower())) from None
OSError: [Errno 98] error while attempting to bind on address ('0.0.0.0', 5000): address already in use
@gloomy fractal
I'd point out two things:
- the above what Arthur said
- you cannot use the API with your bot till it has been approved
Another program is already running on port
5000
@haughty tundra whats?
I only have a top.gg file running
Then it might be running twice
Another program/file is running on your localhost port.
As shivaco pointed out that probably because you're running it twice.
Looking at that you havn't received your developer role here I assume that your bot hasn't been approved to top.gg.
Therefore you can not use the top.gg API as ใใผใชใใ (CF8) pointed out.
So I'm having problem with the hasVoted. So it's returning false even when the user has voted. this is the code
console.log(message.author.id);
dbl.hasVoted(`${message.author.id}`).then((v)=>{
console.log(v)
if(v) console.log('Nice')
})
Nevermind I guess it just took 20minutes for it to register
I need help with setting up the API for my bot. How can i get started?
-servercount @orchid spire
@orchid spire
To have your bot's server count displayed on DBL, please read the documentation on server/shard posting. Click here to see the docs.. You may also find #312614469819826177 useful; however it is strongly discouraged as most of the examples are extremely outdated.
why am I getting the Oops! Error: 400 Bad Request even tho it doesnt specify more
bad request means you're posting invalid data
check how you're posting your server stats
is there a way to fetch how many total votes your bot has and put it into an embed?
GET /bots if you're sending requests directly
@sullen nymph Could you give an example please? (for discord.js)
Are you using dblapi.js?
Thank you
https://raid-shadow-legends.is-inside.me/WRxa1CAZ.png
anyone have any idea as to why shard_count isn't actually posting
or did i break something stupidly again
you could handle the async return value of fetch to check if there was an error or what response there was in general
fetch('...',{...})
.then( response => {
console.log('response code was: %s', response.code);
return response.text();
})
.then( data => {
console.log('response data was: %s', text);
});
besides that if you're in an async function you might want to also await your fetch so that the function resolves after the fetch call has finished @cold ledge
@manic sonnet the function being async doesnt seem to affect it as server_count is being posted normally
only reason i need the function to be async is for the fetchClientValues everything else should be straight forward
yea it's just if you're awaiting postStatus it will finish before fetch has actually finished
that's why I suggested also awaiting fetch
i can try but i highly doubt it would make any difference
it will make a difference if you're depending on that changed state of your api call
and you are running a check or update after postStatus
no i dont do anything after that function
well then it won't make a difference, but I recommend you to await it anyway since you will pull your hair out searching for that issue once you're depending on that async call
and the await didnt do anything
still saem issue
same*
im having the server count post fine but the shard count isnt being posted
so the api is declining the shard_count value in your api call, but in that same call server_count will get picked up?
yes
ive tried manually setting the shard_count to a number and not getting the value from the client but it didn't work
okay i figured out the issue
fetchClientValues() will return an array
server_count will take that array add it up and the length of the array = shard count
seeing as my sharding manager handles the fetchClientValues() function per cluster rather than per shard the array was 1 element
so the api took the array length over shard_count
took me a while to notice in the documentation that it gets shards through server_count too
well then good you got that fixed ๐
so yeah it was me just being stupid and not reading the docs properly
๐
thanks anyway
yw
So with the dblapi.js...
How can i get the bot to console.log the person's tag that has voted for my bot?
that is a express and body-parser thing, you have to set up a webserver
and register it in your bots settings
Hmm but Timo aardappel said it's possible to get the votes without a webhook or a webhook port... @restive otter
Im not really fluent with the api, as long as i remember you have to set up a webserver
Hmm... Idk... Should i ping the timo aardappel to help?
i mean
you could
Hmm lemme see
@dense basalt can you help me with this situation?
@restive otter JavaScript?
Yup
See the docs, itll help
Hmm okie
@gloomy fractal wait idk much about that webhook stuff... What should i do about those?
Hmm ik... But like webhook url and and webhook port should be the url my bot is getting hosted on abd it's port?
Yea... The tag of the user who voted
Just use parts of these 2 examples and you should get what you want
Hmm... The receive vote update is the part but doesn't that require a webhook and a webhook port or something?
the voted event
I really don't want to spoonfood, want you to be able to look at the docs and get it yourself
uh i dont have a list but off the top of my head posted error ready vote
vote being the one youre looking for
Should be vote
It says webhook, but you should be able to just console.log it without needing a webhook
@restive otter didnt log anything at all?
Nope
Did you vote for your bot?
I asked my friend to do it
Did you restart your bot after applying the code
Yup
Is the topgg token correct?
Yup otherwise it wouldn't post the server count lol
@restive otter wrong indentation ?
Wait what?
it looks like its indented a bit too much
Indentation has no affect on code really
Hmm true
I also tried with both vote and voted but both didn't work @gloomy fractal
Keep it vote, restart Iโm gonna vote for your bot and tell me if it logs
the code is wrong
What's the correct one... Tell me
you have dbl.on("vote"), should be dbl.webhook.on("vote"), you also need to add the webhook options to new DBL
if you want vote events
Isnโt it possible without using webhooks to just console.log it?
Hmm can't i do it without webhooks? Timo aardappel said i can tho @vapid cape
you cant receive vote events without webhooks, you can only fetch votes and check if users voted
you dont get vote events if you dont use the webhook
Hmm so if it needs webhooks... Then how do those webhooks work... I'm not kinda familiar with using webhooks
first add the webhook options to new DBL, more specifically webhookPort and webhookAuth
like it shows in the example
I mean ik that but what would be the webhook options?
read the docs please
webhookAuth = what you put in your top.gg webhook authorization
webhookPort = depends on your hosting
you'd know that if you did
Hmm i self-host it so what the port will be?
anything between 1024-65550
usually 3000 or 5000 is fine
you might need to portforward in your router
Hmm how does that work lmao?
@restive otter first finish setting it up so you can test, then deal with the router if it doesnt work
in top.gg under webhook URL put http://YOUR.PUBLIC.IP.ADDRESS:WEBHOOKPORT/dblwebhook
That dblwebhook after the slash doesn't need to be changed? @vapid cape
whatever you want, as long as its the same as in webhookAuth
Hmm it's like a password right?
yes
Oh ok
for example
Authorization: test123
webhookAuth: "test123"
@vapid cape is this correct? Cuz it didn't log anything to the console.log...
Oh ok
Any reason why I'd be getting an error about server_count being missing when trying to post my bot's server count? (the value of 'data' is the body I am sending)
https://i.inv.wtf/nXc7Bnvm.png
0.0.0.0 == localhost/127.0.0.1
Hmm lemme show you something
Correct?
(Are the dbl.webhook.on needed for the posted and the error events?)
Cuz it doesn't log "Server count posted" or any error with both dbl.on and dbl.webhook.on...
no
posted and error are on dbl, not on dbl.webhook
dbl.webhook is only for ready and vote
@severe iron the value of data shouldnt be a string
but idk how you're posting it
@restive otter go here https://reqbin.com/ and try to send a POST request to your top.gg webhook URL
Send HTTP requests to the server and check server responses.
Hmm a post request?
if 'json' in kwargs:
headers['Content-Type'] = 'application/json'
kwargs['data'] = json.dumps(
kwargs.pop('json'),
separators=(',', ':'),
ensure_ascii=True
)
``` this is where data comes from
async def post_guilds(self):
route = Route(
'POST',
f'/bots/{self.bot.user.id}/stats'
)
await self.http.request(
route,
json={
'server_count': len(self.bot.guilds)
}
)
``` and this is the actual code for posting it
@vapid cape is this token thing or something required?
@vapid cape also just putting the url and choosing the POST option and clicking send gives this error:
Could not connect. Error code: 1007
then you need to check your firewall and your router's portforwarding
Hmm what am i gonna do with those?
if the URL is correct, it should give unauthorized without the auth
do you know how to access your router?
Ik
then access it, and look for port forwarding options
you need to set your dblwebhook port (5000) to your internal ip address (something like 192.168.0.10)
Like 192.168.1.1?
or simply to unblock to all internal IPs
192.168.1.1 is to access the router
most likely
Hmm oh
figured out my issue, content type header has to be all lower case 
Oop.
im still getting the
const DBL = require("dblapi.js");
const dbl = new DBL("token", { webhookServer: server, webhookAuth: "password" }, client);
dbl.on("posted", () => {
console.log("Server count posted!");
});
dbl.on("error", e => {
console.log(`Oops! ${e}`);
});```
xD
yk i changed the auth
oh ok good
i had to
lemme look for a sec
@last cedar make sure client is your correct client instance, the same one you login with. also make sure your dblapi.js is updated, latest version is 2.4.0
yes
?
what are widgets?
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)
When I do this, it automatically makes the server widget?
It doesn't exactly "make" a widget
it updates the info on the widget, doesn't it?
def __init__(self, bot):
self.bot = bot
self.token = self.bot.DBL_TOKEN
self.database = self.bot.get_cog('Database')
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)
@commands.Cog.listener()
async def on_guild_post(self):
print("Server count posted successfully")
Does this look okay?
Info is updated on API request to n URL
to get the widget, you use this link https://top.gg/api/widget/:ID.svg
What exactly do you mean by "server widgets"
Just saw it in documentation
That's not widgets 
Does it happen immediately?
using dbl lib to post server count? smh
Should
i just use standard python requests
and the server count hasn't come on the site - https://top.gg/bot/689210550680682560
make sure you saved the code and wait 30 minutes to make sure it's working 
ah alright
i just use standard python requests
badddddddddddd
discord.py + requests = F
async + requests = F
does my bot's event get triggered immediately when someone upvotes?
This isn't working 
it is supposed to
are you using webhooks
Nope
then there u go
But like I don't have a webserver or anything
the only thing that is an 'event' is the vote webhook
if you're not using webhooks then you wont immediately get the notification
you would have to check via calling the api
its just ur public ip:port
I can use any port?
Okay, still doesn;t work
here is what i did
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/vote', webhook_port=3004)
and in the dbl webhook url, I entered publicip/vote
http://<ip>:<port><path>
oh forgot the http
also, when I ctrl+c mybot
oh wait thats because of my
one sec
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/vote', webhook_port=3004)
@sullen nymph is this okay? do I need to specify the ip here too?
Nah
and for some reason I only get the errors when I ctrl+c, maybe because they're loops @sullen nymph what does this mean?
That's interesting
not solving the problem though
The 403 is because you are hosting the bot on a bot that isn't approved
Yes
but it is @shell nest
Right, it's not waiting until the user is cached
attach the DBLClient to your bot object and use wait_until_ready in on_ready, output bot.dblpy.bot.user there
It should be waiting for the user to load before posting 
@vapid cape i did use the right client, and its already updated to 2.4.0
this is my error https://hastebin.com/ruporuvazu.js
@sullen nymph this is the output
also it just stopped my bot
like my bot doesnt come online anymore for some reason
That sounds like an issue with your code
anyone help?
Now I get this/.
hmm okay
omg
I think ti worked
gotta test votes tho
Okay, so my votes don't work
but this worked
@sullen nymph does this look good?
Remember port in URL
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/upvote', webhook_port=3004)
Ah
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/upvote', webhook_port=3004)
It's http://<ip>:<port><path>
I suggest you don't expose your IP in a public server
Oh yeah, that too
It's
http://<ip>:<port><path>
@finite hare Thats what it is
no
I suggest you don't expose your IP in a public server
@sullen nymph Yeah forgot to remove it this time. Thanks
thats..... not that
Like that ^
IPs
Yes
Alright
That's not my ip
Trying again
Next time just use 0.0.0.0
Si senor
Still doesn't work ๐
But yeah, I have the same problem with the vote thing
Doesn't work at all and I have followed the docs throughout
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL(
"token", {
webhookServer: server,
webhookAuth: "password?"
},
client
);
const handleReady = message => {
setInterval(() => {
dbl.postStats(client.guilds.cache.size);
}, 1800000);
}
client.on("ready", handleReady);
``` idk why im getting https://hastebin.com/ruporuvazu.js



