#topgg-api
1 messages Β· Page 156 of 1
yo
using probot can i really put auto roles on a desired level
like if i leveled up on level 10 can i get a role "level 10"
Hello
Can I use this api for my server?
Any requirements?
Hi I'm looking to make a vote reward command , ie vote to use command , how can I do so , any example , I'm having issues understanding the docs
did you want to reset the reward or keep it?
but overall its simple. you have to get the Webhooks setup. the top.gg api will send then a event to the webhook if someone votes. the vote contains some informations like the userid of the guy who voted.
for the vote locking commands, if you use MongoDB you could use TTL to create documents that self destruct after a set time the flow should be then like this:
For the Vote locked Command:
Query the DB to see if a document for command author exist in your Vote Collection. if yes execute the command if no return
or did you want to send people to the top.gg page of the bot for voting?
then its even simpler. just send them a url with the bots page
Uh , like you know the premuim command which u gotta vote to use
then you need the first way ive mentioned (there are other methods but this one is crash resistant)
Can I like use get_user_vote events or something , instead of webhook
I'm not much familiar with webhook tbh
API queries are not really wanted
webhooks are easy.
you just recive a json formated payload that you can handle
So can we use one for a specific server?
Ohk
they work. but they offer the webhooks bcs they need to process way less requests
Are there any Video tutorial on this ?
imagine having 50k clients sending a request every second
probably not. but its not this hard.
Can u show example using webhook?
like its just simple MongoDB queries (if you use MongoDB other databases should also work, exept "Json DBs")
Will JSON not work?
bcs json is not a DB
Ohk
Which is the one for python?
https://docs.top.gg/libraries/python/ scroll down where it say webhook
Ty
So? I can use the code there for when someone votes for a server?
And how to retrieve the dbl token
Does this only work for bots or can it work for server also?
Ignored my link apparently to an up-to-date documentation
sad
topggpy has support for both server and bot votes
How to check if user voted my bot?
Are there examples? I don't really get a perspective on this.
Yes, check the repo's readme for the examples https://github.com/top-gg/python-sdk
FYI, if you installed it from pypi, the WebhookManager.run method returns a coroutine, on the other hand, the master branch one returns a Task. So the former needs to be awaited while the latter doesn't
Umm can someone help?
What library, what language
Thanks
@sullen nymph ```py
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password")
bot.topgg_webhook.run(5000) # this method can be awaited as well
What in the good god is that class setup style 
bot.topgg_webhook = topgg.WebhookManager(bot)
bot.topgg_webhook.dbl_webhook("/dbl", "dblpass")
bot.topgg_webhook.run(5000)
ezpz
The dbl_webhook?
Like, sure that would be a sort of valid constructor if that was Rust which doesnt have default arguments but that is a very unpythonic method of doing that
especially considering that .dbl_webhook("/dbl", "dblpass") looks like you can stack these when in reality they override each other because py self._webhooks["dbl"] = _Webhook( route=route or "/dbl", auth=auth_key or "", func=self._bot_vote_handler, )
Anything you want to suggest? Because this is the only feasible way I could think of that made sense 
Or i've got an new thing you can look at, still need people to try it https://github.com/comhad/webhook-forwarder
WebhookManager(bot, dbl=DBLWebhook("path", "auth"), dsl=DSLWebhook("path", "auth"))
```?
thx
WebhookManager(
bot,
dbl_path="/foo",
dbl_auth="foo",
dsl_path="/bar",
dsl_auth="bar",
)
ffs
Do you expect me to read every dev's mind
I legitimately have issues with naming stuff
eh...
Now do that in one line and tell me if it looks comprehensive
It looks better than needless OOP 
WebhookManager(bot, dbl_path="/dbl", dbl_auth="pass", dsl_path="/dsl", dsl_auth="pass")
Alternatively if you really wanted to make it object based, make a dataclass called WebhookDetails or smth
Cant find anything about what I asked for
- they're just helper methods. I expose the internal
Applicationinstance so whoever wants to use that is free to
yes they're helper methods but they're not massively user friendly or pythonic
bot.topgg_webhook = topgg.WebhookManager(bot)\
.dbl_webhook("/dblwebhook", "password")\
.dbl_webhook("/ahh", "password")\
.dbl_webhook("/f", "password")\
.dbl_webhook("/b", "password")
like that's what your code looks like it should support
In reality it doesnt
My question is what benefit does one get by trying to create multiple listeners for the same webhook type on a different path
Considering you stripped out the test event as a builtin adding these helper functions that look like they should behave one way but act the other
which is litterally my point
dont add constructor or builder methods when they arent needed 
i dont rlly know flask π
Umm hello?
Don't worry, you don't have to deploy it, its already hosted just look at the wiki for advice on how to use it lol
I don't really see a point in changing the current system to this
#topgg-api message considering I prefer to use this logic
Im getting ignored 
which is why adding needless methods is a π
If you want one webhook, you have a helper method to add a simple handler for you. If you don't, work with the webserver property or don't use the webhook manager altogether
How are they needless
also considering the arguments in said helper function has required arguments but then has some random default checks
def dsl_webhook(self, route: str, auth_key: str):
"""Helper method that configures a route that listens to server votes.
Parameters
----------
route: str
The route to use for server votes.
auth_key: str
The Authorization key that will be used to verify the incoming requests.
"""
self._webhooks["dsl"] = _Webhook(
route=route or "/dsl",
auth=auth_key or "",
func=self._guild_vote_handler,
)
return self
"Why does my webhook not work with
''???? "
Can u pls send me the link....sorry for ping
Not sure what I thought when adding the default values
Dont worry about pinging me, and the link to the discord webhook is unique to each webhook and private, so i can try and explain it but cant send you the link
I need to await the bot.topgg_webhook.run(5000) I tried putting it into an async function but starting it results in this error:
Can you send the code?
dbl_token = 'token'
bot.topggpy = topgg.DBLClient(bot, dbl_token, autopost=True, post_shard_count=True)
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password")
async def webhook():
await bot.topgg_webhook.run(5000)
asyncio.run(webhook())
Don't use asyncio.run, that'll close the event loop once it's done running it
You can use loop.run_until_complete, no need to wrap the run method though
ok I will try
Like this?
dbl_token = 'token'
bot.topggpy = topgg.DBLClient(bot, dbl_token, autopost=True, post_shard_count=True)
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password")
async def webhook():
await bot.topgg_webhook.run(5000)
loop = asyncio.get_event_loop()
loop.run_until_complete(webhook())
If it works it works
You can also use bot.loop, did I mention not to wrap the run method
Oh i did
Oh okay. It seems working. Thanks!π
@elfin anvil is this any good? https://github.com/comhad/webhook-forwarder/wiki/Example-usage#forward-webhooks-from-discord-bot-sites
thx
Say it doesn't default to "/dsl" if it's falsy 
I am trying to activate my voting webhook, but im getting this error. My token was working before, any ideas?Top.GG API Error: 401 Unauthorized (You need a token for this endpoint)
you can try reloading your token ig
-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.
Oh wait wrong channel
Can someone help me figure out why the autoposter isn't working? I'm assuming it's set up correctly because it's not giving an error message anywhere but Idk what else I'm supposed to do
I tried adding a webhook, but it said it couldnt save. Why is this
Whenever I try to get a bot, it comes back as 404 not found even though it's on the list. (http://img.dluxe.ml/Z0NbHWUM) how would I solve this?
My code: http://img.dluxe.ml/uTH4-Ss8
does my bot need to be fully submitted first or something?
yeah
Nevermind on that, got that to work, but now finding a bot doesn't give any information about it, just this: http://img.dluxe.ml/l6sNPvpL
this is the get request response you must parse the json from server response
for example
let data = await fetch("fetch url", {
options: 'here'
}).then(res => res.json())
console.log(data)
just put this
.then(res => res.json())
-botinfo
Please include a bot mention or ID
-botinfo @sinful musk
ah ok, thanks
One message removed from a suspended account.
how do i make a vote count
of top.gg
like if someone vote it will come in a channel with his vote count
have some kind of counter (like a database table) that you increment each time a user counts.
Also IIRC there's a way to get the last 1000 votes from top.gg
-bots
-bots
Do you guys just follow everything others do
There's a #commands channel for this, you know
what shiv said
how to api 
Why aren't my webhooks working?
My code:
class Topgg(commands.Cog):
def __init__(self, client):
self.client = client
self.dbl_token = os.environ.get('DBL_TOKEN')
self.password = os.environ.get('DBL_PASSWORD')
self.dbl_client = dbl.DBLClient(
self.client, self.dbl_token, autopost=True, webhook_path='/dblwebhook', webhook_auth=self.password, webhook_port=5000)
@commands.Cog.listener()
async def on_dbl_vote(data):
"""An event that is called whenever someone votes for the bot on top.gg."""
print(f"Received an upvote:\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 upvote:\n{data}")
My top.gg stuff:
π€ how do I know which url to use?
It's your physical server's IP address
ok
Im having issues with Dm'ing users only going by their user ID in python
you can't dm people who have their dms disabled or aren't in a mutual server with your bot
im testing with dming myelf
and my help command DM's but thats by using ctx.author.send()
but this function does not hold reference to a context object so im trying to attain user from ID so that i can DM
but even if i test it with bot.get_user(ctx.author.id).send(message)
it doesnt send anything nor does it error
I think you need to await bot.get_user and then await the .send on a seperate line
that didnt work
I stuffed it with a bunch of prints and it seems to stop at await bot.get_user(ctx.author.id)
Oh right, is it timing out while making a request to discord maybe?
Object NoneType can't be used in await expression
Is the error i get when printing the exception
for await bot.get_user(ctx.author.id)
but even if i remove the await
it doesnt do anything
I think either your bot variable is different or it isn't finding a user, i think that function returns None when it can't find a user
yup its returning None
But all it takes is an int id
which im feeding it
ive done both just ctx.author.id and int(ctx.author.id)
both return None even though i use that same variable to store and access user info in other areas : /
If you're using ctx.author.id to pass into get_user object, you're using a user object to get the same user object, you could try await ctx.author.send
im only using ctx.author.id for testing
the other area i want to use it will be an ID string that ill cast to int
but that didnt work either so
: /
Try fetch_user, i think you need intents / member cache for get_user
fetch was the way to go π
get_user isn't async so you don't await it
-wrongserver
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 :(
-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.
import topgg
# This example uses topggpy's webhook system.
# The port must be a number between 1024 and 49151.
dbl_token = 'Top.gg token' # set this to your bot's Top.gg token
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password")
bot.topgg_webhook.run(5000) # this method can be awaited as well
@bot.event
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 bot.dispatch('dbl_test', data)
print(f"Received a vote:\n{data}")
@bot.event
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}")
where was the dbl_token used here?
@anyone
i mean... can't you just tell? π
i came here because i couldn't find xd
but its still dbl there?
import dbl
# This example uses dblpy's webhook system.
# In order to run the webhook, at least webhook_port argument must be specified (number between 1024 and 49151).
dbl_token = 'top.gg token' # set this to your bot's top.gg token
bot.dblpy = dbl.DBLClient(bot, dbl_token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
@bot.event
async def on_dbl_vote(data):
"""An event that is called whenever someone votes for the bot on top.gg."""
print(f"Received an upvote:\n{data}")
@bot.event
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 upvote:\n{data}")
this was the one old and in the docs
the token was used
as to here it wasn't
Fucking hell
A simple API wrapper for top.gg written in Python. Contribute to top-gg/python-sdk development by creating an account on GitHub.
Absolutely nowhere, we forgot to remove it when writing the example
one last question, can i use both webhook and autopost?
Sure, they don't conflict with each other
like
dbl_token = 'Top.gg token' # set this to your bot's Top.gg token
bot.topggpy = topgg.DBLClient(bot, dbl_token, autopost=True, post_shard_count=True)
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password")
bot.topgg_webhook.run(5000) # this method can be awaited as well
oh ok ok
thanks
Autopost is a while True loop that uses DBLClient.post_guild_count every X minutes, whereas the webhook is an actual webserver
So yeah
-api
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "<password>")
bot.topgg_webhook.run(5000)
this doesn't work for me sadly
The one on PyPi has the run method that returns a coroutine, on the other hand, the one on GitHub returns a task. So, you can pass it on loop.run_until_complete or similar APIs
1.1.0 soon gang

