#topgg-api
1 messages · Page 161 of 1
const { AutoPoster } = require('topgg-autoposter')
AutoPoster('', client)
.on('posted', () => {
console.log('Posted stats to Top.gg!')
})```
It's showing 1 server count on the Top.gg website for my Bot.
the server count and shard count will be automatically posted every 30 minutes when this happens
have you tried also logging the current server count stats in the console to concur if it is actually updating?
within the autoposter event
oh like ${stats.serverCount}
console.log(`Posted stats to Top.gg | ${stats.serverCount} servers`)```
Smth among those lines ^.
yeah
it may help with seeing if your server count is being updated or not, because caching might be involved so every 30 minutes you could potentially just be sending the same cached server count
and that wouldn't be very poggers if that were to be the actual case 
Yeah
It logs in the console fine although it show's it's in 1 server when my bot isn't in 1 server, I'll just wait 30 minutes to see if it's updated or not
¯_(ツ)_/¯
could be related to the client then because IIRC (stats) is just passing the instance from the d.JS client properties
that may be hypothetically cached or just simply not updating at all
but my brain is pretty mushy and gooey now, @hearty lintel is honestly the guy to ask about this, JS is not my expertise
cheers
HOW CAN YOU SEE who has voted through webhook
??
Why doesn’t this work
@client.event
async def on_dbl_vote(vote):
print(f"{vote.user} has voted for me.")
Because:
a) you aren't running WebhookManager;
b) your firewall is blocking requests;
c) you didn't set up your route for DBL votes properly (or at all);
d) if hosting locally, your port isn't forwarded to your device
@hushed reef how did you get that in 8 days thing on your profile. ive seen a few bots using that now and am confused about what it is
It didn't update.
using webhooks, go to https://top.gg/bot/(bot id)/webhooks and replace (bot id) with your top.gg bot id
I know how to get webhooks but I don't know the code?!
can you help me ?
sorry to bother you but have you had a chance to look into that error?
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
// req.vote is your vote object e.g
console.log(req.vote.user) // 121919449996460033
console.log(req)
console.log('-----------')
console.log(res)
}) // attach the middleware
app.listen(3000)
Why don't you work with me?
i only know discord.py sorry, otherwise i would try to help
hey bro
const webhook = new Topgg.webhook(your auth password on topgg site not topgg token) //top.gg/bot/yourbotid/webhook - auth
will the api work in python
what do i put into webhook_path and webhook_auth?
@tardy osprey Can you try logging dblpy.bot?
i dont really understand what you mean by this
it looks like the DBLClient isnt even used in the code i have for the webhook
I'm confused just as much as you are 
wait
ok so i just realized that maybe the first webhook manager i opened wasnt killed when i restarted my vps, going to go check that
not 100% sure, but i think this may be what is causing it
only problem is im not exactly sure how to kill it, do you know how?
nope not the issue rip, i opened it on another port just to test and still the same error
i tried changing the route from dbl_webhook to dblwebhook as well as closed and reopened the python application that was using that port, it fixed the error but... now im not getting any output in console at all
is there any way to see if my vps is getting any connection at all other than on_dbl_test
netstat or something
i can see that it is open with netstat, i just cant tell if im actually getting anything from top.gg
i have no idea what could be going on with this anymore, i can clearly see the connection is open when using netstat -tulpn | grep LISTEN, but im getting nothing printed and i dont know how i would test that the connection is working other than with on_dbl_test
How do I post server count? My discord.js bot is clustered
api vote pls
ex
api.top.gg/bot/bot_id/vote
what do you mean api vote?
Try just working with on_dbl_vote
Hello, I'm getting 500 Internal Server Error when I try to like a comment, it doesn't happen with all bots
I have the Same Problem by edit my bot page
Both known issues
Just fix it then 
hi. i need help setting up webhooks in python
Can someone curse me?
?
type the words "owo curse @rugged light " pleaseee
So what's wrong with your webhooks?
thank you for cursing me but i really don't know how to get the url
i'm so sorry :<
in
from discord.ext import commands
import dbl
class TopGG(commands.Cog):
"""
This example uses dblpy's webhook system.
In order to run the webhook, at least webhook_port must be specified (number between 1024 and 49151).
"""
def __init__(self, bot):
self.bot = bot
self.token = 'TOKEN' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='PASSWORD', webhook_port=8080)
@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(ID)
"""An event that is called whenever someone votes for the bot on top.gg."""
print("Received an upvote:", "\n", data, sep="")
await channel.send(f"Thank You {voter.mention} For voting!")
@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."""
test_data = data
tester = await self.bot.fetch_user(test_data['user'])
channel = self.bot.get_channel(ID)
print("Received a test upvote:", "\n", data, sep="")
await channel.send(f"Tested the webhook and working {tester.mention}")
def setup(bot):
bot.add_cog(TopGG(bot)
what do i put for webhook_path and webhook_port?
im very confuzzled
pls help
The route that comes after domain or ip:port in the URL
The port is... well, a port that the HTTP listener (aka webhook) runs on
how do i get this?
how do i create it?
Well why do you think you can pass webhook_path in the first place
(P.S. please upgrade to topggpy)
You create a route that handles bot votes, which is /dblwebhook in this case
so your URL is http://ip:port/dblwebhook
what is the difference between this and topggpy?
topggpy is the new dblpy and it's actually maintained
this
Also leaked your IP
Your URL is NOT the webhook_path
Your webhook_path is only a PART OF your URL
A password that will be used in the vote requests to your webhook
Hey, I know this is a nooby question but how do i get my bot token? Trying to make a bot which checks if you have voted for a server on the site. tried https://top.gg/bot/:yourbotid/webhooks but replacing my botid but gave me a 404 error
@ionic crater where are you hosting the webhook receiver?
my pc
did you port forward?
in order for the webhook to be sent to you from outside your network youll need to port forward
this is what i have
oh. well again sorry for the basic questions, but how would i pull whom all have voted for a server?
by using webhooks
the json things with lol inside were tests
servers doesn't have an api
I see. lemme read up on that
its quite complicated
or maybe i am being dumb
who knows?
i certainly do not
what language do you use?
Python
lmao... ur the bot dev tho
You'd be surprised how many bot developers here have zero clue about webhooks
192.168.x.x seriously
im one of them 👍
OMG i got a lot to learn.
Traceback (most recent call last):
File "c:location", line 13, in <module>
app.run('my ip', 5000)
File "C:\Users\dylan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\flask\app.py", line 922, in run
run_simple(t.cast(str, host), port, self, **options)
File "C:\Users\dylan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\werkzeug\serving.py", line 1008, in run_simple
inner()
File "C:\Users\dylan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\werkzeug\serving.py", line 948, in inner
srv = make_server(
File "C:\Users\dylan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\werkzeug\serving.py", line 780, in make_server
return ThreadedWSGIServer(
File "C:\Users\dylan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\werkzeug\serving.py", line 686, in __init__
super().__init__(server_address, handler) # type: ignore
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\socketserver.py", line 452, in __init__
self.server_bind()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\http\server.py",
line 138, in server_bind
socketserver.TCPServer.server_bind(self)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\lib\socketserver.py", line 466, in server_bind
self.socket.bind(self.server_address)
OSError: [WinError 10049] The requested address is not valid in its context
i get this^^^
hmmm
good luck 😃
Leaked IP again
its fine
Use .run on 0.0.0.0 instead
i have showed it to half of discord at this point
Doesn't mean it should stay there still
Someone can spam it with requests
Why the fuck does it show your local IP
i have absolutely no idea 🤣
I-
I don't get any of this at all
welcome to the club!
What is my Bot ID.
the id i get by rightclick -> Copy ID or is it something else. cuz boi am i confused
Yep that's the id
Looks something like 136583532972605440
But probably starts with a 7 or 8
does anyone have any idea on how to fix this?
right so https://top.gg/bot/:yourbotid/webhooks should accept it when i put my ID in
it gives me a 404
Oh wait nvm got it
Im stupid
nope i did not get it
It shouldn't matter what the ip shows at tbh.
Unless something changed in the py library that I'm unaware of.
You'll just want to use that url with the public ip(google what is my ip)
Then you'll need to port forward, the guide I posted above should do
ok. thanks
for the first time i received a 502 bad gateway error, what does this mean?
Oh, interesting. Flask does, for whatever reason, output local IP now
how to setup webhook guide can someone give me detailed guide
i dont know of a guide. the docs provides everything you need to know in relation to the webhook itself.
https://docs.top.gg/resources/webhooks/
there are also libraries listed on the docs you can use.
if you have a specific question I can try and help too
Where i can find api key of my bot?
Hi, I have this issue when using the topgg-autoposter library. Has anyone else had anything similar?
node_modules/@top-gg/sdk/dist/structs/Webhook.d.ts:1:49 - error TS2307: Cannot find module 'express' or its corresponding type declarations.
1 import { Request, Response, NextFunction } from "express";```
Have you installed express?
Hello how can I get the tag of vote.user?
So ive been trying to setup webhooks but i just couldn't comprehend what the docs meant. How do i make a webhook from tog.gg to my bot so it can get server voter data.
What is the WebhookManager. where do i put the server id that it will check etc. (Im sorry if these are real basic questions. but i just dont understand the documentation well enough....)
I GOT THE WEBHOOK TEST THING TO WORK!!!!!!!!!
im a genius
is the website down?
acctually nvmd
from discord.ext import commands
import discord
from flask import Flask, request, abort
app = Flask(__name__)
if __name__ == '__main__':
app.run('0.0.0.0', 42069)
ID = 865540361169141790
intents = discord.Intents().all()
intents.members = True
client = commands.Bot(command_prefix = '£', owner_id = 554032717197606936, intents=intents)
class Voting(commands.Cog):
def __init__(self,client):
self.client = client
@commands.Cog.listener()
async def on_ready(self):
print("Dylan's voting bot is alive.")
print("")
@commands.Cog.listener()
@app.route('/dblwebhook',methods = ['POST'])
async def webhook():
if request.method == 'POST':
print(request.json)
return 'sucess',200
else:
return abort(400)
def setup(client):
client.add_cog(Voting(client))
it does not work though
. could someone pls help?
btw this works
from flask import Flask, request, abort
app = Flask(__name__)
@app.route('/dblwebhook',methods = ['POST'])
def webhook():
if request.method == 'POST':
print(request.json)
return 'sucess',200
else:
return abort(400)
if __name__ == '__main__':
app.run('0.0.0.0', 6969)
(ik the port numbers are different btw.)
This isn't related to the issue, but you're not supposed to instantiate the Bot object inside extensions. Besides, it's not used. That's not how listeners work either. Also, flask is sync, unless you deploy it properly, in which case is pretty redundant imho. Why don't you use aiohttp if you were to handle requests yourself? It's a d.py dependency. Another thing, __name__ only be __main__ if it's the current module that's executed. That means that if statement won't evaluate to True since it's not directly executed, rather, imported.
so i should use aiohttp ?
If you know what you're doing. Or just use topggpy for the sake of convenience.
so i have
from discord import client
from discord.ext import commands
import discord
from flask import Flask, request, abort
"""
app = Flask(__name__)
if __name__ == '__main__':
app.run('0.0.0.0', 42069)
"""
ID = 865540361169141790
intents = discord.Intents().all()
intents.members = True
import topgg
client = commands.Bot(command_prefix = '£', owner_id = 554032717197606936, intents=intents)
class Voting(commands.Cog):
def __init__(self,client):
self.client = client
self.client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("/dblwebhook", "password")
self.client.topgg_webhook.run(42069) # this method can be awaited as well
@commands.Cog.listener()
async def on_ready(self):
print("Dylan's voting bot is alive.")
print("")
"""
#@commands.Cog.listener()
@app.route('/dblwebhook',methods = ['POST'])
async def webhook():
if request.method == 'POST':
print(request.json)
return 'sucess',200
else:
return abort(400)
"""
@commands.Cog.listener()
async def on_dbl_vote(data):
"""An event that is called whenever someone votes for the bot on Top.gg."""
if data["type"] == "test":
# this is roughly equivalent to
# return await on_dbl_test(data) in this case
return client.dispatch('dbl_test', data)
print(f"Received a vote:\n{data}")
@commands.Cog.listener()
async def on_dbl_test(data):
"""An event that is called whenever someone tests the webhook system for your bot on Top.gg."""
print(f"Received a test vote:\n{data}")
def setup(client):
client.add_cog(Voting(client))
but then this error comes up
Ignoring exception in on_dbl_vote
Traceback (most recent call last):
File "C:\Users\dylan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
TypeError: on_dbl_vote() takes 1 positional argument but 2 were given
i do not understand why it does not like having data as an argument
forgot self
You can safely remove client = commands.Bot(command_prefix = '£', owner_id = 554032717197606936, intents=intents) from your cog file
Hope you don't come back to complain client isn't defined 
i get this error now:
Ignoring exception in on_dbl_vote
Traceback (most recent call last):
File "C:\Users\dylan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "file location", line 32, in on_dbl_vote
return client.dispatch('dbl_test', data)
AttributeError: module 'discord.client' has no attribute 'dispatch'
You need a Client instance—you already have it btw. Just prepend client with self.. I'd really suggest you learn about OOP though.
what is OOP?
Object-oriented programming
also wasn't i meant to remove the client = ... thing at the top?
Indeed
The intents is redundant too
As well as the from discord import client import
i fixed it!!!!!!!!!!!
It's working now?
hey everyone 👋 how do I get my bot to show how many servers we are in? @ me when responding if you could
const discord = require('discord.js')
const client = new discord.Client()
const { AutoPoster } = require('topgg-autoposter')
const { tokengg } = require('./config.json')
AutoPoster(tokengg, client).on('posted', () => {
console.log('posted to top.gg stats')
})
``` why it doesn't make print `posted to top.gg stats` and nothing shows server count in top gg
I copied the example
@bot.event
async def on_dbl_vote(data):
print(data)
but votes right now do not trigger this event
That event alone is meaningless because nothing's dispatching it. Make sure to setup the web server, not only the event(s). See https://topggpy.readthedocs.io/en/latest/webhooks.html#webhookmanager
hey so I read those for quite a few times and I am afraid that I am still confused
I am not sure what webhook url to enter into the webhooks page on top.gg
I have a question for the topgg api, if I have heroku then how will heroku handle the webhooks? i think it might need some kind of web module or will it just work with the worker module i already enabled?
Also having same here, i think they are working on the site atm
Try regenerating your token, make sure you copy and paste it properly without making any spaces or stuff
@stark dove
I already tried, same error
Oh
#site-status message they're working on the voting system, so that probably has something to do with it
ok, then I'll wait ._.
same Error
401 Unauthorized (You need a token for this endpoint)
crashed my entire bot >_>
Why? I didnt change the token
known issue
They are fixing right now
Oh okay thanks 👍
@commands.Cog.listener()
async def on_dbl_vote(self, data):
"""An event that is called whenever someone votes for the bot on Top.gg."""
if data["type"] == "test":
# this is roughly equivalent to
# `return await on_dbl_test(data)` in this case
print(f"Test vote:\n{data}")
return# self.bot.dispatch("dbl_test", data)
print(f"Received a vote:\n{data}")
i tried to do it like this, not sure if this is what you meant but i still am getting nothing printed in console when sending a test vote
ok so i did some testing (by listening to the port using netcat and attempting to send something using telnet)
[20:05:05] ERROR Error handling request [aiohttp.server]╭──────────────────────────────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────────────────────────────╮│ /home/Fear/.local/lib/python3.8/site-packages/aiohttp/web_protocol.py:314 in data_received ││ ❱ 314 messages, upgraded, tail = self._request_parser.feed_data(data) ││ /home/Fear/aiohttp/_http_parser.pyx:546 in aiohttp._http_parser.HttpParser.feed_data ││ FileNotFoundError: [Errno 2] No such file or directory: '/home/Fear/aiohttp/_http_parser.pyx' │╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯BadStatusLine: 400, message="Bad status line 'invalid HTTP method'"
this seems to be the issue (or maybe only one of many), how would i fix this?
.... i hate this formatting, here is a screenshot instead
to be clear, im almost certain it is something i am doing wrong on my end and not an issue with any other libraries since i get the same output when attempting to send things to the port with telnet
How long does it take for the API to register a vote?
1-3 secs
Still didn't update.
well not sure about that
afaik
cause I voted 2 minutes ago
atm vote checks have failure
I just opened an issue about that
They said it was resolved
Veld said he will look into it after his sleep
wait as in something with the webhook, or with the last 1000 votes?
not webhook then, back to trying random things in my code and hoping for it to work
✅
.... I don't remember what URL you set on top.gg
Mind reminding me? 
http://(ip):5000/dbl_webhook
Tried sending requests via reqbin?
hi
uh not sure what this is tbh
can some one help me with webhooks
?
i use js
i used the code in the example give in the docs
i know my server is recieving the data from top.gg, i can see them when i listen via netcat
but when they go through my bot instead i get nothing
and i am using local host
so i think that the ip for localhost is 127.0.0.1
so can some one help pls
and also i use vscode
did more testing, i specifically get that Invalid HTTP Method error when sending anything to the port that theWebhookManager thing opens. when i open another port with netcat and send anything to there (including the top.gg test vote), everything is fine
sorry for so many pings...
what do i put here??
Any reason why it’s showing 1 server count for my bot? My bot is in more then 1 guild,
I have everything setup as well?
Including responding to the tests on those ports?
Make sure you cache guilds
responding to confirm receiving the webhook on the port i opened with netcat (like to top.gg)? im not sure how to respond with it if that is what you mean, all i know is i did get the data on my server
this is exactly what i did to see if my server was receiving the data or if it was blocking it with a firewall of some kind
yeah, do you just want the whole file or a specific portion?
Whatever that's related to WebhookManager and running it for now
alright ill dm that to you just a sec
@tardy osprey what is that terminal formatting from?
╭── Traceback ──╮
│ │
│ code │
│ │
╰───────────────╯
its from red v3
thanks
Hi I want to show up on the bot servers site.
The written language is BotJS.
What should I do?
Can some one pls help
The api still doesn't register a vote. I voted 9 hours ago and it still returns false.
same
How do I get an authentication key for the webhooks so I can make it report to my Discord Server?
same question
Might be the webhook section when you edit your bot's page.
I mean this
Hey @vital anvil, will you have time to look into the API problems today?
Looks like I didn't vote even though I voted on the api? So do users @vital anvil
i have reset token and stil no chnage
i woke up and my console is spammed
with this error
2 things, did someone vote since the last time you got the error, second, the API doesn't work as intended and they will try to fix it by tonight 🙂
yea
i have voted on 2 different accounts to test
and my "token is invaild"
no issue till like 1am est it seems like
thats when my console started spamming it
Alright, I suggest you remove the use of the variable for now to avoid unnecessary errors.
the siteand thjere api has just broke more and more
Damn I just added voting commands yesterday and it was a big hype xD
seems like
same like last week
i cant even update stats either
There are huge changes thats why
well yea i can tell lol
when i first joined like 6 months ago
almost no issues
now you cant load most pages
At least they know the issues and trying to fix it. They are humans too 🤷
Our best move will be waiting faster 
are votes not working?
Hi ! I have a small question about DBL Stats API, the endpoint widget api is ratelimitable ?
everything has ratelimits
but like i don't have information about it :/ it says nothing on the doc
Hey @jaunty plank any idea on the progress on the API not registering votes?
its been worked on the past few hours, #support message
Hopefully not too much longer
Thanks :)
@tawdry wolf wheres the webhook receiver being hosted?
on the bot's vps (docker container exposed)
I can send a POST request to the address which means it works for me. I guess it's part of the breaks from the new vote api. Patience is key then~
what library are you using for it?
Oh, I'm not using a DBL-specific library. I just added the endpoint to my other HTTP endpoints (using Javalin).
and your post request tests are being done remotely?
(i would guess so with it being on a vps, but we have had crazier setups)
Pretty much, used Postman to send several POST requests and even on Reqbin which all were successfully received by my bot
and you filled in URL and auth on your bots webhook section?
Yep
heck, not really sure what else i can do for you then.
webhooks should work for bots fine. its kinda not working for some servers.
I copied the URL I wrote on the webhook section, pasted it to Postman and Reqbin and tried it several times and all requests were received. It was only the test webhook on top.gg that isn't hitting the endpoint for some reason 
I guess it will fix itself some time
if you dont mind dming me the postman requests(with the url too) i can do some requests myself and see if we can figure something out.
otherwise im not sure.
magic 
hi
NameError: name 'topgg' is not defined
i installed topggpy
and imported topgg
but not working
Mind sending the code?
try:
import discord
import datetime
import keep_alive
from discord.utils import get
from discord_slash import SlashCommand
import json
from giphy_client.rest import ApiException
import giphy_client
from discord.ext import commands, tasks
import asyncio
import random
from prsaw import RandomStuffV2
import DiscordUtils
import aiosqlite
import dbdmusic
import topgg
except:
import os
print('Install discord.py')
os.system('pip install discord.py')
os.system('pip install prsaw')
os.system('pip install discord-py-slash-command')
os.system("pip install DiscordUtils")
os.system("pip install aiosqlite")
os.system("pip install topggpy")
intents = discord.Intents.default()
intents.members = True
intents.presences = True
client = commands.Bot(command_prefix=',', intents=intents, case_insensitve=True)
client.remove_command('help')
slash = SlashCommand(client, sync_commands=True)
rs = RandomStuffV2(async_mode=True)
dbl_token = "secret"
client.topggpy = topgg.DBLClient(client, dbl_token)
@tasks.loop(minutes=30)
async def update_stats():
"""This function runs every 30 minutes to automatically update your server count."""
try:
await client.topggpy.post_guild_count()
print(f'Posted server count ({client.topggpy.guild_count})')
except Exception as e:
print('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
update_stats.start()
Did it print Install discord.py?
If so, then one of the dependencies failed to import, hence topgg wasn't imported.
so instead import discord i should write import discord.py?
Why so?
um, discord.py is installed
and topggpy
Did I say otherwise?
so what should i do?
You print that on exception, that's why I'm asking if that was printed
yes
Actually, just don't use try except for this. You usually want to use try except for backward compatibility.
i use repl.it
Just list the dependencies in requirements.txt or something like that
okay
Take a look at this https://docs.replit.com/programming-ide/installing-packages#python
now it is not giving me any errors
when will it show guild count?
Don't leak your token, regen it immediately
uh
wrongly
Failed to post server count
Unauthorized: Unauthorized (status code: 401)
If you just regenerated the token, make sure to update it in the code
updated
import discord
import datetime
import keep_alive
from discord.utils import get
from discord_slash import SlashCommand
import json
from giphy_client.rest import ApiException
import giphy_client
from discord.ext import commands, tasks
import asyncio
import random
from prsaw import RandomStuffV2
import DiscordUtils
import aiosqlite
import topgg
import os
#os.system('pip3 install -r requirements.txt')
intents = discord.Intents.default()
intents.members = True
intents.presences = True
client = commands.Bot(command_prefix=',', intents=intents, case_insensitve=True)
client.remove_command('help')
slash = SlashCommand(client, sync_commands=True)
rs = RandomStuffV2(async_mode=True)
dbl_token = "secret"
client.topggpy = topgg.DBLClient(client, dbl_token)
@tasks.loop(minutes=30)
async def update_stats():
"""This function runs every 30 minutes to automatically update your server count."""
try:
await client.topggpy.post_guild_count()
print(f'Posted server count ({client.topggpy.guild_count})')
except Exception as e:
print('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
update_stats.start()
Same error?
same
how can i fix it?
Not so sure, but it's likely on you. Did you double check the token?
it's same
uh i write everything correctly
i just change
bot into client
and token is correct
Just to make sure, are we talking about the same token here? Was referring to your topgg API key
i updated
@edgy merlin
Welp, sorry then, can't help you further. Not sure if it's on topgg. I expect it should work if you put the valid token.
ok, nvm
thanks for help
your bots page, webhooks, "show token"
How do I get a Webhook URL
webhook url is generally formatted like this
http://PUBLICIPHERE:PORTHERE/PATHHERE
its up to you to fill in the blanks with the relevant data.
if your hosting on a platform without an ip, youll need to use the project URL.
how often does topgg-autoposter post server count?
Is the api always returning in json?
Every 30 minutes iirc
okay ty
Can anyone help me to make a vote notification in python ?
res.statusCode = 200;
return res.end(JSON.stringify({ message: "Successful" }));
I have this, but occasionally, it's still sending multiple requests
It doesn't happen each time, but some times it does
responding with 200 and closing the connection
and this all started happening after the major update
is there a way to get a bots stats without a top gg token. I'm just trying to get the server count that is publicly available on the website
check pinned messages
Hey how do i check who have voted my bot
rekt
vote tracker bot.
You can read the docs and setup vote tracking https://docs.top.gg/
is there any simple vids out there to lock cmds to voters only
Bhai zoom link kha ho ga
Just check if the user has voted using the api before responding to the command, or if you want to avoid hitting the api too often, use the vote event to store voter ids in your database then check the vote timestamps against the command message timestamp to see if their last vote was less than 12h ago.
or make the command cooldown
that is another solution also
rate limit of top.gg api 60 requests in a minute iirc
How do i know if a user voted for the bot
send GET request to endpoint of top.gg bots/${botID}/check?userId=${userID}
or just use module
okk thanks
Guys, I didn't understand how to do that, when a user votes the bot he sends the message "{id} has voted DKMusic on top.gg"
Why is the api sometimes returning in json and sometimes in html?
That could be the issue for my problem too
probably
Well, sometimes I get a response in json, sometimes in html, just tried on my pc and got a cloudflare error
But for some reason its working from my server rn
That is so random
@willow sphinx Is this a known bug?
Someone?
try webhooks
then we gotta ping someone else
veld? maybe
he is responsible from backend afaik
ban
xd
const Topgg = require('@top-gg/sdk')
const express = require('express')
const app = express()
const webhook = new Topgg.Webhook("my authorization")
app.post('/dblwebhook', webhook.listener(vote => {
const { logVoti } = require('./channelIDs.json')
bot.channels.cache.get(logVoti).send(`${vote.user}`)
}))
``` Why it doesn't work?
Did you edit correctly your webhook settings on the site?
it should be like http://YOUR_IP:3000/dblwebhook
I made it my vps IP since I'm using it on vps
ok
google > what is my ip
it will perform post request to that url
how do i acces to that url?
this url
to verify
test button
Ok
It doesn't work
Why it doesn't work?
@glad merlin
Is it because it's not the same bot? I'm trying it on a test bo
t
@glad merlin
I'm not sure
How i accept it
My vote page is just freezing here like this whenever I open it or for any bot ,what to do ;-;
no vote button no ad
Oh boi
-atmods
@hallow herald
Please do not mention (ping) more than one or two moderators for help, unless there is an emergency.
Here are some examples of emergencies:
- Raids / Multiple members mass spamming.
- Severe disruption of Discord's ToS (NSFW content, etc)
- Anything that requires more than 2 moderators to handle.
Do i need the token of the bot? Like when you are in https://top.gg/bot/id/webhooks and there's the token
const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express() // Your express app
const webhook = new Topgg.Webhook('Password') // add your Top.gg webhook authorization (not bot token)
app.post("/dblwebhook", webhook.listener((vote : any) => {
// vote is your vote object
console.log(vote.user) // 221221226561929217
})); // attach the middleware
Code is with 0 errors, but it doesn't work.
Did you fill in the webhook url and auth on your bots webhook page?
api.setStats(serverCount);
where should i put this so i get server count on my bot page
how can i make a listener who voted? I'm using kotlin
client = commands.Bot(command_prefix = "ar ", case_insensitive=True)
client.topggpy = topgg.DBLClient(client, dbl_token)
@client.event
async def on_dbl_vote(data):
print(f"VOTE RECIEVED\n{data}")```
i got my alt to vote but im not recieving the "VOTE RECIEVED" statement in the console
any help is appreciated
yes, Checked it 3-4 times they are ok!
did you fill it in with the public ip, not private
where are you hosting?
is your webhook url and auth filled in on the site.
should I send you the whole website thing and main.ts?
if you want to
The bot stats thing work nicely, but the voting stuff is not working for me.
what do i put in "password":
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("/dblwebhook", "password")```
thats the auth, you make it. just make sure its the same between the website and code.
How do I add Creator
Unfortunately, that's not available to do so at the moment! 😦
It's a support channel for API's only. Please go to #support.
ok I'm sorry
no issues, Have a great day ahead. 🙂
is there anything wrong with this:
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("/http://myip:5000", dbl_token)
client.topgg_webhook.run(5000) # this method can be awaited as well
@client.event
async def on_dbl_vote(data):
if data["type"] == "test":
return client.dispatch('dbl_test', data)
print(f"Received a vote:\n{data}")
remove the /
ah alright
Im having alot of users who are voting but the API is not showing them to have voted
Ahh... now im getting bad reviews for it aswell
const Topgg = require('@top-gg/sdk')
const express = require('express')
const app = express()
const webhook = new Topgg.Webhook("password")
app.post('/dblwebhook', webhook.listener(vote => {
const { logVoti } = require('./channelIDs.json')
bot.channels.cache.get(logVoti).send(`${vote.user}`)
}))
What's wrong?
lol
someone?
@sacred shell can you do something?
Can you shut the thuck up?
Thanks

Someonje can help?
I am trying to use the @waxen widget-gg/sdk npm module, but it does not work when i try to use it (both vote and test button). When i remove the middleware and just listen to basic posts req res it works. Is the thing broken?
what are valid port(s) to use?
Still looking for help on this, even though im getting less then 1000 votes a month, the last 1000 votes endpoint is NOT showing the last 1000 votes
when checking with check endpoint its fine.
Found the problem, i had to update node to the newest version for it to work.
Are there other events AutoPoster has other than 'posted'?
npm install @top-gg/sdk
i should use this right
btw this is my code
so should the two pair together or do i have to install another thing
o nvm i install npm i topgg-autoposter
'error' is the other event
in discord.js, how can i see if a user has voted my bot without using express (if possible)?
api.hasVoted(id)
WDYM set to what?
i mean what is assigned to the variable 'api'
console.log(api.getBot('ID'))
Logging:- Promise { <pending> }?
Resolve the promise
How ... Kinda newb in this coding stuff....
NVM await ....
Ez
@sullen nymph 404 Not Found
Seems a bot under that ID isn't listed
Shrug no clue
I copied from copy id
Try to update to latest topggjs version
NVM got it
console.log(bored)``` Logged:-`{ serverCount: undefined, shardCount: undefined, shards: [] }`
why is that undefined
?
do i have to manually post number of servers?
Yes
Ok
there is also autoposter you can use
how do i get data of who voted for bot so i can make rewrds for the vote?
can someone help me with this for my discordjs bot?
const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express()
const webhook = new Topgg.Webhook('sure i put auth')
app.post('/dblwebhook', webhook.listener(vote => {
console.log(vote.user)
}))
app.listen(3000)
i try this. But it's not working when someone vote why?
where can i find my topgg token?
pins
yea i found out
Probably the topgg sdk
Idk
soo.... any answers? or do I just use the non-express version
by the way, im not trying to achieve a webhook thing, im just trying to make it DM the person that voted (if possible), thanking that user for voting.
uhhh
I tested the api webhook now it spams me and never stops sending it and i get this error
19.07 04:43:16 [Bot] ReferenceError: member is not defined
19.07 04:43:16 [Bot] at /index.js:327:3
19.07 04:43:16 [Bot] at /node_modules/@top-gg/sdk/dist/structs/Webhook.js:89:23
19.07 04:43:16 [Bot] at runMicrotasks (<anonymous>)
19.07 04:43:16 [Bot] at processTicksAndRejections (internal/process/task_queues.js:97:5)```
It is sent every 10 seconds..
- Member isn't defined
You're not acknowledging the request with a 2xx
ya...
what are you talking about? voted for me thing or member is not defined error?
it doesn't really matter
show index.js 327th line
guess ill have to figure this out on my own /shrug
web dyno enabled with an HTTP listener (express, I guess) running on process.env.PORT port
app.post("/top-gg-votes", webhook.listener(vote => {
console.log(`${vote.user} has voted for me!`)
const voteEmbed = new Discord.MessageEmbed()
.setTitle('I recived a vote!')
.setDescription(`<@${vote.user}> has voted for me!`)
.addField('Thank you!', 'You can vote for me again in 12 hours. \n \n wanna get a shout out here too? Vote for me [here!](https://top.gg/bot/743292394237329440)')
.setFooter(vote.username, 'Thanks')
member.guild.channels.cache.get(votesChannel).send(voteEmbed) //27th line
}))```
well
member doesn't exist in this context
okay
but could i just use another method without using express too? (im not trying to make a webhook lol)
i just want it to dm the person that voted is all lol
Well, that's what a webhook would do. It will listen to vote requests in real-time and you can send a message to a user when such request is received
It doesn't have to be express, that's just the only web framework I can remember off the top of my head lol
wait
would this work
theoretically
meh
ill just mess around with it until i find something i like
thanks for the help :D
Well, it would work, but you wouldn't get the votes in real-time
There would have to be like a command and you'd have to make sure no votes are stacked on top of each other
const Topgg = require('@top-gg/sdk')
const express = require('express')
const app = express()
const webhook = new Topgg.Webhook("password")
app.post('/dblwebhook', webhook.listener(vote => {
const { logVoti } = require('./channelIDs.json')
bot.channels.cache.get(logVoti).send(`${vote.user}`)
}))```
What's wrong?
Hi listen what should i do i cannot get the webhooks
I use local host
Pls dm me if u can help
@topaz kraken what's wrong in thi code?
any error?
Np
I click on the test button, but nothing appens
This is my url, idk if it's good
hey can someone help me setup the webhook
I'm new to this so I don't really know what to do
sorry if its a dumb question
sure
Get the package named "express"
with npm i express
Someone?
wait can I not just set it up with a channel webhook url
do I need to code for it
//const votesChannel with the id of the votes channel
var express = require('express')
var app = express();
const Topgg = require("@top-gg/sdk")
const webhook = new Topgg.Webhook('webhook autho')
app.post("/top-gg-votes", webhook.listener(vote => {
console.log(`${vote.user} has voted for me!`)
const voteEmbed = new Discord.MessageEmbed()
.setTitle('I recived a vote!')
.setDescription(`<@${vote.user}> has voted for me!`)
.addField('Thank you!', 'You can vote for me again in 12 hours. \n \n wanna get a shout out here too? Vote for me [here!](https://top.gg/bot/bot_id)')
client.channels.cache.get(votesChannel).send(voteEmbed)
}))```
there
I still don't get it
Just dont copy paste the code, read it then.
alright
this
express creates something like a domain with your ip
Hoister what's the problem in this? Like if i click the test button nothing works
ok
where exactly do I paste it
Lacuna made me do this, idk if it's right
maybe ad ; after express and instead of bot use client? It depends on how your bot is defined.
i use bot
it is
ok..
read the discord js starter guid they got an awesome discord.js webhook example 👍
alright
VS Code is installing C# depencies
hmm Read their documentation... and maybe use the example from there if that isnt it, and I guess try to define logVoti above the function
It should work
logVoti is defined in channelIDs.json like this "logVoti": "860843237022498856",
maybe define it like this:
const channelIDS = require('Path to the file')
// then this to get the id of that channel
bot.channels.cache.get(channelIDS.logVoti).send('stuff')```
ok
then tell if works
Don't work
No errors
Do i need to specify the token of the bot that is on top.gg?
https://top.gg/bot/id/webhooks in this page
uhh
one sec
in webhook autho u put the thing you putted under the webhook link
like a password or smth
ya then put it in topgg webhook autho
Idk if u can require in a function so i suggest not doing logVoti = require('stuff')
like bot.channels.cache.get("id").send(${vote.user})
ok
just that I feel like it is in ids but not sure.
doesn't work
Hello!!!???
I did this
//------------Top.gg------------
const Topgg = require('@top-gg/sdk')
const express = require('express');
const app = express();
const webhook = new Topgg.Webhook("pass")
app.post('/dblwebhook', webhook.listener(vote => {
bot.channels.cache.get("860843237022498856").send(`${vote.user}`)
}))
What's the problem
Man i don't know, i'm getting help too
yea
@cold root sorry for the ping bu can u pls dm em
No me
alr..
Yea
nothing
btw did it work?
np
Any errors?
ich hab ne frage ich möchte das wenn jemand voted ein webhook gesendet wird wie kann ich das machen 🙂
whats up?
np stands for nope or no problem?
nope
o
So how i do it?
uhhh
idk..
I mean it seems correct
maybe try to paste the id it self
if you didnt already do it
?
in cache channels
Srry if i dont' undestrand but i'm italian
I did it
im russian lol
lol
like this you mean? bot.channels.cache.get("860843237022498856").send(${vote.user})
ya
I did it
I got no idea why it wont work.. ngl
You know who can help?
aha
hello, i added my server now on top.gg, but when i serch on home page, its not visible
Hello how i can detect votes. i want to give voters a role on my server 🙂
By using webhooks: https://docs.top.gg
Hello Dear Top.GG Official I Have A Bot Named Kontz There Are 47 Servers And 301K Users 1. I Was Wondering When The Security Verification Will Be Done. Have a nice day. @willow sphinx @vital anvil
@willow sphinx When Will the Security Phase Be Next?
bro@willow sphinx
Sorry For The Ping
I get a error:
no module named 'topgg'
when I try to import topgg
import topgg
Do you have multiple versions of python installed?
no
Did you install the module?
yeah
Are you using a IDE?
It is almost surely it
oh ok thanks
Make sure your venvs aren't mixed up (if you use them) and that you use the appropriate Python interpreter for the pip executable you used
hold up
what ip am i supposed to use for heroku
this
do i just use the heroku url thing
(it would basically be something like https://MyApplicationName.herokuapp.com/)
You need to bind to the port Heroku gives you, though.
Most likely, have you tried it?
Sure, good luck!
Nope, it failed
What have you tried?
I used the code that was found here:
const express = require("express")
const app = express()
const webhook = new Topgg.Webhook("your webhook auth")
app.post("/dblwebhook", webhook.listener(vote => {
// vote will be your vote object, e.g
console.log(vote.user) // 395526710101278721 < user who voted\
// You can also throw an error to the listener callback in order to resend the webhook after a few seconds
}))
app.listen(80)```
I installed express
Should i show logs
i'm pretty sure it did
but it didnt
should i show logs because there wasnt anything wrong with index.js
But you hardcoded the port.
?
sorry im a bit new to programming n stuff so its kinda confusing
do u mean that i wrote out the port
wait
how do i get the port from heroku to bind to
oh wait...
It's the PORT env variable
oh okay
thanks
ima try that
wait a sec
i think its working
ima test the webhook
how to get username#discriminator
Votes
Ok
JavaScript
oh
vote.user gives UID
But how to get username#discrimninator
fetch from discord api
oh, not directly ?
You set the path to /dblwebhook not /
I guess the lib returns 403 if the auth was missing/didn't match.
I slipped up again I am so dumb
I accidentally made a typo
In my authkey
IT WORKED
Thank you so much norizon
Any other way ?
There's this but I haven't really tried it https://docs.top.gg/api/user/#find-one-user
@restive otter what?
@shell swallow am banned from pokemon bot
Would it be possible to put the vote webhook thingy in another file? The thing is heroku will now idle for web dynos if there isnt any traffic, and the web dyno would be required to run the webhook as opposed to the standard worker module. If I run both, it will run multiple instances and cause my bot to get ratelimited.
-.-
@shell swallow Bro that's my brother fault not mine
But... it's 401... 
Actually I don't remember
Can someone help?
Nice
What are you using firstly?
Are you hosting on your PC or using a VPS (like heroku or repl.it)
What exactly is your vps
Replit
do you meen the console and express?
The console
What shows up in console when you actually run it?
Nothing only the event ready message.
Yes
Wait
I install the required packages
Yes
Oh wait
//------------Top.gg------------
const Topgg = require('@top-gg/sdk')
const express = require('express');
const app = express();
const webhook = new Topgg.Webhook("Dsasadhahùi")
app.post('/dblwebhook', webhook.listener(vote => {
bot.channels.cache.get("860843237022498856").send(`${vote.user}`)
}))
What's wrong?
I forget to put dblwebhook in end
Oh ok
What do you use
js
Thanks i will try (:
Check your vps logs
Ohh
@stark dove thanks for your help(:
I don't know if its possible to do webhooks with locally hosting
It's works
No prob
If it is, i dont know how to do it, sorry :(
Nice
@half burrow wdym
Hello Dear Top.GG Official I Have A Bot Named Kontz There Are 50 Servers And 321K Users 1. I Was Wondering When The Security Verification Will Be Done. Have a nice day.
@half burrow wdym by "Security Verification"
@willow sphinx
Hello Dear Top.GG Official I Have A Bot Named Kontz It Has 50 Servers And 321K Users I Was Wondering When The 1st Security Stage Will Be Done. Have a nice day.
🤐 Muted Kaanxbey#2033 (@half burrow)

can anyone help me to setup webhook?
YouTube

lol veld is done with it 
i have never seen him mute
Actually kinda amazing he adjusted his message every time to account for the server count and user growth 
post bot statistics (shards , total guilds) and also a bunch of stuff about votes
if ur using javascript then https://docs.top.gg/libraries/javascript/
if you use py or smtn else then just click on that in the libs category
what makes you think that?
its express
why wouldn't it work?
is that all of your code or do you define your client and login?
i dont know because i dont know anyone thats done it
its express...
just because you've never seen anyone do it doesn't meant its all of a sudden impossible
You must link your discord account by sending a private message to AuroraBot on discord. How can i do this
i dont think thats top.gg api related
how do i setup webhooks so that it will send when someone votes in my server
wat are we supposed to fill in these?
If you don't know how they work then ignore them
Oh js
I'm using js for my server count ( bot ) and it's not updating after 30 minutes?
this is their official sdk, their own interval
they set the time for that
If only you didn't make other requests yourself.
Hey uhm i have a question
const Topgg = require("@top-gg/sdk")
const express = require("express")
const app = express()
const webhook = new Topgg.Webhook("my auth password")
app.post("that /dbl thing", webhook.listener(vote => {
vote.user.send("Thanks for voting me!");
voteChannel.send(`Thanks ${vote.user} for voting`);
}))
app.listen(80)
Why doesn't this work
No errors pop up
that's in my index
hello
daddy’s here
someone tell me how to check if a user voted for my bot
i want to give the user coins from my bot’s economy if they vote
For me it doesn't work :(
- Ya ain't anyone's daddy, bud;
- Webhooks for real-time vote receiving or use the API if relying on bot votes
Explain "doesn't work"
ah ok





