#topgg-api
1 messages · Page 159 of 1
yea both return the same thing
they dont
posting is for posting stats
getting is for getting stats
they dont do the same thing
well when i get It only gives me shards
{ shards: [] }
you never posted anything to the api then
I really suggest you to go over the docs again: https://docs.top.gg
Startbot
One message removed from a suspended account.

how to get the id of the user who voted the bot?
how can i make my bot dm a user who votes on my bot?
That's what I'm trying to figure out
xd
Hi
Can i know some one who can help me and is using js and replit
Pls dm me if you know
Oh no i need it for api
ah
Do u use
@mighty crater
What exactly do you need help with, what part of the API?
Like see i use replit and i want to make voting rewards
So my repl name is test
That's my code
And it does not work
I am getting this error in my console Top.GG API Error: 429 Too Many Requests I have regenerated the api token and even made it so that the bot updates the stats every hour yet I still get the error
Why does my voting not work
Poketwo voting is being annoying and it’s not letting me vote
what lib ?
discord.js
rate limited 
I could be wrong, but it seems like that’s what most likely happened.
yea tbh that is the only explanation
plus cuz my bot has been growing too so yea understandable
How do I just check if someone has voted when they run a command?
I tried (python):
Voted = requests.get(f"https://top.gg/api/bots/:bot-id/check?userId={ctx.author.id}").json()["voted"]```
But I got an authentication error. How would I set the authentication with my API token in my code so it should respond properly?
- Doing an API request on command usage is a bad idea, so it's probably better if you cache the results (or use a webhook altogether)
- Please use
aiohttpinstead ofrequestsalong with discord.py
Putting those aside, you need to set the Authorization header with your bot's top.gg token and send it in the request
What would setting the Authorization header look like in the code?
I'm new to aiohttp
it's the same in aiohttp and requests, a headers argument that consists of a dictionary with your headers and their values
So like, response.headers['Authorization'] = "API Token"?
Not response
in the .get method itself
since you need to send the header with the request
eg requests.get(url,headers={"Authorization":authstuff})
Is there API/Webhook support for Server Bumps, or is it just for Bot Bumps?
Yes
ohh, ok ty
is it possible to get the amount of votes a user has?
you make it
auth is like a password, you choose it.
ok
pls how can i make when someone make vote it send message from discord bot someone voted
read the docs: https://docs.top.gg
https://comhad.github.io/webhook.html?page=serverless this will show you how
while using https://www.npmjs.com/package/@top-gg/sdk
for handling the votes is the port the port of the bot?
why when someone vote it doesn't do anything !!
if im using like a discord webhook where can i find the port for that
you cannot use discord webhooks
oh ok
i am not using discord webhooks
oh sorry
excuse me?
please explain
this is 1000% a memory leak
it'll add a listener to your code everytime someone votes
and you'll have node crash with maxEventListeners reached(22)
Do bot owners no longer trigger webhook requests upon voting for their own bot?
no they work
do you have a recommendation of where i can get a webhook?
LMAO
is it fine if i slap people with the "learn js first" wall of text even though its not for bots?

Are you sure, as in you've tried it in the past 2 days? That's when it started not working for me, even though it works for everyone else who votes
const discord = require('discord.js')
const Topgg = require('@top-gg/sdk')
const express = require('express')
const app = express()
const client = new discord.Client()
const webhook = new Topgg.Webhook("my auth webhook
")
client.on('ready', () => {
console.log(`ready ${client.user.tag}`)
})
app.post("/dblwebhook", webhook.listener(vote => {
console.log(vote)
client.channels.cache.find(i => i.id === "858730735728328764").send(`**📩 -> \`<@${vote.user}>\` voted in https://top.gg/bot/805607988151975986/vote**`)
}))
app.listen(80)
why it doesn't do anything !!!
literally tried at the time i sent that message
That's really odd. It just suddenly stopped working for me. Didn't even make any changes to any code at all
Both bot votes and server votes
how this work?
anyone wanna share a fully working code for the on vote thing?
read pins theres an example in there
Are library devs given a bypass for that?
Nope. They're supposed to be owners of the libdev bot but teams are broken right now
I've had that question for weeks now lmao
How Can I Get Total Number Of Votes Of A User ?
Jokes on you, my Top.gg website account was still broken while I was a library developer
I had to ask someone for their Top.gg API key and test my code on theirs before my account was even fixed 
Anyone ?

