#topgg-api
1 messages Β· Page 126 of 1
How do I get the port?
ok
u got it?
Yes
alr
then in init
webhook_path='/dblwebhook', webhook_auth='Your password', webhook_port=Your Port
Where's init again, Sorry
this
Ok
Ok
you got it?
Yes
Ok
with get channel where it should send the test
Ok
@commands.Cog.listener()
async def on_dbl_test(self):
channel = await self.bot.get_channel(794922248943304706)
like that?
self, data
Ok
and also await channel.send('test')
Ok
Ok
did it work?
no
is there a error?
no
yeah, then the port is unreachable
What should I put as the port then?
do u have a hoster?
Yes
Maybe your host has its own port
I found it's port
alright then enter it
Same thing
Is the IP you entered that from your bot?
How do I get the ip from my bot?
Should be on your panel
Does your bot hoster have a panel?
Where would it be?
Where you can start up your bot etc
At the dashboard of my host
the ip or port
you need both
I found the port on the internet
the port and IP should be on your dashboard
I've looked everywhere and it doesn't say
well you need to get it
I can't
You can't do it then I think
Is their any ratelimits
Aww :(
referring to the top.gg api?
Any endpoint: 200/second
Stats post: 60/minute
Ban when exceeded: 1 hour
LMFAO
He means the route where you post your bot's stats
So you can post your stats max. 60/minute
"60 times in a minute"
soo @willow spindle If I have a event that dms the user when they vote theirs no ratelimit on that?
I too had this when I wanted to create a link
bruh soos
@modest oar vote for me bot and see what happenens
Were you able to fix it?
u aswell please I want to see if it actually works
ok
can anyone help me setting the API up for Discord.py?
can somebody help me with the api for javascript? im using newest discord.js-version and i am trying to do postStats() but it says me that shard is undefined
@dull thicket @modest oar you guys know that is a test button to test the webhook?
@dull thicket @modest oar you guys know that there is a test button to test the webhook?
@regal harbor Yea I do
@regal harbor Yea I do
@regal harbor Yea
@regal harbor Yea
okay thank you got it working π
how i get token dbl
ok
How to make an API for my website.?
a website runs on a server
the server can have an api
but how you do it depends on which language you're using and other stuff
@hot axle JavaScript
you can use https://expressjs.com
what it does? tbh i did not understand
discord.js v12:
const client = new Discord.Client({
sync: true,
ws: { intents: 1537 }
});
const AutoPoster = require(`topgg-autoposter`);
AutoPoster(my_topgg_token, client);
Error: Unsupported Client
does anyone know why?
is this discord.js or eris
discord.js
i don't think there is sync option in D.js client options
Hello, I am trying to set up a server webhook (not bot) to reward user for voting. How can I obtain the dbltoken?
go to the api page and go to "my bots"
I don't have a bot
well you need a bot to get a dbl token
alright
I think I am approaching this the wrong way
does top.gg has doc for server webhook?
well, technically you can make a webhook without a bot
but it wouldn't be of any use, since you can't use it anywhere
so I am trying to make a webhook that return the users who voted my server
the user are voting for the server which isn't a bot
how do I setup this webhook?
yup
I don't have a bot
so I am confused about how to use the mybot page for my server
Does the widget api route still function properly? It hasn't updated my bot's server/upvote count in quite some time.
New node @top-gg/sdk version 3.0.6
Fixed an issue where if a user was using a different body parser, e.g body-parser, that uses the raw-body package, the parser would fail.
Now returns req.body content if one is available before parsing.
how to i setting a voting system like someone voted my bot then my boy sending a message in the dm "Thanks for vote me!"
Through the webhook mechanics, but remember that your bot cannot dm users that do not share a server with the bot and has dms disabled
how i will use that
Auth is the Key that you can define inside of your code
oh
Also, seems like you're using a discord webhook, a discord webhook doesn't work
uh my server not NFSW
ok
Make sure to keep to the correct channels though please
I did the stupidest thing

Top.GG API Error: 404 Not Found why?
More input, what library, what endpoint are you trying?
at Api._request (/home/container/node_modules/@top-gg/sdk/dist/structs/Api.js:74:19)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Api.postStats (/home/container/node_modules/@top-gg/sdk/dist/structs/Api.js:94:9)
(node:11) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2) ``` discord.js endpoint top.gg/sdk
setInterval(() => {
api.postStats({
serverCount: client.guilds.cache.size,
shardCount: client.options.shardCount
})
}, 600000)```
make sure you're using the newest package version
ok
How do I get the auth of the webhook? I searched and didn't find where that is
Auth is the authorization you can use to identify the request is coming from top.gg
Just to clarify: A discord webhook cannot be used
I don't want to use discord's webhook, I want to put this in a bot
and you need this to keep me going
Yeah, then the authorization you used in your code
But I don't know where I get this auth, I went to the site and I couldn't find it
Ah, is it for me to create the password?
On the github (https://github.com/top-gg/node-sdk)
correct
you need to make the auth yourself, name it whatever you want
then enter it on the bot page settings under Authorization
Ah, thank you so much, I thought I was supposed to get the password somewhere

Cheers
Did I do something wrong?
You cannot use webhooks yet if your bot isn't approved
Okay I am not sure where to go from here. I want to do x when someone voted but I am not sure what I need to do for that, I know the event but Idk how to define dbl
I didn't know, thanks
Please ping me when responding, thanks
What language?
The url should be something like http://yourserverip:port/context
for example http://1.1.1.1:5000/dblwebhook
the ip being from my pc or from the host I am using or...?
Don't see anything saying port thoug, do I just use 5000?
You need Authorizaion aswell
for the api
Which is your top.gg token
Yup
The Authorizaion header
Good job 
how to use Top.gg AutoPoster?
const AutoPoster = require('topgg-autoposter')
const ap = AutoPoster('topggtoken', client)
Just that !
?
Yeah that should work i think
topggtoken=my bot api key?
your top.gg api token
π
Could you give me a link?
Couldn't find it anywhere... I know how to do the stuff once I have the connection, can you just tell me what I need to do before py @commands.Cog.listener() async def on_dbl_vote(data): print(data)
Again, I have never worked with webhooks
Could you give me more specific info instead of referring to the docs?
I believe you have to pass the kwargs into that class
I don't use this API but it seems that does everything for you with the correct kwargs set
I added this to the ready and it didn't work I put my token
const DBL = require("dblapi.js");
const dbl = new DBL('token here', bot);
setInterval(() => {
dbl.postStats(bot.guilds.cache.size);
}, 1800000);```
Can I just put any URL in that field?
Webhook URL
We will attempt to perform a POST request to this URL when sending you webhook data.
Or is that that thing
I want it to show on top.gg on how many servers the bot is
Is this code correct for now? ```py
import discord
from discord.ext import commands
import dbl
class dbl(commands.Cog):
def __init__(self, client):
self.client = client
self.token = 'ToKeN-I-wOnT-sHoW'
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='Some really creative password', webhook_port=5000)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print(data)
def setup(client):
client.add_cog(dbl(client))```
Is that your IP commented out
this would be http://yourip:5000/dblwebhook
I tried that and that did not work when I test send a webhook
Did you press save on the webhook setting
I did
Webhook URL is what you just told me and Authorization is webhook_auth right?
Make sure port 5000 is open
Wdym
Exactly what it says. It's possible that your machine has a firewall that blocks requests coming to port 5000
ok im hosting my bot on a pi so would i put the pi ip or...
you need to portforward then
sorry im dumb wha does that mean
And on your router
k
Where does it post guild count
I don't understand the code, someone explain? And any way I can make it DM me the server count when it updates or send it in a channel
I used an open port now and still nothing happens
the on_guild_post can send you a dm/channel
it autoupdates automatically
oh
you don't see it
ok
Apply listener decorator to on_guild_post
Hi I did the npm thing for top.gg and after installing I got a critical security warning from windows security thing. It said that the app downloads other apps
And to remove it
can be ignored, that's just a warning
unless you installed the wrong one
make sure it is @top.gg/sdk
Ok
Page not found
Bruh wtf
Sorry
Lol
Is that the wrong one
or in the new docs https://docs.top.gg
Ok thx
aaa top-gg*
tf? ```diff
- AttributeError: type object 'dbl' has no attribute 'DBLClient'```
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='If you see this you are cool', webhook_port=57621)```
Idk why I did wrong?
@rain heart (sorry for the ping)
Please ping me when responding
you did import dbl right?
Did you name any folder or file dbl?
Only my class
Well yeah
I see
So I have an economy system would it be possible to give users a bonus reward when they vote. If do is there anything that could help me code it....
So*
the webhooks are for that. you can find code examples on the docs.
https://top.gg/api/docs
Thx
Code now: ```py
import discord
from discord.ext import commands
import dbl
class vote(commands.Cog):
def __init__(self, client):
self.client = client
self.token = 'My-ToKeN' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.client, self.token, webhook_path='/dblwebhook', webhook_auth='Password', webhook_port=17500)
@commands.Cog.listener()
async def on_ready(self):
print(dbl.__version__)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print('Someone voted')
print(data)
def setup(client):
client.add_cog(vote(client))```
This prints me the correct version but doesn't react to test webhook sends. The port is open, the IP correct
who's ghost pinging me?
Could someone help me?
I really need help here 
how do I set up the webhook?
no I mean the webhook for the TopGG class
idk

