#topgg-api
1 messages · Page 117 of 1
Still
how to console.log() the persons id who voted?
i want to start collecting vote information so i can give users stuff, yada yada.
how do i go about it?
How do u get the server count to work?
@loud jewel you send data to top.gg about your server count, either use a wrapper or make your own
Can i show u the error?
Moving to development
How do ik that I get denied
For my bot
And do i need a website for it
how do i know what url i want the webhook sent to?
what are you trying to do
oh idk man
I am just trying to get my bot uploaded
rn
how long does it usually take
so i need a website for it???
no
check #support
so when it asks:
the URL you want the webhook to be sent to
how do ik what that is...
does the api have to use webhooks?
const dbl = new DBL(process.env.TOPGG, { webhookPort: 5000, webhookAuth: 'password' });```
What to write in password?
The password you choosed in your bots edit page
What do I need to create a webhook
the webhook url is the public ip of your hosting service
same for you read my message above :)
also you have to do port forwarding of the port you use
it will be like this, right @pine heart
I think you have to put /dblwebhook
at the end
but yeah rest is right
delete that picture pls
real quick
thx
it shows like the whole token from top.gg!!
you can't show this to anyone!
best is to put it in a config file
anyways
that password... u have to create it yourself
hi
so im making this topgg cog in python and i wanted to check if vote rewards works but dont wanna wait for 12 hrs so i can use on_dbl_test for this?also how do i do that
thx
through setting your webhook url on your bot page and saving it
pressing "Test" should then send a test request to your webhook
oh ok
Remember that you'll need to actually save the webhook by pressing the save button, otherwise testing it wouldn't work

what exactly shud i give in the data parameter

Why

Let's not spam emojis thanks
...?
Data parameter? the data parameter should contain the request data of the webhook iirc
which is listed here https://top.gg/api/docs#webhooks
I see u a fat discord mod
Under "Data format"
What a lovely way to talk about others. I see you're quite the mature individual

K
uh im a bit confused so how shud the final request data look like
Let data print out like in the examples and screenshot what you're getting in response
It should look like the Data Format mentioned in https://top.gg/api/docs#webhooks afaik
Just in json data
can you dm me the webhook url? I'll test it through a request client
do I need to specify a webhook and authorization? (to use the python library)
If you wish to use webhooks, then yes
if not, then not
remember that webhooks are most likely important when you get more than 1000 votes
ok
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print(data)
print(data.user)
``` is this right like that?
I suggest trying it and see
nothing happens
remember that you have to save the webhook on the bot page settings first before testing it
i am doing it without webhook or is it needed for on_vote?
iirc? 😅
if i recall correctly
ok
You can also speak german in this channel if you prefer, i'm able to help through german too
yes i do, that's why i ask
Also wie gesagt: Soweit ich weiß brauchst du den on_dbl_test fürs testen mit dem Test Knopf
moin moin
servus

