#topgg-api
1 messages · Page 109 of 1
Yes
ok
I just changed my vps.
My webhook is not recieving anything anymore, eventhough I changed the webhook URL on dbl's page to my new IP adress.
This is my code:
require("dotenv").config();
const _dbl = require("dblapi.js");
const dbl = new _dbl(
process.env.TOKEN,
{
webhookPort: "5050",
webhookAuth: "my_password",
},
);
dbl.webhook.on("ready", hook => console.log(hook)); // this always works => { hostname: '0.0.0.0', port: '5050', path: '/dblwebhook' }
dbl.webhook.on("vote", vote => console.log(vote)); // I never recieve this.
In dbl settings:
Webhook URL: http://ip/dblwebhook
Authorization: my_password
Please ping me if you're able to help me. 🙂
Check ur firewall if port 5050 will be dropped
For the Widgets tab I input it in index.html but now my website shows as Not secure
Any idea how to fix that now?
It had a SSL Cert before I input it in index.html
Because images or other content is being fetched by a different domain
What do I put on the DNS then?
It doesn’t mean it’s „insecure“
Click on it and read the description
Do u even use a ssl connection?
Yes
Cloudflare Full
I need to input something else on the DNS since of the widgets part in index.html
But I don't know what to input since of that.
Dunno what u mean
The domain name system has nothing to do with ur html file
wait one sec
As I said:
Because images or other content is being fetched by a different domain
Means a site can be shown as note 100% secure because it fetches content from different site
The browser doesn’t check the other sites for a ssl connection it just says it’s insecure
If ur browser shows not secure in general it’s just trash
It's chrome
Just proxy the widget (image) and the issue is gone
If this is the issue.
I dunno since I can’t check it
How do I make it show the amount of servers my bot is in on the bot page?
Sorry just new with a bot getting approved on top.gg so don't know what I need to do lmao.
@soft salmon read api docs on website
I don't get it.
well
I'm a bit dumb when I'm tired
i had one code which actually worked but i lost it
and the new one is not working ;-;
ill have to spend some time testing and coding it
K.
!join
How do I make it show the amount of servers my bot is in on the bot page?
@soft salmon Save the amount of guilds in your bot application into a file or database.
Probably with a timer refreshing the value every X hour/day etc.
Fetch the file/database on your website and that’s it.
Oh lel
Well if so just do a simple curl request to the top.gg endpoint including the header (API token) and the server_count field as JSON string.
Method needs to be POST as u can see in the docs.
Just create a cronjob running the task every 6 h for example.
But you still need to get the amount of servers from somewhere.
For example from a file or database, probably a file - easier and faster.
Easy to do in each language, JS, PHP, batch, shell etc.
I've added the code in my bot, so when will it post server count on the website?
It should update as soon as u send the post request
how do i make my bots status not disapear after awhile? heres my code:
client.once('ready', () => {
console.log('Quack!');
client.user.setActivity("Your Servers!", {
type: "WATCHING",
});
Add a timer which checks the bot status and if it’s different to the one u wanna have, update it.
Oh yeah #development btw
@plucky lance how would i do that, can you dm me?
See #development
where can I find my DBLtoken?
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
what does the webhook do?
I tried using the example in the docs
but i tried voting and nothing happens
"To activate the webhook, navigate to the edit section of your bot and set the webhook URL to something that points to your bot's server. This could even be the bot's IP"
how do i do this?
What bot scopes do I need. I currently have
-bot
-identify
-connections
Enabled. Would I need any others?
can anyone help me please
The awardbot n/a
i wanna do it like
tickety 19k servers
how can i do it?
you need to have a bot on the website and go to the api section on the website
Does this work for the auto server posting? and yes im importing it
how can i put the amount of servers the bot is in on my bot's profile?
well, what language do you use
js
you can just install dblapi.js
npm install dblapi.js
then this is the basic example of what needs to be run
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
the top.gg token listed on the 4th line can be gotten from
https://top.gg/api/docs#mybots
the library will pull your guild count from the client and post it every 30 minutes
more info here
https://top.gg/api/docs#jslib
you can just install dblapi.js
npm install dblapi.jsthen this is the basic example of what needs to be run
const Discord = require("discord.js"); const client = new Discord.Client(); const DBL = require("dblapi.js"); const dbl = new DBL('Your top.gg token', client); // Optional events dbl.on('posted', () => { console.log('Server count posted!'); }) dbl.on('error', e => { console.log(`Oops! ${e}`); })the top.gg token listed on the 4th line can be gotten from
https://top.gg/api/docs#mybots
@jaunty plank i put this in my code?
Well, the parts you dont have.
Obviously don't need to get discord.js again or make another discord client.
.
i would like to ask does vote reset at 12am utc on first day of each month?
https://squiddyskies.xyz/nw3O2.png Is this the correct npm package I need for it?
One message removed from a suspended account.
my host doesn't allow npm install or that they only allow npm package manager that has a bunch of them and shows them but they don't have some that I need like the dblapi.js
Not sure why the lib isn't on npmjs.com
The library is pretty simple if you go to the github and just use the code itself
Yeah I will have to add it in package.json my host just said.
npm i github:top-gg/dblapi.js
Weird host you have there
Ah overpriced for the resources
do it in an empty directory and inspect the package.json that is created
$3 over priced for 1gb ram?
then modify your current one as necessary
The give like .2 of a cpu
But you could get a whole one for the same price with 1 gig of ram from any other provider
I don't have money on me rn.
With more bandwidth and storage
I got -£1.00 so can't afford one
I don't since pebble use a xeon that is a good xeon ngl
i want a gpu accelerated vps that isnt $100000
I need gpu acceleration too
My bots on a ryzen system 🤷♂️
More single core performance
Ah, I do rendering. Looking to move to opengl sometime in the next few months
we should probably move somewhere else
Psh mods are not looking ;)
in any case I am using NLP to analyze phonemics and context to find bad words rather than a simple replacement filter
Sounds exciting
i am also harnessing OCR to look at ascii art and attachments
but I need to figure out how to scan videos quickly
i'll probably also extend the OCR to include emotes
then modify your current one as necessary
@stiff ingot I had done this but now bot won't start up
@stiff ingot I had done this but now bot won't start up
@soft salmon i can't see how an npm package would make the bot stop working
https://squiddyskies.xyz/9n5Aw.png It is showing a red error somewhere that I can't seem to figure out
show me more of the package.json
ah you pasted a whole new block
so remove everything after the comma that is highlighted red (and the comma too)
so everything after line 34
and then in between lines 22 and 23 add a line containing ```
"dblapi.js": "github:top-gg/dblapi.js",
@soft salmon does that work?
no problem
initilize dbl after client
const Discord = require("discord.js");
const client = new Discord.Client(); // this before
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client); // this
oh yeah forgot to do const client
dumb me
https://squiddyskies.xyz/SHwFb.png any idea how to fix?
@raw pike https://top.gg/api/docs
thank you
any idea how to fix my error?
you have more than 1 const client =
Yes
you need to change the name of one of the clients to something else
they can’t have the same name
k
you shouldnt do that, you want your const client to be the actual bot client
I got those for that
you shouldnt do that, you want your const client to be the actual bot client
@jaunty plank So any fix to it then? should I change the top.gg one to bot instead of client?
there is no top.gg client, there is your bot client and the dbl initilization(called dbl), which takes in your bot client
const dbl = new DBL('Your top.gg token', client);
I meant this should I change where it says client to bot?
https://squiddyskies.xyz/5uc2v.png I changed that to lemme test

change that Discord.Bot
discord clients cannot be initlized before requiring Discord
How the hell am I supposed to fix this then?
All i want is to post my server count on the bot's page
const Discord = require("discord.js"); //this must happen before the next line
const client = new Discord.Client(); // this must happen before the last line
const DBL = require("dblapi.js"); // this must happen before the last line
const dbl = new DBL('Your top.gg token', client); // this must happen after the three above lines
This update is nonsense!
Yes
that's in order though @jaunty plank ?
not at all
k
Yeah just changed that now
he just named his client to bot, even after i said dont 🤷♂️
its in the right order for top.gg, not sure if its in the order for commando to work too 🤷♂️
do you have the presence intent @restive otter ?
@jaunty plank What should I do for this?
I'm not sure, #development might be able to help better.
https://squiddyskies.xyz/RIgsi.png And @jaunty plank
you cant declare client twice
delete the client line you added
yep
then everything else goes after const client = commando client
YES
things go in order
dbl cant be initilized until client is
because dbl depends on client
then everything else goes after const client = commando client
@jaunty plank that doesn't make sense
at all
why not
take these two lines, put it after you const client;
because they need to go after it
as i said 6 times
done
lemme try
Fucking doing the same thing
move const discord = require discord.js thing up above?
discordjs needs to be required above client and dbl initlization
can you show me all your code?
Send the index.js file here?
hastebin works better
https://hasteb.in/
k
I did things to show the server, but the console is not getting a notification. Help
kek
just regen your tokens
you didnt move dbl initliziation below where you initilize client
const client = new CommandoClient({
commandPrefix: prefix,
owner: '520377453668204545' // change this to your Discord user ID
});
thats your client line
const DBL = require("dblapi.js");
const dbl = new DBL('token', client);
goes below that
did you update your token?
it might take 30 minutes to an hour for guild count to actually show on your bots page from the first post due to the caching.
Yep! Thanks a lot Woo!
javascript v12
do you have these two events
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
yeah, just gotta give that warning just incase it takes longer. sometimes cloudflare likes to cache things for awhile @soft salmon
Yeah cloudflare like that
@jaunty plank yes available
these two aswell?
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);
available
I'm not sure then, might have to wait till someone else comes around sorry.
@jaunty plank Actually my problem is that there is no notification like in ChoiceSquiddy.
Do you want me to post source code?
the notification just happens in your bots post event in console;
dbl.on('posted', () => {
console.log('Server count posted!');
})
if its not notifying, or giving an error, I have zero clue how to debug it.
I am writing the necessary things, it does not give an error but it does not give a notification.
looks like your fetching a message that was deleted
probably a better question for #development
this is more for top.gg api questions not discord api
oh okay
I get this error when trying to fetch server count
const dbl = new DBL('my topgg token', client);
dbl.on('posted', () => {
console.log('Server count posted!');
})```
that is my code
can someone help me?
const DBL = require("dblapi.js");
const dbl = new DBL(settings.topggtoken, client);
dbl.on('posted', () => {
console.log('[TOP.GG] Server count posted!');
});
dbl.on('error', e => {
console.log(`[TOP.GG] Oops! ${e}`);
});
@restive otter This is my code, and it works for me, maybe try and refresh your topgg token and try that
@jaunty plank try adding this piece to debug it
dbl.on('error', e => {
console.log(`[TOP.GG] Oops! ${e}`);
});
im sorry, I read the messages wrong...
I thought you only had the posted event and were trying to debug it
I need sleep... or coffee
ah i figured it out
the token cut off one letter on the my bots page
so i went to the webhooks page
and got it from there
Is it possible to give reward to user if user votes my server (instead of my bot)?
how to get port path and ip and stuff on glitch?
how can i track server votes
brug
I've added api in my bot and it's still not posting server count
Do i have to do something else also?
Ping me when answered
seem on_dbl_test is not working for me (any python user can help me pls)
I've added api in my bot and it's still not posting server count
@cursive steppe have you got the intent on for server members ?
I don't know what's next
i cannot server count 2
i added the bot to my server but it doesnt show in my profile?
i must have missed something. dblapi.js is no longer maintained is there going to be another way to get bot/user data? pls @me
@grave sundial Someone might take over but for now I'd suggest sending requests manually
ah
how to do this on my own bot? (the server count) if it has anything to do with api explain please cuz i have no idea how it works 😂
Pretty simple, follow the librarys instructions listed on the api page
If your using go yeah
the github link doesnt work tho
Not sure if the url changed or what
Simply use curl (POST method) to post a JSON string {"server_count": value} to the API https://top.gg/api/bots/<bot.id?>/stats as u can see in the docs: https://top.gg/api/docs#bots
And don't forget to add the header --H "Authorization: token"
Can be done in any coding language
A cronjob every X minutes, hours (whatever) ... done
can it be done in scratch 
Puta q oferton
how to get vote updates without using webhooks?
Just send a curl request to the DBL API endpoint https://top.gg/api/bots/<bot.id?>
It will return a bot object
As mentioned above (https://top.gg/api/docs#bots)
Including points (montly votes)
how to do in discordjs?
@sturdy moss not very nice
How would I check if a user (fetched from a specific ID) shares a server with my bot without using the user cache?
I'm under the impression it's impossible but it would be helpful if I could
(discord.js, no intents, ping me when responding)
I need help setting up webhook vote updates on top.gg while hosting on heroku. Can someone help me? (please ping)
I really need to start writing down the rules for the diffrent hosts like heroku and glitch and repl.
Pretty sure for heroku its the same as the example but you use the PORT environment variable and the heroku project url.
Flood
@cursive steppe try client.guilds.cache.size. For me this is working
why doesnt the servers update? my bot is in more than 160 servers rn, I have members intent, my code is in python
does anyone knows how the api works for .Net?
@jagged escarp you know how it works right?
@radiant peak how do I get my bot in more servers
how do I get my bot in more servers
@restive otter people like it and they add it
also #development for bot development stuff
Is there a express-handler for top.gg webhooks? (ping me if there is)
Like the Laffey NPM-Package for another botlist its a express-handler for another botlist's webhooks.
You don’t need a handler?
You kinda do if you want to also have a website in the same port
I mean can’t you just make a route on the site?
ok then
no idea tbh
No there isn't, make your own route
Just console log req.body and you have the variable names
How do I appear there the servers that the Bot i
A very simple solution is: #topgg-api message
@zenith elm - Resend invite! I cleaned out my list. You were a casualty:(
yes?
not work on vote
what did you put as your DBL webhook url
and is your webhook auth the same as in the code
where are you hosting?
so you have a public ip?
yes
?
ok
sorry i was afk
do you have any idea why it doesn't work?
is the URL correct?
Port 5000 opened for incoming TCP connections?
Depends on the OS and which firewall it/you uses
I don't have a firewall
Which OS does the VM has?
Login via SSH and check if for example IPtables is active by default
sudo iptables --list-rules
Hmm incoming connections are accepted
Even if that’s a huge security risk... not gonna discuss about that
So why the votes are not received by my vps
Did you try the test button?
back... got some disaster going aroung

someone else was complaining yesterday already, probably the webhook test doesn't work atm, idk
It's my host who blocks a lot of things we did tests while it worked and they told me to whitelist top.gg
so my code and authorizations are good
the webhook test works
just check if you can access the webhook URL in your browser, not receiving an error
Yes
Save in a database if they have voted or not, then proof by executing the cmd if their database entry is true or false....?
so i want to make a bot voting system, and i wonder what the API needs to update or vote for the System.
"For the System"?
for the Top GG API.
i got when the user already voted it literally says that but now i stuck at the actually vote system
Like vote for the bot when they use that command?
yes
I don't think that's possible
wait was it possible to make a System to vote for a server? but not for the bot?
or i am just really stupid rn?
It's not possible
for server and bots?
This could be abused if it was possible but it isn't
Making accounts to easily everytime and you could maybe have 300 users voting every 12 hours which it why it isn't possible
but is it like possible when the user votes on the bord to somehow get it?
Possible thing, maybe top.gg can just put an endpoint that let's you do a post requestes to actually vote
because i did it on a other Server and the same time i voted i got Server Coins on the Server
DBL api can be used to receive votes
but not actually vote?
Nope
Np
How to authentication
what
@cold creek put your dbl token on header
How to webhook_path
@restive otter ok
@restive otter didn't understand in which header
is there any way of testing the vote integration?
@balmy abyss in your bot edit page, go to the "webhooks" tab and click "test"
Thanks
hi
as my bot has just been verified,
i try to use the dbl api
but when i lunch my program, it told me that "on" is not defined
can someone help ?
@ember swan show your code
Actualy i cant, i’ll told you next to 6pm (sorry for my english im french😅)
but when i lunch my program, it told me that "on" is not defined
@ember swan it usually means you're trying to call an event listener that isn't an event listener in javascript
if you could send me the snippet I could help you debug it
Ok i’ll do next to 6pm
allright
@ember swan tu peux tester ton code en allant sur ta page de bot > "Edit" > l'onglet "Webhooks" > "Test"
Ok merci ^^
Comme ça tu n'as pas besoin d'attendre 12h pour tester ton code.
Ah d'accord j'avais pas compris 😅
x)
DBL -POST request-> Your server
oh thanks for the info @jaunty plank
You use the public ip, and portforward the ip on your router
how can i set up an api.
The webhook is passed for free anyway. Its just an http request.
Which part? The portforward? Or getting the public ip
Type into Google "what's my ip"
Google will tell you
Discord webhooks are not compatible with top.gg webhooks
portforwarding depends on your specific router, that site has guides for all the major routers
@uneven aspen https://top.gg/api/docs
this has all the information on the top.gg api
@jaunty plank Thanks
--> Question. How can i make the bot upvotes to be send in a specific channel?
get the webhook and then send them to that channel
get the webhook and then send them to that channel
@jaunty plank how to do that
Can you tell me steps
webhooks are only available once you have an api token, which you only get when you have an approved bot
once you have an approved bot
Ok
is the thing where some bots show how many servers theyre in to do with the api?
i.e do i have to do something with the api to make this happen
or is it all on the website
ahh no forget it i found the solution
const dbl = new DBL('tkt j'ai mis mon token', client);
dbl.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!`);
});``` @golden adder
voila le code
once you have an approved bot
@jaunty plank how do I do that?
how to submit it? or how to approve it?
Both
I’ve already submitted my bot
it will be reviewed in 8+ weeks
Mmmk
once reviewed it will be approved or denied depending on #rules-and-info and #502193464054644737
@ember swan dac... et quelle était l'erreur déjà ?
I want to test if my vote works, but I can only test it once every 12 hours, is there a way to send sort of a test so I can develop it much faster?
On your bots edit page, in the webhook section there is a test button
but when i lunch my program, it told me that "on" is not defined
@golden adder
Quand je lance le bot ça me dit que ‘on’ est undefined
and it will send a fake vote @jaunty plank ?
Yep
alright, thanks!
another question, why won't this work? https://hasteb.in/zixokepu.py
https://dblpy.readthedocs.io/en/latest/api.html#dbl.DBLClient.get_user_info can someon give me an exampe of how to use get_user_vote for dblpy
...
#commands #265156322012561408 for commands
another question, why won't this work? https://hasteb.in/zixokepu.py
@ripe ether
Did I do that right?
I’m confused and the documents section is too big for my iPhone screen
no, its the url to your webhook receiver. Also, it wont work until your bots approved
Oh ok also how do I get the receiver?
If I need a pc then I’ll ask when it’s my birthday
@jaunty plank this is my code
the basic format
http://ip:port/path
ip is the public ip of the receiver, port and path are defined in the receiver.
the code for all this can be found on the api docs.
https://top.gg/api/docs
@fair sparrow
@oblique axle did you fill in the url and auth on your bots edit page?
i left URL empty. I don't know what to put in there.
the url to the webhook receiver
the basic format
http://ip:port/path
ip is the public ip of the receiver, port and path are defined in the receiver.
wait. Where do i put that?
your bots edit page, in the webhook section
and then i have to press the test button again or i have anything else to do?
fill in the auth with the auth you blocked out in the screenshot
yeah i have filled that
if you have any firewalls on your server this is running on the port needs to be allowed through that
if its on a home network it needs to be port forwarded aswell
#development is a better channel for development questions
bro i barely understand what ur saying xd
is there any way to see the number of times a user has voted? or do I have to keep track of this myself
i believe you have to track it yourself.
https://top.gg/api/docs#users
would this be correct?
def __init__(self, bot: commands.Bot):
self.bot = bot
self.token = 'token' # set this to your DBL token
self.dblpy = dbl.DBLClient(
self.bot,
self.token,
webhook_path='/dblwebhook',
webhook_auth='password',
webhook_port=5000,
autopost=True
)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
"""An event that is called whenever someone votes for the bot on top.gg."""
print("Received an upvote:", "\n", data, sep="")
async def on_guild_post(self):
print("Server count posted successfully")
I feel like you need a listener for each event
and i belive you need to add the cog
def setup(bot):
bot.add_cog(TopGG(bot))
with the on_dbl_vote, thats only for your bot right? im confused.com about this as theres a bot keyword in the data
yes.
I believe they send the bot data with it if you want a single webhook receiver for multiple bots.
ahh ok thank
and i belive you need to add the cog
@jaunty plank i have that
for each event?
doesnt seem to have that
what is webhook_path supposed to be? do we need to change it from /dblwebhook or can we just leave it
you can leave it
so all i need to change is token and password
Petition to rename webhook_path to webhook_route
so for python i can just create a dbl.DBLClient then have a bot.event called on_dbl_vote?
@willow sphinx sorry for ping but is it possible for you to merge this PR https://github.com/top-gg/dblapi.js/pull/31 so that I can pass array of numbers without having TS yelling at me
and about how long will it take for the vote to register?
so for python i can just create a dbl.DBLClient then have a bot.event called on_dbl_vote?
@smoky yew Yup. That's mainly why it requires the bot object passed in arguments in the first place
(More like I cba to make it optional but let's just say it's intended)
and about how long? i made my alt vote a few minnutes ago and no print is getting printed
Should be instant. I suggest using on_dbl_test and the Test button in the webhook settings for easier testing.
Make sure your port is forwarded (if hosting locally) and that no firewall is blocking requests to your machine
i'm not hoting locally
all i need to change is token and password from the example right?
and put the url in your bots top.gg webhook section, update the auth/password there too
if your on a home network you need to port forward.
if you have a firewall you need to also open the port there
i'm on a vps
URL is http://ip:your_port/dblwebhook
all i need to change is token and password from the example right?
yeah
public
Whatever you just said, no
oh and @sullen nymph using a random test bot to test shouldnt break anything right
As long as you have a valid bot running, yeah
hmmm its not firing it i just have
dbl = dbl.DBLClient(bot, 'token', webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
@bot.event
async def on_dbl_test(data):
print(data)
and inside the website
the webhook url is http://ip.sepereated.by.dots:5000/dblwebhook
and the Authorization being the password
anything you can spot here thats wrong?
@glossy basin what does your code look like
@smoky yew Make sure no firewall is blocking requests
ok
import discord
from discord.ext import commands
import dbl
class upvote(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
self.token = 'token' # set this to your DBL token
self.dblpy = dbl.DBLClient(
self.bot,
self.token,
webhook_path='/dblwebhook',
webhook_auth='password',
webhook_port=5000,
autopost=True
)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
"""An event that is called whenever someone votes for the bot on top.gg."""
print("Received an upvote:", "\n", data, sep="")
async def on_guild_post(self):
print("Server count posted successfully")
def setup(bot):
bot.add_cog(upvote(bot))
@sullen nymph
yup it was a problem with the firewall, what data does on_dbl_vote recieve?
Ive just gotten my bot on top.gg and idk how to make a voting reward. Ive looked at the api thing and cannot figure it out
use the webhooks
How?
what language is your bot in
webhooks are like web requests, you receive the request to get the info
ah
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!`);
});
then on your bots edit page, in the webhook section you set the webhook url and auth to your settings, with the correct IP
what makes no sense?
its 7 lines of code
None of them are 7 lines
const DBL = require('dblapi.js'); //this gets dblapi module
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' }); //this initlizes dbl to receive webhooks
dbl.webhook.on('ready', hook => { // an event of when the webhook receiver is ready
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`); // log the url
});
dbl.webhook.on('vote', vote => { // event for when a webhook is received
console.log(`User with ID ${vote.user} just voted!`); // log
});
Do I just wack that in the script somewhere?
pretty much
auth to something reasonable
port can stay the same presuming its not in use
What parts do I need to change to make it work?
well, you can technically get away with just three lines for just receiving webhooks
const DBL = require('dblapi.js'); //this gets dblapi module
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' }); //this initlizes dbl to receive webhooks
dbl.webhook.on('vote', vote => { // event for when a webhook is received
console.log(`User with ID ${vote.user} just voted!`); // log
});
this will not have a ready event, which isnt a problem presuming you dont need it
this code doesnt have a reward system, its just for receiving webhooks.
youll have to make a reward system yourself
So when the webhook is sent how will my bot give the user the vote reward? I dont want to manually do it
When the user votes they will get a crate. Basicly changing the users data
like in a database?
just make a database request to add the item to their inventory, or whatever system you have
Database?
True
I got the code in
Ill see if this works
Where it says your DBL token here do I put my dbl token there?
yes
I now have 2 errors
line 5 says Expected ')' and saw ;
missing semicolon
And in line 2 Unexpected '9'
whats on line 5 and line 9
its just a syntax error, can you give me line 1 to 10?
obviously remove any tokens from those lines first
there is only 8 lines
in your entire file?
const DBL = require('dblapi.js'); //this gets dblapi module
const dbl = new DBL(, { webhookPort: 5000, webhookAuth: 'password' }); //this initlizes dbl to receive webhooks
dbl.webhook.on('ready', hook => { // an event of when the webhook receiver is ready
console.log(Webhook running at http://${hook.hostname}:${hook.port}${hook.path}); // log the url
});
dbl.webhook.on('vote', vote => { // event for when a webhook is received
console.log(User with ID ${vote.user} just voted!); // log
});
Thats what I put in
copy pasted these lines into my IDE, no issues appeared
are you sure you didnt delete something you shouldnt have from your main code?
I did put the token in and that's what caused the errors
ah
i see
you have to make the token a string
like
const dbl = new DBL('yourtoken'
Whats a string?
it has the quotes
ah
so you cant paste your token in without the quotation marks, otherwise it causes an error, its probably a minor mistake on top.ggs side, forgetting to put the quotation marks in the example
in the example it doesnt put a string there, it puts a placeholder
ik but in the other examples it has 'yourDBLtokenhere'
It fixed the errors!
np
Now how do I make it so ppl can get the voting rewards?
what rewards are you talking about? also now this is more a development topic, #development
are you posting your guild count?
Hi
I’m new
client.on('ready', () => {
setInterval(() => {
dbl.postStats(totalGuilds);
}, 1800000);
}); is this @jaunty plank
is the totalGuilds variable accurate?
yes
if i have this:
token = '<token>'
dblpy = dbl.DBLClient(
hb,
token,
webhook_path='/dblwebhook',
webhook_auth='<password>',
webhook_port=5000,
autopost=True
)
@hb.event
async def on_dbl_vote(data):
"""An event that is called whenever someone votes for the bot on top.gg."""
print("Received an upvote:", "\n", data, sep="")
@hb.event
async def on_guild_post():
print("Server count posted successfully")
is there anything else i need to do?
or put anything here?
you need to fill in both webhook url and authorization
with what?
the route to your webhook receiver and the auth you put in webhook_auth='<password>',
the library creates a webhook receiver.
or if you want to make one with code you can
so /dblwebhook there then @jaunty plank
?
ip being the public ip
what ip
the public ip of your bot/whatever network its on
so this: https://henos-bot.henos.repl.co:8080/dblwebhook
well, your telling it to run on 5000, so youd need to change it in your code to 8080
oh
so https://henos-bot.henos.repl.co:5000/dblwebhook
in here, do i put the password i set?
you might also have to change the port in code to use the port env var repl gives you, im not exactly sure if repl requires that
yes, thats the password you set
mky
?
glitch and heroku give env vars, since ive never used any of these platforms its hard to keep track of all their little internal rules
you set the port in both your code and url to the same one?
webhook_port=5000,
in your console?
hmm
so both repl it and uptime robot are saying that?
repl makes helping for these things so much harder 🤔
i'm not sure how repl works, youll have to look at their docs
your overwriting the replit default webserver with the webhook webserver
when you vote, does it come up?
you could also try dropping the 5000 from the url all together
try just from the url from now
ay
potentially those two things are not compatible with each other.
You may need to make a webhook receiver yourself and give it two routes, one for dbl and one for uptime robot
actully, uprobot says 502 Bad Gateway
so it might be able to ping
ill see when that is resolved
it will ping in 5mins
how do i do that @jaunty plank ?
do what
potentially those two things are not compatible with each other.
You may need to make a webhook receiver yourself and give it two routes, one for dbl and one for uptime robot
i am not a python user, or a repl user. no idea how on either
?
how do i get the stats of a bot using dblpy?
This code throws a NoClassDefFoundError
.token("token")
.botId("733409243222507670")
.build();```
can someone help me with the web processes on heroku to receive an upvote; im using discordjs and im stuck
@granite ore DBLClient.get_bot_info?
method used on an instance of the DBLClient class
So initialize DBLClient, store it in a variable, use get_bot_info on it
can someone who knows the python lib help me?
what lib
hm
i had it on my computer
but i forgot the github link
wait imma find it for u
k found it
@glossy basin pm me
const DBL = require('top.gg');
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!`);
});
``` what dbltoken?
@glossy basin dblpy doesn't create a handler for the main route
Doesn't sending requests to the main URL work?
so uptimerobot cant keep it up
@glossy basin you know pinging repl instances like this is against their terms of use right, they could come down hard on discord bots like this at any time like glitch did. to quote their TOS:
10. Interfer with or disrupt the Services or create an undue burden on Replit's website or the networks or services connected to Replit's website;
This line in their TOS is basically open to interpretation by repl to mean 'you shouldnt be pinging to get around the fact it shuts down if idle'. Beware!
They don't mind pinging services
Yeah, blog.repl.it/glitch
but their TOS basically says at any time we can interpret it as NOT allowed
i'd be aware of it, and that they might change their mind if it causes them undue load
what do i puthere? i dnt understand the port path ip thing
because they dont make money out of these discord bots being hosted for free... they might
what request does the server list send for the webhook?
POST request to your webserver
Show code
I get post requests from other sources tho
app.post('/vote', (req, res) => {
console.log("vote")
res.send("voted")
)}```
Did you click test button
const express = require("express");
const app = express();
app.get("/", function (request, response) {
response.send('hi')
});
app.post('/vote', (req, res) => {
console.log("vote")
res.send("voted")
})
const listener = app.listen(process.env.PORT, () => {
console.log("Your app is listening on port " + listener.address().port);
});
``` im using glitch.com and ive got this and tried webhook test but its not showing
@glossy basin you know pinging repl instances like this is against their terms of use right, they could come down hard on discord bots like this at any time like glitch did. to quote their TOS:
10. Interfer with or disrupt the Services or create an undue burden on Replit's website or the networks or services connected to Replit's website;
This line in their TOS is basically open to interpretation by repl to mean 'you shouldnt be pinging to get around the fact it shuts down if idle'. Beware!
@gaunt steeple the ppl in their discord helped me do it

ok
its once every 30mins too
not like once a minute
@gaunt steeple can you help with my problem?
@willow sphinx I see that the PR in dblapi.js is approved, will it be merged and it'll be added in the next version soon? Or you can't do that?
@gaunt steeple ?
sorry i cant advise, as i dont use repl
ok
is there any way to have a event go of when someone votes on the bot?
@willow sphinx I see that the PR in dblapi.js is approved, will it be merged and it'll be added in the next version soon? Or you can't do that?
@formal sparrow uh I can't merge because the commit isn't signed
@willow sphinx um, idk anything about unsigned commits, do I have to do something?
Read this https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/signing-commits it seems like I should've signed when committing
You can sign commits locally using GPG or S/MIME.
Uh, I couldn't really find a good guide to do it for pushed commits, is it even possible or I'll have to make a signed commit and then make a PR?
@glossy basin why dont you use a server like vultr or something?
does dbl.on_dbl_vote(data) (in python) only work for webhooks?
Yes
Is there a way to obtain a authorization token for the API without having a bot on the website ?
What woudl you get a token for if not a bot? 
For getting user/bot data from the api 🤷♂️
Alright, thanks anyways
When testing webhooks, I am not getting an Authorization header.
How are you accessing it
I have it going to a test webhook url that is sending me the data of the request so that I can see whats up.
I mean the header
wdym.
how do you access the header
I am sending myself all of the provided headers in the request when its received by the site.
None of them are Authorization
weird
agreed
my test requests always seem to have auth
do you have the auth filled in on the site?
yes.
can you show us the headers you are getting?
User-Agent: DBL\r\nHost: auxilus.ml\r\nAccept: application/json\r\nContent-Type: application/json\r\nContent-Length: 127\r\nConnection: close
User-Agent: DBL
Host: auxilus.ml
Accept: application/json
Content-Type: application/json
Content-Length: 127
Connection: close
so that
essentially
honestly. might want to make a github issue
{
"bot": "748586188885065768",
"user": "312049173895839746",
"type": "test",
"query": "?test=data¬RandomNumber=8",
"isWeekend":false
}
``` I am getting this as data response too
soo seems to be working right in every other way
Meh ill probably make it a secret webhook url instead at this point. probs will be easier.
honestly, if its only the tests that are not sending the auth header, it might not be a problem as long as your reject all tests.
I dont know if its only tests hmm
are the tokens for posting server count actually 150 characters long or have i pasted the wrong one?
mine is 156
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjI2NDgxMTYxMzcwODc0Njc1MiIsImJvdCI6dHJ1ZSwiaWF0IjoxNDgzMDk5MjAwfQ.8tpNASxdSsfkVF7YparhyV1Ouy5ORQ3AM2jitd_Y-PI
example token
@willow sphinx I've signed the commit, would you be able to merge it now?
api
abuse
Yes venus, this is in fact the api channel, well done, you know where you are 👍
where do i learn api
null
just as you can post the bot guild count on a website, can you also post a server member count?
It seems like no @patent lintel I'm not sure how DSL bot posts it, I don't find that endpoint in docs so it's probably private or undocumented
ok
@formal sparrow DSL can easily post it because we need to invite the bot to our server
and i could also just invite a bot i made to the server
but is there any easier way?
how do I send it to the user who voted for my bot through private messages?
Nah, you can't POST member count.
@rapid kettle my bot can
Not to DSL.
You cannot post member count to dsl
@gritty jasper
Anyone have examples of how to setup my webhook on DSL
Never tried it b4
Anyone have examples of how to setup my webhook on DSL
@jovial kiln what language?
how do I send it to the user who voted for my bot through private messages?
i use discord.js
@steel acorn for dbl, you get the user by ID on vote and then just do a .send() function and dm the message to them
do you have any sample code?
so on the vote you would do ```js
dbl.webhook.on('vote', user => {
const user = client.users.fetch(user)
user.send(Here is your message bucko)
})
thank you
@jovial kiln
const user = client.users.fetch(user)
SyntaxError: Identifier 'user' has already been declared
0-0
dbl.webhook.on('vote', (user) => {
const user = client.users.fetch(user)
user.send(`Here is your message bucko`)
})
is this right?
What about it
Oh
Wait
I defined user twice in that
Change the second one to user2 or something
0-0
looks like your address is already in use by something else.
OH, wait, no, you're sharded? You probably should have that in your sharding manager process not the various clients (which then each would try to bind to port 5000 which only one process can bind to)
@versed storm yeah I figured that out when I read the error correctly lol
👍
can i use the token from dbl api in another bot?
No?
@warm tapir read the channel topic in this channel, it will explain you how to get started with the top.gg api
ok
Hello, I have a question :
It is possible to retrieve the comments on his bot, and receive them with a Webhook?
Please let me know if this is possible or not!

Lihat Ngakugak_lu! (@mabok_heulaahhh): https://twitter.com/mabok_heulaahhh?s=09
const DBL = require("dblapi.js");
const dbl = new DBL('my token', { webhookPort: 5000, webhookAuth: 'my password' }, client);
dbl.webhook.on('vote', () => {
const userx = client.users.fetch(vote.user)
userx.send(embing)
})
is not working
Did you set the webhook url in your bot's edit page in site? @steel acorn
http://your.server.ip:port/dblwebhook @steel acorn
Or if you have a domain that resolves to your server's IP, you can use the domain instead
what do i put on the ip server?

