#topgg-api
1 messages ยท Page 151 of 1
use this event for testing
this event for actual vote
Ye, the logic is pretty simple, everytime TopGG makes a request to your server, you make a request to Discord API.
@commands.Cog.listener()
async def on_dbl_test(self, data):
vote_data = data
print(vote_data)
i have this too
@restive otter thx
Ooo
its not working
Oo ok
try to use port: 8080
i think i found the error
doesnt repl come with https?
I used http for webhook
if you dont have https, dont. but repl has it afaik.
thats normal
yaa it's normal
try port 8080
logger.info("Received an upvote")
alr
its working right. 404: not found is what the py lib responds with when you get request it
as its a webhook, your not supposed to get request it
ok
ie, its not supposed to go in your browser.
๐ are you not reading what im saying
im confused
class TopGG(Cog):
def __init__(self, bot):
self.bot = bot
self.token = os.environ.get("TOPGG_KEY")
self.auth = os.environ.get("TOPGG_AUTH")
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path="/dblwebhook", webhook_auth = f"{self.auth}", webhook_port = 8080)
self.update_stats_channel = self.bot.get_channel(828347053331185704)
self.update_stats.start()
@tasks.loop(minutes=30.0)
async def update_stats(self):
await self.update_stats_channel.send('Attempting to post server count on top.gg')
try:
await self.dblpy.post_guild_count()
await self.update_stats_channel.send('Posted server count on top.gg ({})'.format(self.dblpy.guild_count()))
except Exception as e:
await self.update_stats_channel.send('Failed to post server count on top.gg\n{}: {}'.format(type(e).__name__, e))
@commands.Cog.listener()
async def on_dbl_test(self, data):
vote_data = data
print(vote_data)
add your path on the end, put it in the webhook section
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))
lmao you did a mistake @restive otter
check the spelling
Mayy
oh right
Bot
omfg
caps
๐
Shouldn't it return 405
returns keyerror
It's isWeekend afaik
data["isWeekend"]
Also, better leave it as bool instead of casting it as str
As "false" is truthy
kk
Or "False", w/e you got the gist
๐คทโโ๏ธ im not the developer.
It does return 405 afaik
Oh yeah mb, that wasn't even the webhook endpoint
Has anyone tried opening ports with Google Cloud VMs for the webhook?
Idk if it would even work
You can make a new firewall rule that targets your vm or a network tag the vm has
You mean with ufw right?
I meant the dashboard
Do you know what the webhook URL would look like in that scenario?
Oh yeah I did that but nothing was showing up in logs for me
Idk what I'm doing wrong tbh
Do I need to have the bot online for it to fire?
For what to fire?
For me to receive the data
You need to run a webserver
Allowing through the firewall doesn't do anything if there's nothing running on the port
Is apache okay
How do I make a vote mandatory command in my bot with dbd.js?
Lol
How would I implement the authorization code into my Nginx proxy
no ๐ณ
How should I start first?
I will be happy if someone tells me how I can do it ๐
What the fu** is wrong with top.gg and webhooks? https://cdn.discordapp.com/attachments/714045415707770900/836600653438255134/unknown.png

post your code, explain your approach etc
UH
How can I learn in detail the webhook called here @rain heart
Hello How I can Add Like The
by using the API: https://docs.top.gg
@warm crystal I have a guide here on how to implement it here
https://comhad.github.io/webhook.html
Thank you. I read so what do I do now?
follow the steps on there
How can I get the Votes with discord.py ?
<coroutine object DBLClient.get_bot_upvotes at 0x0000015653B780C0> he send me this
Looks like you might need to await it @restive otter
Hmm
no it does not work
@rain heart I don't know how to print the number of votes my bot has
see above
<coroutine object DBLClient.get_bot_upvotes at 0x0000015653B780C0>
this is what i get
where ?
You can only do it once your bot is approved
My Bot is approved
I have created webhooks. It works. But how do I make a vote required command?
You'll want to store votes in a database and check if they voted.
More of a #development question at that point.
okey
I'm not entirely sure what you mean, but if you mean a command where voting is required to use it, i logged all of my votes in a sqlite3 database and do a look up whenever somebody asks for it