Thought so
self.bot scared me
so to receive upvote webhooks on python, what's the best library to go about creating a web server for that. I saw many examples, i think http.server seems the best, just wanted a second opinion just in case there is a better way to go about receiving webhooks. thanks!
im confused about the webhook stuff π
I dont understand what webhook path, webhook auth or webhook port means, do I need this to use on_dbl_vote
im using dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) without it
i believe you need to create a webserver for it, i used to use webhooks on my d.js bot with dbl (receive on local machine), for that i created a webserver, port forwarded the port i specified on the website and it worked fine
however in the api i never saw the option to specify a server for DBLClient so maybe its different x-x
aye
anyone here
use the api with python
I need help 
yoi
Hi guys
@shut flume are you pro at api?
of bots
yes or no
no i mean
api of bot
Yes
Someone tell me in #support
@shut flume so you can help me?
@shut flume thanks for help bro bye
same I dont understand webhooks for dbl at all π
same bro π
it's cancer
π
What the hell is webhook_path, webhook_auth and webhook_port I have no idea, I just want my on_dbl_vote thing to work π
SAME π¦
π
devil we should kiss and makeout
we relate soo much
im scared now
lmaooo
jk jk
Anyone?
Am I supposed to put stuff here
Im so confused im completely new to webhooks etc
What am I supposed to put here aswell
I just dont understand any of it
lol I dont know what that means as I said Im completely new to all of this stuff
ahhh why do I have to do this just to get the on_dbl_vote to workkkkk ahhhh I dont understand anything anymoreeeeeeee
why cant that be done through the api, why does it have to be done through webhook
I cant find any good guides or explainations how to do this
Ah I cant if I dont know what that is, also I cant its not my router so I cant access the settings
Why do I need that just to receive data on who voted
for example discords api gets users id's etc why cant dbl do the same for who votes
how, you just said you needed to use webhooks
still confused about all the webhook stuff however Ive found another way to do what I want for now, thanks to this #topgg-api message
Thanks for the help
dblpy iirc
is there any way for me to get the time of when someone voted through the .hasVoted() function in the js library or do i have to use webhooks (pls ping with response)
How to add this feature in my bot Plzz help
So any body can't help okk
using the api https://top.gg/api/docs
man
if only who knew how to use topgg api with python π
I need some help π
the py lib docs can help with it https://dblpy.readthedocs.io/en/latest/api.html
A simple API wrapper for top.gg written in Python. Contribute to top-gg/python-sdk development by creating an account on GitHub.
Wha is that?
I u want to use top.gg api u have to read this
but u must have ur bot in top.gg I mean ur bot must be applied
I can't understand
Alright
wait
oh
sorry
I just realized
i can't use the api
π
@fast agate
os I gotta make one on my own
okie no problem
lol, nice
new in programing world?
Where's the docs for the server vote webhook? I need to reference what data it includes
That's for bots
I had seen the one for servers when I first made my webserver but I can't find it now
TypeError: Cannot read property 'on' of undefined
const DBL = require("dblapi.js");
const dbl = new DBL('my-super-secret-token', client);
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
what's the issue...
webhook is undefined
it is defined in the package
wait, does that mean, i'll need to forward port 3000 so top.gg can access it?
If you're hosting it locally, yes
Well, you still had to do it if you were using dblapi.js
oh well, i just won't use it for now i guess
How can i set up the password and the link (webhook)
discord.js
turkish
how can i use discord webhooks for this?
dbl.postStats({
serverCount: client.guilds.cache.size
})
}, 1800000)``` this is not working and giving error
Error: 400 Bad Request
@restive otter use https://npmjs.com/topgg-autoposter
Need api foe welcome command
wdym?
how do i find the ip of a website thats it being hosted ok
like repl is where its hosted
cmd -> ping domain.extension -t
will return the server ip unless it's behind cloudflare/other
How can I check if somone voted for the bot on discord.py?
make a request to the top.gg api
i think there was a /check route or something
/bots/{bot-id}/check?userId=some-user-id
alr thanks
how to get api key
api docs -> "My bots"
what is password
bruh
Just a quick question. Is the @top-gg/sdk module required for the topgg-autoposter module to work or can i just use topgg-autoposter by itself?
Please ping me if you want to reply
I'd say https://tryitands.ee
hi
definetly helped dude
Is there any way I can test out my voting system without begging my friends to vote for my bot again?
what is API to bring up the number of servers?
@restive otter u want to post your servers or get other peoples servers? and what language are you using
post my server and i use javascript when they search for the bot, the number of servers appears
what does he do
it posts your stats
this?
yes
Just a quick question. Is the @top-gg/sdk module required for the topgg-autoposter module to work or can i just use topgg-autoposter by itself?
oh thanks
its how node works, itll end up being installed anyways
inside the client.on?
https://top.gg/api/docs#mybots to get your token
can I create a file called topgg.js and put it?
sure, you just have to pass the client
your client that you made, like const client = new Discord.Client()
wherever you put that you just have to pass that along
where do i put this key?
const AutoPoster = require('topgg-autoposter')
const ap = AutoPoster('topggtoken', client) // your discord.js or eris client
// optional
ap.on('posted', () => { // ran when succesfully posted
console.log('Posted stats to top.gg')
})```
replace topggtoken with your key and client with your client
this?
why
yup
is it in the index.js okay?
yea
go to it and hit refresh data
and if that still doesnt work just give it a few minutes for cache to load
as long as it says "Posted stats to top.gg" in your console it'll work
idk
just paste the code under where you define client
I'd just like to say i've been watching this struggle the whole time, you have patience i'll give you that
try it
How to create API for my Discord bot
see if it logs
xd
a
@hearty lintel hi I wanna Make website but I can't because I need API of the bot how
why client
gonna need to be a lot more specific please
cuz u defined your client as bot not client, so put bot instead of client

