#topgg-api
1 messages · Page 148 of 1
Correct
which line in the docs is the vote tracking? (py)
You need to reply with a 2xx HTTP response
otherwise it's going to re-try about 10 times
okay thanks :D
@rain heart Using the API you provided me, I'm having issues initiating the listener. How can I fix a null ip address?
0.0.0.0 means being able to connect through everywhere
Iike localhost, public ip address, domain
In other words, not bound to any ip
@trail anchor
Sorry for the late response tho
anyone know if there's plans for a top.gg/servers api?
Peculiar, so then why can I not receive the webhook?
The port is open and I see the requests coming into my router and being sent to the correct machine on the LAN
Can anyone tell me what are the data we get when someone votes for the server?
I mean json data
are you using the newest version?
how are you testing it?
authorization is correct too?
Yes
otherwise add the IGNORE_AUTHORIZATION and IGNORE_VALIDATION at the addBotListener
because normally it wouldn't fire the event when it isn't authorized (not correct authorization) or not valid (not the correct json format mentioned on the top.gg docs)
It's authed
see if you're at least receiving anything
I will add the options
i assume you also have started the webhook server using start() on the Webhook after using build()
also,
yeah correct version
and the listener class is correct too? have a simple debug line on the onWebhookRequest method
How so?
Also, I added both options and still no event
just a simple System.out.println("test"); to see if it gets fired
Yeag
dm me your webhook url and authorization if you're comfortable with it, so i can make a test request from my end
have you also pressed save before testing?
I'm sorry
i forget that multiple times