@restive otter don't spam emojis in every channel please

So i've port forwarded the other router
But it still doesn't work
but
at least i get this now on reqbin
does that mean that i've port forwarded correctly?
?
wait i think i have it confused
what is the endpoint?
is it not this?
ohhh
wait no
is it myipadress:5000/dblwebhook?
Yes
well
i put my ipv4 in
if i put my router's it doesn't even show me this
but for now it just shows me that
You cannot make GET requests
meaning you can't just visit your webhook using your browser
or make a get request through postman
use reqbin to test it please
i did
const express = require('express');
const Topgg = require('@top-gg/sdk');
const topgg = new Topgg.Api(topgg_id);
const app = express();
const webhook = new Topgg.Webhook(webhook_authenticator);
app.post('/dblwebhook', webhook.listener(vote =>
{
console.log(vote);
console.log(vote.user);
}));
app.listen(5000);
yeah?
what should i have put?
Authorization header missing
I never understood that
That should be in the header of your request
Is this the request?
You don't need an auth header for vote webhooks, no
i'm sorry i'm very confused
that's only for when you're making a request to the API
You need an Authorization header for your webhook
You defined one
otherwise it would not respond with that
webhook_authenticator
Whatever is defined as that
is your Webhook Authorization
which you need to define as a Header with the request
The HTTP Authorization request header contains the
credentials to authenticate a user agent with a server, usually, but not
necessarily,ย after the server has responded with a 401
Unauthorized status and the WWW-Authenticate header.
it is not the top.gg token
something you define yourself
like a password to authorize the request
just read what I sent
does it matter which one of these three i choose?
It's a bot right
yes
{
"bot": "12345",
"user": "12345",
"type": "test",
"isWeekend": false,
"query": "?random=true&code=123"
}
wait
wut
use this as test data
this is what top.gg sends
use this in your request body
in the content
2xx meaning success
just responds with 204 as there's nothing to return after you made a request
check your console
woah
ok this is nice
does that mean that the invite command should work
not command
listener
One message removed from a suspended account.
i agree
should i use the links you provided
for that
-api
@scarlet cobalt
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.
One message removed from a suspended account.
One message removed from a suspended account.
wdym failed
what's the response you're getting
fetch is making a get request
just saying
FetchError: request to https://ipaddress:5000/dblwebhook failed, reason: write EPROTO 25216:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332:
oh yeah
bruh
i can't do that can i
ok anyway
i tried what you said
it does this
and then nothing
it has to be your public ip address
Then the port isn't open or the IP not correct
try using your public ip on reqbin
don't use the chrome extension though, as you want your webhook to work externally
i tried without and it does nothing
This is one of the reasons why I suggest only using webhooks on vps, as you don't have to go through the portforwarding mumbo jumbo
but i did
i port forwarded through both routers
in exactly the same way as the minecraft server
with only port changed to 5000
and i gave it a pass on the firewall with inbound rules
for both TCP and UDP
is there anything else i need to do?
Then I'm clueless from my end
wait lemme show you
this is on the router i am connected to which is not connected to the internet but to the other router
this is on the router my router is connected to that is also connected to the internet
Again I have no other clue if that doesn't work
And there's no chance that something is wrong in the code?
it's 100% the port forwarding's fault?
Are you using your public IPv4 address as host?
Visit https://icanhazip.com/ and tell me if it shows up an IPv4 or IPv6 (I don't need the IP itself)
ipv4
the same that google gave me
ok can someone tell me now how i could make ```py
global trophy
with open('trophy.json') as f:
trophy = json.load(f)
its in my main.py but i also want it for my topgg cog
Alright, that probably means your ISP is still blocking the traffic (even if your router allows port forwarding)
I have a minecraft server that my friends can join to
Does that mean anything?

It isn't blocking that
And it's port forwarded in exactly the same way
Did you see the status is off?
And btw. it's a TCP connection; not needed to forward UDP connections on that port
i had turned it off to test
but then i didn't save'
when i turned it back on
oh
ok
does it matter at all?
i mean i know there is a difference (UDP is slower but more secure i think)
but will it make it slower or something
Yes, never open up protocols or ports you don't wanna open up!
Oh ok
The connection will never use UDP as protocol.
It's a TCP connection.
^^
Just out of curiosity, can i ask why it's TCP and not UDP?
i don't know python my guy i'm on javascript
oh
lmao... that may be a good question for Google; instead of me copy&pasting Wikipedia lol
they are connection (oriented) protocols
Is it normal for app.listeners() to be 0?
If you're not talking about the topgg API you may ask in #development
What exactly is 0? I don't get that question.
this
ok it seems to be fine
apparently it is normal
thanks for all the help Aurel and Fake
The TCP connection is being started and closed if you respond, which means it may is closed already if you try to log the connection
But I'm not sure about that one tbh
๐
still getting multiple calls for votes with the new webhooks, closing each connection, and responding with 200
reported this error multiple times
devs seem not to be looking into the issue
for reference
@elfin solstice
Ever since you updated the webhooks, it's sending multiple calls from diff servers
First off you are the only one complaining about it, couple of hundred people using it without any issue and that is the reason i doubt its a fault on our side
second off, you are using the officially lib right?
i bet its something on your side with versions cause they added support for it in a later patch version
you can just try to use express directly without that lib and see if that works
i would try that for now
How would I implement the authorization code into my Nginx proxy
Anyone?
I'll check. Iv'e used the same server and code for a year and never had any issues, starting 2 days after your announcement, this started
yea cause as i said already before
it was broken
for years
and then i actually fixed it and people doing it wrong then had issues
it was just working because it was super broken on our side
and when i fixed it all people not following standards were getting hit
and fixed there stuff
oo
I'm using klasa-dash-hooks
and it hasn't been updated, so I'm wondering if its any issue there
Does anyone know how to block inputs without the authorization code with Nginx?
seems like what you would want.
https://www.nginx.com/blog/validating-oauth-2-0-access-tokens-nginx/#Using-the-NGINX-auth_request-Module-to-Validate-Tokens
honestly, didnt know this was a thing, may have to use it.
Ok thank you for the information. I will try it out
Does this look all correct? No errors yet, but no updated guild count to top.gg either
you really copypasted the example didn't you?
Tweaked it a little 
This is a horrible coding practice, I did it this way and it's bad to rely on it but it might work
try declaring the dbl module through the on_ready() listener event. again, horrible practice but the problem is the dblpy module won't initialize the guild count, it only updates it further from here
there's something with 3.9+ that seems to make dblpy not want to work at all
@sullen nymph i believe is aware of the issue since i was sharing it with him
I had to tweak the source code of dblpy numerous times to get mine to work on 3.9+
So the example is a horrible coding practice? 
my example, yes
the official example is how it currently works on any python versions below 3.9
Alright, I am using py 3.8.2
I was trying to look into but I dont understand.
so nginx sends a request to an internal server, if it gets a valid auth response back it passes the request along.
But I dont understand how to set it up. I looked at the first example and was completely lost
Also what would http://my_backend be?
the internal server, the webhook server
So would I point it to the server?
yeah, like a normal proxy pass
The way I am doing it is using this: uwsgi_pass. So would I just run that?
I never have used uwsgi, but I would guess so?
2 last things first of all what is this: proxy_pass https://idp.example.com/oauth/token;
and would I put my authorization code where it is underlined:
proxy_set_body "token=$http_apikey&token_hint=access_token";
I am new to this so I dont really understand
proxy_pass https://idp.example.com/oauth/token;
seems to be the internal webserver that will be determining if the auth is correct.
proxy_set_body "token=$http_apikey&token_hint=access_token";
seems to be the format the headers should be in.
these are the headers your internal webserver will be responding with.
Ok, so I am going to have to make a page at /oauth/token with the token?
yep, and that endpoint can just check if the supplied auth is valid or not.
How would I do that?
depends on the webserver you use.
I am using flask
I dont know flask or python
I gtg but will brb in about 30 minutes
Ok
So would I just check if it = the code and if it does it returns something?
yep
@hushed reef so with this what changes should be made? Any suggestions?
IDK
how can i do vote required command
hello
i need an api help
i need a api like this
https://meme-api.herokuapp.com/gimme
but i needd indian meme api
how do i make it so when someone votes for my bot on top.gg my bot sends a message to a channel i picked

It's not the example
The fucking ratelimiter that was used before is a shitshow that isn't even maintained 
I'm curious why you need another lock to lock the lock creation, what's wrong with instantiating asyncio.Lock in __init__?
my token is correct
i used @top.gg/sdk module
const DModule = require(@top.gg/sdk')
const dbl = new DModule.Api("token", client)
can anyone help
is there anyone who can help
i get an error
(node:12806) UnhandledPromiseRejectionWarning: Top.GG API Error: 401 Unauthorized (You need a token for this endpoint)
@restive otter
maybe your token is not valid/your bot isnt approved
print out your token and check if it matches the one you entered
then you aren't passing it correctly
post your code and wait for someone who can help
i tried many times
A close friend of mine also checked the token when I renewed it and it was unauthorized.
does anyone have the authority to control
then your code is definitely wrong
use postman and make a manual request to post your server stats for example
const dbl = new DModule.Api("my token")
dbl.hasVoted(message.author.id).then(voted => {
if(voted) {
my code
} else {
const embed = new Discord.MessageEmbed()
.setColor('YELLOW')
.setTitle(`You Must Vote To Use This Command`)
message.channel.send(embed)
}
})```
is not it right
I will renew my token and try again
My 20th refresh worked.
I will ask something, the token refresh button and the page refresh button function the same, is this normal?
How do i get it to send a webhook in my server whenever a upvote or something happens on top.gg
I don't know but i would like to know ๐
oh i have to put it in my code
for it to send the webhook
i thought i could put my webhook in there
yes
ok
@restive otter so i put in the top.gg status thing
but i dont understand what the webhook auth would be
man
kid was typing again 
hello
-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.
someone here
go to #general or #general-int
thaks
Is there a python library to handle votes but for servers not bots? Please dm/ping me if anyone has an answer.
Not sure if the official one supports webhooks without a top.gg token
otherwise, don't think so
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
poor shivachinningalla
V1 officially supports it iirc. Though, technically you can use the bot vote handler for handling server votes as it provides you the raw data, can't you?
how do I create voting perks when a user votes for my bot
Create a webhook, and then log the user id somewhere, my recommendation is an sqlite3 database
9780077477394-69861658
Something weird is going on with my bot
Under one route KEKW
everytime i refresh it changes the server amount number
but when i run a direct query with my botinfo command it shows 55 servers
There's a pinned message in this channel that shows you how
I searched myself and found it on webhook settings, thx
Np
How do we get vote logs?
I am new to it so, I don't understand that. Can you please tell me in detail?
read the docs
"bot" if 'isWeekend' in data else "guild" 
best is to just check if the json has "guild" or "bot"
hello, i got a problem with the vote webhooks
https://cdn.discordapp.com/attachments/714045415707770900/837053291396333598/unknown.png
https://cdn.discordapp.com/attachments/714045415707770900/837053333453144074/unknown.png
it was working fine before, it just happened today
and yes, i send a 200 as a result and i tested with insomnia and it works
Where's the link to top.gg/servers api?
There isnt any
yes there is, nvm I found it
Thats not a api
Hi, just wondering, how would i check who voted for the bot?
you can use webhooks to receive events when votes occur if thats what you mean.
@keen cargo dont post links like that, thanks.
How do i setup webhook so that i know who voted
programming language?
python
-credits
@elfin anvil
Auction Credits
What are they?
- If enough people vote for your bot or server per month, you have the ability to get credits that you can then use for auctions.
- Donโt know what auctions is? See here for how to apply.
- These auction credits can be used to pay for any winning bids you may make
- You CANNOT โwithdrawโ them for real money
How does the System Work?
- Each month, bot monthly votes reset
- If you get 100 votes on your bot in the month, you can redeem $15 worth of voting credits (canโt redeem till you actually get 101 votes)
- Any vote after 100 will be worth $1 per 1000 votes (or $.001 per 1 vote)
How Can I Redeem Them?
- At the end of the month, you will be eligible to redeem your credits (you redeem them on your bot or server's
Votespage on your botโs dashboard). You will have 30 days to redeem them before they expire. - After you redeem them, you have 31 days to use them before they expire (so you can technically stack 2 months worth)
**How can I Use them to Pay? **
- When you pay for your winning bid, you have the option to use your credits
- If your winning bid cost is more than the amount of credits you have, make sure to apply the credits first and then pay the rest with the supported payment providers
A more simplified, less detailed version can be found in #580510490074152961 after you get auctions access and any questions can be asked in #auctions-general.
Qbasic
@restive otter What do you think about this? ๐
Considering the fact that I'm not logging anything in case an exception occurs in the autopost
Pog, you should probably as well implement default autopost_error handler just like how d.py implements default command_error
imo logging the dispatching in the module seems unnecessary with the fact that d.py logs it already
But default error handler sounds nice
Xd, I personally never set up my logging level lower than info

