#topgg-api
1 messages · Page 107 of 1
Python has a few modules that can help you with that.
I've used flask before it's not that bad
https://blog.bearer.sh/consume-webhooks-with-python/
Idk how well this would work, but you can try this module https://github.com/top-gg/DBL-Python-Library
@restive otter

@regal fjord so now how do i import "top.gg" because the example is only of "django"
Try just googling how to setup a flask webhook or something
I can’t hold your hand, when you want to accomplish a task try doing it, I’ll be here for when you don’t know how to solve a problem on your own
he left 😎
what is the use of the dbl api?
1. POST server count
2. GET bot info, server count, upvote info
3. GET all bots
4. GET user info
5. GET widgets (large and small) including custom ones. See top.gg/api/docs for more info.
6. GET weekend status
7. Built-in webhook to help you handle top.gg upvotes
8. Automated server count posting
9. Searching for bots via the API
oh cool
why does this code not work
```py
@world.event
async def on_dbl_vote(data):
"""An event that is called whenever someone votes for the bot on top.gg."""
print(data)
i have dbl installed and imported
provided the token
yet this event is never called when i vote for the bot
world is an alias for a custom discord bot client
dragon ball legends@??@?@!@?@?@?
?
@signal pendant is your bot approved?
yes
Its my bot @rapid kettle @restive otter
im helping @fast spruce with bot dev
oh ok
I gave them api-key
wdym
wheres the bot hosted
on my laptop
i don't follow 😕
your port needs to be forwarded through your router
how would i do that and how relevant is it?
wot.
Whats ur code
👍
it'd be best doing the latter
you can still check individual votes but you might get rateliimited
code:-
async def topic(self,ctx):
vote = dbl.DBLClient.get_user_vote(self,user_id=ctx.author.id)
if vote == True:
await ctx.send (random.choice(topic))
else:
await ctx.send ("In order to use that command, you need to vote me")```
this error comes up:-
```RuntimeWarning: coroutine 'DBLClient.get_user_vote' was never awaited
ret = await coro(*args, **kwargs)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback```
and when i put await before dbl.DBLClient this error comes up:-
```Command raised an exception: AttributeError: 'Fun' object has no attribute '_ensure_bot_user'```
I'm new in this can anyone help me
when i put this in TopGG class same error comes
Hello, I have put a script so that in top.gg my bot is displayed on the servers that it is, I followed it with the letter as the documentation said but ..
I have put it in the ready event
for the python lib, should the decorator for on_dbl_vote be @commands.Cog.listener() or @commands.event()?
@fast rose the former
@night fern you need to initialize the DBLClient by calling it with proper arguments
see dblpy.rtfd.io
how can i do the vote function?
x!backup load 41ftwkmsc3
Nicu
ty timoh
how can I run dblwebhook on express router?
Mention me
Hi
@queen lotus you wanna receive webhooks with express?
what should I put in webhookPort? And also, if I'm using both webhooks and posting server count should I make two different DBLs or do I just make one with webhook and client data together? If you know what I mean
Check this for the webhook https://github.com/Giuliopime/top.gg-webhook-tutorial @still dust
you wanna receive webhooks with express?
yes but on router
what do you mean with router?
its like express() just another
ok
-bot
where can I get a sample of what the webhook is gonna send me?
you can use the test command, then log it in your bot
if not, the specifications are provided on the docs page
you can use the test command, then log it in your bot
@austere swallow yeah I already have the thing in my bot
but i'll have to do print(data) and then delete the files from my vps and then upload it again and then run the bot again.
it's kinda of a hassle
lol
k
go to the section under data format
isn't there a parameter for total upvotes the bot has?
I guess I'll just have to retrieve that from the url ig
ok
what's the url for getting upvote count?
I tried https://top.gg/api/bots/707641033210593351/upvote_count but it doesn't work
/api/bots/<id>
My code ```py
class topGGVoteHandler(commands.Cog):
"""some bot owner utils"""
def init(self, bot):
self.bot = bot
self.session = aiohttp.ClientSession()
self.dblpy = dbl.DBLClient(self.bot, "token", webhook_path="/dblwebhook", webhook_auth="auth", webhook_port=5000)
self.users_who_voted = []
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print(data)
@commands.Cog.listener()
async def on_dbl_test(self, data):
print(data)
doesn't work
I have the correct auth, token, and webhook address
and I don't get any errors
what did you put for you webhook url in your edit page
and it doesn't print it?
no
the code looks good to me
When I did it, I didn't put self.users_who_voted = []
but that's probably not why it doesn't work
haha it works now
just shut down my bot & restarted it
is there a way to get the total upvotes a bot has?
Using dblpy?
get_bot_info, returned_value["points"]
ok
Directly accessing the API, /api/bots/<bot_id>, parse the response as JSON, get the points key
Yeah
Do you know why it says unauthorized when I put https://top.gg/api/bots/707641033210593351/ in https://jsonformatter.curiousconcept.com/
so like https://top.gg/api/bots/707641033210593351/authorization:token?
Header, not query param
oh
in aiohttp.ClientSession().post it's the headers dict param
ok
... or .get, same thing in both any case
I have async with aiohttp.request("GET", URL) as response:
so do I do headers="token"
or something like headers="authorization:token"
headers={"Authorization": "efgkhweh.qweq.qw.gerg"}
oh ok
URL = "https://top.gg/api/bots/707641033210593351/"
async with aiohttp.request("GET", URL, headers={"Authorization":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjcwNzY0MTAzMzIxMDU5MzM1MSIsImJvdCI6dHJ1ZSwiaWF0IjoxNjAxODUzODcxfQ.hh9qb77x9N5vZLggvp2p7zs4joQ6NRF9whQ79_pKgpw"}) as response:
if response.status == 200:
json_data = await response.json()
text_data = await response.text()
index = random.randint(0, 100)
upvotes = json_data["points"]
print(upvotes)
```This is my code but it prints `320`
my bot has 20 upvotes
a key in the response JSON
@commands.Cog.listener()
async def on_dbl_test(self, data):
channel = self.bot.get_channel(764951115262853120)
user_id = int(data['user'])
user = await self.bot.fetch_user(user_id)
URL = "https://top.gg/api/bots/707641033210593351/"
async with aiohttp.request("GET", URL, headers={"Authorization":""}) as response:
if response.status == 200:
json_data = await response.json()
text_data = await response.text()
index = random.randint(0, 100)
upvotes = json_data["monthlyPoints"]
embed = discord.Embed(
colour=discord.Colour.dark_gold(),
title=f"Test | {user}",
description=f"{user.mention} thank you for upvoting Ξ X 0 on top.gg! We now have a total of {upvotes} upvotes!",
)
embed.set_footer(text="Note: This is a test")
await channel.send(f"{user.mention}", embed=embed)
leaking your token
blurring it out in the screenshot but not in the code where I can straight up copy it
mhm
do you know why it says aiohttp is not defined?
I have aiohttp installed but it's still saying that for some reason
did you import it