@trail anchor not getting any response from my end, are you sure it's running and possibly portforwarded if using it on a local network?
How do you use easy application bot
-wrongserver
@broken tulip
Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Get Support" button on the bot's page of the bot you need support for, not the "Join Discord" button at the top of our website. If there isn't a button that says Support Server, then we can't help you. Sorry :(
Hope
because i can't make any connection to the url
Do u know how to use any application bot
just times out
read the message above
peculiar...
oh duh
I set the WAN to only the one provided on the docs page
lemme open that up for you
@rain heart Should be good now
and what's the context of the webhook? The value you have entered on the first parameter?
of the addBotListener
GuildWebhook
went through
I got it
have you added /GuildWebhook to the end of the url?
yeah that's the validation issue
one sec
yeah says null because your bot doesn't have me cached and/or can't find me
just print out the user ID for testing
should be 669452973755072524
got it?
Fully, yeah
any errors?
still worried about the validation error though, can you print out the data by using BotWebhookEvent#getRequestString() received by the webhook?
Ready
sent
Nothing
weird, one sec
are you still using the getUserById() method on the onWebhookRequest ?
No
eb.setTitle("Wow! A Vote for our Server!")
.setDescription(voteData.getUserID() /*botInstance.getJda().getUserById(voteData.getUserID()).getAsMention()*/ + " [TESTING] just voted for ...yadadadada")
.setColor(new Color(255, 0, 0));
replace your current addBotListener with
addBotListener("test", event -> System.out.println("test"), "auth");
really weird why it doesn't work
the auth is there
just a lambda for testing
to just print out "test"
oh wait
i see the issue
you're using a GuildWebhook
yes?
are you trying to receive one for a bot or a server?
For a server
Ready, just finished build
still nothing?
still nothing
debugging time, probably an issue with my code, my bad
all good
Can Someone tell me how can I get the user object using discord.py
that the webhooks send me
@trail anchor can't really find what's wrong, tested the guild webhooks, works perfectly with test data
Would having the entirety of both classes help?
yes that would help, otherwise i could send you a test version of the topggwebhooks4j with a bunch of test stuff
Lazy fetch it, cast the id to int and get it from the cache with <Client>.get_user method, if that returns None, fetch the user from the api with <Client>.fetch_user method. The latter is coroutine
I don't have a client object
Wdym? You're using the python sdk, aren't you?
Well, you mentioned discord.py so you must have access to the Client object. It doesn't have to be Client, its subclasses also work.
nvm I am confused now. Can you tell me how can I run the flask app and discord.Client at the same time
Threading, though just use the official sdk.
sdk?
A simple API wrapper for top.gg written in Python. Contribute to top-gg/python-sdk development by creating an account on GitHub.
I need help adding mee6 bot to my server. Any help?
wrong server
Ahh mb
So I noticed that isWeekend is true for votes currently, despite it being Friday in every timezone currently - What is the actual time-window for isWeekend?
Friday-Sunday is considered weekends
Do you know how to do the server vote webhook in js?
nope can't help with it
Ok, I wrote all the code for it, enabled port forwarding and put the webhook details into top.gg but it still didn't work and did nothing when anyone voted
Someone’s looking for a mute 
Banned dream killer#3012 (@rocky nest)
😂
how generate api token?
bot page settings -> webhooks
thanks
How to use the api?
Ty
should be mentioned on the docs
Okay
Is the port that you specified open?
yes
I was got test responce for like 2 times
But after that I am not getting any
How can i make it so if someone votes my bot, this event takes place
db.set(`${vote.user}`, 1)
how do i make the webhook for the bot
wait but where do i get the link for the webhook from?
thats not how that works
https://<your-ip>:<open-port>/<your-post-request-link>
you need a webserver for receiving requests from top.gg. You can use official libraries if you want
I guess
wait so then how does it work if i want to use the webhook to find out if someone voted for my bot
wait so what do i put in the post request link
Like I use python so I can specify
@app.route('/webhook', methods=['POST'])
Then I use webhook
So you need to put something
that listenes to top.gg Post request
oh ok
what about discordbotlist
It is not the server for discordbotlist
ask discordbotlist
and I highly dought that I saw something like that
They don't have a server 
O lol I never really thought of seeing their server then
i did their not responding
this is not our problem, sorry
yeah but the api is similar enough right
Top-gg != Discordbotlist
Nothing similar at all, nor will anyone help you with api related things from there
Your bot needs to be approved first
so hopefully if its approved ill need to know how to use this api
apollo
apollo indeed
nice
can anyone help me Setting up webhooks ? i am not understanding the auth thing
Sa
Its the header you recieve due to post request
who is doing the post request ? me or them
yes so what exactly i have to do ?
import requests, json, asyncio, time
from flask import Flask, request, Response
from threading import Thread
app = Flask(__name__)
@app.route('/webhook', methods=['POST'])
def response():
print(request.headers.get('authorization'))
if request.headers.get('authorization') == "a":
print(request.json)
'''asyncio.set_event_loop(asyncio.new_event_loop)
loop = asyncio.get_event_loop()
loop.run_until_complete(discord_webhook(requst.json))'''
return Response(status=200)
def run():
app.run(host='0.0.0.0',port=8080)
t = Thread(target=run)
t.start()
for some reason the webhook wont send the json data
You don't need threading
Yes
I just learned and did it today
So I am pretty fresh
its still not sending the json data
is anyone have good tutorial to send random memes from reddit via custom api?
yeah but u know how to do it
praw is a good api
Thats request.json
yeah so what am i doing wrong
Remove the auth and try once
but basically if i put a print statement right after declaring response response doesn't send the print statement
Using test
i want to do my custom api
still not working
something like have this guy: https://api.hyrousek.tk
Also create a normal @app.route('/', methods=["GET"])
Idk i needed to do that because flask won't run for me
Wait let me give you mine
ok thx
does have anyone open-source api? XD
wait so ur able to get the member who voted from ur webhook right
nope
@frigid urchin
ok
Here
thx
Me on phone
So please don't kill me
Electricity went down here
Currently power cut
Though i shouldn't show you my auth

