#topgg-api
1 messages · Page 150 of 1
how to set
Do know python?
yes a bit
oh so i just define a value for variable webhook_path
You set it to a string, yes
ah i c
what?
eg: http://<id>:5000/<webhook path>
okay ik this is supposed to be string
but in the webhook path wut shld i actually put
woah rlly?
it can be anything
as long its a str?
so it can be like eg: http://<id>:5000/jonse
Yes
assuming i put the correct id
of course don't set the webhook_path parameter to the full url, only the path
since i used
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path=url, webhook_auth=auth, webhook_port=5000)
the port id here must be 5000 right?
ah
It doesn't have to be 5000, but it works
oh
as long as the port is open on your network and not in use by another app
i c
okay the http://<id>:5000/jonse says site can't be reached
when i put in my browser
Is the port open?
how to know whether a port is open?
Did you forward it in your router's settings?
Yes, that's why I told you to read into webhooks a bit more
wow it sounds like a lot work man
If you've never done anything network related before it's gonna be pretty hard, yes
actually i remember doing smt with network
like i used a port id to hack a system and message the victim
its for a course
no one got hurt
just to be clear
but this was 2 years ago
so can't remember
i got an error saying path should be started with / or be empty
but i use /jonse
wut's wrong here
show how you defined your path
http://<id>:5000/jonse
Yeah no, in your code
def __init__(self, bot):
self.bot = bot
self.token = os.environ.get("dbltoken")
#self.dbl = dbl.DBLClient(self.bot, self.token, autopost=True) \
dblid = os.environ.get("dblid")
#http://<your public ip>:<port>/<webhook path>
url = f"http://{dblid}:5000"#/jonse
#url = os.environ.get("dblurl")
auth = os.environ.get("dblauth")
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path=url, webhook_auth=auth, webhook_port=5000)
async def on_guild_post():
print("Server count posted successfully")
#channel = bot.get_channel(825627974720159774)
#await channel.send("Server count posted successfully")
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print("Received an upvote:", "\n", data, sep="")
#print(data)
channel = self.bot.get_channel(825627974720159774)
await channel.send(data)
user = data['user']
embed = discord.Embed(description="New Vote! Voter: {}".format(user))
await channel.send(embed=embed)
@commands.Cog.listener()
async def on_dbl_test(self, data):
"""An event that is called whenever someone tests the webhook system for your bot on top.gg."""
#
#try:
print("Received a test upvote:", "\n", data, sep="")
channel = self.bot.get_channel(825627974720159774)
await channel.send("Received a test upvote:", "\n", data, sep="")
#except:
#await channel.send("Received a test upvote:", "\n", data, sep="")
url = f"http://{dblid}:5000"#/jonse
Well, I told you to not set the path to the full url
only the path, so url = '/jonse'
Petition to rename path to route
petition to rename path to lastSlashThingsAtTheEnd