@hearty lintel you know when we make website we need to connect the bot with the website but first we need API
does this have to do with top.gg or are you talking about the authorize button on discord?
?
wh
no
in the AutoPoster(..., client)
replace client with the name of what you defined Discord.Client() as
so remove that const Bot and change this to bot
okkk

yess
refresh data and or give it a few minutes to flush cache
thanks you <3.



yes
berry nice

Bump on this. Never got a reply.
works for me, you're using the widget code right? copying the image
is the on_dbl_vote event (python) the non-webhook implementation?
like its delayed
https://discordbots.org/api/widget/id.svg
@hearty lintel
Used it for a long time, stopped working 500 servers ago though.
so your html code looks like this?
<a href="https://top.gg/bot/394019914157129728">
<img src="https://top.gg/api/widget/394019914157129728.svg" alt="Censor Bot" />
</a>```
Img tag, but essentially.
The image loads, but the server count looks behind. Oh, perhaps the post to the endpoint is actually the issue
Oh lmao
u sure ur posting didnt break lol?
what lang do u use?
if js should use the new package
"new package"?
That... Isn't the issue lol. Did the endpoint change in any way other than the domain?
i see, uh not much changed no
can someone please explain this thing to me is it optional is it not, the documents dont help
im trying to make a reward system for my bot's users...
so then yes you needa make a webhook
but then how do i make a webhook??? thats what i dont understand
open a port and use the library for your language to handle it
top.gg -> your webhook handler (webserver)
you can then process it
or store it
do whatever the fuck you wanna
Will this work, I am trying to make a bot that will say bruh whenever you type something
<Client>.on('message', message => {
//handle bruh
});
yea
Thanks
how do I see if a user has voted?
but I thought I had to use the @topgg/sdk or whatever?
there used to be a feature to show your bots library, this has been deprecated, its not been removed from the widget yet @winter basin
when I use the .hasVoted function, does it only return true if they have voted in the last 12 hours?
okk
Hi
my dudes does anyone knows how to make a server count actually working with discord.py
the example doesn't work for shit
could this be because of the environ.get?
Apply cog listener decorator to on_guild_post and make sure you're loading the cog
Press Refresh Data on the bot's page just in case
Fun
it throws an error
What error
what's the error then
that it doesnt load
Yeah, that's not helpful
What's your dblpy version
they cant cload
havent tried it locally tbh
lol try it locally
alright yeah i just thought someone had a similar situation so it will be quick fix. I tried the python script just like in console didnt throw any errors
if it doesn't work, change the env function to os.getenv
you should have done that first tbh
likely os.environ.get is throwing
due to not having that environment variable
more than likely not
alright
While sharing the number of DBL servers, socket hang up gives an error, same code on the site
how do I check if someone voted with an if statement in discord.py?
thanks
@commands.command()
async def votereward(self, ctx):
if ctx.author isVoted == 1:
@shut flume something like this?
well i get invalid syntax lmao
and I can't find anything in the docs about that


Either use dblpy's webhook feature or host an async webhook manually with aiohttp.web/Sanic
I didnt understand hald a word
Which part exactly did you not understand?
top.gg used to be named Discord Bot List (Discord Bots) before and I've been too busy with random shit to fully migrate to the recent changes
As for the webhook feature, https://dblpy.readthedocs.io/en/latest/api.html#dbl.DBLClient
Oki, thx
Doesn't the client.hasVoted() boolean reset every 12 hours?
Good question
ofc it does, as you can revote every 12 hours
its been 12 hours but i dont think that hasVoted() function working probably
how long exactly has it been?
is it you? like are you checking yourself?
yep
https://top.gg/api/bots/789629205611937792/check?userId=745038831472083065 if you go to this is it voted: 1?
voted 0
what's your hasVoted code?
if (topgg.hasVoted(data.user.id) === false) {
alert("You need to vote ZAP-UP on top.gg for using dashboard.");
return router.push("https://top.gg/bot/789629205611937792/vote");
}
are you using it in your browser?
are you passing a token?
yes
i dont think so
i think you're getting an error its just the library doesnt handle it properly
can you show where you define topgg
.hasVoted is asynchronous
ah
await topgg.hasVoted(...) ...
np
Hey, I'm trying to make a request to top.gg/api/bot/:bot_id (obviously the bot id is there) and it says err: Not found, any ideas? I'm sending a request from chrome.
don't have the actual : in the url
I know that
Good 
yeah figured that it is
It is correctly documented on the partially new one https://docs.top.gg/api/bot/
so is it on the old ones? https://cdn.hopefuls.de/UViv
oh ok
I am trying to run the webhook and when it starts i get the start message just it doesn't get when someone votes
Oh fuck nvm brain fart
Make sure you entered it inside your bot page settings
under "Webhooks"
Hi! emm, i do a code for the votes in discord bot, but it don't send the webhook
can i send my code?
if is that correct, yes..
Discord webhooks still do not work
hu, why?
because discord webhooks have their own format that is different than top.gg's
which is why you make your own webhook receiver with code.
Sorry if this is a stupid question, but how do I interact with the api without posting guild counts (using the js lib)?
normally it doesn't even post the guild count unless you explicitly code that in
so just use the lib like normal
and don't use the post method
Β―\_(γ)_/Β―
Oh fair enough, thanks
I'm confused on how to setup a webhook for the api
would it just be https://serverip/port?
rip is there any cooldown for changing it?
ig I'll just have to wait if there is a delay
webhook_path='/dblwebhook' is this supposed to be the webhook url?
+1
make what? the url?
thats just the path part of the url, not the entire url
http://ip:port/path
what is the path?
well in the example you gave the path you set is dblwebhook
I just copied that from the docs bc I have no clue what it is used for
do I need it?
it sets the path of the url
if you dont use it your path will be the default of the lib, or blank depending on the lib.
Traceback (most recent call last):
File "/home/container/libs/aiohttp/web_protocol.py", line 275, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
File "aiohttp/_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: invalid HTTP method
I keep getting that
I'm not sure why
I have the correct token, webhook_auth and webhook_port
I dont think that error is anything to worry about
#topgg-api message
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print("Got upvote")
print(data)
that method is not being called though?
you filled in the url and auth on the website correctly?
ah that's prob it
filling in ip and port and path
also, the dblpy lib seems to have a default path, leaving it blank doesnt mean you have no path.
https://dblpy.readthedocs.io/en/latest/api.html#client
ah ok
@jaunty plank ?
use the api https://top.gg/api/docs#intro
thanks
after fixing the path I am still not getting anything
yes
do you have any firewalls blocking the port?
shouldn't
if on a home network is it port forwarded
or even some VPS's require portforwarding
webhooks are kind of like backwards api's
the top.gg server sends a request to you, rather than you sending a request to it.
any string as long as its the same between your code and the website.
and if the webhook url is http://ip/:port/dbl
webhook_path = '/dbl' should work?
ah ok
is webhook_port required? is it supposed to be something different from the port I provided for the webhook url?
you should be setting a port yes, it can be any valid port you want that is not being used already.
https://dblpy.readthedocs.io/en/latest/api.html#client
while its marked as optional, its required to enable the web hook.
sorry if this is a dumb question I know almost nothing about webhooks but if I am using the port for something like accessing the reddit api would it still work for dblpy?
i dont think the reddit api requires a port, unless they also have a webhook feature.
but mostly, no ports cant be used twice.
but since theres 10's of thousands of valid ports, its not really a problem to use another one
yeah but rn I only have 1 port available from my hosting service
does the reddit api require a port? π€
i dont think the reddit api even uses ports
would I have to setup anything in my server for the webhook to work?
other than that?
hmm
well it seems like it is getting a request
Error handling request
Traceback (most recent call last):
File "/home/container/libs/aiohttp/web_protocol.py", line 275, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
File "aiohttp/_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: invalid HTTP method
but the method is not being called
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print("Got upvote")
print(data)
the lib dev says that error shouldnt affect anything π€·ββοΈ
I am using dblpy
are you using the test button to test it?
yes
that method is only for real votes
π€¦
the on_dbl_test method is for test votes.
I need to port forward for setting up a webhook for my bot?
Ok thanks
Ok, so what i put in that field?
in the url field, you put the url of your webhook receiver.
in the auth field you put the auth of your webhook receiver.
and how i get this?
@jaunty plank
the url?
yes
its typically http://ip:port/path
ip is your servers public ip
port is defined in your code
path is defined in your code
now this isnt completely related to the API but, i'm using aiohttp web App to handle the webhooks in my bot code (bc i dont want multiple connections to the DB)
(assuming this is inside the on_ready event of the bot)
app = web.Application()
routes = web.RouteTableDef()
@routes.post('/post')
async def post_handler(request: web.Request):
print("here")
return web.Response()
app.add_routes(routes)
runner = web.AppRunner(app)
await runner.setup()
site = web.TCPSite(runner, 'localhost', PORT)
await site.start()
however, whenever i test the webhook, it doesn't seem to be handled by the handler. Any suggestions on what i'm doing wrong?
is this the correct way to go about it?
i tried changing the decorator to @routes.post('/dblwebhook') also but no effect. I can confirm the URL on website is correct, as i tested it through a local http server on the same port and it works fine
if it functions locally but not remotely its typically a sign a firewall is preventing it from working.
alright, thanks i'll look into it!
seems you were right its only external connections
sorry to bother, but do you happen to have an idea on how to overcome this? when i create an http.server all post requests come through, so i am not 100% sure if its the firewall(?), but i couldn't really find a way to troubleshoot this. thanks
the webhook is just an http server, so im not sure.
With the python library, how would I reward the user that votes my bot on an on_dbl_vote event?
the passed arg in the function is a dictionary
Get the user key and you get the user ID in a string
Yo, so when I launch my bot and it runs the webhook it returns with ```
Webhook running at http://0.0.0.0:2002/dblwebhook
is this something I should worry about?
ipv4 ip?
@old patio curl -sL api.ipify.org to see ur public ip
Because webhooks are understandable through both common sense in programming, aswell as the documentation, which most people don't even read
Everyone who has done atleast one thing with ips know that ips starting with 192.168 are normally local ones and that you cannot connect to them from external connections
I know the conversation is finished, but you can also forward your localhost through a service on your behalf to test the webhook. That's what I did, at least.
ngrok was a fairly useful / free tool to do this with.
What about them?
how do I receive vote updates
The webhooks can receive votes that go through your bot
sure
Correct
That can be done through your bots code
some libraries have a webhook built-in you can use
ngl still dont understand lol
how
like?
What library are you using
discord.js
Then you're not ready to do it yet imo
I want to see the voters of my bot in my question, how can I do this?
with the new @restive otter/sdk package, can i still post stats on the guildCreate event?
Yes
ok
i don't advise doing that
mk
i'd just post every 30 minutes
does python have one, if it does could you send me a link like you did with the other person please
thanks
from aiohttp import web
PORT = 1234 #Some Number that is Port Forwarded
app = web.Application()
async def post_handler(request: web.Request):
# STUFF
return web.Response()
async def handler(request: web.Request):
return web.Response(text="Hello")
app.add_routes([web.get('/', handler), web.post('/dblwebhook', post_handler)])
runner = web.AppRunner(app)
await runner.setup()
site = web.TCPSite(runner, 'localhost', PORT)
try:
await site.start()
print('listening on Port:', PORT)
except:
pass
I'm using aiohttp web App (with application runner so i can run the code with my bot code). For some reason, it works just fine locally, but trying to send GET / POST requests from outside doesn't work. I can confirm its port forwarded correctly and it doesn't seem to be an issue with firewall either. Any suggestions? (Tbh, i've asked this question before but hoping to find some resolution today)
EDIT: All of this is inside the on_ready event of discord Bot.
does POST return anything? like a message or something
depends on endpoint
stats doesn't return anything
yeah none of the post-ones return anything
just 200 on a successful post, 403 without any authorization/wrong authorization, and 429 if ratelimited
Can you send me the URL you entered on top.gg
its my public ip
you want to test it?
Either that or see if you're entering it correctly
well its MY_PUBLIC_IP:PORT/dblwebhook
its only with aiohttp web server that i cant get it to work, it works fine with http.server library
but since its not asynchronous, i'm forced to resolve to aiohttp
Prepend http:// to the URL
okay i'll try that
get it from the My Bots section of the apidocs
π thx
oh wait mb, it does have http:// before that, sorry
Interesting
if(args[0].toLowerCase() == 'vote') {
if(dbl.hasVoted(msg.author.id)) {
msg.channel.send(':white_check_mark:')
}else{
msg.channel.send(':x:')
}
}
its always sends β what's the problem
Then that user has most likely voted already, let the hasVoted print out
i did it for another account but its still β
let the dbl.hasVoted print out and see if it returns true or false
ok
msg.channel.send(dbl.hasVoted)
Im adding this
msg.channel.send(dbl.hasVoted(msg.author.id))
its printed: Promise { <pending> }
are you here
ok