Ich meine wie möchtest du denn sonst die Webhook Events bekommen?
Webhooks sind einfach sowas wie als ob du eine Webseite besuchst und die Webseite eine Anfrage bekommt
Bloß das die top.gg API bei einem Vote diese Anfrage übernimmt und dazu noch Daten zu dem Vote sendet
aber braucht man dafür nicht von irgendeiner anderen seite einen webhook?
du musst ihn nur empfangen
Ne ne, den Webhook erstellst du von deinem Bot, auf diesen Webhook wirst du dann die Anfragen erhalten wenn ein Vote kommt
Kurzgesagt was Togira gesagt hat
wo bzw wie erstelle ich den?
also http ://ip:port/dblwebhook
Du kannst auch erstmal generell mit Webhooks üben, um mit dem Konzept besser vertraut zu werden
ist public id und server id das selbe?
ip* ja
k
also wenn du mit der ip auf den server zugreifen kannst dann ja
der letzte schritt wäre dann noch port forwarding, also du musst sozusagen den port öffnen
öhh
schick mal einen screenshot dm
jo
With your API, does it autopost or do I have to manually post so often.
Autoposting in regards of stats like servercount/shardcount, yes has to be done by your end
yes through your bot page ofc
I'm dumb, thanks 😂
you should be able to simply do that with webhooks: https://top.gg/api/docs#webhooks
yo Ich werde in zukunft ein tuturoial bezüglich webhooks machen, aber mit JDA ( java ) libary.
Hab das ziemlich schnell jetzt hinbekommen mit hilfe von hier.
benutzt du java?
Während wir grad beim Thema Webhooks sind und java: Habe letztens aus langeweile ne Webhook Library gemacht für topgg webhooks https://github.com/Hopefuls/topggwebhooks4j
Java Webhook Library for Top.gg. Contribute to Hopefuls/topggwebhooks4j development by creating an account on GitHub.
sollte einfach zu verstehen sein 
nope py
Ah dann kann ich dir nicht viel weiterhelfen , sorry!
kein problem
Why does this link not work
what link?
Is it possible to get comments from API?
The reviews? Nope
What I put here: Authorization
You can use this value to verify the requests are coming from us.
Authorization is whatever you want it to be.
It needs to be the same in the webhook section and the code to work.
Hey, i have a problem with the api, I have the message in the console with this code js dbl.webhook.on('ready', hook => { console.log(`Connection à la l'API DBL réussi.`); }); but i have this code and when a member vote for my bot, there don't are the message User with ID ${vote.user} just voted! help me please: ```js
//new vote on dbl
dbl.webhook.on('vote', async vote => {
console.log(User with ID ${vote.user} just voted!);
client.commands.get('new_vote_dbl').execute(client, vote);
});
Did you fill in the url and auth on the website.
me ?
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });??
help-me please
Yes @paper grotto
Yeah
how to use webhooks
Id look at the api docs.
https://top.gg/api/docs
where do i put the api key?
in the yourDBLTokenHere
okay
'key'?
{ webhookPort: 5000, webhookAuth: 'What do I put here?' });
?
auth you set yourself
can be anything text, as long as its secure, and its the same in the webhook section and in your code.
@jaunty plank hook.hostname is the ip of our vps ?
hook.hostname will always return 0.0.0.0
https://github.com/top-gg/dblapi.js/blob/master/src/webhook.js#L40
youll want to use your proper ip in the url you put in the webhook url on the site.
0.0.0.0 pretty much indicates that you can connect to it from anywhere
such as localhost, internal ip (192.168.2.123 for example), through your servers ip or a domain like example.com for example
Hi -- The postStats method under the JS library notes that a server count argument with the description "The server count of your bot." I'd suggest updating this to note that the count is the count of that current shard (if sharding), not the server count for the whole bot. Was a bit confusing.
Where can I put server count function in js, in start event or in index? 
in start
read pins
where?
read the documentation
if you do not understand it, then you're not ready to use the api yet and should learn how to understand documentations
Wait, is that documentation?
is the documentation
If I don't understand what?
do you understand what the https://top.gg/api/docs page says?
what language are you using for coding your bot?
JS
click on javacript under Tools
I understand now, after programming directly, the number of servers will be shown on the bot page, correct?
How do I know the number of servers?
through your bots code
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log(Logged in as ${client.user.tag}!);
});
client.on('message', msg => {
if (msg.content === 'ping') {
msg.reply('pong');
}
});
client.login('token');
--
This?
read the discordjs documentation about getting the guild count
445345 is not defined
says my token is undefined
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!);
});
is whati have in my code rn
so do i have to change anything in the {hook.hostname}:${hook.port}${hook.path} part
Did you replace the yourDBLTokenHere with your DBL token?
yes
@rancid mist I recommend going to the discord.js discord server as that is purpose built for discord.js
@restive otter i did yes
oh i think it was the lack of ' ' on hte token
i didn't have my token inside the ' ' first tiem around
how exactly to i set up server count like this
Which language are you coding your bot in
python
oh then you can use the dblpy library
ight thanks
pip install dblpy
this is documentation
i think theres an example at https://top.gg/api/docs
How can I post the shard count of a bot with dblpy?
I'm currently using
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = os.getenv("TOPGGtoken") # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token,
autopost=True, webhook_path='/webhook', webhook_auth='1234567890') # Autopost will post your guild count every 30 minutes
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print(data)
But how can I also post shard count?
How do we get out dbl token
Is there a tutorial which tells you how to use the API in python?
Python section under tools
What is the reason why my bot is attached to a server with 10K users but shows 3000 in the statistics command?
"Error: 429 Too Many Requests"
have anything I can do to fix it?
this error is happening in the dbl api
You got ratelimited
what do I do to fix?
you're blocked like approximately an hour https://top.gg/api/docs#ratelimits
go through your code and see what requests causes you to get ratelimited
but it's been a few days that this is happening
you somehow did more than 60 requests per minute
It's your codes fault
don't make more than 60 requests per minute
including posting stats, getting stats etc
how would I know the exact time using some code?
Just wait for one hour, optimize your code in the meantime
you should get request data when you hit the limit that indicates when you can retry
So, yesterday I had already fixed it because I thought it was that, but until now I haven't been unlocked
You got ratelimited again
even with the tidy code?
You are most likely sending more than 60 requests in one minute with any of your code
the problem in my code was that I was sending a lot of statistics because I didn't know the limit
but now i'm sending it every 2 hours
this was the only reason to block
Not sure if this is supposed to be in this channel but I'm getting this error and can't seem to fix it
You're missing your dbl token most likely
I added the token in the .env
password?
I added a random password
hey
what is token?
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!);
});```
at the webhookauth:
The token you need to generate on top.gg and a password you can set as well
(bot edit page)
Hey, I've got a question. What would I set as the webhook URL if I want to get my bot's server count widget? I'm using Discord.js on a Node.js server.
I don’t get what you mean.
You don’t need a webhook service to use the widget provided by top.gg
Huh, but under the bot webhook section, it says:
"You will need a token to perform certain actions with the API such as posting your bot's server count and checking who has upvoted your bot."
As https://top.gg/api/widget/servers/753664580676354260.svg is currently undefined.
You can copy the widget URL and use it wherever you want even without providing your server count.
But if the server count in the widget is important for you, you need to report your server count in the first place for example using the dblapi
Ah, ok. Thanks, I found something about it in the docs.
Yeah you can implement the lib into your bot or just run a second instance with your bot as client and the imported lib.
Alright, thanks.
👍
I am having trouble posting the guild count using the dblapi, I can't find what the problem is.
Most likely what I needed help with above.
You need to implement the dblapi into your bot.
I mean, all the other APIs for other bot lists are currently working.
Ah, they may be using different methods to achieve the same goal.
in practice it was supposed to be unlocked, but so far I can't use it because of "too many requests"
discord.ext.commands.errors.ExtensionFailed: Extension 'dbl' raised an error: AttributeError: module 'dbl' has no attribute 'DBLClient'
dpy dblpy installed
giving me error
Did you name any of your folders/files dbl - totally not copy pasted from shiv
PROBABLY NOT.... MAYBE....
https://github.com/top-gg/DBL-dotnet-Library
AuthDiscordBotListApi DblApi = new AuthDiscordBotListApi(BOT_DISCORD_ID, YOUR_TOKEN);
Is the BOT_DISCORD_ID just the long number that you get when mentioning the bot and escaping it with \?
Or is it something else?
What exactly is the Nvm! I scrolled up and realized someone asked this exact same question! Thanks, all!webhookAuth parameter?
Awesome! I'm going to go off of the prior answer. Thanks for your help, Togira!

Again, you are most likely keep getting ratelimited
Anything that interacts with dbls api in your code, counts to the ratelimit
If you have for example a !checkvote Command that checks if that particular user voted, that also counts to the ratelimit
Users could spam it and ratelimit your bot
https://cdn.discordapp.com/attachments/761179160630263828/783984615261208616/unknown.png
what does this error mean i only get it when i restart the extension where the api is. (python)
Oh dear God I'm tempted to literally suppress that error
@wurmi_#4964 feel free to ignore that error
I hate this
Feel free to ignore that error as it will never occur in normal cases and doesn't (at least shouldn't) break any dblpy/top.gg functionality
This is api, not #memes-and-media 
ok thanks but the problem is it doesn't even print the data in my console do you have any ideas?
Well since you got that error, I can assume you got a request sent to you
yeah
yes
Do you have an on_dbl_test event?
Feel free to via DMs :p
ok
with const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
what do i do for password
how do i get this password
so that for example other people cannot make a request to your webhook
that's something you define yourself
so i can choose it?

through this field https://cdn.hopefuls.de/Sflf
this has to be the same as your password in your code
most likely yourserverip:port/dblwebhook
in your case maybe http://example.com:5000/dblwebhook
replacing example.com with your server's public ip address or domain
Yup
probably sounds stupid, but what would that be for heroku
No
how do i use the top.gg token and make it log the user who voted, and log it in the console? I'm on discord.js
you have to do that through webhooks
what should i put here
the url to your webhook receiver.
And what is my webhook receiver
the http server that receives the webhook post requests(or if using one of the libraries, that.)
im confused, what is that, im new to this requests thingies
im self hosting, so i'd need to put my ip there i guess
pretty much, it will be http://ip:port/path ip port and path need to be filled in with the relevant information
@wild lantern
and the path is?
if you are using a library its probably dblwebhook
HELP! i ran the server count on my test bot and i cant get it to update
how can i set the guild count to a specific amount
(main bots guild count)
just temp
through the api ofc, or what do you mean?
you can just make another request to the api
what does the api reply if it accepted my bots/stats post request?
just a 200 response
anything in the body?
the only endpoints that return something are pretty much the ones with the get method
hmm, looks like I am getting a 200, will wait for cloudflare caching to subside I guess
are there any plans/ways to test a webhook without changing it for the bot while it's live?
that's what I've been doing, is there any way to know exactly what the request will look like so I won't end up missing a newline or something and dropping votes for a bunch of people?
say no more
Section "Data Format"
that's the data (in json) a webhook request contains
thank you!

Also, if you're using Authorization, the section "Verifying the request" above it is important too
to test that out with postman, what kind of token would I use? would it be a bearer token I'd test it with?
Just a normal token, best is to just include it in the header section instead of the built-in way of postman
oh really, thank you
my bot's just been using security through obscurity since I didn't imagine it would grow to the point I'd have to worry about this or anything, so I'll definitely need to work on that soon
where do we get our dbl token
top.gg/bot/[bot id]/webhooks
.
hello, i am trying to use the webhook for votes, i am receiving the post request and the auth header, but the post data is empty i am using php
print_r($_POST) => []
Interesting
testing with this code
<?php
include("config.php");
$verification = getallheaders()["Authorization"];
if ($verification === DBL_AUTH_VALUE) {
$fp = fopen(__DIR__ . '/../votes.txt', 'a');
fwrite($fp, json_encode($_POST) . "\n");
fclose($fp);
echo "thank you dbl.";
};
?>
DBL_AUTH_VALUE is set inside the include("config.php");
this creates a votes.txt file with all $_POST data but i am getting [] when i press the Test button
any help ?
hi
@thorny agate something I ran into when I was testing my webhook was I just pressed test without pressing save before it, make sure you save after putting your webhook in
i am receiving the post request and the auth header, but the post data is empty
I had to use file_get_contents('php://input') for mine
thank you ill try this
@wise onyx it works thank you.
😄
For webhooks, does anything actually come in the body when the little "test" option is executed?
Do I need to actually execute a vote in order to get a test event?
I see the thread above with the php://input
this.dbl.webhook.on('vote', (vote) => {
console.log(`User with ID ${vote.user} just voted!`);
});
Yields nothing
addVoteListener() {
this.dbl = new DBL(TopGG.key, { webhookPort: Bot.port, webhookAuth: TopGG.auth });
this.dbl.webhook.on('ready', (hook) => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
this.dbl.webhook.on('vote', (vote) => {
console.log(`User with ID ${vote.authorization} just voted!`);
});
this.dbl.webhook.on('error', (err) => console.log(err));
}
'ready' works - just not vote
Yeah, it'll be your project url - also you have to use Heroku's preset port.
what is the preset port?
process.env.PORT
ok
nope
For some reason, this does nothing in my local environment.
i can't sorry
No worries
I mean, is the process above the same?
your local machine won't understand them
I'm using another service that portforwards a DNS name to my local terminal
I am able to establish a connection from DBL -> my local
I just don't receive anything
ngrok is the service name
idk
If anyone has a second, I would love an answer. It's probably something so dumb / miniscule.
Do I really need to initiate a vote for my bot 😬
Yeah, someone just voted on my bot and I received nothing. That's interesting. I must be doing something wrong 🙄
Nvm - figured it out.
Thanks!
I forgot that it defaults a path to dblwebhook 👍
Hello how do we put the server statistics?
The api is displaying my bot's status as streaming but it is idle.
How do I force the change?
Where can I put the Servers update, in ready event or in main file?
I just started using the API so I'm probably gonna ask something really dumb, but for some reason my bot isnt console logging that it has posted the server amount
const DBL = require("dblapi.js");
const dbl = new DBL(config.dbl, client);
client.once("ready", async message => {
setInterval(() => {
dbl.postStats(client.guilds.cache.size);
console.log("posted")
}, 1800000);
});```
doesn't the Interval execute after the time you entered or from the start?
You can use the Test button :p
For some reason it does work when I use node . on my pc but not on my vps
solved it by using the correct bot token and running it on pc
Yeah, sorry about that. I was an idiot and didn't realize the default path was /dblwebhook 👍 - I appreciate your insight!
:grin:
hn
token:
Your bot's top.gg API Token
Where would one grab this or is this just my bot token or client id?
nvm found it
Does the test event actually send isWeekend - or is that a mimicked value?
Does the DBL JS library check the client ID if you put in the client parameter? I'm asking this because I also have a test bot that runs the same code because I don't want to be posting the incorrect server count.
idk if it does but one thing you could do is if you are using javascript, in the message event do thisjs client.user.username = "<main bot id>";
then it should work
theoretically
Has anyone actually got heroku to work with the dblwebhook?
I believe it's easy to do and there's no reason why it wouldn't work
It's just that people kind of struggle with that a lot
I swear I don't understand how to do it, everything gives me an error ...
Someone could pass me a template in "repl.it" so I can do it :c
Hey hey, what exactly does not work with your webhooks?
0.0.0.0 is a universal-like ip, you wont be able to use it in your webhook setting in your bot page
0.0.0.0 means like "being able to connect to it from anywhere", like for example localhost, your servers ip or a domain like example.com
If you're hosting your bot on a vps, you should be able to use your servers ip in the webhook url
if repl.it, it should be your project url iirc
I use vps.
yup, then your vps ip
are you busy btw?
I want to show you this...
@rain heart where will i put my vps ip?
you wont need it inside your code, you should use it in your webhook url
so for example, my vps runs on the ip 98.11.211.49 (not real ofc) and i want to use the webhook.
You should then be able to use http://98.11.211.49:port/dblwebhook inside your bot page
port being the port you entered ofc
yeah I've already done it actually
can you dm me the url? I'll test if it's reachable through a request client
@rain heart can you send me a friend request?
I unfortunately do not accept friend requests
:/
const dbl = new DBL(process.env.TOPGG, { webhookPort: 5000, webhookAuth: 'password' });```
What to write in password?
Anything you want really, make sure no one else knows it so your data is secure
what exactly to write
so do i need to write this password anywhere else in top.gg bot page settings?

does the api update at a certain time or? cuz like it says on the img i have 10 upvotes but i have 20 on the site,
https://top.gg/api/docs @final bone
How to get webhook of my bot?
it should be in realtime, meaning that if someone votes and you would check the count right after, it should show the correct vote count
read the documentation i sent
Ok thx
can you tell me the bot id you're referring to Nova?
it says on the img, 10 upvotes but on site 20
ye 1s
and what vote count does the api tell you?
are you maybe storing that image instead of refeching it? (caching?)
ill check 1s
see
thats what im doing
https://top.gg/api/widget/778344753795170374.png
in a embed field
now I'm really confused https://cdn.hopefuls.de/TFeI
kk
yeah most likely caching
i suggest interacting with the api instead of getting the widget image

You can use query parameters to avoid caching
Ohhh you're right, i've been using ////////// instead 

api doesnt install in repl.it
if i search dblapi.js it doesnt bring it up
and when it tries to install automatically
it still doesnt work
any fixes?
Repl search is broken
Use shell to install npm packages
how do we do that?
Press Ctrl + Shift + S and type the npm command to install
okay ty
selamın aleyküm
aleyküm selam
this channel is only for suggestion/help/bugs
Whats the endpoint to get all the reviews of a bot. Ping me
There's currently none yet
Ahh!
Okay!
Adding this could be great so that we can show our bot reviews in bot's official website as a testimonial or something
How Can I make a vote checker also if a people vote my bot then the bot send me a message
most people save to cache or db when someone last voted so they can get it immediately but there is an endpoint to check if someone voted recently
- idk the language you use
- I am not going to spoonfeed
- you should learn how to use api/db
Help me how we do a stats with the servers https://top.gg/api/widget/746698030375239822.svg?usernamecolor=FFFFFF&topcolor=000000
I am using node.js and i want learn the but i dont wise how
well an easy way would be to make an array and add the user id to the array, and remove it after 12 hours
but you need to have the webhook on
Woo you can walk him through this
That video looks like its for discord webhooks, not top.gg webhooks
Which are not the same.
There won't likly be a video on it.
youll want to use the docs https://top.gg/api/docs#jslib
specifically, for the vote webhook, using this(youll need to fill in your relevant information)
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!`);
});
with the library installed
npm install dblapi.js
como usa esse server
whats the difference between parseInt() and parseFloat() besides the demicals cutting out on parseInt() are they both basically the same?
practically, yes.
Hello how we do to see the stats for server stats ?
that is the difference tho since integers have no decimals
d, err := json.Marshal(BotDataPost{
ServerCount: len(s.State.Guilds),
})
if err != nil {
log.Print("Error marshalling struct: " + err.Error())
continue
}
req, err := http.NewRequest("POST", "https://top.gg/api/bots/777612933643108392/stats", bytes.NewBuffer(d))
this is how I'm posting, but I get a 400 Bad Request in response. data I post: {"server_count":32}
Do I need content type as the header? docs are very vague
no, it doesn't read the buffer :)
Did you just post?
No I would like to know how to have the stats
Oh what language do you use?
Java script
thanks, that worked!
np
Thanks
@restive otter can u give some code?
use the new library for top.gg; https://npmjs.com/@top-gg/sdk
scroll down, there's an example for how to attach the webhook middleware
thank you
@hearty lintel is that official
pog you have a lib dev role
ye
btw why there is another module for autoposting 
top.gg is making an effort to separate itself from Discord only related things, the new package is just an sdk for interaction with the api. The package topgg-autoposter, is owned by me and is officially recommended™️ lmao
separate itself from Discord only things. Hmm 
for example not handling discord posting from the client
there's still the functional method but it doesnt take a djs client for example and autoposts
instead the sdk is looking to create building blocks for other packages, like the topgg-autoposter
anyways, nice work!
ty
How do I get my dbl token
For bots? Or in general if it’s for bots select your bot of choice and it should show for the in general I’m not sure
For the website so I can see voting
https://top.gg/api/docs
Then select the Lang your bot uses
It’ll tell you which install to use
you can get your token at https://top.gg/api/docs#mybots
is it possible to give your discord bot a custom emoji on its status
yes, but this ain't an api question my guy
which language?
python
@hearty lintel how do I make a test vote
via the webhook tab under your edit bot
what do I do there?
set up your code with your port and path and put your webserver info into those
do you know how web servers work?
not at all
well, do some research on that first
you have to have the other stuff that creates the http server
please learn how http servers work first i can't help you with that
then you put your server ip and /dblwebhook into the webhook url and the auth as ur authorization
wheres my server IP
how're you hosting?
well you need to open the port and put your home ip
do I get my IP?
yea
hey
I need help
I need help about the webhooks again..
can someone join my channel?
Hey can anyone link me to emojify Api
I wanted to test something ...
Hi guys, do anyone have the http(s) request template for the api please? (to post server count)
What am I going to get in here?
Am I going to enter the webhook url?
Yes
I've done everything but when someone votes, the bot doesn't write. What could be the reason?
Your webhook isn't working then
yeah
try to log something in the console when someone votes, then hit the test button on top.gg... if nothing is logged it means the webhook isn't working
How can I see when someone votes for my bot? Using python
Use webhooks
class TopGG(commands.Cog):
"""
This example uses dblpy's webhook system.
In order to run the webhook, at least webhook_port must be specified (number between 1024 and 49151).
"""
def __init__(self, bot):
self.bot = bot
self.token = '' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
@commands.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="")
@commands.Cog.listener()
async def on_dbl_test(self, data):
"""An event that is called whenever someone tests the webhook system for your bot on top.gg."""
print("Received a test upvote:", "\n", data, sep="")
def setup(bot):
bot.add_cog(TopGG(bot))```
@willow spindle Like this?
I tryed the pinned code
and i added
and send a message to console```
But when someone vote it's not giving anything (error resault or ...)
Nothing
learn how webservers work. i asked you yesterday
@restive otter use votepayload.type
Can you give more info?
Can you give me a example ? Im not good with api
if you're using express you should use the webhook middleware
last example shows how to
if you don't know what you're doing you should use the library
DBL?
const DBL = require("dblapi.js");
const dbl = new DBL(process.env.TOPGG, { webhookPort: 5000, webhookAuth: process.env.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 with ID ${vote.user} just voted!`);
client.users.cache.get(vote.user).send(
new Discord.MessageEmbed()
.setColor('#00ff00')
.setDescription(`Thank You for voting me!!!`)
.setTimestamp()
)
});```
This thing is not working!
Please help!
In `console.log()` it comes below thing when someone votes but bot is not sending messgae to the voter!
```js
{
bot: 'bot id',
user: 'voter id',
type: 'upvote',
query: '',
isWeekend: true
}```
Please Help!
can someone make a code to when someone vote for my bot it sends a message?
please
Try using vote.user.id when you are caching
ok
Why dosnt this work?
from discord.ext import commands
import dbl
class TopGG(commands.Cog):
"""
This example uses dblpy's webhook system.
In order to run the webhook, at least webhook_port must be specified (number between 1024 and 49151).
"""
def __init__(self, bot):
self.bot = bot
self.token = 'I hide this right?' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
@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="")
@commands.Cog.listener()
async def on_dbl_test(self, data):
"""An event that is called whenever someone tests the webhook system for your bot on top.gg."""
print("Received a test upvote:", "\n", data, sep="")
def setup(bot):
bot.add_cog(TopGG(bot))```
means?
still not working
yes
then i don't know why
Let me recheck your code
did you test
console.log(vote.user.id);
?
Try to find problem with console.log
ok
its vote.user is the id
@dull thicket one last time. learn webserver, you have to create a webserver, and then set it as your top.gg webhook. if you don't understand it, either learn it, or drop it.
you have to have atleast a basic understanding of how backend http servers work
How do I make a web server
no
What is it then?
read the docs https://top.gg/api/docs
Thanks
If I were to include the object for the webhook inside of my client constructor.
const dblClient = new DBL(token, { webhookPort: PORT, webhookAuth: AUTH });
```would I just pass in the client as-well?
@dusk hound https://www.npmjs.com/@top-gg/sdk i recommend usin the new package
the webhook and client are separate
Will reviews ever be added to the webhook?
Okay, thank you!
Would be nice to have that
const dbl = new DBL('my bot dbl token', { webhookPort: 5000, webhookAuth: 'My authorization' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook on`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});```
that isn't working
I'd suggest using the new package: https://www.npmjs.com/@top-gg/sdk
In order for the dbl vote system to work on your bot, you first need to open 5000 ports on your internet.
How did you know they didn't open that port
Maybe
It was suggested iirc
If I'm running my bot from my computer, what would I have to replace your.server.ip with?
with your public ip of your computer... also change your password now that everyone has seen it ;)
and don't forget to do port forwarding with that port you use
got it, also that is a picture taken right from the new topgg sdk docs 🙂

Sorry if this is the wrong chat to ask but, is there a chat where you can ask questions?
depends on the question, if you're asking for help with the site, use #support , help with coding in #development and if you need help with the api ask here.
if you need help with a specific bot go to it's support server
ok
Is it possible to send the name of the user who voted for the vote without using webhooks??
Pls profile
you can't event a user voting without webhooks, unless you want to make them run a command then check if they've voted, but it's just not really a comparable option
there is no dank memer channel in this server
from?
Dank memer server
no it's not
Hi, so i followed this on the docs, it logs the ready event but when i vote, it doesn't log
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!`); });
Is there something im missing?
is user id the same as the discord user id?
@craggy moss yes
@plucky dock make sure your port is open to the public and have correct information in the webhook settings
how does get_user_vote in dblpy work? it's only returning false
does it need a webhook?
This is the official module right?
what should we fill in authorization section
it cannot send a message on discord webhook
why?
that will not work
Coz it just sends the json data in the request
that is not a embed
you would need to set up another service like ksoft or something that gets the webhooks from top.gg and then parses them into embeds...
Better is just to have your own webserver recieve those requests and then send embeds in a channel
hmmm
😕
Can i get a music youtube api
Lavalink
Huh
Yea
Yup then lavalink...
you would need to host a separate jar file along with your bot
and use a wrapper for the lavalink api like Solaris9's erela.js
I do not know how to do that
wdym by the api? like an official youtube api or lavalink api docs?
YouTube
Pretty sure a music api from youtube does not exist... But theres youtube api for all videos...
I mean API key
Yeaaa I’m dumb
but it can't stream music pretty sure... You can just get the youtube audio links...
then you'd need to use something like ytdl to stream
lavalink does all that by itself...
Again I’m dumb af
Is this deprecated or just some mitsake?
It's deprecated, see #topgg-api message
How do i use express to get the data from vote?
app.post("/vote/dbl", (req,res)=>{
//what do i do here?
res.send(200);
})```
that looks like express am I right?
yes
that method is when a post request is sent to the website.
It's not going to send a webhook
Ahh how do i accept the vote event from dbl then?
it sends the vote to a url right? and its a post request?
const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express() // Your express app
const webhook = new Topgg.Webhook('topggauth123') // add your top.gg webhook authorization (not bot token)
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
req.vote // your vote object
}) // attach the middleware
app.listen(3000) // your port
more info here https://www.npmjs.com/package/@top-gg/sdk
yes you need it
ahh soo do i need the express app also?
yeah
you can just copy the code above
What's the body of the data like
?
for testing purposes?
since i can't test the dbl webhook on localhost?
Nevermind i got it
https://top.gg/api/docs#webhooks for future questions with webhooks
Refer to the data format if you wish to test it with a request client first
Thanks...
Just to clarify: invalid body most likely means that it doesn't match the data format in https://top.gg/api/docs#webhooks
{
"bot":773xxxx210916xxxx3,
"user":4xxxx59887323xxxx8,
"type":"upvote",
"isWeekend":true
}
Yea i fixed it...
And just another question, votes will always expire after 12 hours right?
Well, "expire" on top.gg's end besides the count, yeah
You can handle votes as one-time thing or require users to vote constantly still
yea so like if i add some reward... let it expire after 12 hours...
Pretty much
Nadeko rewards users for 24 hours so it's entirely up to you how to go about this
how to make number server
Read the topic
where