you must have a vps or what ?
well you can just use ngrok or similar
can you help me this command is not working
stop using dblapi.js and use @waxen widget-gg/sdk
how do I add the server voting api to my discord bot? π€
hey how are you guys!
Will there be separate docs links for each api version? i.e. docs.top.gg/v0, docs.top.gg/v1, etc etc
probably
cool beans
Hello, how can I list the people who voted for my bot on my website.
I wonder if there is a sample php code?
thank you, but I guess what I want is not in this document.
You can use api and some database for storing data.
https://prnt.sc/13cxmjk like this for example
You just have to do a simple cURL request via. PHP, decode the JSON response and there you go.
The endpoint is written down in the docs above.
(to receive the list of the last voters)
Mebers+ is not verifi
?
can anyone help me?
ready event is working but vote event is not working when i vote
Scroll up a little and you will notice to use a different library
this is node.js + discord.js
stop using dblapi.js and use @waxen widget-gg/sdk
If Iβm up to date dblapi is depreciated
Well check the netstat, ipconfig etc. on your server.
Depends on the OS of course
i must to write here http://my.server.ip:port/dblwebhook ?
Does the global ratelimit (https://docs.top.gg/resources/ratelimits/#global-ratelimit) also increment when a resource-specific ratelimit is incremented too?
can anyone help me?
http://[host]:[port]/[path]
I haven't looked at the njs docs but I believe it runs on all interfaces, with the path /dblwebhook (user specified) with the port in app.listen
so you'd be serving at http://<your external IP>:3000/dblwebhook
hmm
can you elaborate "resource specific"?
are you referring to for example getting stats from a bot that the global ratelimit also applies to the bot endpoint ratelimit?
if so, then yes
yes
im trying to use ngrok and node but cannot figure out how to setup webhooks for votes, when I hit test I get 403 Forbidden
in my ngrok console
my code
const Topgg = require("@top-gg/sdk")
const express = require("express")
const app = express()
const webhook = new Topgg.Webhook(process.env.TOPGG_API_TOKEN)
app.post("/dblwebhook", webhook.listener(vote => {
console.log(vote.user)
}))
app.get("/dblwebhook", function (req, res) {
res.json({text:"Test"});
});
app.listen(8000)
your token is wrong
TOPGG_API_TOKEN is not your top.gg token
it is authorization for your webhook
like a password that lets your webhook know "yes it came from there and that's correct"
-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.
does the api have server routes, for example servers/:server_id/check to check if a user has voted for the server? ive tried looking on the docs but it doesnt have any info about server routes
there is no api for servers
only webhooks.
thank u
how can i take my api key?
You grab it with your hands, your PC, your mouse, and your keyboard (optional)

reis ab baksana
tamam Γ§ΓΆzdΓΌm
etiket iΓ§in k.b
how i can get how many votes a user has to my bot? (python library)
topggpy >> 
so im trying to port forward for voting webhooks, but it just sets to this, do i just put app.listen(80) in my code?
and do http://thatdevice'sIP:80/dblwebhook in the webhook url box?
-api
cant help you without the actual error
use a different port
that's why you should read the docs
ok this is how it should be for my router?
π
read the error,
What I do
dont define express more then once
do we have to host the webhook to get the ppl who voted?
# This example uses dblpy's webhook system.
# In order to run the webhook, at least webhook_port argument must be specified (number between 1024 and 49151).
dbl_token = 'top.gg token' # set this to your bot's top.gg token
bot.dblpy = dbl.DBLClient(bot, dbl_token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
@bot.event
async def on_dbl_vote(data):
"""An event that is called whenever someone votes for the bot on top.gg."""
print(f"Received an upvote:\n{data}")
@bot.event
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 upvote:\n{data}")```
How do i set the webhoook link in this code?
so will my route also be /path?
so i put the https/{myip}/{port} and /dblwebhook here?
right?
http://ip:port/dblwebhook
fill in ip and port with the relevant info
if you have ssl, then you can use https
http, nothttps(unless you have your server validate SSL certificates);- IP and port are separated with a colon, not a slash;
- Correct, your path/route is
/dblwebhook, simply prepended to theIP:portpart
Thank you π

and the webhook_auth should be the authorization right?
yes
No worries 
Dont define express twice
Am I a developer?
Yesssssssssss
how do i integrate voting webhooks using javascript? (also pls ping)
hi
Hello again π Sorry, but this is for Server Count (java script)?
yep
const Topgg = require("@top-gg/sdk")
const express = require("express")
const app = express()
const webhook = new Topgg.Webhook(Not giving you)
app.post("/dblwebhook", webhook.listener(vote => {
console.log(vote.user)
}))
app.get("/dblwebhook", function (req, res) {
res.json({text:"Test"});
});
app.listen(8000)```
this is my code
it gives me the error webhook.listener is not a function pls help
const Discord = require("discord.js");
const { MessageEmbed } = require("discord.js");
const { Color } = require("../../config.js");
module.exports = {
name: "dicksize",
aliases: ["dick", "pp", "ppsize"],
description: "Show Member PP Size!",
usage: "Dicksize <Mention Member>",
run: async (client, message, args) => {
//Start
message.delete();
let sizes = [
"8D",
"8=D",
"8==D",
"8===D",
"8====D",
"8=====D",
"8======D",
"8=======D",
"8========D",
"8=========D",
"8==========D",
"8===========D",
"8============D",
"8=============D",
"8==============D",
"8===============D",
"8================D",
"8==================D"
];
let Member =
message.mentions.members.first() ||
message.guild.members.cache.get(args[0]) ||
message.member;
let Result = sizes[Math.floor(Math.random() * sizes.length)];
let embed = new MessageEmbed()
.setColor(Color)
.setTitle(`Pp v2 Machine`)
.setDescription(`${Member.user.username} pp Size Is\n${Result}`)
.setFooter(`Requested by ${message.author.username}`)
.setTimestamp();
message.channel.send(embed);
//End
}
};```
this dude just straight on posted some random code without even asking for anything
π
YIKES, for code and idea, first better thing is to do
const filled = '=';
const start = '8';
const end = 'D';
let length = 34;
let bruh = `${start}${filled.repeat(length)}${end}`;
Why are you continuing this
Can you guys stop shitposting? This is a channel dedicated to top.gg API only, not posting NSFW.
@mighty shuttle
Wht abt girls?
Hello, how do I run code whenever someone votes for my bot with python?
How? Where do I start?
see above
For Python please use https://topggpy.rtfd.io/ for reference
oh thank you!
Hello, how can I test a vote webhook?
then size = -1
hi
There should be a save button and then a test webhook, it won't work if your bot isn't approved though yet
Does my bot need to be approved ? If.I want to send a message everytime someone votes for my sever?
yes
Server no
Kekw
bot.command({
name: "$alwaysExecute",
aliases: ['votetracker',],
code: `
**Thanks for voting!**
{You have received 2.500 Luna Coins!}
$setGlobalUserVar[wallet;$sum[$setGlobalUserVar[wallet];2500]]
$globalcooldown[12h;]
$onlyIf[$jsonRequest[https://top.gg/api/bots/$clientID/check?userId=$authorID;voted;;Authorization:{my top.gg api}==1;]]
$dm[$authorID]
`
})β
does this endpoint exist and work?
So I canβt it for server @ all?
Such endpoint exists but I have absolutely no fucking clue how your request is formed
interesting
You don't need to have an approved bot to receive server votes via webhooks
Oh so I can do it?
Aye, you can
May u pls lead me to the docs?
If you're using Python, refer to https://topggpy.rtfd.io instead
TYY
man you guys are so scared of actually making an effort to learn programming that you'll go learn a completely different language thinking it's not programming
what am I even looking at
it seemed easier to me 
have fun finding resources to solve your problems
oki
Can someone help me Iβm trying to make my bot send a message to a Channel when someone votes for the bot
sure, what language?
discord.js
How do I make it to a channel not console log
Also how do u get the webhook auth
its like a password you make it
Oh ok
With webhooks
Omg buttons OP
-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.
Can someone pls help me , Iβm tryna make my webhook send a message when someone votes for my server , how to get the server token?
I joined a few minutes ago with the same question but I didn't ask anything, I just decided to cry

You put in Not get it
There's none
Probably yeah
bot.command({
name: "$alwaysExecute",
aliases: ['votetracker',],
code: `
Thanks for voting!
{You have received 2.500 Luna Coins!}
$setGlobalUserVar[wallet;$sum[$setGlobalUserVar[wallet];2500]]
$globalcooldown[12h;]
$onlyIf[$jsonRequest[https://top.gg/api/bots/$clientID/check?userId=$authorID;voted;;Authorization:{my top.gg api}==1;]]
$dm[$authorID]
`
})
people really learn that just cuz they don't want to learn a real programming language
one could argue that this is a real programmig language
Gg
Hi, i'm trying to migrate to new top.gg api from dbl.api and have a question. I ave access to the api secret, but i don't have a dashboard to send webhook response to. Besides, i can't also provide an ip as i'm using Heroku.
Can anyone help?
So I canβt make it send a message when someone votes for a server?
Read this
If that's what you meant by server token, it's a password created by you
Me?
I understood that part. But what will i put in URL Field?
Whatever the hell the URL to your Heroku app is KEKW
As i don't have a fixed ip and also using worker process of heroku
I'm not familiar with Heroku URLs
Ohkay
Try harder in another server
Are you okay
.networth egirl_pec orange
.networth egirl_pex orange
.networth {egirl_pex}[orange]
@sacred shell
Bdfd
οΌ
ah ok
no
loading is too slow...
pls give me the voting api for discord.js
You have the API, you just need to implement it
-botcommands
Hey! Bots aren't given permissions to send responses in this channel. Please use #commands to run commands.
How to see my top.gg webhook password
Is my webhook url my top.gg webhook password/auth?
No not the url
Then which one?
wym reply function @blissful bluff
that Reply button
it doesn't literally reply to that comment. it just post it as an another comment
ohh sorry
i didnt saw the channel xD
btw is there way to reply?
the literal reply thingy
Authorization
Will I create the authorization on my own
Yes
okay
How to fetch if someone votes on top gg
using Webhooks I guess
webhook nasΔ±l kullanabilirim
how do i make the webhook poster post automatically after some time discord.js
Hello, I'm not able to log the votes for my bot, Is their some specific docs to follow?
How to get the votes of my bot which are not yet expired, that is all votes made within last 12 hours
https://www.top.gg/api/:bot_id/votes
I need only non expired votes
This brings all the votes in the month right?
Is it possible to use the api to post announcements on the bot site on top.gg?
Like these announcements?
my bot is waiting for approval since 2 weeks
Do not ask here, and it will take time
module.exports.command = {
name: '$alwaysExecute',
Aliases: ['votetracker',],
code: `
$dm[$authorID]
**Thanks for voting!**
{SOME REWARDS HERE}
$setGlobalUserVar[wallet;$math[$setGlobalUserVar[wallet]+5000]]
$Globalcooldown[12h;]
$onlyIf[$jsonRequest[https://top.gg/api/bots/$clientID/check?userId=$authorID;voted;;Authorization:{replace with ur top.gg api key]==1;]
$suppressErrors`
}
on api key what i put and is the code correct?
see pins
I have added the code and the auth too, but when someone votes the BOT it doesn't show
the average wait time is around 3 weeks
@floral egret check the url in the bot's page
Must be like: vps_ip:port/dblwebhook
Check also to allow incoming connections by the firewall
current one in javascript next one in C#
One message removed from a suspended account.
One message removed from a suspended account.
From where I can check that?
In my one it is empty
and you have to put it
What will I put there? Where will I get that link that I have to put there?
@smoky marten
The public link to your Server
Normally it comes in this format
http://YOUR_IP_ADDRESS:PORT
example
http://69.69.69.69:8888
Is there anyway to contribute for the top.gg packages
like uploadfiles or?
Oh wait with a pull request?
ah ok
Is the 1 the amount of how much the user has voted this or 1 = voted this 12 hours and 0 = not voted this 12 hours
It's boolean in integer form
0 is false otherwise true
yes that was my second option
yeah all of those confusing things will be fixed with the new version of the api coming 
pog, wonder if supporter, mod, etc would be flags
bro how to make a api dbl
bitflags yes

how to check number of votes?
how do i get the topgg api token
Hm
Lemme check ty
Thats a one very long token
Thanks
hi i have a question are nuke bots allowed
like to publish
but is it against discord tos
then why are there other nuke bots
then why are they on top.gg
just one tip don't let them use it in the test server cuz that whole test server will be nuked
does someone use discord.js. If yes react
and why did you type this in topgg api channel
cuz i asked a question but never got an answer
whats your question
this
not sure why
Sounds like old version
Is there a widget for servers too? (like bots having a picture where it shows upvotes and stuff)
topken=os.getenv('topken')
topgg=topgg.DBLClient(client, topken)
@client.event
async def on_dbl_vote(data):
print(data)
this doesnt print anything when someone votes
Did you literally miss the part with WebhookManager in docs
Oh right they're not updated
is there no way to do it without a webhook
A webserver is what actually receives the votes in real time so without it there isn't
damn i need to find one π©
You can just do that using express
what is the import for python? dbl topgg or something else?
topgg
Install topggpy
yeah i did
just when i wrote topgg it didnt want to work so now i restarted it and it seems fine
yeah its good now thank you

Will this code work?
/* THIS POSTS STATS TO Top.gg */
const Topgg = require("@top-gg/sdk");
module.exports = {
/**
* Starts to post stats to Top.gg
* @param {object} client The Discord Client instance
*/
init(client){
if(client.config.apiKeys.topgg && client.config.apiKeys.topgg !== ""){
const stats = new Topgg(client.config.apiKeys.topgg, client);
setInterval(function(){
stats.postStats(client.guilds.cache.size);
}, 60000*10); // every 10 minutes
const topgg = new Topgg(client.config.apiKeys.topgg, { webhookPort: client.config.votes.port, webhookAuth: client.config.votes.password });
topgg.webhook.on("vote", async (vote) => {
const dUser = await client.users.fetch(vote.user);
const member = await client.findOrCreateMember({ id: vote.user, guildID: client.config.support.id });
member.money = member.money + 40;
member.save();
dUser.send(client.translate("misc:VOTE_DM", {
user: dUser.tag
})).catch(() => {});
const logsChannel = client.channels.cache.get(client.config.votes.channel);
if(logsChannel){
logsChannel.send(client.translate("misc:VOTE_LOGS", {
userid: dUser.id,
usertag: dUser.tag
}));
}
});
}
}
};```
Try it and see
You have the data format example in docs.top.gg, send a manual request to your webhook
60/60s for /bots/* endpoints along with 100/1s global
What am I doing wrong here?
// Require discord.js package
const { Client, Collection } = require("discord.js");
// Create a new client using the new keyword
const client = new Client();
// npm install @top-gg/sdk
// Posts stats to top.gg
const AutoPoster = require('topgg-autoposter');
const ap = AutoPoster('insert token here', client);
ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
})
I'm getting this error:
TypeError: AutoPoster is not a function
at Object.<anonymous> (index.js:46:12)```
always refer to the docs as the first troubleshooting measure
I took the code for one of my other bots. And it works fine with this one. Idk why it had an issue on this other bot 
are you trying to post your server count or just use the api in general?
I want to post my server count
But that wont work so I think the reason is cuz I need to authorize
are you using @top-gg/sdk?
no
can you show me the code of what you're trying to do
I dont have any code
I dont understand what to do when POSTING to an API
I have said this
I am 100% new to web related stuff and that includes APIs and HTTP Headers
what lang, forgot to ask
i'm not good with py stuff unfourtunately
Do I not need to authorize for the wrapper
https://docs.top.gg/libraries/python/ and you can see from here
yes but the docs should tell you
ik
Wonder why you're asking then. I mean I'm late, but w/e, just telling you that dblpy is deprecated, use that instead
Where is there api?
right above you...
const DBL = require("dblapi.js");
const dbl = new DBL(process.env.DBL_TOKEN, { webhookPort: 5000, webhookAuth: process.env.AUTH_PASS });
client.on("message", message => {
if (message.content == "+check") {
dbl.hasVoted(message.author.id).then(c => {
if(c) {
message.channel.send("Yes, you voted me on Top.gg")
} else {
message.channel.send("You haven't voted me on Top.gg")
}
})
}
})```
is it true
idk, it is true that idk what you're asking for tho
dblapi is deprecated
use the current version in pins
-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.
how much does console.log(client.guilds.cache.size) show ?
Which dblapi ?
also Thus should be the code
const Topgg = require('@top-gg/sdk')
const api = new Topgg.Api('Your top.gg token')
client.on("ready", () => {
setInterval(() => {
api.postStats({
serverCount: client.guilds.cache.size,
shardId: client.shard.ids[0],
});
}, 5*60*1000 );
});
client.login("BOT_TOKEN")
Alr, thanks
np
@abstract moth
Do anyone can help with how do I implement top.gg webhooks ? there are many grey areas in the documentation π¦
- with respect to discord.py
Can you update the library name on API page
on the page dblpy is given, but the lib is now called topggpy
It'll be changed soon
stats were not updating using the old one, so you should do it ASAP
which URL i need to paste in Webhook URL ? is is the url from discord webhook copy webhook url ?
in here ?
qwe9j2170puiojwqekl
You need a webserver hosted on a physical machine with access to the internet
not a Discord webhook
is it mandatory to use webhooks .. cant i just use API normal ?
If you don't need to track votes in real time, sure, why bother using it?
coz i am told by people that if i want to track who voted my bot then i need webhooks for it
i just want to give some bonus to people who voted my bot.
https://github.com/top-gg/python-sdk#using-webhook You can refer to this example, it'll run the webserver for you, you just need to pass the right metadata there. The URL would be http://IP:PORT/PATH.
Does the API return if the bot is online
No
how do i translate a webhook message to input data for my bot
by parsing the json data the webhook returns
its quite easy with using API rather than webhooks
Getting this error when using the python wrapper TypeError: object Lock can't be used in 'await' expression
is it the same syntax?
topggpy.rtfd.io, see for yourself
For code relating to webhooks would I stick it into index.js?
in the new API "@ top-gg / sdk" I can't call (req, res) anymore?
you can use middleware
ok
Do you have to use a webhook for python only? Or is it for all of them?
no and yes
post them to api
https://docs.top.gg
new Webhook('auth')
My bot auth token in topgg or the auth password?
auth password
"You can use this password to check whether datas are coming from us" that one?
Yes
There is nothing but you create one yourself
Put on the field what password u want and copy it to the new Webhook('password here')
app.post('/dblwebhook', wh.listener(async (vote) => {
(await client.users.fetch(ID)).send(text)
}))```
Anything wrong
How can I get the monthly vote count for my bot using python?
DBLClient.get_bot_info, monthly_points key in v1.1
monthlyPoints before that
Thanks
Oh I should update the changelog for this probably
A huge thankyou to comhad for providing us with this method.
Important links mentioned in the video
- Integromato :- https://www.integromat.com/en
Comhad github tutorial with code snippet:-
https://gist.github.com/comhad/bd42b56a0399dbfa645aa83fe3cf4c8a
Support me by upvoting my bot here :- https://top.gg/bot/819838809318621184/vote
Joi...
If you are trying to set up vote rewards use this methods it's way easier and less complicated
My router gets the post from topgg, but the callback function is not called. app.post('/topgg', webhook.listener(async (vote) => { (await client.users.fetch(ID)).send(text) }))
Using third-party services while u have to code only 10-50 lines
I have tried both possible methods I felt this is easier at the end it's on ur personal preference I sent the video with the aim of helping someone π
const voteWebhook = new Webhook(process.env.TOPGG_WEBHOOK_AUTH)
app.post('/topgg', voteWebhook.listener(vote) => {
console.log(vote.user)
})
Whats wrong here? Router logs path "/topgg" got a post request. But the callback isn't called
I cba to watch it rn, does it invol e setting up a webserver manually with aiohttp or what?
no
its a different method im using a third party website called "integromat" from there i set up requests to send to the webhooks on discord
lol
am I like blocked from the server?
const voteWebhook = new Webhook(process.env.TOPGG_WEBHOOK_AUTH)
app.post('/topgg', voteWebhook.listener((vote) => {
console.log(vote.user)
})
``` Whats wrong here? Router logs path "/topgg" got a post request. But the callback isn't called
Is the webook_auth the api key?
there's no api key
"Token for this bot"
Idk I haven't used their api for a long time
in analytics
you're better off just waiting for someome else
Can someone pls tell me if my code is correct
const express = require('express')
const app = express() // Your express app
const webhook = new Topgg.Webhook('auth') // add your top.gg webhook authorization (not bot token)
app.post('/dblwebhook', webhook.listener(vote => {
// vote is your vote object
console.log(vote.user) // 221221226561929217
})) // attach the middleware
app.listen('8000', () => {
console.log('App listening on port 8000');
});```
Code?
uhm hide ur Topgg.Webhook auth
The same in my case, it doesnt work for me
He said that's fake
ok
so can someone help pls
No idea, it doesn work for me, I have a pretty similar code
can u help
@coarse rune did u change the URL in topgg?
which url?
the url to which topgg posts votrs
no sowwy i need to get it to work too but i dont have an api yet so yeah
oh
@coarse rune
um idk
i am actually new to coding on top.gg
Change that url in topgg/bot/id/analytics to http://<ur_ip>.<port>/dblwebhook
ok...
If u use online IDE, they shud prolly have their own url like heroku has myapp.herokuapp.com
like this
@winter tusk
Lmao @coarse rune
No
That one
Change /topgg to /dblwebhook for ur case
I did that thing and still didn't work for me ;-;
Oh ok
@Thecubingmaster123#4384 found the problem
The webhook auth is not the bot token
It is wat u set
need a free udemy course!
Do you have to use a webhook for python only? Or is it for all of the languages?
Depending on what you want to do
Collect the data for on_dbl_vote
Then yes you need the webhook for that
A webhook is what actually receives the vote data in real time so it's not limited to a specific language
Yes but many api references i saw for topgg included a new discord Client event, so i was curious to see that in other languages
Ind im also a bit confused
Bc it seems like it was way easier that way
But the api got updated
And now only 1 reference is right
I've been busy lately so I have no time to update the top.gg docs for the Python SDK right now. I should be able to make a PR for that later this week, however.
Well, the node SDK has its own event emitter, but the Python one utilizes your discord.py Client for that
can someone send me the fullfilled api with /check/userid=
Does the serverCount stat expire over time at all?
Nope
Thanks @sullen nymph
i can't figure what to do in server webhooks part
and i am not able to assign the reward roles too
pls help me
what requests?
@shut flume
i have already created teh server'
I'm not sure you guys are on the same page
im making a simple top gg api lib. its ok to publish it?
Or i have to put "This is an unoffical lib" in desc?
It's preferred that you put a disclaimer that your library isn't official
Click on this to show your authorization key
I dont think those are the same, you make your own authorisation
custom authorization for the webhooks
and this to post stats / get bot infos
Yeah
THX
you are welcome
ISelfBot me = await DblApi.GetMeAsync();
on this line i get a error on ISelfBot, it says the type or namespace name could not be found
any help on that?
C# btw
Guys i have following issue with the api (Cannot access 'client' before initialization)
no help for us today pal
For what ?
There a problem With Your Bot Client id
@cobalt ruin
Hiii
thats the litterally easiest thing to fix but let me say:
put whatever you trying to do below
hi guys I was beendet from the AniGame server four spaming in spam chanal wtf

-api @bronze flower
@bronze flower
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.
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 :(
I already fixed it myself
Excuse me, i've tried the different sources of documentation i could find which are:
- https://github.com/top-gg/python-sdk#using-webhook (Code below is using this one)
- https://docs.top.gg/libraries/python/
- https://topggpy.readthedocs.io/en/latest/webhooks.html#webhookmanager
But i still can't get the bot to react to on_dbl_vote. Can someone please tell me what am i doing wrong?
import topgg
# This example uses topggpy's webhook system.
# The port must be a number between 1024 and 49151.
client = commands.Bot(command_prefix=get_prefix, help_command=None, case_insensitive=True)
dbl_token = "notHere" # set this to your bot's Top.gg token
client.topggpy = topgg.DBLClient(client, dbl_token)
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("/http://myIP:19950", "Tester123")
client.topgg_webhook.run(19950) # this method can be awaited as well
@client.event
async def on_dbl_vote(data):
print("Check")
"""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}")
@client.event
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}")
Hello, How can i log the votes? Is there a document which could help?
I tried using the topgg/sdk api but it didnt work
your dbl_webhook parameter is wrong
That's your path, NOT the full url
Could you please give me an example of the "path"
See the docs
Thank you very much for pointing out the mistake! I appreciate it 
Maybe I should make it error out on http in the path string
Oh. Or just output the current routes with full URL
Missing
We all miss sometimes. It's okay to miss, we're not perfect. Just learn from your miss and move on
bruh wrong send
Yes, see webhooks
trying to setup webhooks right, port is open (check photo 1)
https://cdn.discordapp.com/attachments/752853649482449016/850071238072205382/unknown.png
but when i go to my ip + webhook (eg: http://[my_ip]:5555 i get this
https://cdn.discordapp.com/attachments/752853649482449016/850071546620936202/unknown.png
Authorization is setup correctly too (either in code and on top.gg webhook section) however this shouldn't make the not found
show code
that one can work
Second screenshot will tell you 404 because of your path missing
405: Method Not Allowed
yup you cant make get requests
post requests is what your webhook only listens too
use reqbin to make a test request
now
add a auth header
like this
Authorization: basic topgg
or?
remove the basic
i mean my code is here but idk
check the headers from the request, press the "Headers"
how do u do it in the reqbin
ah hwait
nvm
ok hang on
Remove the Authorization: part from the Authorization tab
No, not all of it
wtf
lol
ye exactly lol
the thing is
it used to work till a month ago
hadn't changed code or settings on top.gg
Hi, is there an endpoint to post votes instead of using the website ?
Nope
any way to fix it maybe? my thingy?
idk try restarting it or using another auth
restarted so many times
tried using another auth but still nope
Just to be clear, the limit is 100 per second?
that's the hard limit that will get you banned from cloudflare
so I recommend you don't get too close to it
Will hitting the API once every minute get me rate limited?
Thank you
Do I need to integrate this with flask? and how do i do tht(discord.py)
import os
from main import client
dbl_token = os.getenv('toptoken')# set this to your bot's top.gg token
client.dblpy = dbl.DBLClient(client, dbl_token, webhook_path='/', webhook_auth='password', webhook_port=8080)
@client.event
async def on_dbl_vote(data):
"""An event that is called whenever someone votes for the bot on top.gg."""
print(f"Received an upvote:\n{data}")
@client.event
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 upvote:\n{data}")
@client.event
async def on_guild_post():
"""An event that is called whenever autopost successfully posts server count."""
print(f'Posted server count ({client.dblpy.guild_count})')```
No it should be running already
Hi, I tried to update the server count, But its showing an error, So what can i do?
Is there a way to check how many times a user has voted using the topgg api?
no, you'll have to track it yourself
No clue, maybe try posting the error and the code
I tried with the top.gg/sdk package, the bot automatically crashed no idea why
i used those other packages, it showed error in the console
Still cant help without any errors to show 
you gave the wrong token / no token
nope, its correct
i need help
Me too
TopGGAPIError [Top.GG API Error]: 403 Forbidden (You don't have access to this endpoint)```
const api = new Topgg.Api('my token of top.gg')
let voted = await api.hasVoted(message.author.id)```
on monday that correct, now ocurred a error
the same code
how can i setup the url for the webhook system?
The URL is the public IP address of the machine the webhook service is running on.
Or even a domain name if the target is it's public IP address.
In discord.js how I will make top.gg vote require command
Which package will help me
@mellow zinc
Collect user votes, save them in a database and let only clients access your command if they're in the database.
And don't randomly ping people. Patience!
@ top-gg/sdk

or just use the top.gg sdk and use the method for checking if a user voted
which i think is much easier
lol
Hah yeah, don't over engineer things when you don't have to.
That just returns users who have voted the current month and no previous one
Fetching the users and caching them is similar to fetch them and throw them into a database.
I would also rely way more on my own database then the topgg API
I'm currently looking at
import dbl
# This example uses dblpy's webhook system.
# In order to run the webhook, at least webhook_port argument must be specified (number between 1024 and 49151).
dbl_token = 'top.gg token' # set this to your bot's top.gg token
bot.dblpy = dbl.DBLClient(bot, dbl_token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
@bot.event
async def on_dbl_vote(data):
"""An event that is called whenever someone votes for the bot on top.gg."""
print(f"Received an upvote:\n{data}")
@bot.event
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 upvote:\n{data}")
I'd like to create a vote required command. Where can I get a webhook from to use?
Hi can someone help me make like a timer for voting
how to setup webhook inside python bot?
no no i need my bot to recieve the voter id and give perks to the voter
Oh sorry, this: https://docs.top.gg/libraries/python/ ?
also, is there a way to detect server votes?
webhooks
look i want to detect votes for a server and give perks to the user who voted for the server..... how?
see docs above
give perks meaning give coins
One message removed from a suspended account.
yes, see docs above
One message removed from a suspended account.
One message removed from a suspended account.
i did, and i understood, what i am unable to understand is how to create a webhook for my bot
what url do i put here to make my bot detect the votes
me being confused 
everything is bot votes how tf do i detect server votes helppp
your webserver's url
i did put it, now how do i detect the vote on my webserver
python
@willow spindle i put https://Akaza.ace6002.repl.co
it is my webserver url i think
A simple API wrapper for top.gg written in Python. Contribute to top-gg/python-sdk development by creating an account on GitHub.
not working :((
not working doesn't tell us much
this is what i put and i clicked test but doesnt work
this pic is my code
now check your dsl_webhook parameters
see something on the url and the first parameter
Fuck's sake I need to update those docs
is there an owo channel here?
No
-api
@restive otter
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 made it