@sullen nymph do you use a specific formatter?
Nada
How do you suggest this can be done?
Something like this, I'm testing it
Oh, I think I see where you're getting at
oof, that superfluous f string doe 
Though I'm not sure how that could be applied to Client objects 
Users can override that with @<Client>.event
Ah
@<Client>.event basically just sets the coroutine as the bot's method, so ig it works on both Client and Bot extension, lemme test it
Makes sense
@restive otter Any result? I'm thinking of calling client.on_autopost_error and in case that fails, rely on Bot.extra_events, else just use a default handler
Both Client and Bot pass the tests, I've made a PR
... ya, didn't see the notification
What's the odd of user setting the autopost_error event before insantiating DBLClient lmao? Cuz if they do that, it'll get replaced with the default one we provided
hey how do i know what servers my bot is onยฟ
I usually prefer to think that whoever uses dblpy is a newbie, so anything is possible
Shall I check if it exists first, the thing is it could be an arbitrary function that doesn't even take an Exception object 
It's probably better to check if it exists first lol
alright, ig this suffices
Do you think we should go with
try:
self.bot.on_autopost_error
except AttributeError:
self.bot.on_autopost_error = self.on_autopost_error
```?
I personally prefer this if statement xd
๐ makes sense
how does the voting webhook for servers work exactly?
so not for the bot
i have a question too do i need a website to get webhook?
I have a tutorial that doesn't require a server / website here
https://comhad.github.io/webhook.html?page=serverless
THX
boys
we did it
I ported an entire library to full TypeScript within a night because i was so salty it didn't support the library I wanted to use
so.. new api soon? ๐
there's a way with the api to make a command which make able people to vote without go to the top.gg page and click the vote stuff?
like:
x: !vote
bot: Thanks! You voted me on top.gg
and it log the top.gg vote normally like when someone go on the site and vote a bot in the normal way
Traceback (most recent call last):
File "/home/pi/Desktop/BotDiscord/SmallGames/cogs/topgg servers.py", line 36, in update_stats
await self.dblpy.post_guild_count()
File "/usr/local/lib/python3.7/dist-packages/dbl/client.py", line 157, in post_guild_count
await self._ensure_bot_user()
File "/usr/local/lib/python3.7/dist-packages/dbl/client.py", line 106, in _ensure_bot_user
await self.bot.wait_until_ready()
File "/usr/local/lib/python3.7/dist-packages/discord/client.py", line 890, in wait_until_ready
await self._ready.wait()
File "/usr/lib/python3.7/asyncio/locks.py", line 293, in wait
await fut
concurrent.futures._base.CancelledError
failed to send the server count```
got this error on one of my bots. is that normal ?
can someone tell me a bot for reaction posts?
-api
@novel phoenix
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.
I`m sorry
that's my code ```py
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
@commands.Cog.listener()
async def on_ready(self):
print("TopGG Server cog ready !")
def __init__(self, client):
self.bot = client
self.token = 'my TOKEN'
self.dblpy = dbl.DBLClient(self.bot, self.token)
self.update_stats.start()
@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))
print("failed to send the server count")
def setup(client):
global logger
logger = logging.getLogger('bot')
client.add_cog(TopGG(client))
that's the only one bot which has this error, my 2 others bots don't have it
already tried
but don't fix
why do I have this error ? Unauthorized: Unauthorized (status code: 401)
the token is right
have you updated the token after resetting
I refreshed the web page and the token changed again....
Got Response 200, and after just few minutes, got error 401 back
then you didn't update your token on your production or smth
but token is right
reset it again
I just reseted it 10 times because I always have this error
@rain heart if you want I can send you the code (with token) in DM to see if there is an error, but it is the first time I got this
try it in 5-10 minutes then
as you probably got ratelimited during resetting your token
How would I go about implementing the Top.gg Api to make a command only runnable if someone has voted for the bot?
still don't work
Make a url for webhooks and log the id into a database when it fires
Quando tento usar shards, ocorre um erro no topgg-autoposter. O que devo fazer para corrigi-lo?
opa
sorry
language
languaje
haa
1 second
When I try to use shards, an error occurs in topgg-autoposter. What should I do to fix it?
now is correct
Alguรฉm com api cadsus
still have this error since yesterday
Can anyone help me ?
Failed to post server count
Unauthorized: Unauthorized (status code: 401)
Traceback (most recent call last):
File "/home/pi/Desktop/BotDiscord/SmallGames/cogs/topgg servers.py", line 36, in update_stats
await self.dblpy.post_guild_count()
File "/usr/local/lib/python3.7/dist-packages/dbl/client.py", line 160, in post_guild_count
await self.http.post_guild_count(guild_count, shard_count, shard_id)
File "/usr/local/lib/python3.7/dist-packages/dbl/http.py", line 168, in post_guild_count
await self.request('POST', '/bots/stats', json=payload)
File "/usr/local/lib/python3.7/dist-packages/dbl/http.py", line 144, in request
raise errors.Unauthorized(resp, data)
dbl.errors.Unauthorized: Unauthorized (status code: 401)
This is the right token
it doesnt look like you have the right token
yes it is. I had it before regen the token too
and I have it since yesterday, and only on this bot, not on my others bots
Sometimes I got Response 200, and sometimes 401
@ruby kiln maybe it's worth using something like burpsuite to watch the request pass through?
I use the code told on the API with timeout ๐คท
Maybe some of the request is getting cut off though, probably the auth token if its 401, i had that happen to me a while back
Can you DM me the top.gg token you use?
yeah for sure
@restive otter https://github.com/top-gg/python-sdk/blob/master/topgg/http.py#L114 do you think this loop is necessary in the first place?
A simple API wrapper for top.gg written in Python. Contribute to top-gg/python-sdk development by creating an account on GitHub.
Since as I see it, HTTPException gets raised after the first iteration anyway
Ig it is, the loop will only break on exception other than 429
And 2xx
Actually no lmao, 2xx will break it
Shouldn't I handle 5xx outside of the async with then?
You wanna retry on 5xx?
I'm not sure if I want to retry at all
Since 429 just sleeps until ratelimit is over
Oh yeah, ig the loop isn't necessary then
ty
I'll check it out again later
Sure, no problem
@sullen nymph What's the chance of it getting rate limited again even after sleeping? Like for instance, the user makes arbitrary requests without the rate limit context manager?
Also, have you got rid of this? https://github.com/top-gg/python-sdk/blob/master/topgg/ratelimiter.py#L48-L50
Ig _global_over isn't necessary, because it isn't even used. Isn't there supposed to be await self._global_over.wait()?
Their fault for hitting 429 
There's no way of detecting how many requests are left until ratelimit with v0 API, hence the local ratelimiter
Nope, will do in a bit, thanks
Oop, yeah
Right
but ig you still need to keep the loop to avoid duplicate of codes nonetheless. Maybe you can just take it down to 2 from 5 iterations instead of removing the loop, or maybe recursively call itself after sleeping? Not sure if it'd be a deadlock
the latter is a terrible idea
LMFAO no recursion ty
Duplicate in what sense?
After sleeping, you need to make a request again. So, if you remove the loop, you'll need to handle the exception again, which is just redundant duplicates ig. Ofc, you can wrap it in an inner function so that you only need to call it. But imo loop is way better 
Hey ! I don't understand what is shard ?
If you don't know what it is, just leave it empty
as it is a optional parameter nonetheless
Okay but I don't know what that means, my bot got 1 shard
read the description of that parameter on the left
it contains an array of server counts of all of your shards combined
something like
shard 0 has 5 servers
shard 1 has 10 servers
[
"5",
"10"
]
On the left ?
Sorry I don't see ๐
Does anyone know a simple way to implement the authorization codes with nginx?
I want a simple way because I am new to this
Still having issues with it?
I couldn't figure it out
Is there a reason it needs to be implemented in nginx and not your code?
I can get the authorization codes in my python script?
Yes all the auth headers are sent to your code.
Oh, how would I get them
Yes
Ok tysm
request.headers.get ezpz
When i used apache i had to enable some setting that allow auth codes to pass through in the config, idk if nginx has the same thing, so keep an eye on that if the auth headers don't come through
I was able to print it out but how would I get the authorization header as a string?
Or could I just do:
if not authorizationcode in str(headers):
return
@sullen nymph may be able to help more. I don't know python.
Ok
Do you want to check the authorization from the webhook, or send one through a request?
Check the authorization code from the webhook post
request.headers is a dict-like object (if not literally dict)
That should be part of the data you recieve
So use .get on request.headers
I've done some flask, here's some code i use
try :
auth = request.headers["Authorization"]
if auth == "token" : # Validate the Authorization header, change this token to your own
pass
else :
abort(403) # If the header is invalid
except KeyError :
abort(403) # If there is no Authorization header
or that
I prefer to abort with 401 tho
Unauthorised
Oh
403 is forbidden
Wait 404 is not found
Yeah
Yeah
Thanks for the help
Ya I will change it a bit
Would I have to import the abort like this from flask import abort, ...
Yeah, i'll send the link to the gist
K
And also can I call request.headers in a different function?
Not 100% sure what you mean sorry
Or does it have to be in the Flask function
Oh, if you call another function in the flask route thing?
Ah right, maybe if you passed the request object into the function aswell?
Ok I will just pass the key through it then
Because I have multiple pages because of multiple bot lists
And wanted it to be the easiest possible
Jesus lord what are you doing
Oh dear lord have mercy on you people
I am confused
Hold on, let me logon to my server and get something for you
Not perfect, but it works
@app.route("/top_gg", methods = ["POST"])
def top_gg():
content = request.get_json(force=True)
userid = content['user']
# . . .
@app.route("/dbl", methods = ["POST"])
def dbl():
content = request.get_json(force=True)
userid = content['id']
# . . .
Why not have one route for all requests?
Each webhook has a different json
Ok so one discordbotlist I got the error MissingAllowOriginHeader. And other then that it still lets it through with a wrong auth code
I'm thinking of the wrong DBL here, disregard that
On my apache.conf, i had to write something that returned a header, maybe you need to do the same for nginx?
It worked before
Before I added that thing
The auth protection
try:
if auth == "Code":
pass
else:
abort(403)
except KeyError:
abort(403)
That is the code I put in
Oh
Maybe? I'm not sure, just best to try it
Ok
It still returns 200 but it isn't giving the reward so I guess it works
Also would abort end the function too?
Nvm It all works
Thank you for the help @spice helm
Np :D
Ah, I see
I guess I'll simply reduce the retries to 2
Putting that aside, should I even use the global lock?
... maybe I should, yeah
or not since I'm using a ratelimiter
The ratelimiter itself is already global, so I don't see that it's necessary
Yeah, I guess I'll just remove it