might not be coding friendly
but helps people who don't read docs
LMFAO that would be so worth it
so about 99% of people then, sounds great :)
You still need port 5000 to be open
you see, my smartness, It's almost frightening
def __init__(self, bot):
self.bot = bot
self.token = os.environ.get("dbltoken")
#self.dbl = dbl.DBLClient(self.bot, self.token, autopost=True)
dblid = os.environ.get("dblid")
#http://<your public ip>:<port>/<webhook path>
url = f"http://{dblid}:5000"#/jonse
#url = os.environ.get("dblurl")
auth = os.environ.get("dblauth")
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path="/jonse", webhook_auth=auth, webhook_port=5000)
async def on_guild_post():
print("Server count posted successfully")
#channel = bot.get_channel(825627974720159774)
#await channel.send("Server count posted successfully")
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print("Received an upvote:", "\n", data, sep="")
#print(data)
channel = self.bot.get_channel(825627974720159774)
await channel.send(data)
user = data['user']
embed = discord.Embed(description="New Vote! Voter: {}".format(user))
await channel.send(embed=embed)
@commands.Cog.listener()
async def on_dbl_test(self, data):
"""An event that is called whenever someone tests the webhook system for your bot on top.gg."""
#
#try:
print("Received a test upvote:", "\n", data, sep="")
channel = self.bot.get_channel(825627974720159774)
await channel.send("Received a test upvote:", "\n", data, sep="")
#except:
#await channel.send("Received a test upvote:", "\n", data, sep="")
just make all variable names extremely overinformative, big brain
your url is still the same?
oh, you just didn't remove the vairable
nevermind
see the ```self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path="/jonse", webhook_auth=auth, webhook_port=5000)
yea
Well your code has nothing to do with actually opening the port
5000 still needs to be open brother
so to open i have to go to my router?
Your router and firewall on your PC
Look up port forwarding for the router
Did you look up port forwarding?
as in did i look up port forwarding in the setting search bar or in google
anyways no for both
mmm
ah nvm i do this another time i go college and taking cybersecurity, networking is rlly not my thing i am going to ask my friend for help on this
anyways thq u @night ingot
Also, that screenshot shows your gmail address, just a heads up
https://comhad.github.io/webhook.html?page=serverless if you want a temporary soloution in the mean time
kinda confused
how do i make a webhook to send votes to discord
can someone send me a guide?
damn
For some reason, my bots server count page says 4 servers when its in 100+, why is that? ive even regenned my token thinking maybe that was an issue but it still hasnt updated, i did this over 24h ago
are you posting your server count properly?
Unless it was updated recently; its been working for months. but just a couple of days ago it stopped
import dbl
class events(commands.Cog):
def __init__(self, bot, *args, **kwargs):
self.token = 'My Token'
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)
@commands.Cog.listener()
async def on_guild_post(self):
print("Server count posted successfully")```
To check if my cogs are loading I will need to add a cog listner right?
here
@frail rapidss.coglistner
def setup(bot):
bot.add_cog(TopGG(bot))
print("cog loaded")
or is the @frail rapidss.coglistner
wrong
Sorry for the @
I mean @ commands.cog.listener
Or is this API okay
Still having issues with the webhooks sending multiple responses
108.162.... - - [23/Apr/2021:12:37:29 +0000] "POST /api/votepathhere HTTP/1.1" 504 183 "-" "Top.gg Webhook/1.0.0"
172.68....- - [23/Apr/2021:12:37:32 +0000] "POST /api/votepathhere HTTP/1.1" 200 24 "-" "Top.gg Webhook/1.0.0"
162.158.... - - [23/Apr/2021:12:37:33 +0000] "POST /api/votepathhere HTTP/1.1" 200 24 "-" "Top.gg Webhook/1.0.0"
108.162... - - [23/Apr/2021:12:37:33 +0000] "POST /api/vvotepathhere HTTP/1.1" 200 24 "-" "Top.gg
this is for 1 person who voted
this all started after the webhooks were updated about a month ago
it happens randomly
Iv'e used the same code for the past year and never had any issues
it's responding from different IP's and I responding with 200 as was told but it's still not resolved
How do i use the webhooks? like, for voting can i just put a webhook to a channel in my server? or is it for something else
anyone have code for the server top.gg server count i can use for discord bot maker? the progam instad of actual coding lol
im using this but doesnt seem to work https://rawdata.dbm-network.org/search?show=MNi3CV&page=1&searchInput=top.gg
Want to post your server count to Top.gg? Here you go! Enjoy!
You might need to do:
npm i https
npm i querystring
I think so.. It doesn't happen all the time
maybe a few times a day if that
most the votes are fine
I'd suggest making sure then
Webhooks arent directly compatible with discord webhooks, but i made this which shows you how to connect them
https://comhad.github.io/webhook.html?page=serverless
then what?
Are there any things you need to enable to get your discord bot server count or is it just this:
there a good node lib for this?
read pins
oh cool ty
You got it working already?
Use the @top-gg/sdk
Think that is a better option, easy to set-up
Is that enough for it to work?
No it is not working.
Why not ? @acoustic lark
Not sure
I will look again
Still not working
I will look for errors on my PC when I am on it
In webhooks I think
Yep in Webhooks tab in your bot
@rain heart Yop
So i try to use your lib for webhooks, but i got this from my console, How you fix it ? I don't receive tests from Top.gg btw
What IP are you using on top.gg? Make sure the Authorization is correct
It is not the 0:0:0:..
so now i get <Response [400]> what does this mean?
And have you added a listener aswell?
I create a listener, i authorize the connection in my firewall, and my Authorization is correct
Add Options.Ignore_Authorization and Options.Ignore_Validation at the last parameters
Of the listener
code py if message.content.startswith('e!gif'): print (message.author.id) r = requests.get(f'http://top.gg/api//bots/830771134177083393/check?userid={message.author.id}', headers={'Authorization' : os.getenv('TOPGGTOKEN')}) print (r) if any(word in r for word in voted): gifid = ''.join([str(e) for e in message.content.split('e!gif')]) await message.channel.send(f'https://cdn.discordapp.com/emojis/{gifid}.gif?v=1')
i will try
Not //
oooh
Remove the second /
i did and still got the 400 error
Re-check the docs then
i did and i am still confused
have you tried making a manual request using just the url and a random user ID?
Try userId with a capital I instead, at the end of your url
It's case-sensitive, yes
oooh
if you enter the url in your browser, it will tell you what's wrong
one sec lol
@rain heart I try but same problem, started under 0:0:0:0:0:0:0:0 and no test received :/
@spark raven
Show the full log
it should say something like "Listening under" etc
because of the parameter being wrong then
http://ip:port/BotWebhook would be your webhook
otherwise DM me the url and I'll try to make a test request
you had userId not correctly
it is case sensitive like Spaxter said
(f'http://top.gg/api/bots/830771134177083393/check?userId={message.author.id}', headers={'Authorization' : os.getenv('TOPGGTOKEN')})```
still no tho... still error 200
It works now, thanks ^^
Don't forget to remove the 2 options again, otherwise it would still fire when either the request being invalid or no auth being there
Yup
what the fuck is voted in that snippet
where
this
no clue 
1
if any(word in r for word in voted):
yeah
What does it even check is my question
meaning voted would be 1 if they have voted
Yeah how do you define voted
And why are you using the in operator in the first place
voted = ["1"]```
bc its how i know how to do it, and i am super stubborn lol
if the response has 1 in it, it allows the emoji to go through
I hope you do realize that you could just do r.json()['voted']
instead of whatever the fuck that isn't working
because
Are you okay
As the API documentation suggests, you receive a response in JSON format
...fuck me
r.json() where r is your response attempts to convert the response text into a dictionary
then from that you get the voted field which contains either 1 or 0
Oh and yeah
in with requests.models.Response objects doesn't work as you think it does :)
You either do directly r.text for checking the text or x in r.json() to check if a dict key is returned in the response
ok
Hey, Should I need to turn on Privileged gateway intents for posting server count?
No. All you need is the guilds intent
Ohok
That is on by defualt right
I don't remember. It's probably better to make sure it is enabled explicitly
Hi, I have a question. If we want to make a webhook. Can we make a flask webserver
?
Yes but you will have to make sure you can run your discord.py bot alongside with it
If you want to run them together, you can run your aiohttp webserver as a cog
Ok thanks! ^^
whats the path for webhooks? https://my-ip:port/dblwebhook right?
ignore the slash after my-ip
its some discord formatting error
my-ip:port/dblwebhook is what i meant
/dblwebhook would be your path
ah ok
but yeah as i read the pins and experienced myself
they dont seem to work currently
is your webhook server running behind a firewall or router?
Hey so I'm getting the unauthorized error when trying to use the DBL API
My token is correct, but it still tells me unauthorized.
I'm trying to use get_user_vote() and get_bot_upvotes() and it's telling me unauthorized
This surely isn't because I defined DBLClient in multiple cogs, is it?
you have to make sure your DBLClient has a token/has the right token
the token is not your bot token, but the one found on top.gg bot page
Yes I have that and it is correct
I'm loading the token from a .env, and it was working fine yesterday
the only thing in my DBLClient is client and token respectively
I used to define webhook but there isn't a need
Make sure you have the correct bot client that's connected to the correct bot account
dblpy gets bot.user.id for both of those endpoints
dbl.DBLClient from the dbl package with matching DBL API tokens
bot client as in your commands.Bot instance
yeah
client = commands.Bot(command_prefix=prefixes, intents=discord.Intents.all())
dblc = dbl.DBLClient(client, dbltoken)```
dbltoken is a string retrieved from a loaded .env
does returning a 404 status code and 20x status code the same ?
to top.gg when receiving webhooks
Refresh your top.gg token
I did
Try again 
Is this JavaScript or I’m wrong
Python
Yeah I’m wrong
Are you sure you are copying the entirety of it?
someone tell me meme api
-api
This channel is ONLY for the Top.gg API!
This channel is only for: suggestions/help/bugs to do with official API libraries and API docs found at: https://docs.top.gg
Any Off-Topic conversation may get deleted and muted.
If you need help with development about your bot or development in general, feel free to use #development.
https://docs.top.gg adresinde komuta oy zorunluluğu getirmeyi bulamadım nasıl yapabilrim sadece 1 tane komuta uyguluycam
nope..
I am..
yeah totally
Its not discord.webhook if you have top.gg sdk
const express = require('express') const { Webhook } = require(`@top-gg/sdk`) const app = express() const wh = new Webhook('webhookauth123')
consts
!play
authorization is what you want to use to authorize requests
not your bot token or top.gg token
something you create yourself
so webhooks token...
something you create yourself, yes
You go to your bot page, click on edit, click on webhook
At the url you doo http://host ip /url with port>/dblwebhook
Authorization you just place a password or a token that you make yourself.
Any plans on updating the API for Java?
Still waiting for that aswell, the maintainer of that library hasn't worked on it whatsoever since 2019
Thought about taking it over, though I doubt my current Java knowledge might be worth it
If you know someone who'd love to take over, feel free to DM Veld 
I don't think my Java knowledge will be any good either. Perhaps I could look at the current source code and tinker around with it
bot page settings -> webhooks
I mean I would be able to make a library for it, but I doubt it would be as extensive as the current one
I'd love to give it a try
isnt there a long token for the bot
its not there
it is there
Tbh all I really need is for me to know when someone votes
oh then feel free to use my library for webhooks: https://github.com/Hopefuls/topggwebhooks4j
Java Webhook Library for Top.gg. Contribute to Hopeful-Developers/topggwebhooks4j development by creating an account on GitHub.
Does it work with JDA? It says it's compatible with Javacord
It should work with JDA aswell, it was just tested with Javacord
Thanks a lot! This will help me immensely :)
also kinda made the listeners the way Javacord would make it, but should definitely work even without any Discord library
-networth
you're in the wrong server
@rain heart https://hopefuls.github.io/topggwebhooks4j/ doesn't seem to be working
@rain heart in your LoggersBro example bot, is there a reason why you set your port to 6969? Sorry for all these questions
Thanks!
@rain heart anything I could be doing wrong here? Nothing is coming through my bot
final Webhook wb = new WebhookBuilder().addBotListener("BotWebhook", new BotWebhookHandler(),
"TOKEN").setPort(8199).build();
try {
wb.start();
System.out.println("Voter webhook successfully started.");
} catch (IOException e) {
System.out.println("Voter webhook unsuccessful.");
}```
What's token
Authorization, to authorize the webhook requests
Any request not matching the Authorization will not fire the Webhook
So I create my own authorization token and put it in where I have "TOKEN"?
You're talking about the settings in the webhooks section right?
You can set it to whatever you want, like "MyWebhookCode" or "NobodyIsGoingToKnowThis"
Yes i am
The addBotListener
Correct
That has to be the same as the String you have with "TOKEN"
Okay, and what am I supposed to do with the long generated token?
Where does that come in
That's only for interacting with top.ggs api
Doesn't have to do with webhooks
Such as with the Java-SDK
If I want my bot to recognize when people vote and get their snowflake ID, I would need to use that right?
You can use getVoteData on the event of the webhook to get everything the webhook sent
Like the User ID, Bot ID etc
The webhook library doesn't touch the top.gg api at all, it just parses what is sent to the webhook and fires the event if the data is valid and is authorized
Can the authorization token have special characters
I'm not quite sure what I'm doing wrong. I've fired the Test vote multiple times but nothing seems to be coming in on my end.
Do I need to have a webhook URL?
hi
You need to enter it on your bot page, yes
Make sure it isn't https or 0.0.0.0 or localhost
Can I use Discord's webhook bots
You can't use discord webhooks there
-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.
Don't all webhooks have https
Your selfhosted one can't be https as it is using a different port
And https is only for actual webservers
I travel around a lot so it would mean I have to change the URL all the time. Is there any other method for the webhooks
There's not, no
Unless you want just logs, which you can do with either Vote Tracker or a different bot
But if you want to reward users on your bot, there's no other way
Thanks - somehow missed the answer for this. Anyone know what timezone it's in?
Could I open up a port on a cloud VM and use that?
@sullen nymph i've got an error stack for you, having issues with API guild submissions.
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\17046\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "D:\Work\Coding\Coding\GitHub\Transword\Transword.py", line 118, in on_ready
await transword.API.post_guild_count()
File "C:\Users\17046\AppData\Local\Programs\Python\Python39\lib\site-packages\dbl\client.py", line 160, in post_guild_count
await self.http.post_guild_count(guild_count, shard_count, shard_id)
File "C:\Users\17046\AppData\Local\Programs\Python\Python39\lib\site-packages\dbl\http.py", line 168, in post_guild_count
await self.request('POST', '/bots/stats', json=payload)
File "C:\Users\17046\AppData\Local\Programs\Python\Python39\lib\site-packages\dbl\http.py", line 93, in request
async with rate_limiter: # this works but doesn't 'save' over restart.
File "<string>", line 6, in __aenter__
TypeError: object Lock can't be used in 'await' expression
Python 3.9 compatibility issues
You can scrap the ratelimiter module and locally add the one I have on the GitHub repo
having trouble finding this
It should be on the sdk repo
A simple API wrapper for top.gg written in Python. Contribute to top-gg/python-sdk development by creating an account on GitHub.
And I'm sure you know how to delete a package

