#topgg-api
1 messages ยท Page 89 of 1
have you tried the test button
it worked?
something might be wrong with your webhook
shard_count in server posting
Ok thx
await self.dblpy.post_shard_count()``` doesn't seem to work
thx
@stuck moon
Hello. In the js library, do I have to call .postStats regularly?
Or is it automatically done?
If you provide your client to the DBL constructor, you don't need to post stats manually
Alright, thanks
was anyone having a problem with top.gg server count with python
I think i did everything but it doesn't seem to show the correct count
i have set a config var on heroku
what do I do to appear online on the site?
^
your bot needs to be in this server to appear online
if your bot is not yet approved, you need to wait for approval
if your bot is already approved, it might have been kicked. check #mod-logs for your bot's id and see why it was kicked
@viral solar @gentle pewter
ty
does anyone here have experience integrating the webhook thing with nodejs?
yes, what are you having trouble with?
okay great, so i'm trying to catch votes
i npm installed http, express and the dbl api
it was approved a while ago, but never entered this server
const http = require('http');
const express = require("express");
const app = express();
const port = 3000
const server = require('http').createServer(app);
const listener = app.listen(port, function () {
console.log("Listening on port " + listener.address().port);
});
const DBL = require("dblapi.js");
const dbl = new DBL(config.dblToken, client, { webhookServer: listener, webhookAuth: config.webhookauth });
dbl.webhook.on('vote', async vote => {
console.log(`User with ID ${vote.user} just voted!`);
let voter = await Player.findById(vote.user);
if (!voter) {
voter = new Player({ _id: id, joined: Date.now() })
}
if (!voter.inventory) {
voter.inventory = {};
}
let inventory = voter.inventory;
if (!inventory[`commoncrate`]) {
inventory[`commoncrate`] = 2;
} else {
inventory[`commoncrate`] += 2;
}
await Player.updateOne({ _id: `${vote.user}` }, { $set: { inventory: inventory } })
});```
@viral solar what is its id?
so, i'm trying to get this to work
my id?
@split prawn are you using express and http for anything else? if not, you dont need them at all, dblapi has its own internal server
oh really
@viral solar your bot's id
i didn't know that
is 573905687822860288
okay tim I removed that
@viral solar
sorry if I'm being too dumb, I never really used webhooks before
webhooks require either a webhookServer if you use an existing server, or webhookPort if you want it to create one
so go ahead and change it to webhookPort:3000
yeah, done that change
@viral solar you fix the issue, or disable the feature that made it get kicked, then you contact the mod who kicked it
ok thanks
sorry tim, so how do I get it to work?
const DBL = require("dblapi.js");
const dbl = new DBL(config.dblToken, client, { webhookPort: 3000, webhookAuth: config.webhookauth });
client.on('ready', () => {
console.log(`I'm ready! Logged in as ${client.user.tag}!`);
client.user.setActivity(`${config.prefix}help`, { type: 'PLAYING' });
prefix = config.prefix;
dbl.on('posted', () => {
console.log('[DBL] Server count posted!');
})
dbl.on('error', e => {
console.log(`[DBL] Oops! ${e}`);
})
dbl.webhook.on('ready', hook => {
console.log(`[DBL] Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
})
oh alright
the dbl.on blocks dont need to be in the ready event
dbl waits for your bots ready event iirc
the autoposter does, but the webhooks dont
but its much better to check if the client is ready inside the webhook vote logic
lol
discord.js's ready event may fire multiple times
use a .once 
which would make it keep adding new listeners
yeah using .once would be better
but that would also make it lose its activity on a reconnect lul
okay great thank you so much tim
here i just place the VM's IP right?
and open port 3000
correct?
yes
okay tysm
oh alright
perfect, ty
is that because of the v12 new caching system?
and is there some way i could change that?
I don't know, but my bot isn't in 6 servers lol
No, it's at like 89 or something
Oh waitt
Nevermind, sorry
My bad
I was on the testing token
I can't use api for some reason
What are your webhook settings in code
app.get("/", (request, response) => {
response.sendStatus(200);
});
var server = http.createServer(app);
const listener = server.listen(process.env.PORT || 8000, function() {
console.log("Your app is listening on port " + listener.address().port);
});
const webdbl = new DBL(client.config.dblToken, {
webhookAuth: 'mypassaword',
webhookServer: listener
})
webdbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});```
@willow spindle
?
@heady moat add /dblwebhook to your glitch url
๐
Hallo Does anyone know How can i make a private room for voted
Example if the member vote the bot send in the channel
{user} You have voted the bot
you can use webhooks
Discord.js
https://top.gg/api/docs#jslib scroll down
https://top.gg/api/docs#jslib scroll down
@willow spindle
Then?
??
:+1:
hey how to make a command, where yout type vote and u vote then check and it checks if u voted and gives user prize
I've installed the dblpy library on my vps with "pip3 install dblpy" but when I integrate the example server count to try, it said "raised an error: ModuleNotFoundError: No module named 'dbl'"
I don't really understand because i imported the module
try pip install dblpy
so idk
@split prawn how i set that?
hey how to make a command, where yout type vote and u vote then check and it checks if u voted and gives user prize
@fast spruce which library
can someone aproof my bot plz

Why are you listing an undone bot on a public bot list website
wrong channel for this
ok
@fast spruce which library
@willow spindle discord.py
I suggest you use dblpy's webhook
no, its from the api docs
@restive otter https://top.gg/api/docs#mybots
doesnt matter, you can get it from both of them
webhookServer:server,
webhookAuth: '--',
webhookPort: 8000
},client)```
server and port are mutually exclusive, use only one or the other
do you have an express.js server?
or an http.createServer?
show your createserver code
do you have dbl.webhook.on("ready")?
yes?
also, what does the console.log say
what is listener.address().port
in your console
ok, so delete process.env.PORT || and leave only 8000. delete webhookPort from dbl, change webhookServer to listener instead of server
and change https to http in your top.gg url
Azure
what
@oblique sluice which language?
did you install dblapi.js?
did you setup the webhook settings?
it works on glitch too
did you configure it correctly tho?
anyway configure it again
then show it
this is glitch or vps?
you're using the express server for uptime right?
anyway remove webhookPort, since webhookServer disables the port anyway
show your top.gg settings
what is lbd?
ldb is your project name right?
glitch uses a specific port defined in an evironment variable, and links it to port 80 (http), so change your port to process.env.PORT
and in top.gg remove the port
the url should be ldb.glitch.me/dblwebhook
and your server should be .listen(process.env.PORT)
authorization in top.gg is the same as webhookAuth in dblapi, right?
they have to be exactly the same
ok
so save everything
and try the test button
(you have to press save in top.gg as well, before testing)
it does
your project is named ldb or lbd?
you wrote two different things
do you get the webhook running at http://... in your console?
Yo
I ain't getting the vote event from the api
Why it is showing "0.0.0.0:0"?
its normal to show that
@oblique sluice im testing on reqbin and your url is getting 404
like it doesnt exist
I get the webhook.on('ready') event with 0.0.0.0:5000 but not the vote event
show code and show top.gg webhook settings
@oblique sluice try manually setting a path
webhookPath: "/dblwebhook"
@fiery spear do you have an existing server? are you hosting on glitch?
Glitch
@oblique sluice did you put it with or without a slash? i forgot to add the slash before
still nothing
do this instead
response.sendStatus(200)
})```
and remove all dblapi.js code
@fiery spear show your server code
http.createServer and express if you have it
all of it
basically gonna try without using dblapi.js at all
did you add the app.post code?
still getting 404
@fiery spear ok, remove webhookPort from new DBL
and show your top.gg webhook settings
@oblique sluice, for example ; if (hook.type === "test"){ //... }
if you don't mean it, sorry . idk
how to download dblapi.js for heroku
He says module not found
Can someone helpme? I want to use dblapi.js for herou but he says module not found
@oblique sluice yes
test it with reqbin
and check if your vps requires opening ports in their firewall
what error are you getting on reqbin?
that means no webserver is running on the destination
welp ig2g
hi, i'm using ipv6 for the vote webhook thing but it doesn't seem to work, does the API support sending requests to IPv6 hosts?
(the server seems to be configured properly since it works in browser)
~~code (in case there's something wrong in it) : https://hastebin.com/zuqubapoju.js ~~
I got my answer, yes it does!
Twixgamer I guess its best to check google or ask support from heroku

@sand wraith show code
Ahh alright enjoy lockdown 4.0 @sand wraith
Ooiioooo
lol
HAIIII
py?
?
What is your question?
I deleted it for a reason
Can you ask your question instead of just sending screenshot of your bot page?
Bah infaite his me but his and I've been waiting for 3hours a red box
It takes 2-3 weeks >.>
Your bot must be online during reviewing
Ok
guys how can i set this link in my bot edit https://top.gg/bot/:ID/edit
what
API opptiones in edit
asking me for URL and authorization
i got the authorization already
but idk what to tipe in URL
can you send screenshot
k sec
@heavy storm the url is where top.gg will send vote webhooks to
you want to receive vote webhooks?
its my first time to do a bot i just wanna know how many servers my bot get in like other bots
then you dont need that
ohh what i need then?
you need to post your server count using the top.gg api
i checked the link and still dont get it ๐ฆ
which language are you using
arabic/english
programming language
english
programming language
javascript, python etc.
^
you can use official javascript library
https://npmjs.com/package/dblapi.js it has autoposter
oky ty alot for help โค๏ธ
A webhook being a webserver running on a machine
not a Discord webhook
Yeah, that's what a "real" webhook is
Yup
sorry 1 more ask
do i need to edit this or leave it? ('Your top.gg token', client); its db1api.js
Enter your top.gg token and remove client if you don't need dblapi.js to automatically post your server count
Are you sure the cog is loaded properly
does it actually post count or error?
it posts some weird count says 13 servers but my bot is on 39
@sullen nymph yes i'm pretty sure
Error: postStats requires 1 argument
dbl.postStats(client.guilds.size)
Sorry for this stupid question, but what happens if someone do this dbl.postStats(9264)?
Would that be legal?
Yes
Ah
@lavish elm its possible to fake it, yes, but if found out you will be banned
nobody does that
Oh ok, happy to hear that then ๐ @vapid cape
My webhook doesn't work at all, can someone help?
well, of course not
;(
How can I setup a webhook that can be used with the api?
Does the shard count of the bot's shards gets sent to the website automatically or needs to be sent manually?
Hmm
i need help
show code
what is postStats
server count
how to use dblapi.js? im new to it so
i dont know how to get the token, i have the code
The token is in your bot's page
Go all the way to the bottom, the token is above the widget config
How do I get my bot to send a message to the console every time a user votes on my bot?
console.log("User xxx voted")
Put that inside the webhook handler
About the webhook part, give express.js a read
thank you
@mossy bay The python api straight up doesnt even work for me, I had to remake it.... Ill send you the code I wrote if you like
where is client coming from?
thats an unofficial module so it is not supported here in #topgg-api
move to #development
@spare mulch ye sure that would awesome
@sullen nymph Was the user key in the payload a int or str again?
How can I solve N/A
-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.
Is the api working ๐ค
Im getting 403's even tho i just regened the token and logged it
nvm
Regen your token
how do i
test the vote system?
do i have to wait 12 hrs every time i want to test?
where
below the "save" button
How to solve that N/A in my bot
-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.
What is stopping someone from posting a fake server count to DBL? I hope there is some sort of verification in place?
What is stopping someone from posting a fake server count to DBL? I hope there is some sort of verification in place?
@narrow coral fear
omg thanks KuuHaKu and NMW03!!
mod only
Hello I want to ask if you can send the bot to the user's DM saying: "Thanks for voting for me" in this api ...
If you are using node.js, do you already know how to use a vote event?
If you are not using node.js, idk cant help you
@obsidian tide I'm using nodejs
Ok did you already npm install the dbl npm thing?
yeah
Did you define it and set the webhook?
[DBL variable].webhook.on('vote', vote => {
[client variable].fetchUser(vote.user).send('message')
}
I think
Change [DBL variable] and [client variable] to the vars
OK thank you
me too xD
Lol
thanks
np
@obsidian tide I forgot to tell you that the version of Discord I'm using is v11
You should really upgrade to v12
Then you can implement vote.user
I think
ok i will test
@obsidian tide error in log: TypeError: client.fetchUser(...).send is not a function
Hmm
Idk
Ask how fetchuser works in #development
I havent really used it before
Or google it
@silk echo fetchuser returns a promise
so you have to do the following
client.fetchuser(etc).then(fetchedUser => {fetchedUser.send(contents)})
thanks
help, where can i find the webhook url?
@pallid field the url is the server where your bot is hosted. for example http://IP:PORT/dblwebhook if you're using a vps, or YOURPROJECT.glitch.me/dblwebhook if you're using glitch, etc...
how to get counter with bot shards on webiste like this
by posting shard count with server count
how to do it? @willow spindle
which lib
@restive otter
Take a look at https://top.gg/api/docs#intro, for further questions you can ask them in #topgg-api
As Xig said in #support ๐
Have you read https://top.gg/api/docs#intro ?
yep
So what exactly don't you understand?
i read this but i dont find answer for my question
@silk echo
@umbral atlas agora รฉ sรณ perguntar em inglรชs
hm
what does this mean
i put my webhook link in so when someone votes i get a notifcation in a channel
So I need to make a webserver and after that what do I do?
I didnt realise getting vote updates were complex
then you can accept the requests and use the data to send messages (through a discord webhook if you want, I suppose), or do stuff on your bot like giving users rewards
I made a webserver but how do i do the rest
learn js
im trying to add the discord.py server count example to my code but it gives me errors saying bot is not defined
and do i replace 'token' with my dbl token?
k thanks
JS isnt your only option, you can make a website in just about every language
Java, C#, Rust, Python, PHP, exc
webhook api is not working
correct?
arnt u suposed to make web site with html??
u know rust?
@jagged mantle i believe it would be easier to use the official library for that
there's an example specifically for webhooks in the examples section
they told me i should ask this here..
I have created a webhook and copied that url to the webhook setting for my bot on the website of top.gg, but when I press TEST I don't receive a message from the webhook in my defined channel. Does someone know why this is??
Well
Are you talking about discord's webhook?
If so, that's not the webhook that you're meant to use
@restive otter
You're supposed to create a webserver for listening to http requests, which will be triggered one top.gg sends a "user has voted" request
Oh really okay! I tought it was just a discord webhook I had to make!
No lol, the idea of using a webhook to listen to top.gg votes is to be able to handle it somehow (ex: giving credits to said user for voting)
what's endpoint??
lol
But it's a path to some part of your webserver
Le poop
The Node.js framework is used to create server based applications. The framework can easily create web servers using http.createserver,"http" and "request" modules are used to processing server related requests.
Give this a read
node.js
You'll understand how it works
Use the dblapi package
@restive otter in what context
even when i voted for bot it shows i havent voted
You are the owner?
dbl.hasVoted(message.author.id).then(voted => {
if (!voted){
}
That happens sometimes, I have the same issue
i use this
When I vote for my bot, it doesn't regisyer
you mean the ID?
right click on ur bot and copy the id
DBL hmm
sorry i cant help :c
ok
@foggy yoke - https://top.gg/api/docs#mybots
Spice up your Discord experience with our diverse range of Discord bots
@foggy yoke @marsh orchid the dbl token is only available after your bot is approved
huh then why does he need it
Probably to setup voting rewards
oh ok
@knotty garnet My bot is approved on my main that was disabled
What?
Ah
I see
If your main was disabled I think you can ask the mods to remove the bot from the site then reapply with the current account
Visit https://top.gg first
Spice up your Discord experience with our diverse range of Discord bots
i used the sample code for discord.py to display server count and it worked fine, but hasnโt updated the server count since then? even though it should automatically do so every 30 mins apparently
is there smth more i need to do?
code?
My bot just got verified today
Why and what is this api ?
I have absolutely 0 knowledge about it
Can anyone share a guide or documentation or ? Explain
I would be grateful
@green mantle ` class TopGG(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.token = 'my dbl token'
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)
async def on_guild_post(self):
print("Server count posted successfully")`
hi
wait from the python library, is there anyway to get votes?
If I want to make auto rewards giving for voting. Should I put the DBL API library thing in the shard file or the main file? I am using eris-sharder.
Hi
!H
@wet wing there is a bug in that example. You need to mark on_guild_post as cog listener. That should make the listener fire
Also don't hard code your token as an attribute in a cog class
Where i cant see a dm notification example
You listen to webhooks
Whenever you get the vote
Get the user id from the payload
Get user from that id
And DM them
.
Don't dot post
Hey guys can someone help me with posting server count?
I basically just copy pasted the stuff from the python library
but im trying to run the command below
bot.add_cog(TopGG(bot))```
and dont know what to put in for `bot` in `def setup(bot)`
i feel like im over thinking it
I replaced it with client, but that doesnt work
How did you define commands.Bot?
@tardy snow
Cause if you did bot = comma... that's right
I used this from the website
import dbl
import discord
from discord.ext import commands
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, autopost=True) # Autopost will post your guild count every 30 minutes
async def on_guild_post():
print("Server count posted successfully")
def setup(bot):
bot.add_cog(TopGG(bot))```
@daring cove
yeah i replcaed it
Cause if you did
bot = comma...that's right
So?
i dont get what you mean by bot = commands.Bot
oof
;-;
To use cogs you need to use commands
so ur saying to do
To use commands you need to define commands.Bot or commands.AutoShardedBot
commands.client?
So how are you loading the cog?
its defined in the class, why do we need to load it
So how many files do you have?
Does anyone use dbscript?
A cog is an external file that you can add to load classes
You need to have a main file
thats what i did rn
i just put the code i put above in my main file
and then i did this when im trynna run it
setup(bot=client)
okay here
Nvm it's not, my bad
This is an example of a cog in the main file
class TopGG(commands.Cog):
def __init__(self, bot):
bot = commands.Bot
self.bot = bot
self.token = 'Token'
self.dblpy = dbl.DBLClient(self.bot, self.token,
autopost=True) # Autopost will post your guild count every 30 minutes
async def on_guild_post(self):
print("Server count posted successfully")
def setup(bot):
TopGG(bot)
You don't need to do setup
but when i do this
client.add_cog(TopGG(bot))
i get this AttributeError: 'Client' object has no attribute 'add_cog'
oh wait
hm
ok
you do need setup wot
If its in a cog
you need to add cog
also
you cant use cogs
with discord.Client
yeah
it can only be used with commands.Bot
i figured that out, so i got rid of the setup, and used bot = commands.Bot
and then did bot.add_cog(TopGG(bot))
but i keep getting an attribute error bot.add_cog(TopGG(bot))
you do need setup wot
@green mantle it's not an external file
he still needs to the cog
What
still needs to add the cog sorry
use add_cog anywhere in your code (probably after you create the class)
so cog is a class
which is this stuff
class TopGG(commands.Cog):
def __init__(self, bot):
bot = commands.Bot
self.bot = bot
self.token = 'Token'
self.dblpy = dbl.DBLClient(self.bot, self.token,
autopost=True) # Autopost will post your guild count every 30 minutes```
which i have,,,
and then did
bot = commands.Bot
bot.add_cog(TopGG(bot))
im just having a hard time understanding the add cog part
Can you show your full code
@sullen nymph full code regarding this? or like my entire bot
lol
ive leaked it too much
Your main file
so send it
And yeah, make sure you don't post your token.
Eh, sure, send it
ok gimme a sec ill just push it on githhubb
ok
https://github.com/sanjana0109/PasselBot @sullen nymph
omg
wait
this stupid
shit
ok ur good
it pushed
And replace discord.Client with commands.Bot(command_prefix ="p.")
just a question, did you read the docs?
Lel
oh ye i tried toing that @daring cove
if message.content.lower() == 'p.servers'
Poor man
I suggest to use commands, not events
not*
oh
Not that
For the on_message
@client.command()
async def your_cmd(ctx):
await ctx.send("hello")
```this will send hello when you type p.your_cmd
Instead of ```py
if message.content == "p.your_cmd":
await message.channel.send("hello")
i can do that
But it's just a tip
no i was thinking of doing it anyways
I suggest you get a cog listener deco on on_guild_post
And you are using simple defs, but d.py is asyncso you should also write your functions in async.
Not everything has to be an async function
i store them in gdocs
and all i store is thhe server id, channel and mode, and blacklisted channels
okay
so back to the orginal problem
before yall started picking on my code
lol
ok
hmm ok
What you're doing is creating a separate bot object right before loading it into a different bot instance
thats what i was orginally confused about cause in the dbl api it said bot is a client obj
so i tried just giving it client
like client.add_cog(TopGG(client))
I'll need to get back to the docs soontm
But yeah, what it actually meant is that it needs to be an object with property guilds
Yeah
Switch your client to commands.Bot
and then switch back?
Remove bot = commands.Bot in the cog itself
ok done
Use client once you change it
client.add_cog(TopGG(client))```
Yup
self.dblpy = dbl.DBLClient(self.bot, self.token,
autopost=True) # Autopost will post your guild count every 30 minutes
110
im confused tho when u change it to commands.Bot, how does that interact with the discord api?
ok nvm im the big dumb
it still dont work
ill get there
eventtually
how i do it for a while on the auto poster
options.statsInterval
im confused tho when u change it to commands.Bot, how does that interact with the discord api?
@tardy snow the commands.Bot basically has more tools to simplify creating commands and other tasks
It doesn't send any different requests from discord.Client afaik
Could you update the code on GH?
want to do this have a time on discord.js can someone help me?
yeah
@young haven You can provide your d.js Client to DBL constructor and set the interval
@young haven You can provide your d.js Client to DBL constructor and set the interval
@sullen nymph I didn't understand how to do this
Refer to dblapi.js documentation for an example
yes i already consulted but i didn't find an example with posting interval dblapi.js

Wait how do I send test-votes?
Test button on bot's edit page
Oh there it is. Thanks
Is it normal for me to get this error when exiting ^Csys:1: RuntimeWarning: coroutine 'Command.__call__' was never awaited Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x106b1f748>
Oh ok
Idk, i'm using the example on the dbl.py's github to send the server count and receive votes. I seem to be sending the server count O.K., but I dont see to be able to receive votes. Is there something im not doing right? ```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, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
self.update_stats.start() # Your linter may say this is wrong, but your linter is wrong
def cog_unload(self):
self.update_stats.cancel() # Your linter may say this is wrong too, but again your linter is wrong
# 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))
@commands.Cog.listener()
async def on_dbl_vote(self, data):
logger.warning('Received an upvote')
print(data)```
I'm going through the API for DBL and I am getting some thoughts...Where does this actually post the stats on DBL? js client.on('ready', () => { setInterval(() => { dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total); }, 1800000); });
Can someone help me?? how is this N / A changed to number of servers?
https://cdn.discordapp.com/attachments/264445053596991498/719789292595183707/unknown.png
i use discord.js
-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.
I do not understand if you read from there
I'm having trouble understanding the webhook/vote updates part of the api...can someone walk me through getting the port and password for it?
actually just the port...
sooooooo
I'm having trouble understanding the webhook/vote updates part of the api...can someone walk me through getting the port for it?
do you use dblapi.js?
yes
i just don't know much about webhooks...plus it says I need a port but idk where I'd get the port from
nowhere, you choose ot
I put in 5000 like in the API docs but I'm getting this error when I start my bot with a dbl.webhook.on eventjs dbl.webhook.on('ready', hook => { ^ TypeError: Cannot read property 'on' of undefined
is your variable name dbl.webhook?
here's my code ```js
const DBL = require('dblapi.js');
const dbl = new DBL(process.env.DBL_TOKEN, { webhook: 3000, webhookAuth: notgivingmypassword });
dbl.on('error', e => {
console.log(Oops! ${e});
});
dbl.webhook.on('ready', hook => {
console.log(Webhook running at http://${hook.hostname}:${hookport}${hook.path})
})```
well i havent used dblapi for ages so cant help sry
but also when I clicked the test button on the top.gg page to test the webhook nothing happened...does that mean I set it up wrong?
idk
does anyone else know?
Does dbl have vote event without webhook?
Are you getting the same error as I am?
idk
have you tried with a webhook?
@restive otter ?
i need without webhook BRUH
I know...but have you tried it with the webhook...I'm just asking because that's how I'm doing it and I'm getting an error BRUH
I'm getting this error with this code...any ideas?
const DBL = require('dblapi.js');
const dbl = new DBL(process.env.DBL_TOKEN, { webhook: 3000, webhookAuth: `notgivingmypassword` });
dbl.on('error', e => {
console.log(`Oops! ${e}`);
});
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hookport}${hook.path}`)
})```
```js
dbl.webhook.on('ready', hook => {
^
TypeError: Cannot read property 'on' of undefined```
are you the person who made a github issue
yep...did it get a reply? I haven't checked
oh yep it did lol one sec let me try
heeey it works...thanks
ok so when I test my webhook on the bot edit page nothing happens...the url I put into the URL field is the url that discord gives me when I make a webhook right?
ping me if anyone has any ideas so I can see when I wake up
its not a discord webhook
oh?
but replace the 0s with your public ip
wait but what if I want the votes to be shown in a discord channel?
i figured that's what it did
you can take that vote event and send a message using your bot
gotcha
you can also give people rewards with it if you have something like that
i done const app = require('express')()
check the example on the website
so where does the test actually get sent to? like where am I looking to see if it's correct?
hey guys, just trying to implement a postStats from whats in the documentation, but client.guilds.size and client.shards.Id are both undefined. Guessing discordjs was updated?
i don't even know what a shard is tbh...but it was giving me an error so I took that out of the code
ok cool I'll remove shard too
what even is a shard?
When your bot gets so big you have to shard it, which basically causes it to be split and run more than once
A guild is assigned a shard
gotcha....it's the parent of a guild pretty much
Very basic but yes
then multiple guilds are assigned to a shard
like kids lol
also...when I test the webhook where am I actually looking for it to tell me if it works or not?
Your code, the vote event should fire
is it ok to put postStats on guildCreate? or is it better to have it running in an interval
to avoid any limits
Suggested to use an interval instead
ok but when you test it on the website...where am I looking for it to tell me if it's working?
thanks @sullen nymph will do
you have no clue do you?
Not exactly sure what you mean
but what am I logging? and where? I am legit reading the docs and it just says push the test button

Press test button, request comes, code handles the request
Output anything you want
Even the vote data
ok the little pop up shows but nothing else happens...
I'm guessing you guys can't help since you aren't actually helping at all
Can someone help me get my webhook working correctly?
What do you mean by "pop-up"
You need to have code in your bot that handles the webhook post
Inside that code, handle the post, and if you have code that tells you something when it posts, then you know its working
when you press the test button...the little popup at the top of your screen that says the test may take a few seconds
Yeah, a request was sent to the URL you entered. From there, your code will handle the sent request
And how you handle the request is up to you n to implement
but you guys aren't explaining it so I can understand it
The docs explain it
obviously not good enough
The returned vote data can be found in the webhooks section on https://top.gg/api/docs
Spice up your Discord experience with our diverse range of Discord bots
here is my dbl code I have in my main bot file...```js
const DBL = require('dblapi.js');
const dbl = new DBL(process.env.DBL_TOKEN, { webhookPort: 3000, webhookAuth: process.env.PASSWORD }, client);
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});
dbl.webhook.on('posted', () => {
console.log('Server count posted!');
});
dbl.on('error', e => {
console.log(Oops! ${e});
});
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!);
});``` what do I need to change
The vote event
ok what about it?
Use it to handle the votes
I'm not even doing anything with votes right now dude.
I'm on the bot edit page trying to test it
the vote event is fired for tests too iirc
then how do I do it to work with tests then
Read the webhooks section in the docs
I did and it's not giving me anything I understand...is that not obvious
It explains the difference between vote and test requests
ok I see that...do I change it from 'vote' to 'test'?
ok. now It's making sense...thank you...finally
ok I get this error when I test it...js (node:39280) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized
actually when my bot starts up
Oh you're also posting your server count twice
Anyhow, do you set an env var DBL_TOKEN
client provided to the DBL constructor and postStats
yep
ok I regenned my token and now I'm not getting that...let's trying this again now I guess
so how long do I wait until I assume the test failed lol
ok well imma go to bed...please please pleaseeee ping me with ideas and solutions if anyone has them
What should I use as the Webhook URL for the api? 
your bot's hosting information
ah like ip and port?
http://<ip>:<port><webhook_path>
ip - IP of the machine the webhook is hosted on
port - open port
webhook_path - endpoint for DBL to send requests to (default is /dblwebhook)
if hosting on services such as glitch/heroku/replit/etc replace IP:PORT with your project url
no, you dont need to create any folder
okay