can someone show me a example of voter only command as im facing errors in my code
can someone show me a example of voter only command as im facing errors in my code
@night fern you can use the API to get a list of members that voted for your bot (if you get over 1000 upvotes per month, you'll have to use webhooks). With the list of voters, you can iterate through them and find if a specific user is in the list of voters. Or you can useon_dbl_voteand then put the users id in a database and then search the database for the user. There are a lot of ways you can do a command for voters only.
if response.status == 200:
json_data = await response.json()
text_data = await response.text()
upvotes = json_data["monthlyPoints"]
embed = discord.Embed(
colour=discord.Colour.dark_gold(),
title=f"Test | {user}",
description=f"{user.mention} thank you for upvoting Ξ X 0 on top.gg! We now have a total of {upvotes} upvotes!",
)
embed.set_footer(text="Note: This is a test")
await channel.send(f"{user.mention}", embed=embed)
````local variable 'upvotes' referenced before assignment`
should I indent the embed to be inside if response.status == 200?
yeah
path?
wait oh
so i need to use one of the libraries? i don't know how to program on any of these [python/javascript/c#/java]
Well, it's a thing of convenience, not forcing you to use one of them
you can make a webhook server if you want
alright
Good
@violet spoke can you please show one example of get_user_vote python
well, thanks, i'll try that
Why is the dblapi.js npm package marked as deprecated from 2.4.0 on?
please ping me with the answer
For it to publish my bot server count do I have to run in terminal
Or is it automatic
That’s what the API is for
Do you know how to send HTTP requests through what ever language you are using?
Why is the dblapi.js npm package marked as deprecated from 2.4.0 on?
@stone sierra they did some major changes to stuff with the API iirc
maybe that's why
Yes, but what do I have to use then?
Normally use the API without the wrapper
@sudden sable read above messages
@violet spoke can you please show one example of get_user_vote python
@night fern I don't know what language you are using so I can't really show you one
Not really.
I don't provide it in examples. Feel free to use it whenever attempting to recreate the same DBLClient instance with same arguments (e.g. webhooks)
Generally things are closed on bot shutdown
ive figured out somemore of the get_user_vote code but now its preventing the cog from being loaded and saying unclosed client session
even after i use close() thing
I assume you're using autoposter
Dear lord no
lol this is my first time doing this thing
eh I don't see the point in using .close at all
Initialize an instance of DBLClient in the cog init and use that instead
i was testing if it works there
on dbl vote wasn't printing anything/ send a dm
async def on_dbl_vote(self, ctx, data):
print("Received an upvote:")
await ctx.author.send(f"hey {ctx.author.name}, thanks for voting!")
```
There's no ctx in DBL votes
then how do I send a dm?
access the user key in data, convert it to integer, get user for that ID, send message
like this?
async def on_dbl_vote(self, data, user: int):
try:
print("Received an upvote:")
voted = int(data.keys(user))
voted_users = bot.fetch_user(voted)
await voted_users.send(f"hey {ctx.author.name}, thanks for voting!")
Can someone help me im getting a 503 Backend fetch failed error
That’s a server side error
Do you know how can i fix it? I havent gotten a error like this in the past so i have no idea whats wrong
Weird
-api
TOP.GG API ONLY!!!
ANY OFF-TOPIC CONVERSATION WILL BE DELETED AND MUTED
This channel is only for SUGGESTIONS/HELP/BUGS to do with OFFICIAL API LIBRARIES and API DOCS found at: https://top.gg/api/docs
is there a way to get votes from a server with a bot?
I've looked over the docs and there doesn't seem to be
Only with a webhook
can you send the doc page for that?
There isn’t one
basically
it sends a POST request
and Authorization header contains the auth you set
kk ty :)
Hi
Hi
Hi, where do I get DBLToken?
you get one when you have a verified bot
So basically if I want to get response when someone votes for my discord server I need a bot there registred as well, right ?
One message removed from a suspended account.
One message removed from a suspended account.
Yeah exactly, I'm new to this and I don't wanna be spoon feeded but how do I handle 'vote' event when someone votes for my server ?
you need to set up a webhook, basically an end-point hosted somewhere to accept vote data.
So everytime someone votes, top.gg posts that data to the webhook, with the Id of whoever voted, what time, etc
Thanks
How could I make a vote commands using this? Like what is the structure to use this: get_user_vote(user_id: int)
like vote for the user?
@granite ore the url is the url to your webhook server(wherever your running the code)
the auth is the auth you are receiving
@jaunty plank is the url like an actual url or like 123.456.7.8
if you have a domain you can use one
or the ip works just as well
http://ip:port/path
works
https://VxRP.themyth.repl.co can i use that
yeah repl it urls work iirc
does replit give you port 5000?
oHHHHHHH
ok
thanks
ok well it still didnt work lolo
i think repl is different from repl.it
try port 80
code not working
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='https://discord.com/api/webhooks/766856937542385695/zldM***', webhook_auth='password', webhook_port=5555 , autopost=True)
you cannot use a discord webhook
@restive otter You need an HTTP server listening for POST requests to the /dblwebhook route
-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.
Ok
The Python lib for auto server count keeps giving me this "Method has no argument" error or whatever
Show full traceback please
Ok
"resource": "/c:/Users/lpkea/moderatus/classic/cogs/owner.py",
"owner": "python",
"code": "no-method-argument",
"severity": 8,
"message": "Method has no argument",
"source": "pylint",
"startLineNumber": 33,
"startColumn": 5,
"endLineNumber": 33,
"endColumn": 5
}```
Hmmm
-help
like this?
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5555 , autopost=True)
Yeah I did
Use a webhook and send messages to Discord on votes
What's the library you use for your bot
Py
Use dblpy 
Ok
Hi. I was wondering what was the criteria for accepting bots on top.gg?
@fossil stream see #rules-and-info
I have a bot that I am very proud of which should be finished in a few weeks. Would it be alright if I submit it for review now, because it's going to take a while for it to reach the end of the queue?
Sure, 7-8 weeks is plenty of time
Awesome, thanks shivaco.
did you enter that in the webhook_path arg
yes
it's the thingy after the domain
The full URL you set no top.gg
webhook_path stays /dblwebhook
was this successful?
🤔
set webhook_path to /dblwebhook
ok
Restart the repl and try it

changed the webhook to
'http://127.0.0.1:5000/dblwebhook'
:k3llyhmm:
@sullen nymph what?
my bot just approve and now what to do here with the api thing
please tell me
pls give a best website for my vote webhook
you make the webhook yourself or with one of the libraries
no need for another website
either one, it would be better as an export in its own file imo, but thats up to your own workflow
imma create new one
imma put it in handlers/ready.js
@jaunty plank where do i get the top.gg token
what said its too long
""
nvm
i change it to ``
it still not work when i put ""
KJJIKKHWXJBJYJAS
i got so many error
i need webhook.js and vote.js
how to setup api, webhook, vote thing
my mind are blown
the docs do a decent job of explaining it
im having a brain problem
everytime i got error
it my discord application token
or api key
kk
im copying every examples in docs and paste them
cause i have no time
im about to sleep
host the webhook on port 8080 but don't specify it in the URL
webhook_path set to /TopGG?
wtf
wdym
just saying 404 doesnt really mean anything on that platform.
atleast as far as setting things up right
but it didnt print anything
exactly
w h a t
i want to make, so when user votes for my bot in top.gg the bot gives him a special role in bot support server. does beggining of a code looks alright? discord.py
async def on_dbl_vote(self, data):
data = int(data.user)
guild = Bot.get_guild(id)
topggbot = Bot.get_user(id)
role = discord.utils.get(guild.roles, name='name')
...
lmao idk that sorry
Ok oof
Wait
Is it data.user?
i want to make, so when user votes for my bot in top.gg the bot gives him a special role in bot support server. does beggining of a code looks alright? discord.py
async def on_dbl_vote(self, data): data = int(data.user) guild = Bot.get_guild(id) topggbot = Bot.get_user(id) role = discord.utils.get(guild.roles, name='name')
pls help
data["user"]
eyes


I will try this, thx
Hmm
async def on_dbl_vote(self, data):
data = int(data[“user”])
guild = Bot.get_guil(id)
topggbot = Bot.get_user(id)
role = discord.utils.get(guild.roles, name='name')
if guild == None:
return
elif guild.get_member(data) and guild.get_member(topggbot):
if role == None:
return
elif role in member.roles:
return
elif not topggbot.guild_permissions.manage_roles:
return
await data.add_roles(role)
So this must work...
guild not guil
are you sure it's Bot and not bot
or whtever
What is defined as id
My Client = Bot in my case :)
data is a dict and get_member only takes int IDs
guild not guil
@sullen nymph
I turned my pc off, it’s hard to edit the code with mobile
I'm pointing out the issues
Wait
You can edit them later
But data is int
data is a dictionary unless you're emitting the event yourself somehow
it is correct
🤔
Oh, so everything is fine, as the line does it.
Thx a lot 🙏🏻
Really helped me :)
I will edit the code tomorrow, when I use PC

hello
can someone help me with the dblpy module
I am not sure how to make something get called when someone votes for my bot
btw I do not use cogs for my bot```python
class TopGG(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.token = 'dbl_token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
@tasks.loop(minutes=30.0)
async def update_stats(self):
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))
await asyncio.sleep(1800)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
logger.info('Received an upvote')
print(data)
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))```
I am not sure exactly what to put instead of DBL token
and if I have to call these functions somewhere
like setup
is there any way to do this without cogs
p supertramp ain't nobody but me
@spice rapids im not a pro in dbl module but as of dbl token u can get it in website, click on edit option in ur bot and on left there are 4 options and one of them has dbl token generator
and itll be kinda messy if u dont use cogs for this one
u gotta remove whole def setup at last, commands.cog after class, and replace @commands.Cog.listener() with @bot.event
and if u using @tasks.loop then no need to use asyncio i guess
and much more
which idk how to setup for main file
wont give any error though 
Pointless and may cause unintended behavior
indeed
My on_dbl_vote doesn’t work ;(
We need a bit more info than that to help
Show your code, show the errors you're having, etc..
One second, I am pasting the code...
https://pastebin.com/CFHURJD (editing the code)
Sorry for being dump or smth.
I am 99% sure I am just too dump to understand python, I am like sure I have some stupid mistakes there.

OHHHHH
Wait
Guys
add cog listener decorator to on_dbl_vote
actually initialize the webhook by setting the webhook arguments
leave it so that it's set to /dblwebhook by default
Cog listener decorator isn't optional
K thx
discord.py doesn't just assume any function name of which starts with on_ is an event

P.S. the very bare minimum for the webhook to start is to set webhook_port
also
wtf
from cogs.Variables.Prefix import Bot why is this there
use self.Bot, not Bot
Oh it’s...
you are importing a class, not an instance
I define after self.Bot = Bot
you don't need that import there
also on_dbl_vote only takes data argument but since it's a cog listener (in a class), it must have self as first parameter
there's no "bot" object being passed to the function
Yeah, ok :)
aka it's on_dbl_vote(self, data)
Why?
Oh XD
If you have a VPS, you can set up a webhook
Well, it’s not vps, so there is no need to
Thx a lot :)
Sorry for wasting your time
I am being dump
it's fine
I am 

wheres the api?
so when we listen to on_dbl_vote(self, data), does it automatically detect new votes?
wheres the api?
btw I do not use cogs for my bot
hello
can someone help me with the dblpy module
I am not sure how to make something get called when someone votes for my bot
btw I do not use cogs for my bot
hi, i have an idea on creating a reward for those people who vote the server, then what command do i have to make?

You need to use a webhook
You'll get a link to the api docs
unless it’s role rewards
ok
i see
thanks
i dont understand
can you explain with the code
i dont understand
ok
The example code is in the docs
On your bot's page. Click "edit" go to "Webhooks" tab on the side @restive otter
Can anyone please explain me about Authorization process 
@restive otter API Documentation (https://top.gg/api) >> My Bots >> Click your bot profile >> You will see Generate API key or Regenerate Api
The another way is :
Webhooks (https://top.gg/bot/your_bot_id_here/webhooks) >> you will see something Like -
What is the webhookport and webhook auth?
the file it requests?
i dont understand the question, the webhook is sent to your webhook server. it doesnt look for a request.json
@jaunty plank doesn't it send this in a json file?
Not in a file, just in the body of the post request
oh ok i did some more research and i get it now
Confusing at first but the nice you figure it out it is easy
File "/app/app.py", line 126, in respond
if data['Authorization'] == 'my_auth':
KeyError: 'Authorization'``` why am i getting this?
Oh yeah
no wait
wtf are you doing
What's data?
The Authorization is in the request headers
oh ok
data = request.json
print(data)
return Response(status=200)```
and it returned `{'bot': '748670819156099073', 'user': '697628625150803989', 'type': 'test', 'query': '?test=data¬RandomNumber=8', 'isWeekend': True}` so how am i supposed to see the auth? i dont get it
It’s in the headers
you need to like have a website
that too
http://ip:5000/dblwebhook
the library is making a webserver and starting it
Hello, I want to make a command. When I vote with dbl, it will send a message to the specific channel without using the command.
I didn't do it I would be very happy if you could help from dm
http://ip:5000/dblwebhook
@uncut verge do that, ur ip address goes inip
Hello, I want to make a command. When I vote with dbl, it will send a message to the specific channel without using the command.
I didn't do it I would be very happy if you could help from dm
google translate is used
well can you help
https://top.gg/api/docs
I would start by looking at the api docs
just send the command 🙂
the docs have the code for the libraries
theres a bunch of libs, so i cant just send code
https://top.gg/api/docs#webhooks if you want do create a vote webhook
@uncut verge do that, ur ip address goes in
ip
@patent lintel I am using repl.it to work on the bot and they provide a domain,
just send the code 🙂
you can do it with your repl domain
yeah
what lib/language @restive otter
js
contains code examples
https://top.gg/api/docs#jslib
^
thank
also i dont get how to access authorization header in python
what lib are you using?
you can do it with your repl domain
@jaunty plank Like this?
yeah looks right to me
Nothing is happening when I vote thou
not sure what ports repl allows
hmm, ill check
so you might wanna look at their docs
from Flask import from flask import Flask, request, Response
#Some Code and setup stuff
@app.route('/webhook', methods=['POST'])
def respond():
data = request.json
if data["Authorization"] == "geronimostilton12":
print('I got a vote from ' + data["user"])
return Response(status=200)```
And `data["Authorization"]` doesn't return the auth.
test button on your bots page @uncut verge
"request.headers.get('your-header-name')"
it just says this
now it tested
so did it work then?
listen for votes
use the test button @restive otter
STOP FLOODING CHAT
pls stop spamming
I didn't flood chat
You dumbass
from Flask import from flask import Flask, request, Response
#Some Code and setup stuff
@app.route('/webhook', methods=['POST'])
def respond():
data = request.json
if data["Authorization"] == "geronimostilton12":
print('I got a vote from ' + data["user"])
return Response(status=200)```
And `data["Authorization"]` doesn't return the auth.
I want to use the command in the basement to see if it will work when you vote
nah, mods have to do stuff
theres way smarter people than me here
Anyone codes in Python?
yeah
this is for https://top.gg/api
If nothing happens does that mean the test failed?
I saw in the docs that test triggers the vote listener?
well, it depends on what you set it to do
if you set tests to do nothing, it will do nothing
but nothing happens
repl it right?
ye
your setting it to port 5000?
I switched port to 5001
ye
does repl it support 5001?
hmm, lemme try 3000 bc i know it supports that
also, try making your link start with http:// rather than https://
i dont know how repl handles https
k
Is there a ratelimit on the server count post?
hey, not sure if this was already found but there's an mistake/typo in the api doc example (for python):
In the first example with automatic server count, on this part
async def on_guild_post():
it needs a self inside the () since it's inside a class
R
@lone bough top.gg/api/docs yeah?
yeah
Mhm, admins are aware
Docs are planned to be reworked so that'll stay there for a while I believe. Feel free to refer to the README on Github or dblpy.rtfd.io
alright thanks :)

hello what do i see if my webhook is successfully working? im trying to test it first
means application programming interface
its how everything happens on the internet
ah

hmm, lemme try 3000 bc i know it supports that
@uncut verge 3000 always worked for me hmm
is it possible
to make the dbl ready event
inserted to another file instead of index.js?
Is making join for join possible?
Example:Member+
-api
TOP.GG API ONLY!!!
ANY OFF-TOPIC CONVERSATION WILL BE DELETED AND MUTED
This channel is only for SUGGESTIONS/HELP/BUGS to do with OFFICIAL API LIBRARIES and API DOCS found at: https://top.gg/api/docs
Sorry
where can i find my server's dbl ? and the webhookAuth pasword
-help
where do i put these command ?
Wdym @molten lantern
@willow spindle how do u start on ready event in another file
In an example, it says should use dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);, shouldn't i be using client.guilds.cache.size instead of client.guilds.size?
same goes for the shards right
I'm getting the error ReferenceError: client is not defined at const dbl = new DBL('Your top.gg token', client);
and yes, i did replace the top.gg token with my token
nvm
it was in a seperate file without the require('discord.js')'s
i am facing a issue. When i vote using my alt on my bot i see that when i try to see if the user voted api sends false as i voted it takes 5 mins before it actually sends true
Do you need a password for the webhook
What does this mean? (node:22) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized
How do I solve the error No module "dbl" found?
Py?
yes
pip install dblpy
?
Hope that's it. Otherwise no idea
I have it installed... I am getting that error on Heroku
is it possible
to make the dbl ready event
inserted to another file instead of index.js?
Yes
Anyone knows how to setup a vote webhook for .Net?
I dont think any of the official .net librarys support webhooks.
I think you'll have to make one manually.
This article elaborates on how to create a OWIN self-host console application for the WebApi that recives webhooks.
Could be a terrible guide, not a .net dev not sure
does anyone know how to add guildcount to bot like other ones have? like if you go on https://top.gg/list/top, then you can see that.. for example 'Dank Memer' has 3,602,011 servers. does anyone know how to do this?
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))
Does this only work if your bot uses cogs?
I've added it to my bot (one .py page) that doesn't use cogs, but it doesn't seem to update the server count (count still shows N/A)
How long did you wait @acoustic peak ?
The websites are cached
ok.. so i see that in the javascript library, it shows the code
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}`);
})
but why would you make a new client? do i just use the client i am already using? and which token do i use? the one that is attached to my bot?
Your using your normal client its just showing you need a discord.client.
The dbl token is the one you get here
https://top.gg/api/docs#mybots
How long did you wait @acoustic peak ?
The websites are cached
@jaunty plank I did it about 12pm, its 5pm now and still saysN/A
Is the print your doing printing from time to time? @acoustic peak
let me check
ooh! it worked thank you @jaunty plank!
Np
@jaunty plank no output either
I have
does it post over and over, or just when i restart the bot? if it only posts when i start the bot, how can i make it so it posts when the bot joins or leaves a server?
Over and over in 30 minute intervals iirc @cinder locust
awesome. thank you so much!
but my bot is just a 1 .py file bot, the api part for the server count includes cogs
but my bot isn't build with cogs
Honestly, im not a python dev.
Shiv will probably be on soon to help with this issue @acoustic peak
Alright, thank you 🙂
Node.js:
how do i make the vote event, because i dont understand the code on the website
one last thing: to get an update when someone votes, what do i use for the password? the example gives this code:
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!`);
});
up there where it shows '{ webhookPort: 5000, webhookAuth: 'password' }' what do i use for the 'password' part? do i leave it as is?
Password can be whatever you want. Dont leave it as is however
and the port?
You need to update the spot on your bots edit page where it asks for webhook url and path
Port is any available port you have
ok
3000 or 5000 are typically available
what should i put for the webhook url? i dont own any websites, do i just choose a random thing?
google.com xd
ah ok
ill try it later
@rapid kettle, Woo said you might be able to help lol
i used my VPS ip, but dbl.webhook.on('ready') still gives 'http://0.0.0.0:5000/dblwebhook'
ah ok i didnt know if it would keep that or say the path i put
0.0.0.0 is just logged to all users. Just means whatever public ip
ohhh ok ok ok cool
@rapid kettle
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))
Does this only work if your bot uses cogs?
I've added it to my bot (one .py page) that doesn't use cogs, but it doesn't seem to update the server count (count still shows N/A)
I added the code about 5 hours ago
but the website is still showing N/A
idk
okay
This is a fake shiv. The moderator shiv is the one who made this library
That was a good nap
@acoustic peak you don't specifically need a cog for dblpy, it's just that the example snippets do
@sullen nymph ah right! That's probably why the snippet isn't work 😂

hello how to run the dbl event one time only when i use ->vote
cause everytime i send ->vote it runs again
@restive otter what do you mean? The vote event only fires when there is a vote or if you test the webhook.
the dbl event is tied to ->vote command
yes
It goes in your index file
all the dbl events goes into index file?
See the pins here for examples
in calling the documents in index file
so i thought it'll be possible to be tied in a command
mongodb documents **
i successfully set it up
just having problem in rewarding
👍
if the api key binded to the application id cause my bot has a dev version and i dont wana upload that one to top.gg
Is your dev version running off the same code but it's a different client? @restive otter
well its running a diffrend js main file
and its ran locally rather then on the vps
Just do something like
if (client.id === IDHERE) {
//dbl code
} ```
i did
Should be ok then
Yeah. It won't post because the client id is different. If you didn't have that if statement it would post.
oh i see
But basically no, the token isn't linked to the client id
good
So if I had your token I could post to your page from my bot if I wanted to 😂
i see
hey, im attempting to use the dblpy module, using the webhook example in the api docs.
def __init__(self, bot):
self.bot = bot
self.token = 'dbl_token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
This is the code used in the example. For webhook path, what url do I use? I am generating the webhook for a discord channel so do i just paste that in? and for webhook_auth, what do i put there? and does the port number matter?
Please ping me if anyone responds :)
If someone votes for my bot, how long does it take to get logged in the console?
hi I’ve been getting a issue on tracking votes
Can anyone help me
Who’s experienced
With dblapi.js
hey, im attempting to use the dblpy module, using the webhook example in the api docs.
def __init__(self, bot): self.bot = bot self.token = 'dbl_token' # set this to your DBL token self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)This is the code used in the example. For webhook path, what url do I use? I am generating the webhook for a discord channel so do i just paste that in? and for webhook_auth, what do i put there? and does the port number matter?
@midnight kite A webhook is a reverse API, you're the one receiving requests
webhook_path is the string that comes after the URL, http://ip:port
by default it's /dblwebhook so your URL becomes http://ip:port/dblwebhook
Thanks a lot :) but I decided to just go with using the regular api since I didn’t really have a need to use webhooks and regular requests seemed easier
Fair
@trail sigil my merry friend
TOP.GG API ONLY!!!
ANY OFF-TOPIC CONVERSATION WILL BE DELETED AND MUTED
This channel is only for SUGGESTIONS/HELP/BUGS to do with OFFICIAL API LIBRARIES and API DOCS found at: https://top.gg/api/docs
ty
how do you find your dbl token for the api?
do i need to fill these?
no
k
how do you get points from the top.gg/api/bots thing
points?
it calls votes points
how webhook works?
@regal harbor every time your bot gets a vote on top.gg, it fires the vote event in the code.
See pins for more info
my stuff?
ip is the public ip of the vps/server/network your on
port and path you define in your code
i really dont get it
when i set up something of the example codes my bot in console says this
or
what im supose to do with that i put it on the page and i press "test" and nothing happens
i dont understand the port and path
what im supose to do with that i put it on the page and i press "test" and nothing happens
@regal harbor you need to wait a bit for it to send the webhook
do anything while the test is going and it'll stop
How to set a message when you use a discord webhook?
So you can skip the code in your bot itself
@spring flicker you can't use a discord webhook
discord webhooks are different from top.gg webhooks
someone help
well what have you tried up until this point
this.dbl = new DBL(this.config.tokens.dbl.token, {
webhookPort: this.config.tokens.dbl.webhook.port,
webhookAuth: this.config.tokens.dbl.webhook.pass
});
this.dbl.webhook.on('ready', async (hook) => {
console.log(`Top.gg webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
this.dbl.webhook.on('vote', async (voter) => {
console.log(voter);
const user = await this.users.cache.get(voter.user);
voteRewards(this, user);
});
my code
to receive webhook
but i am receiving nothing if i click test
Looks like valid stuff
where are you hosting
for now testing in my local machine
how?
Did you forward it in the router settings?
doing rn
but i dunno how to do tp-link
like fill in what here
what to fill in ip address
oh dear lord
i am nub at these type of stuff
never tried to do port forwarding
i don't wanna mess up the router
service port would be the port you run the webhook on
Internal Port would also be the port the webhook runs on
and IP address would be your computer’s private IP address
Don't bother
Someone that doesn't know about these kind of things will get them selves into a security pickle
security pickle
well how to do port forwarding in a azure vm tho?
anyway i did forward it in the router settings
i hope it works now
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
What do i need to enter for "yourDBLTokenHere"
your dbl token
where do i find it, and what is it?
is it the APi key?
Yes
ok ill try it
it doesnt work
nothing got logged
const dblweb = new DBL('API Token', { webhookPort: 5000, webhookAuth: '12345' });
dblweb.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dblweb.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
nothing got logged
where you hosting
if you are trying to get the webhook to work when self hosting you may have to port forward to get the network pointing port 5000 to where you are hosting it
ok
Why is there only a snippet for the Cog version of the server count for python on the API Docs page?
How do I get a webhook to send a message every time someone votes
I’ve tried all the ways and it doesn’t work
I'm having some trouble with getting the widget to work anyone got a template of how it should be set up?
<img src="https://top.gg/api/widget/745358062025703445.svg"> this is how mine is set up
@molten lantern #development
Also a #502193464054644737 question
wth is a snowflake
can i just convert it to an integer normally?
or is it already an int
it's a string but you can convert to integer manually, yes
ty!
how to open ports in a vps any guide?
I made webhook to work in my pc but I cant in the vps
Is there a way for me to fetch current amount of votes for a specific bot/guild through an api?
@regal harbor you have to tell your firewall to open the ports, a lot of vps'es use UFW, so it would be sudo ufw allow <port>
@white onyx thanks!
whats api
An application programming interface (API) is a computing interface which defines interactions between multiple software intermediaries. It defines the kinds of calls or requests that can be made, how to make them, the data formats that should be used, the conventions to foll...
site is down
api. you request something from a server's api endpoint that performs a CRUD operation which means it Creates something, Reads something(server reads something and you get it back), Updates something on the server, or Deletes something on the server. basically.
when you request a webpage you (client) request data from the website (server) such as the latest news or top discord servers or some shit. that's a read or a http get request
an example of hitting GET api endpoint