@sullen nymph 
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\17046\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "D:\Work\Coding\Coding\GitHub\Transword\Transword.py", line 118, in on_ready
await transword.API.post_guild_count(
File "C:\Users\17046\AppData\Local\Programs\Python\Python39\lib\site-packages\dbl\client.py", line 160, in post_guild_count
await self.http.post_guild_count(guild_count, shard_count, shard_id)
File "C:\Users\17046\AppData\Local\Programs\Python\Python39\lib\site-packages\dbl\http.py", line 168, in post_guild_count
await self.request('POST', '/bots/stats', json=payload)
File "C:\Users\17046\AppData\Local\Programs\Python\Python39\lib\site-packages\dbl\http.py", line 105, in request
kwargs['data'] = to_json(kwargs.pop('json'))
File "C:\Users\17046\AppData\Local\Programs\Python\Python39\lib\site-packages\dbl\http.py", line 222, in to_json
return json.dumps(obj, separators=(',', ':'), ensure_ascii=True)
File "C:\Users\17046\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 234, in dumps
return cls(
File "C:\Users\17046\AppData\Local\Programs\Python\Python39\lib\json\encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "C:\Users\17046\AppData\Local\Programs\Python\Python39\lib\json\encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "C:\Users\17046\AppData\Local\Programs\Python\Python39\lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type method is not JSON serializable
we're upgrading!
Looks like TopPY really hates fucking 3.9 
-api
If that vm has open ports, yeah
anyone?
-servercount
To have your bot's server count displayed on Top.gg, please read the documentation on server/shard posting.
-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.
-bots
that's intentional
how to setup webhook?
also the bot has to be approved before using widgets
you said to me?
Getting Started
Start by setting up your webhook URL in the edit form of your bot on this site, it can be found at https://top.gg/bot/:your-bot-id/webhooks. Once you've entered the URL you want the webhook to be sent to, you're all set! If you need help setting up webhooks inside of your bot** don't be afraid to ask in our discord server in the #topgg-api channel.**
Actually try it yourself first before entering here
not working 😦
read pins then
it's easy you do by yourself
if you're only referring to the misspelling, yeah that's intentional
should a code be run or just specify the url?
you need code
ok 👍
ofc widgets are broken 
ok I don't want to be a baby, but can someone who uses python please send me your code to see if someone has voted using API? i have been trying for so long so can someone please help me?
Thx for fixing 😅
thank @craggy sentinel
I wrote a flask app and put it here
https://comhad.github.io/webhook.html?page=dedicated
tysm!
Np :D
-wrongserver @velvet dune
@velvet dune
Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Get Support" button on the bot's page of the bot you need support for, not the "Join Discord" button at the top of our website. If there isn't a button that says Support Server or you were banned from the bot's support server, then we can't help you. Sorry :(
Ok
I have a guide on this :
https://comhad.github.io/webhook.html?page=serverless
ty
That's assuming you don't have a VPS or anything like a server exposed to the internet, i have an alternative guide if you do
Nah I do not have a VPS
Ok, then just use that guide for now
i did this script to send a message when a member vote for my bot
I don't think you should post your token
no
Reset your token

i copy paste
import discord
from discord.ext import commands, tasks
import requests
import aiohttp
from aiohttp import web
import logging
import dbl
from config.config import la_couleur, lien_vote
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = "my token"
self.dblpy = dbl.DBLClient(self.bot,
self.token,
autopost=True,
webhook_path="/dblwebhook",
webhook_auth='password',
webhook_port=5000)
async def webserver(self):
async def handler(request):
return web.Response(text="Hello, world")
app = web.Application()
app.router.add_get('/dblwebhook', handler)
runner = web.AppRunner(app)
await runner.setup()
self.site = web.TCPSite(runner, '0.1.4.8', 5000)
await self.bot.wait_until_ready()
await self.site.start()
@commands.Cog.listener()
async def on_dbl_test(self, data):
print(data)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
vote_data = data
voter = await self.bot.fetch_user(vote_data['user'])
channel = self.bot.get_channel(824737862779273230)
em = discord.Embed(title=f"[Nouveaux vote]({lien_vote})", colour=la_couleur, description=f"{voter} ({voter.mention}) vient juste de voter !")
em.set_footer(text="Vous pouvez voter toutes 12 heures !")
await channel.send(embed=em)
logger.info("Received an upvote")
print(data)
def setup(bot):
global logger
logger = logging.getLogger("bot")
bot.add_cog(TopGG(bot))
top = TopGG(bot)
bot.loop.create_task(top.webserver())```
So i did this script to send a message when a member vote for the bot
but it's not working
and there is not error
in my terminal
Can I use a discord webhook as my webhook???
No
what type
Not directly, see that guide i sent you
Okay
You can put it into that site and then forward it to a discord webhook, that's what i use to do
Hmm, is it possible that logger might stop an error printing?
HTTP request right
Yes
ok
Sorry, i've not used the SDK that much so i don't know much about that
what is sdk ?
Software development kit, the thing you're using for webhooks
Your webserver method is redundant as passing this would set the webhook automatically; those 2 are conflicting. Also, why are you instantiating 2 different cog objects?
You know, I'm not surprised that the way the webhook works in v0.4 managed to cause this to happen
So when is v1 rolling out 
this one right? @spice helm
Is there anything wrong with this?
Not working no errors tho
const webhook = new Topgg.Webhook("your webhook auth")
wat does it mean by webhook auth?
and where can i get it
authorization you create yourself
has to be the same on your bot page settings and code
see docs
lacks of self parameter
wdym by that
is it this thingy?
what ever i put in this field
yes
ight thanks
you create it yourself, it authorizes your requests
k
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.
Instance methods should have a parameter that takes the instance of the class, which by convention named self. So, add it. Though, it should've posted the stats to the API despite this lacks of self parameter, it just won't print it.
Ive been told that doesnt work all the time, so use the http module instead, if you scroll down on the guide it should show you how to use discord webhooks with that
Okay ty
Where should I add it
I need the counter,py too right?
If you want to log them too, yes, add it to your bot
Yes, but you'll have to code something to save the voter info if thats what you want
Yes, it will need to be active at any point someone could upvote
But how to a start the program, I can only find run once
Should be a little switch you can click into on
this right
yeah
Alright, thats all working then :)
thanks for the help i really appreciate it
Np :D
Is there a way I can @ the user who upvotes my bot?
As in ID or USERNAME or something like that
Yeah, that'll work, just use the 1.id variable from integromat
Wait no
It might be something else, i used that webhook for discordbotlist aswell im getting confused, just check the docs for whatever is a user id
Hey, I need some help with the webhooks
I'm running my bot on a Raspberry Pi, and I'm very new to webhooks
My Bot's Top.gg webhook URL is in the format http://MY-IP:PORT
It doesn't work
going to that web address leaves a 404, and going to that web address /dblwebhook returns a 405
It doesn't work and I'm new and confused
so any help would be appreciated!
:D
You cannot make get requests
Get is referring to going to the website in your browser
Then your url is wrong or faulty
Posting code could help
Postingn your approach could help
self.dbl = dbl.DBLClient(self.client, dbltoken, autopost=True, webhook_path='/dblwebhook', webhook_auth='69420', webhook_port=5000)```
are you portforwarded? are you using your public ip, not internal.
hmm
Just tried two different IPs, neither of which worked
I tried the one that I can use for things like SSH, and I used one I got when i curled canhazip.com
did you port forward? zero chance it will ever work without portforwarding.
Again, I'm very new to webhooks. Could you explain?
sure. routers have firewalls, any incoming request is blocked unless you tell your router to accept requests on that port, and where to send the request to.
ie port forwarding, forwarding the port to a specific device.
ah
https://portforward.com/ has guides for most router models on how to port forward.
its very router specific.
alright
Will I have to restart the router or anything after port forwarding?
depends on the router.
We have an old TredNet one, so I would assume so
Can someone help me? I'm trying to make the webhook work on vps but I'm not getting it
Have you filled in the webhook url and auth on the website?
yes
I'm using like this:
Webhook URL = http://my.server.ip:80/dblwebhook
Authorization: ...
in this model I meant
You can't use port 80 for webhooks
it would be 5000 right? I already tried too
It would be whatever you set it to in your code
in my code I did not define any port because there is nothing written there in the libraries
There should definitely be a port definition somewhere in the code
what library are you using?
const express = require('express')
const { Webhook } = require(`@top-gg/sdk`)
const app = express()
const wh = new Webhook('webhookauth')
app.post('/dblwebhook', wh.listener(vote => {
console.log(vote.user)
}))
app.listen(80)
in js
use a different port than 80
in your app.listen you set port 80, yes
ah, I didn't know what this part is for
I put 5000 and nothing yet
what is the address you've entered on your bot page url
it has to be in your case http://serverip:5000/dblwebhook
it cannot be 0.0.0.0 or localhost or 127.0.0.1
I'm using this one
You need to put your actual server IP
What do you do if you are locally hosting?
I put my ipv4 address in place of serverip but nothing happens when anyone votes
but it doesn't make much sense because the ip would be the machine's and the machine I use to allocate the bot is the vps
exactly the same problem as mine
You need to use the public ip address, not the machine's local one
Yeah I did
I used a website to look it up
And make sure the port you're using is open
I have set up port forwarding in my router for it
A free open port check tool used to detect open ports on your connection. Test if port forwarding is correctly setup or if your port is being blocked by your firewall or ISP.
check if it's open on here
How can we know if someone votes our bot?
You can check if someone has voted through the API. Or use webhooks to know exactly when someone votes
Is this the code?
The ISP itself say it is open but the website says it isn't
yes
I literally gave a copy and paste of the site, I just took a little something
ty
i have problem with api
don't show up
^
ReferenceError: ap is not defined
at Client.<anonymous> (C:\Users\jakem\Desktop\EvalZero-main\index.js:63:3)
at Client.emit (node:events:369:20)```
maybe app?
you using old version use new one 😅
https://npmjs.com/@top-gg/sdk
I need help also
how can i make vote system?
const Topgg = require(`@top-gg/sdk`)
const api = new Topgg.Api("MY TOKEN CAN't SHOW ")
api.getVotes()
it retunes nothing
@restive otter do i need this too topgg-autoposter
no need
you can do manually
and how can i know if it work
const Topgg = require(`@top-gg/sdk`)
const api = new Topgg.Api("Your Top.gg TOKEN Here ")
setInterval(() => {
api.postStats({
serverCount: client.guilds.cache.size
})
}, 1800000)
use this and see your top.gg bot page
what is this shardId: client.shard.ids[0], // if you're sharding
shardCount: client.options.shardCount
you are not doing sharding
i think
if your bot is in too many server and you using sharding
like 5k or 10k servers
😅
don't show
you should have to run this with your bot bot code
do
do?
put your token 😅
I remove so i can take the photo
did i do it righ
setInterval(() => {
api.postStats({
serverCount: client.guilds.cache.size
})
}, 1800000)
TRY only this much
🤔
🤔 then why it works for me? Oh God what happening?
I didn't getting any error
"@top-gg/sdk": "^3.1.1",
it wired
is the api working for anyone
should i restall it
@restive otter
i am still have problem with it #
hello, I using heroku for host my bot, and Idk how to to detect when a person votes with this
how to get the ip ?
actually my code
const { Webhook }= require("@top-gg/sdk");
const topgg = new Webhook('Auth-test');
const express = require("express")
const app = express()
app.post("/dblwebhook", topgg.listener (vote => {
console.log(vote.user)
client.channels.cache.get('815356140375638057').send(`${vote.user} vote !`)
}))
app.listen(80)```
Idk much about heroku, but googling it says it doesn't have a static ip, but you could use this i made
https://comhad.github.io/webhook.html?page=serverless
@spice helm can you help me
I'll see what i can do
Idk much about node, but do you get an error?
Hmm, how many shards do you have?
32
Ok, right, it says its posting every 30 minutes, maybe its waiting 30 minutes before it first posts?
Try bringing it down to 30 seconds maybe? Then it should maybe give an error or post it, just don't forget to reset it afterwards, i've made that mistake lol
not work
Nothing? No error? Did you put the token back in?
```const Topgg = require(@top-gg/sdk`)
const api = new Topgg.Api("Your Top.gg TOKEN Here ")
setInterval(() => {
api.postStats({
serverCount: client.guilds.cache.size
})
}, 1800000)
(edited)
[20:06]
i did this
i Don't get any error
do u i need add token in api .js
@restive otter
do i need to have an authorization header with your token
You can't post your server count without providing your dbl token, no
@night ingot i have put my token where it tell me add it when save and restart and iit won't show up
it still won't show up
i have try again it won't show up
Did I code right @night ingot
I don't do js, unfortunately
Ok do u who dose kno
W
‘’’const Topgg = require('@top-gg/sdk')
const api = new Topgg.Api(‘token’)
setInterval(() => {
api.postStats({
serverCount: client.guilds.cache.size,
})’’’
}, 1800000) // post every 30 minutes
That got in my code
owo ping
if you are having trouble, its best to use the auto poster then
I'm still trying to make the automatic voting system, but it doesn't answer the test on top.gg, so I decided to put:
const webhook = new Topgg.Webhook ('...')
console.log (webhook)
then he replies:
Webhook {
authorization: '...',
options: {error: [Function: error]}
}
When setting up port forwarding for the Top.gg webhook, which application name should it be?
Ping me if anyone has an answer :)
http, unless you have https configured.
thanks
So, I enabled port forwarding on my router and my bot still isn't receiving the webhook test
This is what my rule looks like on my router
the IP address is the address of my Pi
Application name is HTTP and Computer Name is also my Pi
That's the only thing I've done with my router
and my definition of the DBL API is this
self.dbl = dbl.DBLClient(self.client, dbltoken, autopost=True, webhook_path='/dblwebhook', webhook_auth='69420', webhook_port=5000)```
and the webhook URL in the bot dashboard is this
http://RASPBERRYPIIP:5000/dblwebhook```
Any help would be appreciated!
so theres two ip's.
an internal ip, looks something like 192.168././(or 10.0.0.*) and an external ip, which has just random numbers.
when port forwarding you want to use the internal ip, not the external.
the url needs to be the external ip, the one you got from the website.
yes.
Still not working
your auth in your code and on the site is the same?
indeed
please dont spam
they are both "69420"
this is a support channel, do you need anything?
do you know anything else?
I really am not sure what else to try tbh.
The documentation gives the IP for the DBL webhook, but I'm not sure where to put that
Would I need to add it as a firewall rule?
oh like to attach to an ip?
oh, good point. do you have ufw or iptables on your pi?
i forget if pi's come with a system firewall by default.
UFW's status is active and port 5000 is active for ipv4 and ipv6
Would I need to add it as a firewall rule in my router?
oh wait, would I have to allow 5000/dblwebhook?
or just 5000
well then yeah it's enabled on my Pi
so it says
5000 allow anywhere on a line when you do ufw status?
yeah
do you mind dming me the exact url you are putting on the website?
sure
Hey how can I use discord webhook
top.gg webhooks are not compatible with discord webhooks.
sorry
Yes, there's no requirement to give out rewards for voting
My code is not working
Is port 5000 open on your network? Are you using the right url on your webhooks page?
Also, you can't use Discord webhooks for this
How can I check right port?
You don't check for the right port. You pick one that isn't in use, and open it through port forwarding
If my bot reaches 100 servers or more, does it stop working until it got verified or what happens then?
Not related to the api channel, but when your bot reaches 75 servers you can apply for verification, until then it will be limited to 100 servers
ok thx
Now I'm using 3000
And itz giving me an error port is already in use
how can i invite the bot in my server
@smoky swift
is there a api for bot dev in java not jda idk why it is not working well
hm ok
i toad this channel call api so my thing was a api so i did sorry for mistake
yeah
How do we do ? because I guess you need to provide an ip but top.gg doesn't have a static ip
there is special herokuapp link for each heroku project iirc
Would you have this link please?
I am trying to use repl for my bot so I gave my repl webserver link to the webhook and it's hosting in 5000 port
But it's now working
The data is not printing after I vote
so the Vote trigger is not working
Pretty sure you need to provide the port here as well
Yeah port is needed to enable the actual webhook
Still not working
ik
Change https to http
As https only works for ssl requests, using a port doesn't work there

