#topgg-api
1 messages · Page 80 of 1
did the console show an error?
try this ```js
let embed = new Discord.MessageEmbed()
.setTitle("Vote !")
.setDescription(${vote.user} a voté sur | https://top.gg/bot/688390331523530978)
.setColor('#00AAFF')
bot.channels.get('694001560539234364').send(embed).catch(console.log)
check your console
and still crash?
anything in the console?
what is your discord.js version?
check your console
Yes
do you see testing123?
you get the message?
Yes
or if for some reason top.gg is not working, but thats unlikely
so there's nothing more i can help with
I have save
I have put game07.ouiheberg.com:25578/dblwebhook
I have make and look
Its like you
The problem : i have test and nothing on my console
if you want to test using reqbin, you need to put {"user":"test"} in the content
Im using dbl npm in discord.js
seems like webhook.on ready works, it logs 0.0.0.0:5000
but on vote and on posted doesnt seem to work
however dbl.hasVoted and all other methods are working
show code
const bot = new Discord.Client();
const DBL = require('dblapi.js');
let dbl = new DBL(process.env.DBLTOKEN, { webhookPort: 5000, webhookAuth: process.env.DBLKEY }, bot);
dbl.webhook.on('ready', hook => {
console.log(`📯 Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('posted', () => {
console.log(':ribbon: Server count updated and posted!');
});
dbl.webhook.on('vote', vote => {
console.log(`💎 User with ID ${vote.user} just voted!`);
});
posted is not a webhook event
dbl.on("posted")
what did you put in your top.gg page?
dbl.webhook.on
vote is on webhook
ahh the authorization key?
and url
is authorization the same as your process.env.DBLKEY?
yes
When clicking test button
app.post('/dblwebhook', function(request, response) {
console.log("Someone voted!");
});```
this is fired
and of course, i check headers and authorization
to make sure its from dbl
But webhook.on vote
is your webserver running on the same process as the bot?
doesnt seem to log anything
im not gonna lie
i have no idea what does that mean, i guess it is, and what i'll say will probably point whats wrong
im using glitch rn
so i guess its running in the same process
then you need to use the existing webserver on dbl
remove webhookPort:5000 and add webhookServer:listener
where listener is what you put under whatever = app.listen()
I tried what you suggested, the dbl.on("posted" works.
But the dbl.webhook.on("vote" doesnt seem to work. Im testing with the "Test" button
show your current code
let listener = app.listen(process.env.PORT);
let dbl = new DBL(process.env.DBLTOKEN, { webhookServer:listener, webhookPort: 5000, webhookAuth: process.env.DBLKEY }, bot);
dbl.webhook.on('ready', hook => {
console.log(`📯 Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.on('posted', () => {
console.log('🎀 Server count updated and posted!');
});
dbl.webhook.on('vote', vote => {
console.log(`💎 User with ID ${vote.user} just voted!`);
});
app.post('/dblwebhook', function(request, response) {
if(!request.headers || request.headers.authorization !== process.env.DBLKEY) return;
console.log("❤️ New vote registered!")
console.log(request.headers)
})
however, the webhook on ready logs this
📯 Webhook running at http://0.0.0.0:5000/dblwebhook
you said you're on glitch?
remove webhookPort:5000
your url in your edit page should be https://your-project-name.glitch.me/dblwebhook as well if it isn't
it is
Tim, not working still after removing port
Steven in my bot edit page it is
https://MYPROJECTNAME.glitch.me/dblwebhook
are you using express directly or via http.createServer?
^
uhmmm
if you're using http.createServer, try using the server variable instead of listener
if it still doesnt work, just use your post handler, it all the same thing anyway
in fact you dont even need dblapi.js at all, you can do everything with node's http
yeah
to receive new votes too?
you said your app.post("/dblwebhook") was working, right? then just use it
tried the createServer think, not working
but using /dblwebhook, i cant find the user id
you can
it's just a web request
trying rn
just handle every request that gets sent to your server
check if it's from dbl
and then use the data that got sent
ez
wow, nice
i've used apis just requesting and parsing json
but i used request.body and it didnt work
i used the bodyParser.json()
and it now logs:
blank
{
bot: '484148705507934208',
user: '290640988677079041',
type: 'test',
query: '?test=data¬RandomNumber=8',
isWeekend: false
}```
thanks guys
congratulations
now use that data as you want to
don't call it an npm
I can see that you're also from a spanish country, and it's a very common mistake to call node modules NPMs @sick stag
just call them modules (modulos) and you'll be fine
yeah 

thanks, ill keep working now. Finally working 
kk
Tim my friend have vit for the bot and the bot not send message
im getting a 404 when trying to find my bots last 1000 votes,
(GET - returning not found)
tried both
https://top.gg/api
https://top.gg/
as bases
are either of those the correct base url for finding a bots votes?
you don't have a bot on the site 🤔
nevermind, the .net library is easier to use
am i not allowed to access other bots' vote count?
i tried with dank memer
you need api key
for get api key you need to an approved bot on site
also thank you, was about to try without that
@willow spindle to*
👌
const dbl = new DBL(process.env.dbltoken, {webhookPort: process.env.PORT (should be set to 3000 by default), webhookAuth: 'same as here https://lumap.is-inside.me/xv967mPM.png '}, client)```
ye
https://lumap.is-inside.me/e1WPi3LZ.png assuming ur using glitch, this should be https://[name of ur glitch project].glitch.me:3000/dblwebhook
try another
3001?
yes
replace name by ur glitch project name tea
LEARN HOW TO READ
try another
try 5000
first make sure code is working
second update url
well
r u using glitch?
just try process.env.PORT
no
just try it
u use what log gives you
well for me on glitch most ports work
i just use express with port 3004 and rest of stuff 3001 - 3003
Can you help me because when my friend vote or i test on the top.gg test button they aren't message in my console or my channel
post code
Ok
const DBL = require('dblapi.js');
const dbl = new DBL(".............L8Fg4", { webhookPort: 25573, webhookAuth: '...' });
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 ${vote.user} just
voted!`);
let embed = new Discord.RichEmbed()
.setTitle("Vote !")
.setDescription(`${vote.user} a voté pour BryXou sur \nhttps://top.gg/bot/688390331523530978`)
.setColor('#00AAFF')
bot.channels.get('694001560539234364').send(embed).catch(console.log)
});
hide more of ur token
Yes
you're not passing dbl the client
?
http://${hook.hostname}:${hook.port}${hook.path}
this url
check it
if nothing, check that the port is open
Okey
When i launch my bot i have a message in my console : running webhook on 0.0.0.0:25573..
So its ok
I have look
what does it show
404
Its not an webheberg
Why it work when i make a http request
My host support can open new port
const dbl = new DBL('DBL TOKEN', { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
let destekKanal = "697077636492689508";
dbl.webhook.on('vote', vote => {
destekKanal.send(`${vote.user} top.gg üzerinden oy verdi teşekkürler!`);
});```
can you help?
Like me
The message dont send when i vote or test
And on http request online it work
It's most likely a port issue
My on_guild_post function is never called (python)
My code is this:
import dbl
import discord
from datetime import datetime
from os import getenv
from discord.ext import commands
class TopGG(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.dblpy = dbl.DBLClient(self.bot, getenv("dbl_token"), autopost=True)
async def on_guild_post(self):
time = datetime.utcnow().strftime('%H:%M:%S')
print(f'[TOP.GG] {time} - Guilds atualizados: {len(self.bot.guilds)}')
def setup(bot):
bot.add_cog(TopGG(bot))
Because autopost calls its own internal function for posting guild count
in the examples has the on_guild_post, but ok
Funny you say it because I confused it with update_stats
I don't understand why self was missing there
yeah
Should I inherit the DBLClass and modify the post function?
the on_guild_post
0.3.4
@sullen nymph i found the error
this line dispatch the on_guild_post
but in the examples has not the @commands.Cog.listener()
i guess it's the problem
sitting here with my non commands.bot client not having these issues
tbf
it would work if it was within the class which inherets bot/client
so ig that where u got that from shiv
No I just couldn't use dblpy at the time of writing that example and I haven't been using d.py for a while
F
still not working, should I wait the 30 minutes?
What does your cog look like rn?
import dbl
import discord
from datetime import datetime
from os import getenv
from discord.ext import commands
class TopGG(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.dblpy = dbl.DBLClient(self.bot, getenv("dbl_token"), autopost=True)
@commands.Cog.listener()
async def on_guild_post(self):
time = datetime.utcnow().strftime('%H:%M:%S')
print(f'[TOP.GG] {time} - Guilds atualizados: {len(self.bot.guilds)}')
def setup(bot):
bot.add_cog(TopGG(bot))
this
It should've technically sent a request when you loaded the cog
yeah
i dispatched the guild_post inside an eval and i got the print
so isn't the function
Wait and see if it works 
ok
If you can use the DBLClient attached to the cog, idk what could be causing it 
yeah, maybe in the first request the guild_post doesn't work yet
I think the problem is the dispatch
I tested with the on_dbl_vote
but i got nothing
Dispatch is defo working
Nvm
i was running with another token
lol
(i think the problem is this)
Should've given an error
It was supposed to throw an exception
hmm
Why when a people vote i don't receivded a message in my console ?
I have test with http request and it work
When i test with top.gg test button nothing on my console
Im on v11.6.3 discord js
Same problem, my on_dbl_vote never gets called
Did you initialize the webhook
no
Did you initialize the webhook
@sullen nymph how?
If you specify wenhook_port in DBLClient kwargs, the webhook will run
Refer to dblpy docs :p
A person has vote for my bot but it write the id of the person how to get his username
{clientUser}.fetchUser("id")
Ok thx
@fluid rock show code please?
@fluid rock sa a marché pr toi ?
How to get the username of the person when the person vote ?
@restive otter et toi quand quelqu'un vote tu recoi un message ?
?? ou
Donne ton url
bah jsp c'est quoi mdr
Genre l'url que ta mit dans la partie api
@fluid rock wait... A second
Where's the posted event in your dbl code?
@fluid rock do you have that event?
console.log('Server count posted');
}```
@fluid rock if you don't have this event it will not update the server count...
I removed this event
I thought it was useless
the posted event is only for logging, its not required
if you want to use the autoposter you need to add your client to dbl
get it from client
vote.user is ID of the user who was voted. So you can use client.users.cache.fetch(vote.user) for get User object
@willow spindle plz vote for test https://top.gg/bot/684773505157431347
use "Test" button
click edit button and scroll down
yes
show result
await
await/async
await client.users.fetch....
.... async vote =>
^
Discrim?
i want flav28#8314
.username + .discriminator
.tag
use then() https://nmw03.is-inside.me/PDIZiiW1.png
that wont work
unless he puts the entire embed inside the .then
just do this
(await client.users.fetch(vote.user)).tag
you await the promise first, then get the .tag property of the result
if you do without the extra (), it tries to get the tag property from the promise before it resolves
👏
I have a site, how can I do it this way
iframe
I don't understand, can you help me, buddy
so
okey
thx
np
white screen @subtle matrix
i don't think it's works with the /
so just
nvm
it works for me
i tested it
I could not
try use this then
google is not a browser
@willow spindle uu türk reis
<iframe src="https://discord-uzayli-bot.glitch.me/komutlar.html">
<p>Your browser does not support iframes.</p>
</iframe>
</body>
</html>
oh
@subtle matrix can you throw the edit part
yes
Hello. Console is telling
Webhook running at http://0.0.0.0:5000/dblwebhook
What is the variable of setting the ip??
What should i add ?
My vps ip : port 5000
change your DBL to new DBL(token, {webhookPort:port, webhookAuth:auth}, client)
you dont need 2 DBLs
1 DBL can do both
Aha
And in website should the vps' ip start with http?
Or only ip
Aha
Thaaaanks
Fixed when added ```/dblwebhook` in the website
Thanks a lot bro 
👍
get it from client
I dont see can you give me an example ?
I dont understand it
...
ok
any reason why API is suddenly returning false for voting even though I (and other members testing it) have already voted today? its been working before
my bot doesn't like to post they server count. The library is discord.py, I just need to know why it won't update
What's your code looking like
lol ngl its 3 am I just copied over the example but filled in the required bits
y'know, showing the code wouldn't hurt in this case 
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = '*****'
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)
If i remember correctly it does it every 30 minuets
with the autopost
What's the current server count?
What's your dblpy version?
Try using post_guild_count yourself and see if that does the trick 
@sullen nymph where? im completely new to the api
Eh... anywhere in your bot?
You can do self.bot.dblpy and then call bot.dblpy.post_guild_count from anywhere where you have access to your bot object
ye didnt work
Wot
IT still didn't post the server count
there is no error
I did when you said make sure its okay

کسی ایرانیه اینجا یک سوال دارم
HEy guys does anyone here has an example on how to use the c# api
the documentation is wrong i think
my bot is not yet approved maybe its that
yes, you need your token before you can use the api
is there no way to use dblapi.js with other libs that arent djs or eris
and if that is the case is there documentation on how to manually post stats because i cant find it
yes you can manually post stats with dblapi and also without it
with dblapi
without dblapi
ok
so what is recommended interval for posting
the interval on first ss would suggest 30 minutes
a good interval would be whenever a server adds your bot
30min is the default in dblapi
i personally do 24h
some people do on every guild create/delete event
does it?
yes
if u try inviting a bot it tells u guild count
or an approximation of it for large bots
well, idk if that info can be accessed programatically through the api
anyway if thats something that will be eventually available for all bots and if it will be accessible and accurate, top.gg will probably eventually switch to it
otherwise, it will keep being this way to ensure accurate guild counts and availability for small bots
also @vapid cape where is that page that describes how to manually request
still cant find it
i need to figure out what is returned
thats not always true
you can try making a request to it
lol wtf is the ratelimit on posting
i successfully did it once
but now its returning weird ass error
ok nvm might be my end
it's.....well.....that you're being rate-limited
o
How's top.gg api working with discord.py?
Read the docs, theres an example
Discord said that the verification process takes around 5 days and maybe more at the beginning with the amount of verification needed.
can someone help me?
im tryting to do this
``` console.log(User with ID ${vote.user} just voted!);
const role = bot.guilds.get(675254454139748352).roles.find('name', 'Person_Vote_BGBot');
const user = vote.user
let embed = new RichEmbed()
.setColor(#5780cd)
.setAuthor(<@${vote.user}> Upvote !)
.setTimestamp()
.addField(User <@${vote.user}> With ID ${vote.user} Just Upvote For my Bot )
.addField(He UpVote in https://top.gg/bot/672883668594720773 )
.addField(We Have <@${vote.count}> UpVotes )
.setFooter(bot.user.username.toUpperCase(), bot.user.displayAvatarURL)
bot.channels.get(694189734146211901).send(embed)
bot.channels.get(694189734146211901).user.addRole(role);
bot.fetchUser(vote.user).then(u => { u.send(Thanks For Voting To BGBot) })
});```
but idk how i can define vote.user to add a role
let guild = bot.guilds.get(guildID)
let role = guild.roles.get(roleID)
let user = bot.users.get(vote.user) || await bot.fetchUser(vote.user)
let member = guild.members.get(user) || await guild.fetchMember(user)
await member.addRole(role)
await user.send("thanks")
await bot.channels.get(channelID).send(embed)
Imagine not using v12

then the member doesnt exist in that guild
console.log(member) then
ok
Hello, someone with this error? Prism is not a constructor
One question:
The BotID is the id of the bot user?
yes
oh ok, thx for anwsering
np
It can't be more obvious
:V
@wet sequoia @restive otter @knotty garnet This is the API channel. Any off-topic conversation or #development related topics in this channel will be deleted and muted the next time as we don’t tolerate this at all here. Please consider reading this channel’s topic 👍
I'm using dblpy module and hosting the webhook at http://HOST_PUBLIC_IP:2468/BOTNAME/vote, so in https://top.gg/bot/:ID/edit wbhook URL do i put http://HOST_PUBLIC_IP:2468/BOTNAME/vote?
Yes
alright
also https://i.imgur.com/XhUtcU6.png it keeps saying module not found even though it is very much installed
nevermind just had to reboot
gotta love py
@left egret but we were talking about the api
const dbl = new DBL(yourDBLTokenHere, { webhookAuth: 'password', webhookServer: server });```
uh I don't know what do I need do define as password and server :/
I've never used webhooks and I'm completely lost
password is whatever but you dont need server unless you are using expressjs or something
If im not mistaken, the consturctor automatically posts stats every 30 mins right?
No need for
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total)```
I think so yes
Including shards too?
iirc it does sharding yes
dope
How does that work with shards tho? Will it automatically add stats acrossed shards or-?
yes
dope
it will say x shards x servers
Where do you recomend i post stats while started? I was doing it in my main file but do i really wanna post stats every time a new shard spawns? @pale fulcrum
so I dont know if I do anything correctly
but I have a main file
that has all of my functions, I call the DBL.start() which sets the webhook and shit, and also works for shards
Terano.DBL.Start(client, config.token.dbl); this is the code I use
start creates a new DBL with its token and my client

and I guess dbl does it
Lmao i was gonna ask about webhooks next... this jawn confuses me :joyL
webhooks are not my strong suit but I guess nothing is tbh
if you just use dbl's webhook, you set a webhookAuth and webhookPort then make a listener
Currently i have my new DBL(etc) and DBL.on('events") etc etc in the same file that i spawn my shards
Yeah for now i wanna make sure i do stats right
its a bit confusing now that i sharded
Actually i probally do want it to fire every time a new shard is spawned.... otherwise if a shard goes out it wont count that shard's stats
(When it restarts)
Is there anyone here with a sharded bot that does stats and vote webhooks? Definetly need some help lmao
technically, I did test sharding so I might be able to help
lmao
We have a very complex error/command/shard/event handler, so im just a bit confused on where i should put the DBL constructor.... also not sure at all how vote webhooks work :jyo:
been reading docs for the pkg but
so the way I do it, is that In the index.js, I do the normal shit (I have no idea how it does not error saying the port is already used) but the vote webhooks just send a post request to your webhook that says a user voted
Lmao so everytime you start a new shard you do this?? Thats stupid
(Also not sure how your shard managers and hanlders are setup but)
ok I dont know how it works but it does
@pale fulcrum Where do we get the webhookAuth?
you set that to whatever you want
Oh? Do we even need it?
yes
I see...
in your bot's edit page, scroll down and set the settings for the webhook
So like
const dbl = new DBL('TOKEN', { webhookPort: 69, webhookAuth: 'whateverIWant'}, client)```
ahhh i see them
So we just copy the value there and put it in webhookAuth
so it would be http://your.ip.here.forthevps:PORT/dblwebhook
for the webhook url
or whatever
Yeah...
Lmao im legit just using this to get votes
Heres what i got @pale fulcrum
dbl.webhook.on('ready', hook => {
util.success(`Top.GG webhook started at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.on('posted', () => {
util.success('Top.GG Stats Posted');
})
dbl.on('error', e => {
util.error(`Error posting Top.GG Stats: ${e}`);
})
dbl.webhook.on('vote', vote => {
client.channels.cache.get('693204858068664491').send('working')
});```
Seems to not send anything
what do you use for hosting?
no the webhook logs no matter what
Ah
you need to see if you can access from outside
How should i go about this?
You can put the address in something like chrome and see if it loads
it should load and say there is no webpage if open
thats localhost
Obviously
Gateway adress yeah>
yeah so can you access it from outside of your local network?
Yeah and i cant open the port on my local networrd
id have to test on vps
Wait so where do you have all this code? Becouse currently i have it starting up with every shard in ready seems kinda inefficient @pale fulcrum
I have it in the index.js which the main.js calls for sharding
I do not know if its supposed to work
technically, you can set the webhook to a different one and use other shit to call it for the bot but idk
I have:
-Index.js which calls main.js for sharding (i have a constructor)
and i have my dbl stuff in main.sj
its more efficient to have dbl on the sharding manager
at least the webhooks, for posting is less important, but still more efficient
My handler is super complex
so idk 😂
@vapid cape Hold up, if you start webhook thing on each shard, then the port is already used by the first shard lmao
so that dosnt work
yes
you have two options, either put the webhook listener in the manager, or make it work only on shard 0
So youre saying to toss it in here
shard(filePath, shards = 2) {
const manager = new ShardingManager(filePath, {
token: this.token
});
if (shards === 0 || isNaN(shards)) {
manager.spawn()
} else {
manager.spawn(shards)
}
}```
I'm a bit confused haha
yeah ill just use 2 constructors lol
and get the guild count from broadcastEval
so ill have
const DBL = require("dblapi.js");
const dbl = new DBL('TOKEN', client)
dbl.webhook.on('ready', hook => {
util.success(`Top.GG webhook started at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.on('posted', () => {
util.success('Top.GG Stats Posted');
})
dbl.on('error', e => {
util.error(`Error posting Top.GG Stats: ${e}`);
})
. . .
shard(filePath, shards = 2) {
const manager = new ShardingManager(filePath, {
token: this.token
});
if (shards === 0 || isNaN(shards)) {
manager.spawn()
} else {
manager.spawn(shards)
}
const dblHook = new DBL('TOKEN', { webhookPort: 5184, webhookAuth: 'AUTH'})
dblHook.webhook.on('vote', vote => {
client.channels.cache.get('693204858068664491').send('working')
});
}
I did in the 2nd one
const dblHook = new DBL('TOKEN', { webhookPort: 5184, webhookAuth: 'AUTH'})```
ah i didnt see it
but still, there is no client in the sharding manager file
so that will not work
that makes no sense tho?
We have a class that's called from this file to spawn shards
Whatever shard it is haha
We also have a client.shard.id value to know which shard its running on
so let me get this right
you have shard 0 and shard 1, then you have a copy of shard 0 in the manager file?
@vale sonnet ok, so...
you have a regular non-sharded client on your sharding manager file
when you cross 2500 guilds, that client will no longer login
so essentially you have 2 copies of your bot, one sharded, one non-sharded
No... that client is onyl one shard
do you set the client.options.shards anywhere in your code?
Nope
((Also would like to note, a diffrent team meber wrote our new cmd handler just 2-3 days ago, and i really dont know too much about how it works))
Lmao
you call main.js from your index.js right?
once main.js is loaded, it starts a client, and logs in to that client
well we have 2 main.js files
then the shard method is called, and the shard method creates fires main.js again, which in turn creates another copy of client
Well heres the thing
!pp
in the main.js file we use enmap and have client.shard.id = id and if you check that value its diffrent for each shard
So im positive it creates a new shard
and is working correctly
or else that value wouldnt change
We have one that calls the handler func
and bot manager
const {BotManager} = require('../modules/command-handler/main')
const retr0n = new BotManager('TOKENk','MOGNO-STR', 'Retr0n')
retr0n.handler(__dirname + '/commands', __dirname + '/events', ['516840368843522073', '269309639332593665', '588521648349642753'], '3.0.1')```
Anyway, idrc about that stuff, justt need dbl to work lmao
bc that all works just finw
it all works fine doesnt mean you dont have possible ghost clones of clients running somewhere wasting memory
Lol the bot takes up literally no memory
you sure about that?
how are you measuring that?
even after running a few hours?
After running for days
doesnt sound right to me
│ 7 │ ◉ retr0n-3.0-3 │ default │ N/A │ fork │ 25821 │ 2D │ 3 │ online │ 0% │ 52.7mb │ hpaulson │ disabled │```
2d, 52mb
htop says the same
THats with 2 shards
is your discord.js modified in any way?
Nope
then thats impossible
use v12
Both versions of my bot are very low... newest version runs around 55mb 2 shards
an unmodified discord.js on 2000 guilds with no commands whatsoever, just by being logged in, will consume 300-500mb ram after a few hours regardless

i have tested this multiple times and i have worked with discord.js's internal functions
i have my own library to control this behavior
im telling you, something is off
Either way we got 16gb ram, the bot uses the least of all our processes, so im good haha
dbl webhook still aint working though
Sayin port is alreqdy in use, bc of shards
then just make it if(shard.id === 0) { start the webhook listener }
So like
client.on('shardReady', (id) => {
util.success(`Shard ${id} connected`)
client.shard.id = id
if (id === 0) {
const dblHook = new DBL('TOKEN', { webhookPort: 5184, webhookAuth: 'AUTH'})
dblHook.webhook.on('vote', vote => {
client.channels.cache.get('693204858068664491').send('working')
});
}
})```
yeah so thats what I ended up doing
xD
this.on("shardReady", id => {
if (id && id == 0) Terano.DBL.Start(this, this.config.token.dbl);
this.logger.log(`[ Shard Manager ][Shard ${id}] Ready | Watching ${this.guilds.cache.size} guilds!`.green);
});```
mine is built into the client extension
same concept tho
Name same error
Error: listen EADDRINUSE: address already in use :::5184
at Server.setupListenHandle [as _listen2] (net.js:1309:16)
at listenInCluster (net.js:1357:12)
at Server.listen (net.js:1445:7)
at DBLWebhook._startWebhook (/home/root/retr0n-master/node_modules/dblapi.js/src/webhook.js:45:18)
at new DBLWebhook (/home/root/retr0n-master/node_modules/dblapi.js/src/webhook.js:27:12)
at new DBLAPI (/home/root/retr0n-master/node_modules/dblapi.js/src/index.js:69:22)
at Object.<anonymous> (/home/root/retr0n-master/modules/command-handler/main.js:14:13)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1336:8)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
code: 'EADDRINUSE',
errno: 'EADDRINUSE',
syscall: 'listen',
address: '::',
port: 5184
}```
can you console.log the shard id?
nvm
i had the webhook stuff in the other construct
aye
seems to be workiing
How do i test and see if it works when soemone votes
there is a test button
yeah nothing happened
Aslo would it make sense to only post stats on shard 0 too? or every shard?
My current output is:
✔️ Shard 0 connected
✔️ Top.GG webhook started at http://0.0.0.0:5184/dblwebhook
✔️ Top.GG Stats Posted
✔️ Shard 1 connected
✔️ Top.GG Stats Posted```
But when i click test nothin happens 
dblapi will post the guild count for each shard separately
huh?
what did you put in the url and authorization?
Where? In the construct?
in the website
top.gg sends the webhooks to the url you specify in the url field
with an authorization header specified in the authorization field
OOh
lmaooo i didnt even see that box
so should i put the url it logged (with my ip ofc)
yes
Did that, still nothin
Wait, are the event listners supposed to be within the shard event listner?
feel like there may be scoping issue here
dbl.webhook's event listener has nothing to do with the client or anything
its a simple webserver
No ik
im saying
This is my webhook code
client.on('shardReady', (id) => {
util.success(`Shard ${id} connected`)
client.shard.id = id
if (id === 0) {
const dblHook = new DBL('TOKEN', { webhookPort: 5184, webhookAuth: 'AUTHO'})
dblHook.webhook.on('ready', hook => {
util.success(`Top.GG webhook started at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dblHook.webhook.on('vote', vote => {
client.channels.cache.get('693204858068664491').send('working')
});
}
})```
does it have to do with the fact its inside the client.on('shardReady',
true
Wait couldnt i put my stats construct in the same spot @vapid cape
bc client is acessable
yes you could
Just tested again, cosole log didnt fire
there's only 3 possible reasons
- url is wrong
- authorization doesnt match
- port is blocked by firewall
I did ufw allow for port, so thats good
url and auth are totally right
At the URL should it just be white screen?
somewhere in headers
i dont use postman so idk
you can try sending a request without authorization
you will receive 403 forbidden if its working
Yeah i got 403
lemme try reqbin
with auth
does it go in the token box?
Okay i put it in custom and got 400
https://raid-shadow-legends.is-inside.me/eRFJRHQ4.png
anyone see why this wouldn't work?
Just use the package lol @cold ledge
@vale sonnet cant with the sharding manager im using dum dum
if i could have it easy i would
Lmao then make a better handler for shards 😂
this one is good lol
if you consider not ebing able to use packages good then-
anyway my issue has nothing to do with shards
if you aint gonna be helpful leave the chat
not helpful
add headers: { 'Content-Type': 'application/json' },
anywayyy @vapid cape bassed on our previous convo i take it youre fairly experience with sharding?
a bit
Nvm cant even ask here lol, just read channel topic
you can ask in #development
hey
So when i POST to the server that dblclient is hosting, it works fine. If i include all the fields and stuff it acts as normal, however the webhook test button and actual votes aren't firing at my server? why?
You might have the port issue?
no its the right port
Can someone explain why whenever I type the link to get to my bots page it says 403 forbidden
Your bot hasnt been added so you can only access the page if you are logged in to the account that added it
Oh
@restive otter Hey are you aware your bot Kepi is getting getting ratelimited 10k times in 30 minutes?
lol
if you just and only want to post stats, which would be better, using the package or just node-fetch

Is there a way to GET, how long time left there is on a users vote cooldown?
Can't seem to find it here: https://top.gg/api/docs#users
i don't think so
Hmm odd, I know that other bots do it somehow
/bots/{bot.id?}/check
That's what I'm looking for, nvm 😄
ok ok
Hello, I do not understand how the API works, I should receive the votes there? no ?
@vapid cape Go in private?
Oh, I'm questioning the same topic it seems. Inside the "authorization" field, we input any password we'd like right?
Yup
On the JDA Api the api.getVoters() method is depreciated, what should be used instead?
a database?
you can store voters in a db and fetch from there when you need to
or you could make a request to the api yourself
looking at the source code, doesnt look like there is a replacement, so you should still use it i guess
@vapid cape The problem I have is it's very inaccurate, there's no telling when a user voted etc. Even setting a 12 hour cooldown internally, it still produces names of users that haven't voted in the past 12 hours
because it uses this endpoint
thats how the top.gg api works, its not the library's fault
How can i add how many votes Cloud Music has to botinfo?
how can i authorize myself
with your bots api token
Can you explain more?
you normally make a http GET request to the url with your bot's API token as the value of the Authorization header.
its like that for every bot
@green mantle
I don't think it is. You just need to use the correct url^^
In your case OSMX, try http://top.gg/api/bots/597444503242276874/votes
i mean no
you litterally cant access it
unless you have the headers
even tho it was the wrong url to begin with
i can access that page(for my own bot) while logged in through a browser
Yeah you can access that endpoint from the browser
Is this method still working? I tried to eval client.shards.total and it failed
Hmm ok thanks
In the JDA library, how do you return the total number of votes?
The total in api.getvoters() is inaccurate
Its not inaccurate
The library you're using is basically making api requests to the official api
So, it's not the library's fault
You can still use the raw api
Wich i prefer especially if you don't want to use third party packages
can someone help me?
i have this code:
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 `)
.addField(`He UpVote in https://top.gg/bot/672883668594720773 `)
.addField(`We Have ${vote.count} UpVotes `)
let guild = bot.guilds.cache.get(675254454139748352)
let user = bot.users.cache.get(vote.user) || bot.users.fetch(vote.user)
let member = guild.members.cache.get(user) || guild.members.fetch(user)
const channel999 = member.guild.channels.cache.find(ch => ch.name === 'upvotes-logs');
channel999.send({ embed: embed }) });```
but idk why it dont work
i use discord.js v12
The guild ID must be a string not a number at:
let guild = bot.guilds.cache.get(675254454139748352)
and fetch is an async function
async vote => {
...
await bot.users.fetch(vote.user)
...
that means the token is wrong
my website was offline this morning so webhooks stopped working
and GET/bots/{bot.id?}/check endpoint still not working
do you have any plan to fix it ?
I dont think you can actually use the normal check for votes considering Koya gets easily over 1k votes a month
Guys. I am using JavaScript.
How can I not post the current ID
As it said that it’s optional
Current ID?
@restive otter token not available means you tried to get a vote event before the bot was ready
What's it doing when it tests the webhook? I think I set everything up properly but I'm not getting any data



opinion
facts