i tried that
then? 
no luck
show ur code
and where should i even put the code
i think anywhere should be fine
ok
ok wait
@safe comet
const express = require('express')
const app = express()
const Topgg = require('@top-gg/sdk')
const w = new Topgg.Webhook('what should i even put here?')
app.post('/topgg', w.listener(vote => {
console.log(vote.user)
}))
app.listen('8000', () => {
console.log('App listening on port 8000');
});
^^
u should out the webhook password form ur bot/server
then paste the url from express in the uhhh
dashboard?
idk what its called
what url
what r u trying to do?
r u getting a vote from server or bot
if bot i cant helo u with that since idk how that works
i only know server
if someone votes on top.gg it will print it in console
thats what im trying to do
bot
The webhook service is basically a webserver listening to incoming requests (from topgg).
The webhook URL you have to enter on topgg is the public IP or DNS of the machine your webhook service is running on.
i dont have a bot so i dont know how to get the token/pass
dns
hm
That requires to add an inbound rule for the port (TCP) you specified in the code if the default policy is DROP.
If that hostname has your machine as target the webhook service is running, then yes.
ok but what about the code itself
this
If that’s the example from the docs it should be up to date and working
docs
As long as port 8000 is accessible
i mean i get the port 8000 log in console
That doesn’t automatically mean the port is open tho
Just test it by entering the hostname or IP of your server your webhook service is running on on topgg, click save and test.
The code is a webhook service
so i cant use it?
As I mentioned above this code is creating a webhook service/listener for incoming requests on your system
yes
Topgg is sending this request to your system if you have entered its IP/DNS on topgg
If the webhook service is running it will receive the posted request
The IP/DNS of the machine the code you showed above is running on
The machine has a public IP and/or DNS you have to enter on topgg to “let them know” where to send the requests to
If you wanna receive a SMS the sender needs to know your number, too
If i use someone else API key will it work? Just wondering
Technically yes
Oh
sooo i tried the top-gg autoposter thing
i put my token in but it gives this
TypeError: (topggtoken) is not a legal HTTP header value```
im still learning so i used the example from the docs...
but here ig
const poster = AutoPoster(process.env.TOPGG_TOKEN, client)
poster.on('posted', (stats) => {
console.log(`Sucsessfully posted data onto top.gg! | ${stats.serverCount} servers`)
})```
just want to know whats wrong. so i can avoid myself from not making the mistake again
i have a feeling i did smthn wrong... but im still learning so yeah
where do i get the token from?
from your bot edit page
ah
Guys
Where do you think I went wrong I've been trying for 2 hours please can you help me
const DBL = require('top.gg');
const tokenn = ayarlar.dbl
const dbl = new DBL(tokenn, { webhookPort: 5000, webhookAuth: 'testingx!5x' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
let sunucu = client.guilds.cache.get("there is SERVER ID")
if(sunucu.members.cache.get(vote.user.id)) {
client.channels.cache.get("there is channel id").send(`Thx ${vote.user.username}! I gave you role.`)
} else {
client.channels.cache.get("THERE IS CHANNEL ID").send(`Thx ${vote.user.username}!`)
}
});
Check the pins here for examples. I'm not sure what package you're using there but it's not what's recommended
Isn't that dblapi.js? That's deprecated.
Use the packages in the pins.
Why Didn't You Put SetInterval ?