TYSM

Does anyone know how to do dm user?
@bold totem please change your nickname and avatar in the next 10 minutes
As you're impersonating staff
@bold totem last warning, otherwise you will be removed from this server
Understandable
back to api topic
ok
const client = new Discord.Client() // Your discord.js or eris client (or djs ShardingManager)
const AutoPoster = require('topgg-autoposter')
const ap = AutoPoster('Your Top.gg Token', client)
ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
})```
there you go
hey im trying to use the check endpoint on the api and this (https://top.gg/api//bots/811275024140075049/check?userid=246757653282422795) isnt working. 246757653282422795 is my id. Am I doing this wrong?
You need to put a capital I in userId
api/ not api//
Is there a way to see why the bot got ratelimited?
Investigating your code
Does your bot send messages if the user is on cooldown?
Only if you code it that way, you can just make it ignore the user if they're on cooldown aswell
Is it smart do do that?
I'd probably make it so that it tells the user that they're on cooldown once, and then ignores them until it's over
<@userid>
I have done this but it is still not working
is there something wrong with this?
I have no clue at all what that is supposed to be
It doesn't look like you even tried to @ someone here?
{ "<@user id>" : "<1.name>", "content" : "Thanks for upvoting CheerBot", "avatar_url": } This is it if I copy and paste might be more clear than screen shot
Where are you getting that data from?
still no clue what that is supposed to represent
Through top.gg webhooks
Oh no sorry I am using integromat for the webhook and HTTP requests
That wut I have on top.gg
But I am using integromat for the webhook and HTTP requests
Still no clue what that data is you're getting, probably ask the user who recommended it to you
kk
Well a user gave me a tut for it
I will re read it
Found the tut https://gist.github.com/comhad/bd42b56a0399dbfa645aa83fe3cf4c8a But I will re read it now
-api @timid hawk
@timid hawk
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 think I know now I will test it now
Sorry how do I @ the user is it <@username>?
<@userid>
Hello, do you know how our bot server count does not display on top.gg ? So far it's N/A
You need to post your server count using the api.
Can I have the donc of the API pls ?
Thanks 
How I can do that ?
Theres a few libraries listed on the left side menu that can help.
Or you can post it using this endpoint.
https://docs.top.gg/api/bot/#post-stats
a question has a problem if the input type is RDP and not HTTP?
Rdp is a completely different protocol. Would be extremely weird if they implemented it since everything supports http since the mid 90s.
I understand, because I am not able to open a port in http that is not 80
and when I test in the canyouseeme it gives error
You can use any port.
When I do that (https://top.gg/api//bots/807660646820741150/stats) I have {"shards":[]} but I don't know how I post my server count
You need to post to it. You cannot just put it in a browser.
How I post ?
that's the problem, he won't let me create another door other than 80
Okay it's good dbl.postStats
Oh that's frustrating, is there an "any" option? Or other.
I can only change the protocols and I can create a custom TCP so yes I can change the port would that solve?
Yep that works
did not work
i need voting rewards but not on vote of my bot, i mean for the server
for the bot i have a cog, but i want it for a server specifically too
but cant find smth about server in the docs
{user}
Hey @acoustic lark, you ok?
Yeah Just that Idk how to make it @ the user
Have you tried the angle brackets and at sign?
Does it need to be in the content part?

Yes
should this be okay
bruh stop tryna self add in the API channel lmfao
Yes, but make sure you put the actual variavle, and not just the actual text for the variable
ik the web site is not in but it does not make a difference
TIAS
as in not passing it though like this "<@userid>"?
as in "Try It And See"
When you click, you should see a pop up window with some variables, replace userid with that variable
This?
brb need to go for my tea
Thats it
It works but It is my userID @spice helm
are you the one voting?
then its going to be your id
yeah but it is not my username
your missing @ and >
@acoustic lark
is what it should be programmatically.
if you copy paste that into chat, itll tag you
Okay thanks @jaunty plank and @spice helm
Ah nice :D
-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.
@ember karma
i need voting rewards but not on vote of my bot, i mean for the server
for the bot i have a cog, but i want it for a server specifically too
but cant find smth about server in the docs
why does the .NET lib not support posting for one shard's shard counts...
this is mildly infuriating- i only have options to post total server count, total server count with shard count, and shard id + shard count + array of all server counts
when would the 3rd ever be useful??? the array could be aggregated and sent with the 2nd
am i missing something or is this just poor design?
ideally, i'd like to post with body params server_count (as a number, not an array), shard_id, and shard_count
Just a heads up https://img.cringe.dev/jzCX
You're better off doing http requests than using the Library if you need these features
as the library hasn't been updated for a year and a few months
Though the java people are crying more
https://img.cringe.dev/36r9
thanks for this, i'm considering just rewriting the whole thing
the code base looks pretty sub par as it is
whats a port i can use
self.site = web.TCPSite(runner, '1.1.1.1', 8080)
i used 0.0.0.0 8080 for keep_alive
Wait can I use topgg api for my bot to send messages or nah?
no?
gotta import dbl
Yes ik
But after that can we do that?
You make requests to Discord API to send messages, not TopGG API.
Yes ty
Wait. So is it possible, for me to make a discord.py bot which posts a message everytime somebody votes for my server ?
teach me
@wide nexus
@restive otter You have to stop the flask or any other web hosting things
like keep_alive()
?
Yaa
So I make a differect repl
that right
Yaa
Just delete the keep_alive
ya
np
now it prints 404 not found
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 = 6000)
self.update_stats_channel = self.bot.get_channel(828347053331185704)
self.update_stats.start()
this correct?
webhook url inside topgg is set to