I don't understand much :( what I should do
Come back to it once you're able to understand documentations
im using python
and getting this:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: object Lock can't be used in 'await' expression
all im doing is data = await self.dbply.get_bot_upvotes()
im doing it from my beta testing bot, is that a problem?
The problem is that you are using Python 3.9
Hello. What are the webhooks used for when we edit a bot?
Votes
Ok
^
Each time a user votes for your bot, a request is made to that webhook
which you can use inside your bot to give rewards for example
K
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});
@sonic sorrel this?
essentially yes
Inside your ready event
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);```
this would be inside the ready event
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
}); ``` this entire thing is a ready event
@sonic sorrel sorry for ping. where I put the code
Inside.. your bot code
How did you get your bot submitted if you do not know where your client.on('ready') is?
oh
Or are you just a bit confused?
no no i know where it is ahahha
okok working
How can I do that? For Viewing Servers
Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien
Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien

read the topic
Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien
already banned

@left egret ^
friends, I will add the command system by voting the bot, but I am getting an error. Is there anyone who can help?
Can someone please tell me how to solve this error
I m using python and this error is occuring in get_bot_upvotes()
Show error
I typed your dbl token and got an error like this
Not related with top.gg API. Learn basic JS syntax first. || and don't use glitch||
can someone help me please?
@willow spindle To use the command can you issue the voting command







