#topgg-api
1 messages · Page 143 of 1
it worked now , thanks a lot . I didn't remove that slash as I double checked it was running correctly in browser
Yeah your browser probably trimmed one of them
yeah I checked it corrected the url and removed that slash
Hey so the top.gg docs say I can find a webhook at my bot site. When I go to that site, though, I don't have a webhook
Can anyone help?
What url are you looking for exactly?
Because the button I showed you leads to that exact url
That's where you enter your own webhook address. You need to set up your own system for it
Hello
When I set up my own system, does Top.gg give me the authorization or does the system I set up provide that as well
You can set up your own authorization token in the webhook page for your bot. But it's not required to use one
I don't think so, but I can't say for sure. Never tried it
y my users are getting multiple rewards in 1 votes
What library do you use
means?
@sullen nymph this is my code
@sullen nymph see this i just voted before vote i was having 0 crate and after vote i have 6 crate
how can i do it do it
here is the logs
Interesting
Does the webhook have to be where your bot is being hosted?
Probably a dumb question if the answer is yes
@sullen nymph dude see this its also spamming in dms the vote rewards and now it increase
please tell how should we fix
@sullen nymph ?
@craggy sentinel have there been reports of webhooks firing multiple times for a vote from the same user?
Note: the webhook does respond with 200
needs to be a 204 iirc
oh nvm docs say 2xx aswell
thats the first real report i've seen yet
there were several reports prior but those were always people who haven't read #site-status 
are you sure it's actually responding?
like have you checked if the endpoint actually works with something like postman etc.
its working but its giving multiple rewards and dms in 1 votes
not sure if you understood me
because that would actually make it a bug on your side
and top.gg wouldn't be involved at all
how do i setting my webhooks?
You guys gonna host a webhook service on your server which listens to the incoming dbl webhooks
You have to open the port you specified in your firewall INBOUND TCP
Take the public IP address of the machine and use it as your webhook path
ya but i don't know how to do it
Do you even own (rent) an own server?
i have my own server
OS?
debian
Well than find out which firewall the system uses, maybe ufw or iptables
ok
Both rules are simple to setup, e.g. sudo iptables -A INPUT -p tcp -m tcp --dport 9999 -j ACCEPT
Replace the destination port 9999 with out actual port
ok i'll try
Two useful commands:
ufw status
systemctl status iptables.service
https://docs.top.gg/api/bot/#individual-user-vote is this lifetime, or within a certain time period ? (So if a user voted for my bot two months ago, would this still return true?)
Within the past 12 hours
thank you
Python Short Question...
When i use this Command...
await hook.get_user_vote(user_id=185449287356907520)
than it gives "TRUE" back....
Is TRUE = voted for the bot
and
FALSE = Not voted for the bot ?
Correct
e
I’m simplistic terms. In discord.js how can I say, “once a user votes, do something.” I don’t really want to do it through webhooks. Ping me if you know
You can’t djs has nothing to do with topgg.
If somebody votes on topgg that has nothing to do with djs, too.
You can only send a request to the API of topgg and basically ask which user voted, take his user id and do something with it.
Similar to webhooks but for these you don’t need to ask the API who voted, they will send you a webhook or let’s say an information including the user (id).
You can work with that.
This whole process doesn’t require djs because it has nothing to do with it.
If you wanna use the user id you got to for example send a DM to the user djs will be library to use to actually send that message.
Let’s say you wanna promote an user who voted for your bot.
You will walk through the mentioned ways above, using the djs library your bot is probably running with, check the user id you got if the user actually exists on your Discord server and if so promote him.
Send a message, assign a role etc.
All this sounds more complex than it actually is.
Using a common lib to create a webhook service OR a lib to send cURL requests to the API of topgg
And using the response in your bot code or a several instance of it just to send a vote-thank message or assign a role etc.
At least just a few lines of code
how to check who voted for my bot using dbpy?
Yeah me too I need to know how 😅
I read the documentation and I try it bot, nothing happens
Yes
import discord
from discord.ext import commands, tasks
import asyncio
import datetime
import sqlite3
import os
import time
from collections import OrderedDict, deque, Counter
import math
import random
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
import io
from io import BytesIO
import requests
import aiohttp
import logging
import dbl
class BotList(commands.Cog, name='Ranks'):
def __init__(self, bot):
self.bot = bot
self.token = 'The token of the api.' # 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):
"""This function runs every 30 minutes to automatically update your server count"""
logger.info('Attempting to post server count')
try:
await self.dblpy.post_guild_count()
logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
except Exception as e:
logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
# if you are not using the tasks extension, put the line below
await asyncio.sleep(1800)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
logger.info('Received an upvote')
print(data)
@commands.Cog.listener()
async def on_ready(self):
print("Dbl is loaded !")
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(BotList(bot))
The python api wrapper for top.gg
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'dbl_token'
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)
async def on_guild_post():
print("Server count posted successfully")
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print(data)
user = data['user']
embed = discord.Embed(description="New Vote! Voter: {}".format(user))
channel = self.bot.get_channel(int(chnl_id))
await channel.send(embed=embed)
def setup(bot):
bot.add_cog(TopGG(bot))
i tried this to check votes, but it doesnt seems to work
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'dbl_token'
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)
async def on_guild_post():
print("Server count posted successfully")
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print(data)
user = data['user']
embed = discord.Embed(description="New Vote! Voter: {}".format(user))
channel = self.bot.get_channel(int(chnl_id))
await channel.send(embed=embed)
def setup(bot):
bot.add_cog(TopGG(bot))
import dbl
import discord
from discord.ext import commands, tasks
import asyncio
import logging
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = '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):
"""This function runs every 30 minutes to automatically update your server count"""
logger.info('Attempting to post server count')
try:
await self.dblpy.post_guild_count()
logger.info('Posted server count ({})'.format(
self.dblpy.guild_count()))
except Exception as e:
logger.exception(
'Failed to post server count\n{}: {}'.format(type(e).__name__, e))
# if you are not using the tasks extension, put the line below
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 get undefined variable 'logger' should I replace import logging with import logger or from logging import logger
And I'm trying to know what the returned data is, however, I keep getting this
I am having trouble getting the top gg api working with updating the server count
The bot works and I am not getting any errors
it just doesn't update the server count
(the 'token' part has my token in it when I'm using the bot)
Can someone help me with the python version of the lib?
It says that my bot is in 6 servers on the websife but it’s in 140
Same, I did auto post = true and it dosent update
did you debug the code to see the result?
How many of you fail to apply the cog listener decorator
How do we do that
@commands.Cog.listener()
Where tho?
Are you aware of how decorators work
Oops
I don’t have that thing at all
I only have the listeners for on vote and on test vote
Yes, I was confused
All I have it in self.dbpy the Boolean auto post as true
Do u need anything more than that?
Make sure you apply a bot object to DBLClient that's actually your public bot
I have self.client
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, client):
self.client = client
self.token = token'
self.dblpy = dbl.DBLClient(self.client, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port="PORT", autopost=True)```
Port, password, and token are my things I took them out
@sullen nymph it posted b4 idk why it’s not working anymore
What does the API do?
Ohhh, it allows you to show server count on the top.gg website?
i'm having trouble with webhooks
i think ik what's wrong but
i can't seem to CURL my webhook link from my VPS
but I can from my PC where I'm running
it
Which screams networking issue but Idk how to fix it
VPS in Germany ^
Cmd (my computer ^)
looks like ppl outside my network just cant get thru but idk why
bruh am i slow
You need your external IP address
Probably best not to leak it here
true
but i'm clicking refresh IP as soon as I'm done here so i don't mind
DDOSS away
Make sure your machine doesn't have a firewall that blocks requests to port 5000
netsh advfirewall firewall add rule name="Webhooks" dir=in action=allow protocol=TCP localport=5000 enable=yes profile=any
Make sure to add a firewall rule for your Windows device if you host the webhook service on it.
I'll be hosting it on my VPS but I just need to test on my device, but will do
Still no luck by the way
Ran that command & replied with "Ok."
Even tho you will have to setup an inboud rule for your specified port
Protocol TCP
You will be able to see the rule in your firewall settings.
Advanced firewall settings
Inbound rules, sort by name
did you run the command two times?
than delete one of it
ye did
Last step now is your router to forward the port 5000 to your device
oh gosh port forwarding
Atm the router blocks incoming ports
not sure if there's anything else to do past this
TCP port 5000 to 5000, no range, no UDP
Make sure you actually forward the port to the DEVICE the code is running on
oh
Not as of now
Oh since I saw like dyno and those bots have it so I was curious
Ayyy
It worked
I'm gonna go learn more about this now so I can do this in the future
It is random
Thank you for the help my man
If I understand correctly, we opened up the port on my computer's firewall, then router's firewall, then directed it to my device
No problem
:)
One more comment:
errr nvm
lmao
🤨
hm
Yes your device firewall is the first instance, the router the next, your ISP the last
yea
If a connection is "coming" to you aka. INBOUND the direction is vise versa
That makes sense
any firewall needs to allow these inbound rules, they usually drop
Just for security reasons of course
Same thing for a server
But the provider firewall will not block your requests because you're responsible for what happens on your rented machine
This mostly requires only to open the port in the device firewall the code is running on aka. adding a new firewall rule for inbound rules
Got a response from the webhook btw, so 🙂
Oh on thing more
Yeah for sure
Response with a HTTP code 200
Means successful
Could respond with 204 too
this might sound preposturous but is it possible the library i'm using handles it for me
yeah i think the python-sdk lib for dbl does the response for you
maybe, dunno snakish-lang or the lib in general
Fair enough
I'm excited to do this all over again but with ubuntu in a few hours
Meh i'll figure it out it's probably easier, last time I had to open a port it was just 1 command
Not even more complicated at all
Using ufw or iptables
yeah ufw enable 5000 or something
sudo iptables -A INPUT -p tcp -m tcp --dport 5000 -j ACCEPT
for example
and for ufw:
ufw allow 5000/tcp
Can someone help me? I have setup everything for the python lib correctly, and I did auto post= True in the self.dblpy thing.... a few weeks ago, it was running fine and all, but I may have ran my beta bot on it, and due to that on top.gg it says my bot has 6 servers. Now, it dosent post at all and it’s not doing anything. It’s stuck at 6 servers can someone please help?
I am using this in nodejs alongside discord.js
const express = require('express')
const Topgg = require('@top#2386-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 is your vote object e.g
console.log(req.vote.user) // 221221226561929217
}) // attach the middleware
app.listen(3000)
I run the test and nothing happens. Still a user voted and did nothing on the console
I still have a question:
Webhook URL, what is it?
IF my bot is running locally. I have used the public IP, the local IP, and nothing
Just scroll up a little and see what I wrote above.
You will have to setup an inbound rule for your firewall for the port you specified.
Additionally hosting at home requires to open the port in your router and forward it to the device your code is actually running on.
You will of course have to use your public IP address as webhook path.
Even if all is setup correctly your provider could still be the last instance which may filters your incoming packages you can't do anything about.
thanks I did the steps, and it remains the same.
Although I highly doubt the provider will help me.
It is still somewhat difficult to understand the help in English.
Make sure you even have a public IPv4 address
DSLite is a common routing method today which can result to may don’t have a public accessible IPv4
!ping
!ping
read pins
Webhooks
just did
class TopGG(commands.Cog):
def __init__(self, client):
print("loaded")
self.client = client
self.token = token # set this to your DBL token
# Autopost will post your guild count every 30 minutes
async def on_guild_post(self):
print("Server count posted successfully")
@commands.Cog.listener()
async def on_dbl_vote(self, data):
with open('bank.json', 'r') as f:
load = json.load(f)
print(data)
user = data['user']
try:
load[str(user)]
except KeyError:
return
load[str(user)]["Balance"] += 750
load[str(user)]["Votes"] += 1
load[str(user)]["Crates"] += 2
voter = self.client.get_user(user)
await voter.send("Thank you for voting on Top.gg! You got **750** and **2**.")
Why didn't the on_dbl_vote event get triggered?
have you added your webhook url? have you added the webhook port on your constructor that activates your webhook?
i dont want a webhook i only want it to dm the user and give them the rewards
look, i never made a webhook
ah
because magic
makes sense.
wait there is???
i want to test votes and when someone votes it will increase their balance and stuff
You can test requests and see if your code works
ok fair enough
def __init__(self, client):
print("loaded")
self.client = client
self.token = token # set this to your DBL token
# Autopost will post your guild count every 30 minutes
self.dblpy = dbl.DBLClient(self.client, self.token)
So like that
Don't forget the webhook arguments
lemme find that
You see which port and route is available on your machine and use them
The general idea is that the dblpy webhook is a wrapper for an aiohttp webserver, where you need a port to run the webserver. On top of that, there are handlers for specific routes like /dbl, /, etc.
Let's take for example a random URL
http://0.0.0.0:port/path
port is the port to run the webhook on
/path is the path to run the request handler on
Any port that isn't locked by a firewall
For my examples I specify 5000 or 3000
alright
self.client, self.token, webhook_auth="nope", webhook_port=5000, webhook_path="/")
@sullen nymph so that would work?
Yeah, seems good
alright, thanks!


class TopGG(commands.Cog):
def __init__(self, client):
print("loaded")
self.client = client
self.token = token
self.dblpy = dbl.DBLClient(
self.client, self.token, webhook_auth="no", webhook_port=5000, webhook_path="/")
async def on_guild_post(self):
print("Server count posted successfully")
@commands.Cog.listener()
async def on_dbl_vote(self, data):
channel = self.client.get_channel(781596060438233150)
with open('bank.json', 'r') as f:
load = json.load(f)
print(data)
user = data['user']
await channel.send(f"{user} has upvoted!")
try:
load[str(user)]
except KeyError:
return
load[str(user)]["Balance"] += 750
load[str(user)]["Votes"] += 1
load[str(user)]["Crates"] += 2
voter = self.client.get_user(user)
await voter.send("Thank you for voting on Top.gg! You got **750** and **2**.")
@sullen nymph sorry for bothering you but, this still does not work 
Did you vote or use the Test button?
voted
asked one of my friends to vote
i have the dbl voting bot and it sent that my friend voted
but MY bot didnt send anything
I suggest using the Test button in Webhooks section along with on_dbl_test event to actually test the webhook
What URL did you enter on top.gg?
its not a webhook :/
im not using a webhook
the bot gets a channel and sends there
webhook_auth="no", webhook_port=5000, webhook_path="/"
Do you know what a webhook is?
yes
a message sent to a specific channel with it's webhook url
isnt that what it is?
... no
A webhook in web development is a method of augmenting or altering the behavior of a web page or web application with custom callbacks. These callbacks may be maintained, modified, and managed by third-party users and developers who may not necessarily be affiliated with the originating website or application. The term "webhook" was coined by Je...
O
Well, you are correct under the context of Discord webhooks, but not the programming definition
pretty much
Make sure the port 5000 is accessible and that you are entering a proper URL on top.gg
what url does it require? the channel's webhook one?
The URL to your machine where your webhook runs
see this example
Well, wherever you run the bot
Then yeah, http://host.ip.address.here:5000/
i have the server address not the host's ip address
yeah use that ig
errrrr
or should i keep the port 5000?
if your code is correct, yes
What does your browser show when you open that URL yourself?
site cant be reached url took too long to respond
Are there any designated ports for you to use by the hosting company?
2022
but it says sent an invalid response
Did he even open the port on his device?
It's not hosted locally
Doesn’t matter by default the firewall should block this inbound rule anyway
Try hosting the webhook on that port and specifying it in the webhook
Depending on the policy it drops any inbound rules or accepts all.
Instead of guessing he could just check the firewall settings. 
Do you know what Sweplox is
That’s a question for me or him?
You
Never ever heard of that.
@dusky monolith as for you, do you use Sweplox directly or discordbot.sweplox.net
sweplox
https://sweplox.se/ this?
So regarding the context it’s a managed hosting service and no server.
Seems so
Ah alright which probably means he has no control about firewall rules or ports...
Oh I see they also offer VPS
Hmm... could probably still be the issue 
Anyone here
hi
How are you
I am new here so can anyone help
What help do you want
err.... I am making a music bot so how can I upload it on top.gg
and how will it be online all the time?
ok
@plucky lance
I need a diff port
I dont think 19555
Is right
is that a good port
or
Ok so I did all the steps on port 80
and it works
but when I test it doesnt work
it says its open
yes i am
hosting locally
const Topgg = require('@top-gg/sdk')
const api = new Topgg.Api(config.toptoken)
const express = require('express')
const app = express() // Your express app
const webhook = new Topgg.Webhook(config.topggwebhookauth)
const dwebhook = stuff for discord webhook
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
dwebhook.send(`<@${req.vote.user}> has voted for News Agent on top.gg!`)
})
app.listen(80)
My code
@shut flume
yes
and is token
and my webhook
Oh tru
When I go to it
it says that
but it all seems fine
in my top.gg
its
ip:80/dblwebhook
so how do If ix
fix
Ok what do I fill in?
what sthe step name
and data
which...
i dont get that
idk what to do this is what I dont udbnerstand. What am I supposed to post
i know nothing about that
and where is it in the docs
ty tho
Im there
do I put my id
Ok so what am I suppoded to do here
like what to put in request line and data
Thats all I need
I dont get what else your saying
ok
so to do that I need those 2 boxes
im using djs
ok
so how cna I fix that
the header thing
ok im doing
@shut flume It did nothing
Ok. I dont think its code as its from the js code from the docs
But im not recieving data
yes
hlw?
I have seen my webhook working
perfect
but
For a few days.
when someone votes once.
It counts 10 votes for the guy...
1 vote = 10 times a webhook returns.
pls ping me. why
Sorry, I’m busy today, no time left@barren kestrel
I keep getting this error when I try to do a post request:
at=error code=H14 desc="No web processes running" method=POST path="/dblwebhook" host=benbot-2ndv.herokuapp.com request_id=6c773c69-503a-4135-bf2c-14bba3e5021c fwd="60.16.666.180" dyno= connect= service= status=503 bytes= protocol=https
I am hosting with Heroku, Ill send the code in my next msg
from discord.ext import commands, tasks
import dbl
import libs.database as db
import os
#host on repl now?
KEY = os.getenv('TOPGG_TOKEN')
PORT = os.getenv('PORT')
print(PORT)
if KEY == None:
from dotenv import load_dotenv
load_dotenv()
KEY = 'nopedopedo'
class TopGG(commands.Cog):
"""
This example uses tasks provided by discord.ext to create a task that posts guild count to top.gg every 30 minutes.
"""
def __init__(self, bot):
self.bot = bot
self.token = KEY # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='ryertyertyrt', webhook_port=PORT)
self.update_stats.start()
def cog_unload(self):
self.update_stats.cancel()
@tasks.loop(minutes=30)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count."""
await self.bot.wait_until_ready()
try:
server_count = len(self.bot.guilds)
await self.dblpy.post_guild_count(server_count)
print('Posted server count ({})'.format(server_count))
except Exception as e:
print('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
@commands.Cog.listener()
async def on_dbl_vote(self,data):
print(data)
print(data.isWeekend)
print(data.bot)
print(data.user)
await db.query(
f'''
UPDATE users
SET votecount = votecount + 1
WHERE id = {data.user}
''')
@commands.Cog.listener()
async def on_dbl_test(self,data):
print(data)
def setup(bot):
bot.add_cog(TopGG(bot))
ping me and also... hellloooo?
ok I am getting off for a sec, dm me please
Can someone help me with the python version of the library
just ask and wait for someone who could answer your question
data is a dictionary not an instance of any class
Use keys not attributes
As for your error, turn on your web dyno
Why does my bot say N/A in the servers box?
How do I make it show the number of servers my bot is in?
Is there a way I can test the voting API with my dev bot with a different ID?
As long as it’s not approved, no
Since users can only vote for existing (approved) bots on the website
Np
I am using discord.py's library and I want to use the on_dbl_vote and on_dbl_test events. They do not seem to activate when someone votes though
I've read in the docs that for it to work, you need webhook_port and some others. What do I put there though?
self.dblclient = dbl.DBLClient(self.bot, self.dbltoken, webhook_path="https://discord.com/api/webhooks/772783784935686146/mywebhook :)", webhook_auth="12345", webhook_port=5000)
I tried that
But it did not change anything. What do I need to put in the webhook_port, webhook_path and webhook_auth?
Please ping on answer
Hey! How would I post a variable with all the servers the bot is in instead of using dbl.on("posted")?
Hello. I can't connect automatic grading notifications. why?
!join
Please anyone?
it has nothing to do with discord webhook
They are not discord webhooks..
That's what I thought. Well what webhook URL can I put there?
I don't have my own website where I could do it
^^ On top.gg what do I put in URL and Authorization? And then what do I put in the webhook_port, webhook_path and webhook_auth?
Python
And the module dbl
My server's URL? What do you mean by your server
Well on that IP my website is
With server IP you mean the IP of my VPS hosting my bot right?
So all bots having vote reminders and such need to have that?
I have an webserver using express.
console.log('[EXPRESS] STARTING SERVER');
const express = require('express');
const app = express();
const Topgg = require('@top-gg/sdk');
const webhook = new Topgg.Webhook('18S2l7h07Id894.A1n6r03O62k55o4k8.eo1nds8iwaf78');
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
console.log(req.vote)
});
app.listen(25569, () => console.log('SERVER READY'));
Hmm okay. So what do I put here
My VPS' IP is http://144.172.75.74/
How do I set up my webhook? lol
yes. i host my bot on an Root-Server
Oh so I actually need to like add something to my website?
Is that what I want? I use django
What do I want to do with them
Oh but isn't the voter data supposed to end up in my bot?
So I can do something with it
Not much
Also, could I do the webhook stuff on another webserver than the one hosting my website? Because then I can run it on a different port than my website. Then I could even run that one with JS which you know I guess
No
How would you do it
But how
I don't use JS. I just want that to work lol
I still don't understand what I need to do on my server
What do you mean by handling them?
I am clueless
There is no guide for that. If I don't even know what do handle
If you have no clue what handling means in regards of requests, you're most likely not ready to approach that yet. Come back to it when you have more knowledge
elf.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)```
Hey, I was wondering if the values webhook_path and auth were the same ones you can find on the website of your bot under webhooks?
The path is related to the URL
see this #topgg-api message
As for the auth, it's a password you create
So its not the stuff on the website?
Well, yes and no. You create the webhook with certain parameters and then specify them on the website
Hm
Where can I learn about creating a webhook
This is basically what you need as of now, aka the webhook args
Right, but I need to create one correct
Which part are you confused about?
Or something
Passing webhook args to DBLClient makes it create one for you
Oh
Uh
I just tried it with the default code on the docs, with the info under webhooks
So I assumed I did it wrong
Wait no
thats completley wrong sorry
its another bot that does that
Ok starting over
I need to create a link and a password
Well, it works, it's just suggested that you adjust the args to your needs
The linked message here explains what URL to use
I'm created a new bot
As for the password, it's just anything you enter
since that's what it is, a password that dblpy will use to confirm that requests are actually coming from top.gg
So
Let me see if I understood this
I can enter anything as a password
That much I got
Then the webhook url is the only thing I'm failing to understand
I need to create a webhook for the site to send data to
Mmm, basically yeah
this?
It's a URL for you to enter on top.gg in the Webhooks section on your bot's Edit page
Does that work for anybody?
In some cases where you have SSL you'd use HTTPS instead of HTTP, and sometimes a domain instead of an IP
but generally yeah that works for most people
Replace 0.0.0.0 with your external IP though
and replace the stuff with your webhook settings like port and path
How do I know what each of those things are
I host locally atm
Then first make sure your port is open in firewall settings and forwarded to your machine in router settings
uh
Google can help you here
Is this dangerous?
Dangerous in what terms?
Outside attacks
Also, does this port have to be open under the specific device the bot is being hosted on?
Top.gg doesn't expose your URL to anyone but you, so I don't see any significant reasons to be exactly worried
hm alright..
is the port 5000?
Whatever you set as webhook_port. In your case, yeah, it's 5000
In firewall settings, yeah. Inbound requests to that port
What do you mean? 
like
you asked about my ip earlier
But I dont see how that comes into play rn
Right now it doesn't. You will need it later when you enter the webhook URL on top.gg
alright
For this, is /dblwebhook the exact thing I'd use?
Correct
TCP
Did you forward the port to your device in router settings too?
Google your router model 👀
Fast 5250
Can't find much on that specific model
This might help though https://portforward.com/sagemcom/fast-5350gv/
I don't own this model
Like
I dont have access to its account and stuff
Oh, how come?
Oh
I guess so
Could we use the on_dbl_vote function without a webhook?
no
look at the documentation for your library over at https://docs.top.gg
there should be a webhook example
So, I need a webhook on my top.gg page for this to work, right?
webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000```
you will need to make a webhook server yes
Help
if you are using a VPS/server, open the port for the webhook port as stated, then put the url (http://<your-vps-ip>:<webhook-port/<webhook_path>) into the webhook area on top.gg
and test it
yeah that's the part I'm worried about
I have no clue how to set one up
you need to log in to be able to edit the bot
also, wrong place, next time go #support
are you running it on a VPS/server
I have a raspberry pi that I'm hosting my bot
ah at home, I see
then you will need to configure port forwarding to forward the port from your router to the rpi
then the IP will be your public ip of your router/internet
if you are using a dynamic IP provider, it is recommended to get a DDNS service to keep track of the current IP
dang
Alright thanks
np!
Please Owo Cash
-api
This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.
If you need help with development about your bot or development in general, feel free to use #development.
is there a way to automatically detect server votes similar to bot votes with on_dbl_vote
hmm, I'll look into it, ty
when I do https://top.gg/bot/:yourbotid/webhooks (with my bots id) I get error 404
how do i approve it
Authentication is performed with the Authorization HTTP header as such
Whhat this means?
Not of the website, header of your request
U mean where we paste the auto-post code in main.js,??
There's no explanation about it in brief!!
Because it require a general knowledge how to work with APIs.
There can’t be a step by step guideline for anything and anyone.
why
Why do think there’s a driving school instead of let anyone learn by doing?
Why do you think most jobs require to study?
because.... because
so how do u setup a webhook inside a bot?
My friend gave me this:
That's rude 👎
const DBL = require('dblapi.js');
const dbl = new DBL(apiToken, { webhookPort: 9008, webhookAuth: 'BTSsuckslikewtf' });// in webhookport: 9008, replace the "9008" with your host's port.
dbl.webhook.on('vote', (vote) => {
console.log(`${vote.user} has voted me!`)
const webhook = new Discord.WebhookClient("ID","token")//replaces with ur webhook information
webhook.send(`<@${vote.user}> (\`${vote.user}\`) has voted me!`)
});
dbl.webhook.on('ready', hook => {
console.log(`Webhook up and running at http://${hook.hostname}:${hook.port}${hook.path}`);
});```
Yeah because it requires to have some knowledge about these things.
If you wanna do HTTP requests aka. cURL requests then it makes sense to learn about what it is, what methods are, what a header is etc.
These step by step guidelines you’re speaking about is nothing else than copying code without any kind of understanding and wonder why it doesn’t work after.
also, stupid qustion, how do u know host port?
Yeah the truth can be rude.
People are providing help in here every day but it always require to know the basics of what you’re doing since nobody will write the code for you.
if u pay they will
It’s the port you specify of course.
its 9008?
You write 2 para of lecture, if you've stated how to do it.. it would be helpful. But it's okay keep it up.🙂
How do I know if my is 9008?
Or do you speak about the source port? Or destination port?
uhhh
Thanks for help!
You’re defining the port your webhook will listen to. You have to open that up in your firewall.
INBOUND TCP your port number
i dont have a firewall
Well if I use google to search for cURL requests using headers it will probably show you millions of examples and some also explain what what means.
Where do you host the webhook service?
At home, on a server etc.?
home?
OS?
Question mark... what?
At home also requires to forward the port in your router to the actual device the code is running on.
If it’s on Windows then, yes you have an active firewall.
Any idea why this could be happening ?
It's a loop which is supposed to check the users reacted to a specific message and check if they have voted, if not it sends a reminder
My code:
@tasks.loop(hours = 1)
async def reminder(self):
await self.bot.wait_until_ready()
channel = self.bot.get_channel(710341374188453898)
message = channel.fetch_message(808091364196876288)
reaction = message.reactions[0]
print(reaction.users())
users = await reaction.users().flatten()
print(users)
embed = discord.Embed(title = "Vote Reminder", description = "Thanks for voting I really apprreciate this <3\n__**[Click here!](https://top.gg/bot/747965125599821914)**__", colour = discord.Colour.dark_red())
for user in users:
voted = await self.dblpy.get_user_vote(int(user.id))
if voted == False:
await user.send(embed = embed)```
It the library you’re using outdated?
no i don't think so
Well invalid HTTP method is a weird error if you didn’t change the library.
It doesn’t follow there actual method which is needed for the request.
For example GET or POST
what should i check ?
In the first place check which version that package is and if it’s up to date and when its last update was.
I can’t remember if the methods for requests to the topgg API have ever changed.
If the issue is a py related issue I can’t help u with unfortunately.
I don’t speak snakish 
Where can i find my Ip adress
How do I track the votes for a server (not a bot) using the api
In the docs it only tells about bots and users
u can repurpose it
Google "my ip address" and google will give u it
Ignore that error
hi how to setup dblwebhook in python
did you read https://docs.top.gg/
y this dont work
const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express()
const webhook = new Topgg.Webhook('...')
app.post('/web', webhook.middleware(), (req, res) => {
console.log(req.vote.user)
bot.channels.cache.get("795394146143043584").send(`<@${req.vote.user}> has voted for me on top.gg!`)
});
app.listen(1251)```
did you try the 80 that the docs provide...
80 isn't something you should use for the webhooks
well
sa
-api
This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.
If you need help with development about your bot or development in general, feel free to use #development.
you're trying to access an endpoint with a token that can't access it
wot? it is a refreshed token and it should work
what are you trying to do exactly
upvote check system
yeah
post your code here and wait for someone who can help
ok
wtf it works when i set up a different environment for it
same bot btw
just another index.js
..
My bot's server count isn't updating as it should. I have the code 100% set up correctly and it has worked B4, but now for somereason it's not workibg
are you using repl.it
or replit.com?
for some reason, my projects on replit cannot access it but if i host the bot and the api locally, it works
Where can I get a bot token?
see pins
sorry!
whats the api url for posting server count?
the python library isnt working for me so im going to do it manually
where
i cant find
wait
no
sorry
can someone tell me if i am doing this right? this is python
headers = {"Authorization": "secret"}
data = {"number": len(bot.guilds)}
async with aiohttp.ClientSession() as session:
await session.post('https://top.gg/api/bots/671801771345182782/stats', data=data, headers=headers)
its not updating the server count on my bots page
json= not data=
Yes
do i type the ?
No
got that fixed, some lag from top.gg apparently, those that recieve the 403 error should be fine now
Is it possible to have the server post code work on v11? If so could someone send the code or help...
Thx :)
you should use v12
Use v12
is the isWeekend field of the bot webhook schema always true? other than today being saturday, this entire week the isWeekend field was true.
whats this dbl api?
-api
This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.
If you need help with development about your bot or development in general, feel free to use #development.
our api
is dbl api yours?
it responds with 1 during Friday-Sunday, 0 the otherweekdays
yes
how may iget that?
read pins
my mind is in pain 😅
ah alright, i was just parsing it as true/false. gotcha
ty
and whats the ame api
best is to just read https://docs.top.gg
k thx
No token given or token invalid
remove the :
ok
Can’t they be turned off for specific roles?
Maybe worth a community vote to disable embeds for anything < mods
some users use screenshot urls for demonstrating things, which would make it not worth it
-help
-api
This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.
If you need help with development about your bot or development in general, feel free to use #development.
Just an example how to use the authorization header:
Where to get api token?
From the site by editing your bot.
Is showing the amount of servers your bot is in the api or is that something to do with the amount of servers it’s in
Nope you’re basically reporting the current server count to topgg
Oh because some bots have the amount of servers on how do I do it?
It’s not being reported automatically.
You have to do it manually just by sending a cURL request (HTTP request) to topgg or a library which does the job automatically.
Both being explained in the docs pinned at this channel.
👍
doesn't help much
whats error code 1015
its my first time making vote webhook
i was testing
for the first ever time
OH I KNOW WHY
I DID alwaysReply for messages, and it requests every time
there's the issue then
shit
how long i shall wait?
an hour up to 24 hours
how do I setup the api in bot?
I got this from friend
const dbl = new DBL(apiToken, { webhookPort: 9008, webhookAuth: 'BTSsucksLikeWtf' });// in webhookport: 9008, replace the "9008" with your host's port. in "AnyPassword" u can choose a random password.
dbl.webhook.on('vote', (vote) => {
console.log(`${vote.user} has voted me!`)
const webhook = new Discord.WebhookClient("id","token")//replaces with ur webhook information
webhook.send(`<@${vote.user}> (\`${vote.user}\`) has voted me!`)
});
dbl.webhook.on('ready', hook => {
console.log(`Webhook up and running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
but...
it doesnt respond.
Where are you from?
Will there ever be a member count endpoint?
probably not
any update on this? https://github.com/top-gg/python-sdk/issues/35
TypeError: object Lock can't be used in 'await' expression
What does genious api works for?
how do you add @abstract moth and @wild lantern to servers ?
This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.
If you need help with development about your bot or development in general, feel free to use #development.
k
It's fixed in v1.0 so you'll have to wait until it's fully released
ew
@everyone
i seriously need a help in getting a dbl api 😦
why this dont work
const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express()
const webhook = new Topgg.Webhook('...')
app.post('/web', webhook.middleware(), (req, res) => {
console.log(req.vote.user)
bot.channels.cache.get("795394146143043584").send(`<@${req.vote.user}> has voted for me on top.gg!`)
});
app.listen(1251)```
Port 1251 opened up?
You need to add a new firewall rule.
INBOUND TCP 1251
On the device the code is running.
Running at home makes it even more difficult.
so it'll automatically work? or ill have to update my dbl version
You'll have to wait until I actually get everything done and release it
i host the bot on somehost, and it have at "Network" the host ip and port, that is 1251
ik im late but dblapi.js is deprecated. Have a look in
Can someone help me?
@tasks.loop(seconds=1800)
async def server_count_post():
headers = {"Authorization": "TOKEN"}
data = {"server_count": len(client.guilds)}
async with aiohttp.ClientSession() as session:
await session.post('https://top.gg/api/bots/762361400903204925/stats', json=data, headers=headers)
await session.close()```
what is wrong with this?
No need to close the session since the context manager does that automatically
That looks alright. Can you print the response?
oh it does?
How do I do so lol
Assign the .post to a variable
Then you can print response.status
its printing 400
That's interesting
it did post the guild count tho
so its finally not 6 anymore
🤣 as long as it works
Make sure to add the content type to the header
how?
Same way you added your token to the header lol
aiohttp should do that automatically
If you pass the json parameter, it should set Content-Type accordingly
Hmm ... 400 as response is weird
thanks!
const Command = require("../../base/Command.js");
const { MessageEmbed } = require('discord.js');
const DBL = require('dblapi.js');
const Resolvers = require("../../helpers/resolvers");
class DJ extends Command {
constructor (client) {
super(client, {
name: "dj",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: [ ],
memberPermissions: [ "MANAGE_GUILD" ],
botPermissions: [ "SEND_MESSAGES", "EMBED_LINKS" ],
nsfw: false,
ownerOnly: false,
cooldown: 5000
});
}
async run (message, args, data) {
const dbl = new DBL(this.client.config.apiKeys.dbl);
let voted = dbl.hasvoted(message.author.id);
if(!voted) {
const vote = new MessageEmbed()
.setTitle("Error!")
.setFooter(this.client.config.embed.footer)
.setColor("RED")
.setTimestamp()
.setDescription(`${this.client.customEmojis.error} you must vote me to use this command`)
return message.channel.send(vote);
}
}
}
module.exports = DJ;```getting error```TypeError: dbl.hasvoted is not a function```
hasVoted, not hasvoted
ya
I just changed that
@sullen nymph now you can
can you send the code i should use it on my main.js?
What's your library?
What does the shard_count endpoint even do?
You can use the autoposter package https://npmjs.com/package/topgg-autoposter
I don’t see any shard count on the page :/
i already downloaded it
What do you mean by "endpoint"?
Like, the stats post endpoint, it has an option to post shard count, what does it even do?
Yes, but what does that data go to? What does it do and what is the purpose?
I just don’t see a “shards” count on the page
I see server count but no shards
I have...
Similar to server count, it should be shown on the bot page
Am I doing something wrong here then?
I’m posting both, but it’s not showing?
Is there another key I need to send?
Nope
🤔
Are you using JS?
Python
Are you stringifying the keys?
Keys are strings and values are integers
i also get json {} as a response with this:
That means the request was successful
Suggest you print the status code along with the response text imo
The request was successful then
I get a 200 "ok" status
Yup, then it's all good
Send a GET request to the link and see if the API actually set the shard count
aka you can just open it in browser while logged in
null
a?
how ı can get my webhook lınk?
I needed shard_id
Webhook URL is created in the following format: http://ip.address.of.yourmachine:port/path
port is the port you run the webserver on, path is, well, a route/path you set to handle top.gg requests
do glitch links work?
how i can set handle top.gg requests