Flask docs
I learned just how to recieve post request
With headers
oh
But for me thats confusing
oh ok
As i don't have a bot object
how to create in js the api thing i need to add server count any help
One message removed from a suspended account.
Could literally run 2 webservers where one would be the middleman 
wait im so confused why its still not working
it works perfectly fine on requestbin
heres the code
for some reason hello doesn't even get printed
so i don't think the error is in response
but ive looked at other examples and theirs works even though they do the same thing
Are you sure you entered the correct url in the edit page?
yeah i did
Hey guys I am new
What did you enter on top.gg
How to make a Bot?
headers are additional information sent to the api,
such as the token,
and yes thats the token, you need to send it with your request so the site can verify that you are the one sending the requests
depending on the language you are using, and http library, you can easily search how to add headers to your request
Ok, i'll try thanks
-b 781727349431205919 ads in multiple channels
Banned sunny_$#0398 (@analog sigil)
Woah, scary.
Oh, sorry for ping ;-;
all good
I'm a bit confused with this authorization thing
The autoposter is working
But where exactly am i supposed to put the top.gg id?
I put it here
this isn't doing anything
and this gives me the 401 not authorized error
Wdym
Why would you need to change that?
Where does the notification arrive that the bot has been approved? Or not
idk just that I thought maybe to ur bots name, bc I can't get the API to work and I have no clue why
in DMs from @celest pier
Thanks
Are you sure your dbl token is correct?
and you don't actually have 'DBL_TOKEN' as the value
I have made a variable called DBL_TOKEN so I done DBL_TOKEN=<my bots token>
you're defining it as a string
yeah
not a variable
You're setting your token to literally 'DBL_TOKEN', not the variable
Remove the quotation marks
exactly
Sorry I put DBL_TOKEN=<'my bots token'>
that's not what we're referring to
Yes, but your self.token is not defined correctly
kk
you're setting that to a string too
So make that DBL_TOKEN not 'DBL_TOKEN'
If that's your variable's name, yes
Okay thanks
DBLTOKEN = 'DBL123'
print(DBLTOKEN) # Print the DBLTOKEN variable
print('DBLTOKEN') # Literally print "DBLTOKEN"
is what you're doing
you need the top one, not the bottom one
correct
Okay ty
It is not working, not sure why I will double check that My variable is working
That should be all
You need a @commands.Cog.listener() decorator over the on_guild_post event for that to print anything though
kk I will add that now
That will only make sure it prints anything though
Like this right?
Mhm
Will I need to do
`@frail rapidss.Cog.listener():
async def on_guild_post()
print("Server count posted successfully")`
That's not how it works, no
Without the @ and the ID on it just @ commmands
like this?
So on this
Okay ty
Not working still no errors
And you're sure the dbl token is correct?
Yeah
Do I need to import discord if not I will check on a different coding IDE
If there were missing imports you would have gotten an error
true
Can someone tell me why am I not getting a post request from this?
Just made this in pycharm should this work, My discord bot is not coded on pycharm
I am not getting the post request for bot
Well as you can see that's not going to run since you haven't imported commands from discord.ext
kk thanks
From docs this is the webhook path then what will be the full path
The full path is
http://<your public ip>:<port>/dblwebhook
or if you're hosting on a server, the public ip of that server
But Can you tell me why can't I get post request to the webhook in like server
??
Like I can get a Post request for server votes
With flask
how would i make it so that i send the user a message that they have been given the reward for voting
but the same app is not getting the test post request for bots
and i wanna be able to trigger this function from another function
I'm sorry, I can't really tell exactly what the issue is
hi bartick
Can this be a issue on bot vote side?
hi
I don't believe that there are any issues with bot votes right now, no
Will this work I some removed some of the code bc it was erroring in pycharm
Yes
it will
I am also doing the same
I mean just did
And it updated my guild count
Okay thanks
@night ingot Sorry for the ping though. But I figured it out. The Test vote (webhook test) for bots is not working. But the normal vote is working just fine
And Do you know why the bot vote counter not increasing?
Probably just takes a while to update
okay
Did you load the cog
As in i removed it in the @ commandss.Cog.listener()
async def on_guild_post():
print("Server count posted successfully")
hi um whenever someone votes my bot on top.gg, the webhook is getting recieved multiple times... i tried resetting the webhook secret and checking other stuff and it doesnt seem to work...
You need to respond with a 2xx HTTP response, or it's going to keep re-trying
Have u made the webhook more than once?
@thorn gate refer to this message
#site-status message
oh ok thanks
Are you loading that cog?
As in the class topGG(commands.cog)
No as in, are you loading the cog from your main file?
Not 100% sure wut u mean new to coding?
Ima try It passing it my DBL token through as just the token
So <'my dbl token'<
Add a print in the setup method so you can make sure the cog actually gets loaded
yes
Should It show once I boot up the program?
That should print when you start your bot, yes
No it has not, must not be loading.
Should I re-enter the API and see if that works?
What? no, if your cog isn't loading, nothing you do in that cog's file is going to change anything
You should look up how to use cogs in discord.py
does anyone know how I will be able to use a voting webhook with Discord.JS sharding? it seems it requires a Client object to use a dbl webhook, but I can't use a client with more than 2500 guilds in my main index.js file...
#Host the webserver to recieve the info about users that voted for Bubble
app = Flask('')
@app.route('/webhook', methods=['GET', 'POST', 'OPTIONS'])
def response():
global usersVoted
if request.headers.get('authorization') == "12619611":
self.giveVoteReward(request.json["id"])
return Response(status=200)
def giveVoteReward(self, userID):
global economyCol
economyCol.update_one({"_id" : userID}, {"$inc" : {"balance": 1000}})
print("success")
app.run(host='0.0.0.0', port=8080, debug = True)
error: No module named economy
name of file this is in:
economy.py
this is outside a class but the file has a class named economy
could someone pls help
hi, i've created a webhook integration into my server and set the url into top.gg page, now how can i get a message every time someone votes?
ye is it
i tried but i didn't got any message
wait i actually got it
but it shows.. weird af
right
nvm i'm dumb
^^
hey
ummm
in the place
http:// 0.0.0.0 :19132/dblwebhook
wait nvm
wait
WAIT
I NEED HELP
why does it say 0.0.0.0 at that place, and not my ip or smth?
ok so i think i have some trouble with opening my port
so in the router settings (check ss below) i set up my port forwarding with my public ipv4 first. This gave error message:
Intranet IP address and LAN IP must be in the same network segment
I contacted some other ppl and they said i needed to take my computers private ip address (so a 192.xxx.x.xxx)
I did and opened the port on the local ip, as you can see on the photo
In the top.gg webhook page i use my ipv4 ip
still nothing comes through and doesnt print the data, anyone that can help?
i checked 10 times if its being forwarded to my correct device, still nothing. my router just doesnt want to open the port, any ideas?
https://cdn.discordapp.com/attachments/782034872830918666/832352329725378610/unknown.png
ping me if you reply, gonna go offline for now so i can check mentions later
Which part confuses you?
The entire thing?
Does anyone know of a way to get a free endpoint for webhooks without exposing localhost?
You won't be able to receive webhooks without opening up your network to them, no
Anyone kind enough to explain me the voting part on the docs?
Pretty sure no one is going to explain the entire thing, it's better if you ask more specific questions
Yea how do I check if someone voted the bot
Also how do I make a webhook which checks that
https://top.gg/api//bots/:yourbodid/check?userId=:userid
You can use this url to check if a user has voted
So change the :userid to the user's id?
What language are you using?
dblpy is a library that can be used to set up a webhook listener
https://dblpy.readthedocs.io/en/latest/api.html
Still confused
a fast way can be, into the webhook url on top.gg, you can place http://yourvpsip:7000/dblwebhook, and in the code you can use ```py
dbl_token = 'your-token'
bot.dblpy = dbl.DBLClient(bot, dbl_token, webhook_path='/dblwebhook', webhook_auth='your-auth-password', webhook_port=7000) #webhook_port is the number you have set into the url
it return json, so on the on_dbl_vote event you can use the data thing to get what u need, as like the username of who has voted (it returns the member ID, so you need to use fetch_user or get_user to get the username)
and to give it a reward.. idk, if you have a db, do stuff with your db in the on_dbl_vote event, ez
read pins
oh ok ty
anyone know how to show the correct server count on top.gg after implementing sharding in Discord.JS?
do anyone know how to disable or set top.gg webhook not to retry if the server didn't return status code 2XX
cuz i don't really know how to handle the thing
like return 2XX status code
you have to return 2xx yourself
if you don't, it will continuously retry
you can just do response.code(200) no?
What should i do now?
if I were to set up a webhook on my bot on port 5000, is this what I would type in for the webhook URL on my bot page? http://myIpAddress:5000/dblwebhook
@commands.Cog.listener()
async def on_dbl_test(self, data):
print("Received a test upvote:", "\n", data, sep="")
doesn't work i setup everything correctly in the top.gg webhook page, in my code and my port is open (i check via an online port checker for double check
def __init__(self, bot):
self.bot = bot
self.token = 'MyRealToken'
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/dblwebhook', webhook_port=5555)
still nothing
and if i type in the ip with port and webhook path i get returned this (in browser):
405: Method Not Allowed
How do I post my server count to top.gg whilst using sharding? Right now it just displays the server count of one of my shards, not the total number of servers.
u could use repl
using the webhook code provided
const Topgg = require('@top-gg/sdk');
const express = require('express');
const app = express();
const webhook = new Topgg.Webhook(topggauth);
app.post("/dblwebhook", webhook.middleware(), (req, res) =>
{
console.log(req.vote.user);
});
app.listen(1030);
doesn't work.
- console isn't logging anything
- port 1030 is open
- my ip is public
canyouseeme.orgcan make a connection to my ip with port 1030- listener is listening, shows up on Resource Monitor
- Wireshark isn't picking up anything
What am i doing wrong? 
- Whitelisting port/topgg ip doesn't seem to change outcome
in express ?
I don't code in js, that's my assumption
o
oops it does not work any other solution ?
ahhh its working well last time but dk why dbl added retry function
Hello, Does Bot with other language (Not English) is allowed?
yes
Out of curiousity, why is the ratelimit retry_after an hour? isn't that a bit excessive?
because the decision was made to have ratelimiting blocks an hour long
as long as you're not hitting ratelimits, you should be fine
Fair enough
It's also pretty easy to avoid hitting ratelimits. Huge bots use the api and don't hit them.
A huge reason is if your bots offline for a bit, and you don't receive the webhook, you can still receive it later.
Status codes are extremely simple to use in any library.
hey
I got this
dbl.on('posted', () => {
console.log('Server count posted!');
})```
But its not responding.
(ping me when replying to me.)
Did you fill out the webhook url and auth on the site?
auth?
ummm
I think
is it the place where says webhook
and needs URL and password thing?
ya I did fill it up...
it does know it, sence my dbl is described like this:
const dbl = new DBL(apiToken, { webhookPort: `${portTopgg}`, webhookAuth: 'xxxxxxxx' })```
That's your code, the website doesn't know where to send it to.
yes it does tho.... I filed up the form and everything
the top.gg token
the webhook url
port
host name
Ok, where are you hosting? A vps? Home? Nat server?
home
my computer
But soon it will change, but not now...
You'll need to port forward
I did...
I got it setted up
Thats what portTopgg is
const portTopgg = config.json```
and then in config.json its
"portTopgg" : "xxxx"```
That's not port forwarding.
Portforwarding is done with your router.
https://portforward.com/
no
no no n ono no
I already know
I portforwared that port @jaunty plank
on my router thing
Try using postman to it.
whats that
Yeah. Let's you make your own requests.
what does it mean by no module named economy?
this is in a cog
wait is it becuz i set debug to true
dude i tested it without the debug
and it worked lol
@commands.Cog.listener()
async def on_dbl_test(self, data):
print("Received a test upvote:", "\n", data, sep="")
doesn't work i setup everything correctly in the top.gg webhook page, in my code and my port is open (i check via an online port checker for double check
def __init__(self, bot):
self.bot = bot
self.token = 'MyRealToken'
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/dblwebhook', webhook_port=5555)
still nothing
not sure if this is related to the other webhook problems but..
trying to use the 'test webhook' feature, wasnt receiving the web hook (ip/port exposed via ngrok tunnel), although it did work fine via a manual post request via postman
went ahead and tried to see if it was just a networking problem on my side, used https://webhook.site/ to generate a unique url for capturing requests. once again, a manual POST request with postman worked fine, but the 'test webhook' button didnt see any results
is there an outage right now?
The vote webhook works for me, but the authorization value I specified isn't sent with the request. Is this broken? (I did save it properly)
are you talking about the test webhook, or the live one?
weird..
I just started trying it out
I'd like to use the authorization for security, but I guess it'll work without for now
But would be amazing if someone could help me
Both
But it's in neither
These are the headers and raw headers that come with the request
i dont see it in my test webhook either
Do you receive it in the live one?
Oh no nevermind
I guess I'm blind
It's in the raw headers
also the normal one
Ok then nevermind
It took it's sweet time setting the value then
Thank you for your help though!
(it didn't work a minute ago)
xD
¯_(ツ)_/¯
indeed ¯_(ツ)_/¯
using the webhook feature, is there any way to get an automatic message posted in a channel when the bot gets upvoted?
i know that discord has the built-in <webhook>/github to handle github webhooks; is there something similar for top.gg?
uh is there a way to fix this in url
{"error":"Unauthorized"}
I doubt it. You'll probably have to setup your own webserver and listen for requests
Make sure you send your secret properly. You should probably show the code that you use to send the https request
is the cooldown between votes exactly every 12 hours? or is it every 12th hour of the day, e.g 12am, 12pm?
every 12 hours
Can I use top.gg to provide stats for my website? I just want to get the server count? Is there like a public api I can use so I can have some js get the server count of my bot?
Top.gg doesn't have your server count
You provide that yourself through your bot
But if you for some reason want to get the servercount from Top.gg's site you can use the API
https://www.top.gg/api//bots/:yourbotid should have a field called "server_count"
But that obviously won't work if you don't post your stats through the API first
And it only updates every 30 minutes
what exactly is the webhook url
Is it the http://yourip:openport/dblwebhook
?
i opened that port too btw
yeah but i dont receive test webhooks, maybe i did something wrong?
Are you sure the port is actually open?
Would you be able to show your code?
The code of your webhook listener
Without the auth and token
^^
import discord
import asyncio
import dbl
import logging
from discord.ext import commands, tasks
class Vote(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'token'
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/dblwebhook', webhook_port=5555)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print("received an upvote")
print(data)
@commands.Cog.listener()
async def on_dbl_test(self, data):
print("Received a test upvote:", "\n", data, sep="")
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(Vote(bot))
Yeah that looks right
I assume you've also hit "save" after you entered that?
yup
Hmm, okay
Well, then you know the webhook url is right at least
Does it print anything if you actually vote for the bot?
nope
in that cog i have a "vote" command and that works
cog is loaded in perfectly
and no errors in console
double checked the token, correct too so ehh
also, the auto guild count update works
this happens with my webhook
code:
app = Flask('')
@app.route('/')
def home():
return "I bet you are here since you want to invite Bubble to your Discord server."
@app.route('/webhook', methods=['GET', 'POST', 'OPTIONS'])
def response():
try:
if request.headers.get('authorization') == "12619611":
giveVoteReward(request.json["id"])
return Response(status=200)
except:
print("An error occured with the webhook")
def giveVoteReward(userID):
global economyCol
economyCol.update_one({"_id" : userID}, {"$inc" : {"balance": 1000}})
print("success")
def run():
app.run(host='0.0.0.0',port=8080)
def keep_alive():
t = threading.Thread(target=run)
t.start()
not sure if the UI is misleading, or im just dumb. but i was under the impression you could 'test' without 'saving', thats how its worked on some other sites ive used in the past
spent a good hour or so because of that earlier
i mean that is not the case tho, cus the code doesnt work still, but my port is open and checked that and the webhook address is correct too
not in your case, just something that happpened to be and possibly another guy earlier :p
i think i mightve found the issue with this
it was cuz i was tryna run the function i made but since i was testing it wasn't working properly cuz it wasn't sending a user lol
can you send a manual post request to the webhook
also, are you sure thats a public ip address
https://canyouseeme.org/ to see if the ports open and visible
my friend wants to know if you can check if a user has voted for a server instead of a bot.
hi, when sharding with my bot, how would I update the autoposter and vote listener for top.gg, if anything even needs updating?
its open
copy pasted the ip from there
in the top.gg so ye
Can you try sending a mock post request to it
how do u do it?
does anyone know if you can check if a user has voted for a server instead of a bot.
ye just fill the webhook in ur server im guessing?
How do you define Response why are you not ensuring that you respond with a response at all times
Wdym I am
Oh well the try statement doesnt really matter it's just in case of error
Yeah and in case of error guess what happens
You don't respond
Because an issue is occurring
Probably
oh wow its that important?
Is there an endpoint for the last 1,000 votes for a server like there is for bots
can anyone help me with webhooks? they still arent working for me
apparently the same thing is happening to me ,_,
your listener is listening but webhook's not showing up?
yeah
i dont get it either lmao
i am having problems with the api it was working just fine and correctly before but now its just not
I can't use this ! Can anyone assist me please.
I tried this many time but didn't get where i m making mistakes 😦
Post your code and what your attempts were, then wait
Okay !
import discord,dbl
from discord.ext import commands
class TopGG(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.token = 'my_token'
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/dblwebhook', webhook_auth='MyTestPassword', webhook_port=5000)
@commands.Cog.listener()
async def on_guild_post():
print("Server count posted successfully")
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print('Received an upvote')
print(data)
@commands.Cog.listener()
async def on_dbl_test(data):
print(f"Received a test upvote:\n{data}")
def setup(bot):
bot.add_cog(TopGG(bot))
print("TopGG Loaded ! ")
And on bot page :
Webhook Url : "https://discord.com/api/webhooks/833565640379334697/mqJKmFDHgTTJV7slMuX8tzMu-DCptXR6xatlq_hbvpxWqUTnxNgdqh57XLYVe7f73WAX"
Auth : MyTestPassword
@rain heart
then
http://yourip:port/dblwebhook
Local IP ?
I have hosting my bot on heroku.com and replit
where did i find that public ip.
@rain heart
Is it same with server page ?
this one.
I need to use https://myip:port/dblwebhook/ for server voting logs.
or can use discord webhook url.
you cannot use a discord webhook
again
you need to host a webhook yourself
the code you're using is supposed to handle these requests going into your webhook for you to reward users, have logs etc
Which is why it's obvious you should use your own webhook url than discord's, as you want to receive them, not discord
i have a webhook host myself (just openened my port on my router checked if its open)
and i have it in top.gg as http://myip:port/dblwebhook/
and in code it is k
but i don't get the requests
Use postman to test it
What's the IP you're using? It cannot be 0.0.0.0 or localhost or 127.0.0.1
yeah i filled in my browser and i get this then: 405: Method Not Allowed
if you look around here, you can see someone else tried helping but no success
You cannot make a GET request to it
Use Postman to make a post request
As you're POSTing data to it
how can i make a post request?
What could "unauthorized" tell you
that it cannot connect hmm
unauthorized
Let that go through your head
Then think how you could fix that
I can (partially) guarantee you your webhook kinda works though, just you bit confused with authorizing
ill see again thank you
hey, how can I get my bot vote thing
as in when someone votes they get smth
got it
How can i get votes?
Both: https://docs.top.gg/
I DONT UNDERSTAND
What do you not understand?
Fully read the docs
i am indeed confused with the authorization, no idea how to fix that either
Authorization is what authorizes a request, add a Authorization header on reqbin with your webhook auth
If you're using JS there is a perfect example on https://www.npmjs.com/package/@top-gg/sdk
using py 
WHat is my express app?
ook so i checked right,
i have my webhook authorization (on top.gg) set to my lets say for example "code"
in my code i passed in the self.dblpy the webhook_auth="code"
but still doesnt work tho
in the reqbin i added in the header
{"authorization" : "code"}
same error
I use js
Use reqbin, then check the response
How to use vote in discord.js
yes i did, same response so i am guessing i do something completely wrong tbh but i have no idea how to fix
the blurred is always my public ip and is everywhere the same ^^
HELP ME I DONT NOW HOW TO GET VOTES
import dbl
import discord
from discord.ext import commands, tasks
import os
import asyncio
import logging
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = "my_token"
self.dbl_auth = "auth_code"
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth=self.dbl_auth, 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))
finally:
print("guild post attempt done")
@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))
Hey guys, I wanna know 2 things:
- How the use of logger affects my code! Is is necessary to post guild count or just for logging purpose of top gg API.
However it is posting count.
- My on_dbl_vote event is not working
Please Help !
It's not necessary and afaik it does nothing if it doesn't have any handlers.
But why my on dbl vote event not working
It is not printing any data on vote
def setup(bot):
global logger
logger = logging.getLogger('bot')
Also what will the logger return?
That doesn't look like any vote event related thing unless I'm wrong
-servercount
To have your bot's server count displayed on Top.gg, please read the documentation on server/shard posting.
Is there a way to let the api return a Boolean if a user voted?
is it possible to get server vote tracker ?
but my bot is not on top.gg
You need an approved bot to use the API, so you'll need to wait for that to happen then
so it's not possible to use private bot for this
I can't get my port open.
I've added port forwarding on my router but it still says port closed when you use a lookup tool
i want it to return a bool. is that possible?
ok
Anyone know how to fix it?
read the manual of your router, helps the best actually
hi, i can't fine where is the api
thx
Hi! How would I know that on the weekends, it's double rewards?
There should be a field in the vote data called "isWeekend"
def setup(bot):
global logger
logger = logging.getLogger('bot')
what will the logger return or holds?
Ah ok, thanks!
@rain heart can u help me out
no py knowledge
Anyone else?
@commands.Cog.listener()
async def on_dbl_vote(self, data):
logger.info('Received an upvote')
print(data)
Why my event not working?
Is your webhook path correct? Is the port open?
import dbl
import discord
from discord.ext import commands, tasks
import os
import asyncio
import logging
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = "my_token"
self.dbl_auth = "auth_code"
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth=self.dbl_auth, 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))
finally:
print("guild post attempt done")
@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))
did you enter the correct url in your bot page?
did you portforward incase you're hosting from your home network?
But you entered port 5000 in the client?
Now it is telling server already in use
You don't need to use flask if you're using the built-in webhook client from dblpy though
Yep just an eg
First of all you need to decide if you're gonna use flask or dplpy to listen for webhooks
dblpy @night ingot
Yes, then that url would be correct, replace 0.0.0.0 with your public IP
and add /dblwebhook at the end
http://<your public ip>:5000/dblwebhook
What if I'm using flask to listen
Then it's the same, but different port and different path
Also the event from dblpy won't work if you're using flask, so you'll need to set up your own logic for that
pls help
How do I get webhook password?
You set the webhook auth/password yourself on your bot's page
it's there to verify that the webhook is coming from Top.gg and not someone else
Hey, i have a quick question. How i get or find a API Token for the API?
bot page settings -> webhooks
?
okay
what's the authorization on your code
topgg
same as in my code
and filled that also in in the tester
Your authorization is wrong on some point
the webhook works, just your authorization being shit
post your code please, even if i dont know py
i need assistance with rewards on vote, can someone pass a github/video link? *discord.py
how can i add shards in my website?
by posting stats, see the docs above
which section exactly?
search for stats then
-b 663069883009073202
Banned PROFESSOR#1628 (@autumn verge)
I'm getting an error 404 while trying to do a test vote
It just started now
whatever you've entered
Few minutes ago it showed me the json
it isn't existent
I was telling about on dbl test and vote
can't help then
why?
post your code and wait for someone who knows your programming language
wait but you may know the reason for such error while post requesting the data
Under the stars
There flies a bird
It flies around
And yells at you...
SEND YOUR CODE
what are you trying
what?
What have you tried, which examples are you using
but what tells you 404
What's your webhook_path
then your webhook is making a request to something non existent
Instead of the data json I am getting this
read what shiv said
□
Duh
I am getting the post request anyways
what?
your webhook is literally http://yourip:port/http://localhost/dblwebhook
according to your path
only set it to /dblwebhook
My application is getting the post request and the problem is instead of the data containing the vote details it sends my app 404 Error
read what i just said
please
your path is set to http://localhost/dblwebhook, which automatically makes your whole webhook url http://yourip:port/http://localhost/dblwebhook
only set it to /dblwebhook
is it related to the top.gg api?
webhook_path is only the path not the full url
exactly
I don't quite understand what you say btw
Under the dark sky there is a light
It flies around like a shining star
And the star shall say to thee once more
Read the fucking docs, you utter cock
webhook_path is not your full url
path
not related to the api
not related to the 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.
http://69.42.13.37:1337/mypath
/mypath is your webhook_path
ngl I swear I'm about to make a github wiki with FAQ stuff
the server count on my bots top.gg page is wrong. it doesnt seem to be throwing any errors either because we made it send a message when an error occurs
why is the count not working?
it doesnt update right away if you're expecting that
http://my_application.cu/dblwebhook my current webhook URL
its the same for days now
your constructor
Yes so set your webhook_path to /dblwebhook for fucking crying out loud
what lib?