Migrating from dblpy to topggpy is gonna be fun experience
or pain 
Hmm, try going back and doing it again?
Go to the home page of the site and try it from their? This is odd, i got an error but refreshing fixed it
Did you follow the URL on the gist?
That was just an example, your not suppose to follow that
No worries
thanks ;-;
Did it work?
Alright, super
i don't have a bot ;-;
wait i do have a bot
but
wait im confused
Different language?
no
Alright, what's confusing you?
it says
Sign into discordbotlist.com, go to your bot, and press Edit, scroll down and you will see a webhook section.
which bot ._.
;-;
Ez
It will work with top.gg don't worry, i wrote this based on discordbotlist as an example
bu
but
the bot thing?
@spice helm is the real G
it says go to your bot
Aww ty :D
This is the right page
oh ok
Just paste the intergromat URL there
wait
how will it know
which channel i have to put
The guide gets to that
Not as many steps for the discord webhook i think
Click on the right of the webhook icon, and click Add another module, search and pick HTTP, then Make a request. You will now have a blue HTTP icon linked to your webhook
where do i do this
On the intergromat page
home page?
No, the one with your webhook
That's it
Nice :D
;o
did u do it before? or do u know
cuz idk how to do it or
yk
:<
I don't know how to do it sorry
oh ok
Which module do I need to use to detect votes?
I think there's a dblpy module, or something like it i'll get the link
A simple API wrapper for top.gg written in Python. Contribute to top-gg/python-sdk development by creating an account on GitHub.
for discord.js
Oh, right
...
https://github.com/top-gg/node-sdk this what you're looking for?
Hmm, did you get the data for the webhook?
uh?
You have to click listen and then test the URL
yes
it works
but how do i do like, when someone votes, it mentions the user and saying "message"
Try doing the listen thing again, but make sure you click ok when it's done, it might not have saved
whas dat thing?
listen
thing

yes
Should be blue, then click it and test the webhook, and then click ok on it when you are done so it saves
I call it and upvote trigger because that what starts the process running
Yes, now test the webhook
ok
And click ok on that when the button isn't red anymore
k
what is webhook.channels.cache?
when i clikc this
with the link
it doesn't respond
shoot ur right...
ye I did that
Not sure what you mean, plus i only have two buttons not three?
how do i test
the work i did just now
Not sure how it works, i think you need to update the webhook link and then test it but idk how with unapproved bots, try Only update i suppose?
ok
it works
but
how do i do like when people vote this come with the username of the voter
;/
Were you listening for the data so it had the red button?
no clue
i didn't do it like that
here
i did this
and then that came
how?
what's that red lines
You see how that button is red? If you look at it on your end, it should be blue, click it so its red
ok after that
Click copy, paste it into top.gg and click update
Then click test, go back to the webhook, and it should be a green tick
ok
yup
its green
but the message didnt come
That's right, now click ok
Don't worry