hi ahh i was testing the on dbl vote event in python and when i test voted for the first time, i got this error
/root/redenv/lib/python3.8/site-packages/topgg/webhook.py:141 in _run │
│ ❱ 141 self.__app.router.add_post(webhook["route"], webhook["func"]) │
│ /root/redenv/lib/python3.8/site-packages/aiohttp/web_urldispatcher.py:1167 in add_post │
│ ❱ 1167 return self.add_route(hdrs.METH_POST, path, handler, **kwargs) │
│ /root/redenv/lib/python3.8/site-packages/aiohttp/web_urldispatcher.py:1094 in add_route │
│ ❱ 1094 resource = self.add_resource(path, name=name) │
│ /root/redenv/lib/python3.8/site-packages/aiohttp/web_urldispatcher.py:1071 in add_resource │
│ ❱ 1071 raise ValueError("path should be started with / or be empty") ```
i dont understand the path thing
it says path should be started with / but wouldnt i put the complete url for my webhook?
No
If you put your Discord webhook URL there I'm praying for your soul
It's a route on your machine's IP:port
aka http://your.machine.ip.address:yourport/mypathhere
route = path
its not a discord webhook. its an integromat webhook url. i was pretty puzzled as to how to use the topgg api so i sadly had to move to yt tutorials lel
so route to my bot file?
Start praying shiv 😌
Lol
Do you really need topggpy webhook for that?
I thought you could redirect the request from Integromat to Discord webhooks directly
well i mean, there isnt any proper tutorials or anything and im a guy who really needs a proper turorial to understand how to do stuff the first time
i could but i dont just wanna do what the guy does in the tutorial. i wanna use the official event listeners provided by the library
i am pretty sure his way might cause a few (maybe many) problems in the future. idk its just me
🤔 then you don't need integromat
im really sorry for being petty here, but if not then could u guide me how?
You want just one middleman, aka your topggpy webhook. Top.gg would send requests to it, and you would handle them however you want to
The catch here is that Integromat would process the requests for you and do something, but since you want to do that with your webserver, you can scrap Integromat altogether. You want to receive the vote data directly in the webserver and process it manually
Say, save it in database or post a message in a Discord channel
oh wait nvm
so i put my vps ip then the port aka 5000, and then the route to my bot file?
Not that route
Your local files don't have anything to do with it really. You set up a listener on some port, which would handle various paths (routes), which are set via the helper methods in topggpy
If you want bot webhook on ip:port/dbl, you set the path to /dbl
oh ok. then that should work? imma tias
(try it and see)
oh and ill have to put the same url in my topgg bot profile right?
yup
This
yeye ok thank u so much for bearing my dumb ass 
Hey that says you're a bearable dumbass unlike some people
We both are dumb so it's ok
oh i totally get u. i get to face 1 or 2 everyday. u probably get to face more tho lmaoo
respect 
o7
ummm im still getting the same error 
heres what i did
self.bot.topgg_webhook = topgg.WebhookManager(self.bot).dbl_webhook("http://myip:5000/dbl", "password")```
and yes i did replace my ip with my actual ip.
Idk python but I'm pretty sure if it's like JS you just do the path
self.bot.topgg_webhook = topgg.WebhookManager(self.bot).dbl_webhook("/dbl", "password")
But then again I could be completely wrong
its the thing as js just different syntax cause ik both languages but i prefer py
same thing as*
imma try that too
Lemme know if that works
it finally worked thank u so much ur a lifesaver
Np 🙂
yo can i have some help im trying to make it send a message when ever someone votes for my server
const Discord = require('discord.js')
const client = new Discord.Client({})
client.login("TOKEN")
const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express()
const webhook = new Topgg.Webhook('very-special-auth-thing')
app.post('/voted', webhook.listener(async vote => {
let channel = client.channels.cache.get('771606504544403466')
let user = await client.users.fetch(vote.user)
channel.send(`${user.tag} voted for the server!!`)
}))
app.listen(2020)
any issue?
Yea nothing sends
did u vote/test voted
have u put the correct url for the webhook?
try console logging vote or something
error in the code or something else?
can you send an example code for the api in discord.py
thnx
const express = require('express')
const app = express()
const Topgg = require('@top-gg/sdk')
const w = new Topgg.Webhook(process.env.topgg_webhook_auth)
app.post('/topgg', w.listener(vote => {
console.log(vote.user)
}))
app.listen('8000', () => {
console.log('App listening on port 8000');
});```
is there anything wrong with the code? cause when i tried voting, it dosent print anything.
Use w not app ig
where can i get the token for the API?
See pins
@proud cloud
@restive otter No ads thank you
While using the api to post guild count its keeps showing attribute error aexit
What does that mean?
Traceback might be helpful
Interesting
so i put
const w = express()?
What does the official example say?
Ok so basically for the vote thing
https://u.suck.rocks/QMYuAzgy
const express = require('express')
const { Webhook } = require('@top-gg/sdk')
const wh = new Webhook('authhere')
const app = express()
app.post('/webhook', wh.listener((vote) => {
console.log(vote.user)
}))
app.listen(port) // the port of your machine (where your bot is hosted)
ooh k
whats up?
sure
thanks
client.users.cache.get(vote.user).send("Thanks for voting!");
no problem :)
in return i will add your bot to my server
thank you :)
But am using the python wrapper and that code is in a separate cog
Could you help me?
That doesn't change the fact that you should post the traceback
it gave me an error
How do i do this?
what error?
yes ofc
COuld we do it in DMs
sure
@coarse rune what error did it give u?
i sec
ok
ok
const webhook = new Topgg.Webhook(token)
app.post('/top.gg', webhook.listener(async vote => {
client.users.cache.get(vote.user).send("Thanks for voting!");
})) // attach the middleware
app.listen('8000')```
const express = require('express')
const { Webhook } = require('@top-gg/sdk')
const wh = new Webhook('authhere')
const app = express()
app.post('/webhook', wh.listener((vote) => {
console.log(vote.user)
client.users.cache.get(vote.user).send("Thanks for voting!");
}))
app.listen(port) // the port of your machine (where your bot is hosted)
thats scam
Nope still the same error
@lilac nacelle
hm
uh
TypeError: Cannot read property 'Api' of undefined```
code:
```js
const { Webhook, Topgg } = require('@top-gg/sdk')
const api = new Topgg.Api(process.env.TOPGG_TOKEN)
client.on('ready', () => {
api.postStats({
serverCount: client.guilds.cache.size
})
})```
did u use the one i send u?
here
why
Idk
didnt u do what i send higher up?
I did this
this
Yea i did it
Can anyone help me to create vote command on discord.js if yes then dm me
nvm, i used the autposter and it works!
for the topggpy built-in webhook do i only have to open the port in my firewall?
I host it on replit.com
oh
oh
idk if u can
Pretty much for any webserver
so yes
yeah yeah i know i have to but is it purely my firewall that has to allow it
Mhm
Not sure what else would be required tbf 
I dont know lmfaoo just making sure
wht comes in password section in
self.client.topgg_webhook = topgg.WebhookManager(self.client).dbl_webhook("/dblwebhook", "password")```
Any text you want
ok
It's your topgg token
Nope
uhh r u sure @golden adder
That's used in DBLClient. Webhooks' authentication is done via "passwords" that users create
ok
Oh my bad 
I might be misreading or missing something but what URL do I need to put in the webhooks section. Using the topggpy webhook so /dblwebhook, I tried putting in /dblwebhook in the URL but that didnt seem to do anything
cant figure it out for the life of me
Are you sure the webhook is running and that you're not visiting the wrong port?
bot.topgg_webhook.run(5000)```
I have this under the \_\_init\_\_ in my class
opened port 5000 in my firewall TCP and UDP
hi
TypeError: Cannot read property 'send' of undefined This is the error sent in the console but the message is also send so can someone help me and it is in Discord.js
Is it possible to retrieve the notifications of our bot with the api of top.gg?
And the announcements too?
can you help me ?
yes
does each bot have its own topgg token
yo the server post always worked but suddenly I get this: AttributeError: __aenter__
@lilac nacelle i have a question add me
so @sullen nymph how do you plan on supporting discord.py v2 and v1 when that happens 👀
I'm not even aware of the changes that are planned to be implemented this far
Is it really that bad that i'll need to support it separately lol
idk, that depends on how they handle the depreciation of get_event_loop and asyncio.run creating a new event loop meaning bot.loop will likely have to change or become nullable
🤷
okay well at least im getting an error this time;
OSError: [Errno 10048] error while attempting to bind on address ('0.0.0.0', 2060): only one usage of each socket address (protocol/network address/port) is normally permitted
- No my bot is not running twice since I am using a seperate beta bot only on this PC
- I changed the port to 2060 and allowed it through my firewall + router/modem
- This happens every time so even when I change the port and try for the first time
What to do....
what OS?
windows 10
run netstat -a
yeah its listening
i ran it again with 5050 and it opened that one
i put the .run() right after i defined bot and its nowhere else in my code
so
if that port is already listed as listening on netstat before you run the port is taken
unless @sullen nymph feels like adding SO_REUSEADDR
nahnah as soon as i run the bot it shows up
gimme a min
imma clean up my code and put everything in a separate file instead of having to import from other cogs since i was gonna do that anyway
might be trying to rerun the piece of code
Sounds like it
I was thinking abt that during work and I knew i had to do it anyway
was fine in the beginning with 2 helper functions but now its too messy
😂
Alright the error is gone now but with one_dbl_test there is no output, I put 0.0.0.0:2060/dslwebhook as the webhook URL is that correct?
0.0.0.0 is supposed to be replaced with your machine's IP address and the URL must start with http://
alright alright, wasnt entirely clear to me
thanks i shall try rn
alright seems to work just fine, didn't work at first and then i had the brilliant realisation that i forwarded the port to my server and not my PC that I'm running the beta version on
🤦
Thank you very much shiva
🤣
What'd be the best way of checking when someone votes? For example my bot sends me a DM saying @ xyz voted...
OK thanks
What’s been happening to the topgg webserver lately? For the past week like once a day I’m getting returned 503 errors when auto posting my bot server count.
ok
It’ll be fixed soon hopefully, the site is currently getting DDOSsed. 
Alright
Hello I am new in development I would like to know which ones were TOP.GG api and how to find it
My code error Top.GG API Error: 401 Unauthorized (You need a token for this endpoint)
how to get the dbl token
read this
oh k
wait for approval

but ok i wait ...
it takes about 3 weeks or more
Ok
Other than port 5000, what other one can be used?
Whichever that's open and not occupied
Well you can technically assign anything in a unsigned 16 bit integer range but anything bellow 1024 requires admin / sudo to bind to as they're classed as reserved ports
Okie
ok how i fix this error
what error?
hi i need help with settings up a webhook for my discord bot on topgg
this link leads me to an error page of 404
so i asked here, which was the second option
Are you replacing :your-bot-id with your bot's ID
what id is that
wdym
What library do you use for your bot?
node.js
https://www.npmjs.com/package/@top-gg/sdk this could help you
@sullen nymph so i am to insert this information first
and it would look like the webhook url will be made alr or?
and how do i know like what port to use
Berry for the love of fucking God add some kind of tutorial in your docs...
There's a screenshot right under that code snippet
Refer to that as your URL template. You choose any port you want
oh like my pc ye? What about port
oh ok
If you're gonna host locally, make sure the port is forwarded to your PC in your router settings
@sullen nymph ok so i followed an npm thing and they said DBHtoken
i entered my token but it said that its not defined
Wrong package
Bullshit, it's not official
This is the official package
If it was it'd be updated
Except 💀
I wouldn't call someone who says that something is official out of the blue a "good" bot dev
hello where do I have my API key
wot
so do i just stick with what im doing?
i did*
my own router port
blah blah my ip
Host on port 3000 but send requests to 443 (aka https://xxx.xxx.repl.co/)
Are you hosting locally or not?
i believe yes
If you're running shit on replit.com then no you're not and you don't need to forward ports
so i just stick with what i have?
I assume so
oke
ok @sullen nymph i followed the steps but it didnt console log my id when i voted
hmm
What url do I enter for my webhook url?
its alr imma sleep now and work on this tmrw
Generally http://your.server.ip:port/path
is there any public service where I can have a hosted webhook url for me
I don't think so
hello where do I have my API key
How to get a message from bot telling that someone voted on top.gg
ah ok
One sec
@sullen nymph welp i dont get a traceback only this attributerror AttributeError: __aenter__
I only want to post the server count
How to get a message from bot telling that someone voted on top.gg
That might be because it's getting the __aenter__ from the tuple instead. @sullen nymph maybe you wanna use AsyncExitStack instead?
I told you
Read the docs and you also need your bot approved first
he told you to read the docs
Lol my bad
npnp
Were you making a request to non-bots endpoint?
If you were, you should be able to reproduce it
I mean I just had ratelimiter.py running with a custom function that did ratelimiters = global_rl if True else (global_rl, bot_rl) with async with ratelimiters
context_managers = (global_rate_limiter, bot_rate_limiter)
async with context_managers:
...
``` doesn't seem to equal ```py
async with (global_rate_limiter, bot_rate_limiter):
...
Yeah, that's the thing. You should test it with the tuple instead
I'm suggesting this
from contextlib import AsyncExitStack
ratelimiters = global_rate_limiter,
if url.startswith("/bots"):
ratelimiters += bot_rate_limiter,
async with AsyncExitStack() as stack:
for ratelimiter in ratelimiters:
await stack.enter_async_context(ratelimiter)
...
If you don't like the import, maybe you can make an async null context manager
https://github.com/top-gg/python-sdk/blob/master/topgg/http.py#L111 This URL also has been replaced though, so it always starts with the base url
A simple API wrapper for top.gg written in Python. Contribute to top-gg/python-sdk development by creating an account on GitHub.
3.8
Btw this is the code and it always worked *
@tasks.loop(minutes=30)
async def update_stats():
try:
await client.topgg.post_guild_count()
print(f"Posted!")
except Exception as e:
print(f"Failed! \n{e.__class__.__name__}: {e}")```
Oh yeah, AsyncExitStack isn't available on py3.6. Are you planning to support it still, shiv?
Considering d.py will drop support for py3.7 and earlier
you should do because discord.py still supports 3.6
v2 jumps straight to 3.8 minimum required version but that will require a redesign of the sdk to support properly i feel
We'll see the breaking changes, eventually
If it's going to follow the asyncio stuff, bot.loop will either be removed or become nullable which means the sdk wont be able to rely on that or assume the loop before it's in a async context
along with le tradition depreciation of get_event_loop, loop kwarg etc...
Seems it hasn't officially supported 3.10+ though
v2 will likely support anything beyond 3.8
I mean the sdk will want to conform to the changes regardless because best practice™️ and loop kwarg and get_event_loop is gonna cause you issues in the world of 3.8+
Yep, I mean, it hasn't yet, seeing the classifiers didn't specify 3.10 explicitly
I'm just guessing the implementation of the run method is still gonna be "get or make", try to get the running loop, if RuntimeError raised or the loop is closed, make a new one.
it cant / shouldnt be
because you will pretty much always run into the two event loop same thread issue
We probably have to shift to another channel 
because asyncio.run is supposed to become the standard way of starting an async runtime context (libs shouldnt do it) it always makes the loop so anything created outside of the async context wich uses get_event_loop or makes it's own loop will break
hence why all the loop kwargs got depreciated with this to discourage use of get_event_loop
most of the changes are happening because people cant be trusted to manage and cleanup their async code, people realising that developers cant be trusted with low level event loop systems 
rl1 = AsyncRateLimiter(10, 5, callback)
rl2 = AsyncRateLimiter(5, 3, callback)
for _ in range(60):
async with rl1 if False else rl1, rl2:
print(_)
I can't check for its compatibility with py 3.6..3.9
🤨
I mean, thats certainly one way to remove the limited constant folding python has
def foo():
return 1 if False else 2, 1
5 0 LOAD_CONST 1 (False)
2 POP_JUMP_IF_FALSE 8
4 LOAD_CONST 2 (1)
6 JUMP_FORWARD 2 (to 10)
>> 8 LOAD_CONST 3 (2)
>> 10 LOAD_CONST 2 (1)
12 BUILD_TUPLE 2
14 RETURN_VALUE
def foo2():
if False:
return 1
else:
return 2, 1
12 0 LOAD_CONST 1 ((2, 1))
2 RETURN_VALUE
I can technically just divide the HTTP requests into separate functions
I'd like to keep support for 3.6 for now
what are you trying to do?
Guess what 
can i offer a suggestion
Sup?
drop 3.6 and write it as a breaking change
it's not worth it
because 3.6 is going to reach eventual deprecation at some point in the future, although not right now
plus what you're doing is gonna be a no-no later on
Eh fuck it we're dropping 3.6
yeah it's just genuinely not worth the hassle
I mean by that point
the current setup only supports 3.7 well
3.8+ can be considered pretty un-pythonic in terms of the async ecosystem beyond that
i also cant see why you even need to drop 3.6?
like what are you doing that requires what 3.7 gives you
#topgg-api message because AsyncExitStack doesn't exist in 3.6
Thought you chose the ternary
It refuses to work properly
... and you need this why? for the sake of 2 context managers?
You can have an async null context manager to keep support for 3.6
Or maybe chillfish knows another way?
then just handle the bot endpoint one differently
I mean looking at the code
you're not using AsyncExitStack for what it was originally intended for, you're using just as a way of applying 2 context managers with one being optional?
The current implementation is the other way around btw
It doesn't work anyway so 
Pretty much
why dont you just like... code a basic setup yourself :P
Do manual acquire
l
import asyncio
class CtxMany:
def __init__(self, managers):
self.managers = managers
async def __aenter__(self):
return await asyncio.gather(*[
manager.__aenter__() for manager in self.managers])
async def __aexit__(self, exc_type, exc_val, exc_tb):
return await asyncio.gather(*[
manager.__aexit__(exc_type, exc_val, exc_tb) for manager in self.managers])
basically waht you're trying to do
ah feck missed the unpack
which method isnt awaitable
technically we can actually simplify this a bit more i think
what about it
import asyncio
class CtxMany:
def __init__(self, managers):
self.managers = managers
def __aenter__(self):
return asyncio.gather(*[
manager.__aenter__() for manager in self.managers])
def __aexit__(self, exc_type, exc_val, exc_tb):
return asyncio.gather(*[
manager.__aexit__(exc_type, exc_val, exc_tb) for manager in self.managers])
oh yes i see
didnt call it
Is anyone feeling like making a PR for this or do I stay up longer
I believe in you
I don't believe in myself but thanks 
Cuz "Limit all lines to a maximum of 79 characters."
is that some PEP bullshit
Yep

Will there ever be an endpoint for bot announcements?
that's honestly a veld question
why are you following the 79 character limit
yikes
100 is regarded as more reasonable
I personally don't
120 >
88 chars is the default ye
my sweet spot is 110
110 is too long
i barely do 100
100 is just the limit that word wraps text in pycharm's copy paste font and size 10
also just about the limit of github markdown as well on desktop
this extends a bit past 110 (is at 113) but i like this length
i will never really go past 110 though
because then i'll start breaking it down into shorter lines
now this is past 110 in python
https://i.imgur.com/DAJRQMt.png
miss using one line if statements like that
no confirmation. though i have heard about webhooks for announcements
Escucha "Tu Timidez" 🥰 → https://youtu.be/20yijqIJx18
🎵 Escúchalo en todas las plataformas digitales de música: https://lnkfi.re/BailaConmigo
📻 Sencillo producido por DJ Dayvi & Victor Cardenas
🌎 Sigue a Harmor Music
►Facebook: https://www.facebook.com/HarmorMusic/
►Twitter: https://twitter.com/harmormusic
►Instagram: https://www.instagram....
good moosic
thanks @hushed reef
for?
asking
ok
This is occuring when i am pressing send test. Pls help
Also can u pls help me to solve it
I saw some users using votetracker.xyz having trouble and I was wondering if it may be related?
What's your webhook url?
;s
it is for replit.com
yes, topggpy
@golden adder
Thnaks
how do I check if a user has voted? I'm very new to webhooks
just use the API route for vote checks
GET: https://top.gg/api/bots/{bot_id}/check?userId={user_id}
thanks
2021-07-01T18:23:51.238171+00:00 app[worker.1]: Traceback (most recent call last):
2021-07-01T18:23:51.238173+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/topgg/client.py", line 151, in _auto_post
2021-07-01T18:23:51.238174+00:00 app[worker.1]: await self.post_guild_count(
2021-07-01T18:23:51.238174+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/topgg/client.py", line 212, in post_guild_count
2021-07-01T18:23:51.238175+00:00 app[worker.1]: await self.http.post_guild_count(guild_count, shard_count, shard_id)
2021-07-01T18:23:51.238175+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/topgg/http.py", line 190, in post_guild_count
2021-07-01T18:23:51.238184+00:00 app[worker.1]: await self.request("POST", "/bots/stats", json=payload)
2021-07-01T18:23:51.238185+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.9/site-packages/topgg/http.py", line 121, in request
2021-07-01T18:23:51.238186+00:00 app[worker.1]: async with ratelimiters:
2021-07-01T18:23:51.238186+00:00 app[worker.1]: AttributeError: __aenter__
what the heck is this?
Update it
ok, thanks
The same thing happens to me
Refresh data
Just reload the page
How can I fix this error?TopGGAPIError [Top.GG API Error]: 403 Forbidden (You don't have access to this endpoint)
are you using a valid top.gg token? not discord bot token
That would've been a 401
They're trying to access an endpoint the token doesn't have access to
yes
How do I make the web hook so it posts a message every time someone votes for my bot on top.gg?
(Pls ping me in response)
did you seriously copy and paste my question
😒
i need help
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send('Hello Express app!')
});
app.post('/vote', (req,res) => {
console.log(req.body)
console.log(req.headers)
// res.end()
})
app.listen(3000, () => {
console.log('server started');
});
this no work? it says it has an error during test
Pro tip: you should say THE ERROR here too, if it has more details.
same error
you fixed it?
Help:
UnhandledPromiseRejectionWarning: Error: 403 Forbidden
the error is when i send the test in TOP.GG not my code i get nothing in my code
like this @tepid bison
hey there i cant get the on_dbl_vote working (python), am i required to setup the webhook like given in example in docs or running the sole function in a event should work?
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password") bot.topgg_webhook.run(5000)```
Like is it necessary to have this setup before i can use `on_dbl_vote` event?
Yup
It's necessary
yes, make sure the port is forwarded in ur router and that u have the right url and authorization on the top gg page
a
can someone help me with getting the webhook part of top.gg to accept my webhook?
i dont understand what i'm doing
im trying to do this vote tracking for my server but...
Says changes were done, but the test doesnt work
hello, i am getting this error in topggpy
Failed to post server count
AttributeError: __aexit__
class Handlers(commands.Cog):
def __init__(self, hyena, colours):
self.hyena = hyena
self.colours = colours
self.unmute_temp_mutes.start()
self.update_stats.start()
self.hyena.add_check(self.toggle)
@property
def category(self):
return ["None"]
@tasks.loop(minutes=30)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count."""
try:
await self.hyena.topgg.post_guild_count(len(self.hyena.guilds))
print(f'Posted server count ({self.hyena.topgg.guild_count})')
except Exception as e:
print('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
ignore other things
just the update_stats task im talking about
Update it
update what
It's fixed on v1.3.0, if you're already on that version, then it's a different story 
wait
i updated it
lemme try it again
thanks its working again


Hello, I had a question since the rework of the website I can't find my top.gg API key, where could I find it pls ?
On the webhooks tab in the edit section click "Show token"
I got this when I click on the webhooks button is that normal ?
okay it's all good, I've refreshed the cache and now it's working
Thank you
You're welcome
Not related to Top.gg API
it is tho
It will work if refresh it i think
hello i have question how do i show the servers that my bot is in . The bot is already approved by discord ? tnk
Check the pins for the documentation.
Hi I have a problem with my bot, about votes, every time someone votes for it it doesn't send the webhook, much less the vote message
@runic atlas please reset your webhook token
I cannot generate another webhook token on top.gg
lmao cant open webhooks tab on my bot.
gives me this image as well (replied)
ive tried: clearing my cache (3 times), and using 3 different browsers. (same result on all of them)
command | all] [#channel | role]
same
same
Ctrl + F5 isn't working for you ?
How can I add this bot to my server
what bot
same
why top.gg sever takes long respond
i cant see webhooks announcements Analytics Votes Widgets all of them give me the same 404 message
Same
const { AutoPoster } = require('topgg-autoposter')
const ap = AutoPoster('my_token_was_here', client)
error: Unsupported client.
Any ideas?
i define my bot as client
How to make a topgg api
hello can anyone help me to activate my bot's voting messages by webhook? I'm not getting
Try regenerating your webhook token
Done that multiple times
Show me your full code pls
I got a bunch of stuff in between
Oh
Mostly setting presence and stuff like that.
I see. Well, You should define client before adding that code. Did you?
I have a command handler, client is defined, yes.
Djs?
yes it is in discord.js
You are using that code in a command handler? If yes, Don't. It should be in your main file.
Use in main file
I'll give that a go
Ok
Same thing
const client = new Discord.Client()
const { AutoPoster } = require('topgg-autoposter')
const ap = AutoPoster('Your Top.gg Token', client)
ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
})```
I have exactly that, just without
const client = new Discord.Client()
and
ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
You need to add the ap.on
Still no luck
Weird
appreciate ya trying <3
What do you define client as
const { Client, Collection } = require('discord.js');
const client = new Client();
hello can anyone help me to activate my bot's voting messages by webhook? I'm not getting
what's wrong with my code? he doesn't send the voting message
https://sourceb.in/AK6HR6hG7C
@runic atlas
Hey
in the webhooks option
Ok
@runic atlas im getting a webhook password from this page
?
@runic atlas !!!????
Yes Yes
Ware @runic atlas ?
Deleted
You should delete the image you send before.
ok
@upper lark done
But iwant get a webhook data information
@upper lark
@upper lark hello?
@runic atlas hey?
😑
Hey what are you trying to achieve exactly with the webhook?
So what you do is create a webhook yourself you want top.gg to send a request to everytime someone votes your bot. You then paste that webhook URL in the webhook settings of your bot and boom.
Read more about the top.gg webhooks here: https://docs.top.gg/resources/webhooks/
How to create
I'm not going to give you a tutorial on how to setup a webserver and do those things.
But if you are using javascript you could use express to setup a webserver and create your webhook. Thats all I'm gonna give you.
You pasted a top.gg webhook link?
Thats not going to make your bot automatically post a notification when someone votes??
Yeah
@coarse rune can u teach me how u made vote rewards?
@half compass You can use the webhook functionality for that. You can configure a webhook in the webhook tab of your top.gg bot settings.
Sure
Which language do u use @half compass
discord.js
heroku and github
Hello
I would like to put the servercount of a bot on a website. I tried with fetch("https://top.gg/api/bots/ID/stats") and then retrieve the data but I got this in json: {"error": "Unauthorized"}.
This is because no one is logged in, from my website. How can I fix this?
You need to provide authorization with that request, read the docs under https://docs.top.gg
Yes
Save it in a file that's hidden
how ?
Well, first of all, how does everyone see your token
if they look at the source code
yes
Use .gitignore
Oh you're spamming all the channels?:D
Hi all! Hoping to find some support here:) I'm trying to add my colleague to the team I just created, but I dont seem to be able to do so...
Inspected the browsers network traffic and apparently this call (containing our team ID) fails with a 500 (and no response message):
PUT https://top.gg/api/client/teams/199833927912218624/invites``` This is the payload (correct imo){"role":2,"userId":"591901029969166352","useDiscord":true}
Is there another way to add `591901029969166352` to my team?
No luck there since it's an issue with top.gg, unfortunately
Teams have been broken for a while now
alrighty, no workaround exists for my colleague to get to the bots analytics?
Sadly, nope. One (and pretty much the only way) is for you to send them to your colleague manually
I don't think they are or will be, unless you literally scrape the webpage itself somehow
and that doesn't sound possible from what I remember
OK
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)```
In this do i have to edit the `webhook_path`?
Up to you. /dblwebhook is perfectly fine though. You'd better migrate to topggpy by the way
Wie bekomme ich das N/A neben meinem bot weg bzw was bedeutet es?
got it. Thank you.
Is there a tutorial on how to display your bots server count on the website?
Dein Problem ist genau das gleiche wie meins
Hello how to check if a user has voted or not. Discord.js btw
Ok so is it correct?
const top = require("top-gg/sdk");
const api = new top.Api("Token");
if user = await api.hasVoted();```
Did you try it
Opening my project
Pls tell how did u do it
Do let user no if user
Another question as i cant get the on_dbl_vote working, do i need to have a webhook setup in my bot's page to get it working
And in a hurry
Do you have it?
I mean do you have the vote tracker in your bot
Hi.Ich möchte in Python gerne die top.gg libarys verwenden.Allerdings benutze ich nicht
@bot.commands
def Command:
....
Sondern:
if message.content.startswith("Command")
...
Kann ich die libarys trotzdem benutzen?
Ok
So you have to get the webhook auth first
And then you have to setup the app and listen for the webhook
Hi, I would like to use the top.gg libarys in Python, but I don't use it
@ bot.commands
def Command:
....
Rather:
if message.content.startswith ("Command")
...
Can I still use the libraries?
Amd then after voting you have get the user and add your reward
How? I use heroku for my bot hsoting
Pls help
yes, you can still use the python API wrapper despite the way you declare commands
But I don't have an @bot at all, for example
So long as you use discord.py, you are fine
Ok give me your webhook link
For this
Which webhook link?
Btw I I it but it's not automatic
I used integromat
Is there a topgg python api?
l can't vote any bot in pc but l can in mobile how?
How do I do vote tracking for discord.py with top.gg?
https://docs.top.gg probably
thanks
But the example in the Website is Not working
Because i have no @bot
Sending the code might be helpful. What do you mean by not working though? Did it raise errors? If so, send the errors as well.
What did I just see....
What?
can someone please explain to me how to add the server number to my bot?
How do i make this example, work for servers instead of bot? Everything i see is for bots, bots and bots. Nothing server related.
That doesn't seem to require any bot instance.
And the payloads are similar, you can technically use it for servers, ig.
yes, but how?
what am i to put here?
cant access my webhook 
ok figured it out, but how do i add this package?
i cant run any npm commands
ok got it all sorted out
How to create my own DBL webhook
Run a webhook service and enter it’s IP/DNS on topgg.
Or use already existing libraries.
Examples and more infos can be found in the docs.
Those are pinned in this channel.
how do we setup a voting event for discord.py
It wont allow me to test anything
What are the dependencies exactly for autoposter? I keep getting unsupported client error
const { AutoPoster } = require('topgg-autoposter')
const ap = AutoPoster('my_token_was_here', client)
ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
})
I got top-gg/sdk & topgg-autposter installed. Pretty much it
Hi i use Python but different than the others.
I use not @bot.command
it's best to look at it yourself
https://github.com/Tobias2021/dcbot_german
Can i use Nevertheless the API because in the Page the example ist Not working
Hello, it's possible to know if a user has vote for a server ? I tried to find but I only see for a bot.
That's such a poorly managed project
Yes you can
topggpy works fine with discord.py
but where do I get the @bot then
It literally refers to your discord.Client instance
bot = discord.Client
?
bot = discord.Client(...)
discord.ext.commands.Bot subclasses discord.Client so both are allowed
Okay thanks for your answer
bot = discord.client
@bot.event
async def on_dbl_vote(data,message):
await message.channel.send("Vote")
why is this not working
Why message there lol
Also, you are supposed to use an existing instance of discord.Client
Seeing your code, you can just do ```py
class MyClient(discord.Client):
async def on_dbl_vote(self, data):
...
Hi, i am using dblpy. Mentioned in the docs (https://topggpy.readthedocs.io/en/latest/api.html#client) is a "bot’s Top.gg API Token", where can I find it?
nvm
Man's using dblpy yet referring to topggpy docs
🤣
I should make a separate documentation for dblpy that simply yells "THIS IS DEPRECATED. MOVE TO TOPGGPY INSTEAD"

Does anyone know how to show on the page how many servers my bot is on?
well if you can read i said "nvm"
you can simply use autopost. (https://pypi.org/project/topggpy/) go to the bottom of the page
I mean by default
uh, idk about that, sry
"by default" as in what
how would i give a role for voting for my bot?
I think, they meant on the website directly or smth like that
what's the /dblwebhook ?
I'm trying to get the user how has vote for my server but I don't find where in the docs so I tried this but I don't know what's is the /dblwebhook
It's called path, reading an article about anatomy of a URL would help.
Hi, when I look in the topggpy documentation, I see that the event "on_dbl_vote" do not return WHO voted
is there a way to see that ?
It does provide you the ID of the user.
hm ok cool, because I can't test directly, and the documentation show just this information about the event "on_dbl_vote"
https://topggpy.readthedocs.io/en/latest/models.html#botvotedata
oh ok no it's inherit from VoteDataDict
Ye, it only shows the type hints it has. But, it does inherit VoteDataDict which has user attribute. So, you can do data.user/data["user"], either works.
Exactly



