#topgg-api
1 messages Β· Page 155 of 1
I just want to collect user votes on my server
I have a bot, but I don't really wanna make it public
Any idea why it shows this?
My bot isn't verified
But I need to run a webhook to get server vote details
Hmm, I always shows get this error when I try to setup one
Maybe, I'm mixing it up. Do you have a different webhook for servers?
Something like this?
Wow, thanks man. Just needed to get that link
Damn, that was easy. It worked. I was seriously messing it up
Thanks again
oh thnx , cud u show me an example of how that works
"""
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 = '[insert token here]' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='path', webhook_auth='yeet', webhook_port=5000)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
"""An event that is called whenever someone votes for the bot on top.gg."""
print("Received an upvote:", "\n", data, sep="")
@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."""
print("Received a test upvote:", "\n", data, sep="")
def setup(bot):
bot.add_cog(TopGG(bot))
i copy pasted this code to test out the vote command
but there was no output on voting
am i doing something wrong here
Have you loaded the cog? Is that path a placeholder? Cuz it should start with a slash.
Do we need to set anything in the bot settings page for webhooks for dblpy to work?
Yes
what do we need to set?
The URL at least
what url? /dblwebhook ?
That's the path, the URL will be something like http://IP:PORT/PATH
the ip of where the bot is running on?
The public one, yeah
I used it and tested it and it doesn't seem to work
I put http://IP:1234/dblwebhook
and the password
Try accessing it through your browser, it should show 405 if it's running
It's not appearing in browser, saying it "took too long to respond"
Make sure the port is open and it's the exact same port and path you put in the code
webhook_path='/dblwebhook', webhook_auth=password, webhook_port=1234
@restive otter is it fine to enter example data like this?
I don't see any other "sensible" way of doing that so uh 
I guess so, there's nothing wrong with it
Thanks
Assuming that d's reference isn't used, since if something is popped, it might break the tests.
If it works, it works 
I wonder if the docs build from the objects' __doc__
Sphinx does, yeah
Ah, cuz syncing them by hand seems a pain
how do u load a cog?
lmfao no way I'm gonna copy-paste class docstrings 
Changelog and additional notes I have to do by hand though, so that's the painful part
and what is the path supposed to be?
Is that your main file? If so, just put the bot.add_cog line on the top-level, meaning, put it outside of the function. Otherwise, just load it with bot.load_extension
ah ok
Let me know what u need exactly. If you don't wanna use a lib, you can do a simple HTTP POST request to send your current server to topgg.
i just need to be able to take the user id of the voter
thats it
rest all i can do
Well if it's supposed to happen "live" you will have to setup a webhook service
To receive incoming requests from topgg
thats what im trying to do here
also
what excatly is bot supposed to be
The docs already contain examples how to do so
lemme check
Keep in mind you have to setup firewall rules for incoming connections
uhuh
And don't think about hosting the webhook service at home
Alright, this means you don't have to deal with a router firewall but still your own system firewall
ok
After installing the lib as the docs say you have to specify a webhook port your service will listen to, for example 5000
I hope I didn't miss something when listing what I've changed 
That port (e.g. 5000) needs a rule in your firewall
INBOUND rule on port 5000 TCP
That's all
and how do i put in a firewall rule
depends on the OS
of the host?
yeah, your webhook service will run on
hmmm
The host you're using might have a GUI for it
im using heroku
wud that work?
actually can't tell you, dunno that service provider
Heroku dynamically changes the PORT afaik, get it from os.environ or os.getenv
ayt thnx
It's amazing how many mistakes there are in the docs and no one ever pointed them out
that sounds kinda sus tbh
Exactly
Is there even a single soul reading it lulw

Didn't expect that tbh 
Me neither 
pretty sure half of that was from me
That's nice
Ya that'll be changed soon
this isn't really an api question, but have you used apscheduler before? and if so which job store do you rec
Never. I only use asyncio tasks and while True loops in my projects to mimic cronjob behavior
hmm okay
it's just because I want job persistence so that's why I was considering using it, ofc I could just save a bunch of datetimes in a sql table and use that as a way to work around it
but that's a little scuffed

Hi, I didn't get bot because of that code from top gg and now it's out of the code that I'm sending to top gg doesn't answer please what to do now π₯Ί
Best way to get votes for a specific bot via python?
like an event when someone votes? or just generic get the number of votes
generic
I dont think the library has that ability, youll need to make the request yourself.
https://docs.top.gg/api/bot/#bot-stats
oh the lib might have it actually
hmm
yeah i think i see it
I appreciate it my guy π
Unhandled exception in internal background task 'update_stats'.
Traceback (most recent call last):
File "D:\PycharmProjects\Tricorder\venv\lib\site-packages\discord\ext\tasks\__init__.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "D:\PycharmProjects\Tricorder\cogs\general\LoopedTasks.py", line 39, in update_stats
print('count', await self.bot.dblpy.get_bot_info())
File "D:\PycharmProjects\Tricorder\venv\lib\site-packages\dbl\client.py", line 226, in get_bot_info
return await self.http.get_bot_info(bot_id)
File "D:\PycharmProjects\Tricorder\venv\lib\site-packages\dbl\http.py", line 180, in get_bot_info
resp: Union[dict, str] = await self.request('GET', '/bots/{}'.format(bot_id))
File "D:\PycharmProjects\Tricorder\venv\lib\site-packages\dbl\http.py", line 144, in request
raise errors.Unauthorized(resp, data)
dbl.errors.Unauthorized: Unauthorized (status code: 401)```
oof
print('test', await self.bot.dblpy.get_bot_info())
get bot info requires the id of the bot you are trying to look up
oh or not
you didnt use your token
Hit the Edit Button on your bot page
Press the Webhooks button on the sidebar
Hit Show Token
Copy
because it constantly expires for me
never afaik, unless it gets leaked, or you(or another one of your devs) reset it
hmm
Unhandled exception in internal background task 'update_stats'.
Traceback (most recent call last):
File "D:\PycharmProjects\Tricorder\venv\lib\site-packages\discord\ext\tasks\__init__.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "D:\PycharmProjects\Tricorder\cogs\general\LoopedTasks.py", line 39, in update_stats
print('count', await self.bot.dblpy.get_bot_votes())
AttributeError: 'DBLClient' object has no attribute 'get_bot_votes'```
ok
aaaand forbidden
Unhandled exception in internal background task 'update_stats'.
Traceback (most recent call last):
File "D:\PycharmProjects\Tricorder\venv\lib\site-packages\discord\ext\tasks\__init__.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "D:\PycharmProjects\Tricorder\cogs\general\LoopedTasks.py", line 39, in update_stats
print('count', await self.bot.dblpy.get_bot_upvotes())
File "D:\PycharmProjects\Tricorder\venv\lib\site-packages\dbl\client.py", line 203, in get_bot_upvotes
return await self.http.get_bot_upvotes(self.bot_id)
File "D:\PycharmProjects\Tricorder\venv\lib\site-packages\dbl\http.py", line 189, in get_bot_upvotes
return await self.request('GET', '/bots/{}/votes'.format(bot_id))
File "D:\PycharmProjects\Tricorder\venv\lib\site-packages\dbl\http.py", line 146, in request
raise errors.Forbidden(resp, data)
dbl.errors.Forbidden: Forbidden (status code: 403)```
did you give it the right token for the bot you are looking up?
how I do setup a webhook url to send webhook data to?
the url is just whatever the url to your webhook receiver is.
http://PUBLICIP:PORT/PATH
port and path you choose in your code, ip is the public ip your webhook can be received at.
how do I make a reciever?
theres a few libraries that can do it for you, or you just make a webserver.
https://docs.top.gg/
I'm using dblpy
I'm already using it but I don't understand
does client.dblpy = dbl.DBLClient(client, topgg_token, webhook_path='/dblwebhook', webhook_auth='hehexd', webhook_port=5000) create a webhook at localhost:5000?
the webhook would be at
http://PUBLICIP:5000/dblwebhook
it can listen on localhost too, but localhost isnt something top.gg can access
so the http://PUBLICIP:5000/dblwebhook i'd put in webhook url settings right?
yep, will need to replace the actual ip, but yep thats it
I tried accessing http://localhost:5000/dblwebhook but I get 405: Method Not Allowed
yep thats normal, its a webhook, not a website.
you cannot "get" a webhook like your trying to do, only post to it.
how i access the data?
Why am I getting TypeError: on_dbl_test() takes 1 positional argument but 2 were given
this is my code
class TopGG(commands.Cog):
def __init__(self, client):
self.client = client
client.dblpy = dbl.DBLClient(client, topgg_token, webhook_path='/dblwebhook', webhook_auth='hehexd', webhook_port=8015)
@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}")
Forgot a self parameter in the method
client.dblpy = dbl.DBLClient(self.client, topgg_token, webhook_path='/dblwebhook', webhook_auth='hehexd', webhook_port=8015)
like this?
In the on_dbl_test event
I dont understand what u mean
Do you understand how a method should refer to the instance of the class it's used in
hi so i was wondering how i could use the api so when they try using the command after using it it tells them how much time they have left to vote again
Server count blank - what to do?
Ask in support.
You canβt remove your server count or post null using the API
Use a database and use topgg Webhook to save vote data. Then add 12 hours with the last vote time to get when the user can vote again
Are you posting it ?
app.post("/dblwebhook", webhook.listener(), async (req, res) => {
const hook = new Discord.WebhookClient("id", "token")
const user = await bot.users.fetch(req.vote.user)
const embed = new MessageEmbed()
.setDescription(`${user.tag}(${user.id}) just Voted Me On Top.gg`)
hook.send(embed)
});
Is This Correct?
where i need to do bot codes or top.gg page
read the docs
How to get the server count on bot home page
@restive otter You can do this by using the top.gg API. This is the endpoint you are going to need: https://docs.top.gg/api/bot/#post-stats
Idk how to use their api
Well then you have the documentation to tell you all about it! Here you have the "getting started" part where they explain how to send requests and how to authorize with their API: https://docs.top.gg/api/@reference/
what may be causing this error
AttributeError: module 'discord.ext.commands' has no attribute 'loop'
here is the cog btw https://ghostbin.co/paste/75q4ws
For which code
You should pass an instance of Client or its subclasses, not a module. Also, why would you attach the DBLClient to a module?
owh lol. i was being stupid
Sounds like I have to add a check for such cases? π
Sure, ez 2 lines
evil giggles assert isinstance(client, __import__("discord").ext.commands.Bot)
lmao
you should check it against discord.Client doe
class WhatEverErrorItsCalled(TopGGException): ...
if not isinstance(bot, discord.Client): raise WhatEverErrorItsCalled("some message")
Oh no, no docstring 
You haven't updated topggpy's readme btw 
Hold on I'm busy having a pointless argument on Twitter
lmao
One message removed from a suspended account.
I hope your keyboard disconnects from your PC while you're playing Overwatch
One message removed from a suspended account.
One message removed from a suspended account.
I hope your drivers will always be outdated
One message removed from a suspended account.
β€οΈ
how do i take the bot field in spring boot , idk how to take Snowflake type variable π€
pong me and tell pls o:
well that answers my question
well i guess call it express in java :p , not really tho
Perhaps I placed this in the wrong channel previously... But I don't see a "bug reports". Indirectly API related? (don't hurt me lol)
Website bug.
Yo. I'm unable to reply to reviews or thumbs-up reviews, it seems.
I get a nice little load bar at the top along with the loading circle for a long time (20 seconds or so, for completion), then when it finishes, nothing changes. No page POST, no reload, and on refresh nothing has updated.
- Explain the state of matter
Indirectly not specifically the API itself, but yeah - website bug
on python im trying to print the bot.dblpy.guild_count, but all it returns is that its a method of an object at a certain address
more specifically
<bound method DBLCient.guild_count of <dbl.client.DBLClient object at (address)>>
thats with the ()
Is it possible to get a bots monthly votes via the API without an Authorization token?
I dont think any endpoint is available without a token.
hmm. Than is it possible to get it if you dont have a submitted bot?
nope. the api is for bots only.
What version
I wanted to make something that you could enter the bot ID and it would display the monthly votes for that bot.
thats what top.gg does.
I know.
python 2.7
I was going to try to make a badge on shields.io for it
2.7 what
They redirected me here
Even in -botinfo it says my bot is in 0 servers
Js
discord.js?
Yes
Thx
so this would not be possible.
Whats the webhook auth?
its a password for your webhook to know if the request is coming from top.gg
you choose what it should be.
ok
dbl_token = '***' # set this to your bot's top.gg token
bot.dblpy = dbl.DBLClient(bot, dbl_token, webhook_path='/dblwebhook', webhook_auth='****', 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 use this code. why it doesnt work?
did you fill in the url and auth on the website?
yes
where are you hosting? home/vps/replit/heroku
@restive otter
class DataDict(dict):
"""Generic class used in topggpy to represent received data from the API."""
Would this technically be correct or should I use another word instead of Generic?
Cuz to me it sounds reasonable but wrong at the same time
Hmm, I don't think it's a generic class, because the value type varies
"The base class for TopGG models" or something? xD, I'm bad at wording 
It's indeed a base class, isn't it
np
Oh God autodoc is such a pain
Like it refuses to refer to the local types folder when I use types.X with current module set to topgg
But when I change current module to topgg.types, I can't refer to DBLClient.generate_widget without having to specify the module name!
Oh God
const Topgg = require("@top-gg/sdk")
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)
What does the /dblwebhook respresent?
Webhook URL?
@sullen nymph Sorry for ping but can you help?
studio visual code
visual studio code is a place to code, not host.
are you hosting from your computer?
yup
/dblwebhook is the path, not the whole url.
http://ip:80/dblwebhook
80 being the port you are using
ill just host it on replit lol
ohh ok. Is the express part a must? Or can I just skip it and log the user only instead?
the express part is the actual webhook itself(more specifically the webserver hosting the webhook). without it, you cannot receive when someone votes.
Still doesnt work
are you using the replit url with /dblwebhook at the end.
top.gg webhooks are not compatible with discord webhooks.
you need to use the url to your webhook receiver(the code you used above) not discord.
const Topgg = require("@top-gg/sdk")
const express = require("express")
const app = express()
const webhook = new Topgg.Webhook("private auth")
app.get("/", (req, res) => {
res.send("The Bot is preparing to get uploaded...")
})
app.post("/dblwebhook", webhook.listener(vote => {
const hook = new Discord.WebhookClient('webhook-id', 'webhook-token');
hook.send(`${vote.user} just voted!`);
}))
app.listen(3000, () => {
console.log("express server started")
})
@jaunty plank Its saying
webhook.listener is not a function
are you on the most recent version of the sdk
i just installed it
sorry for the basic question, but did you save the file before running it
I have auto-save on
so yes
and I reran the process too
in your package.json is the version 3.1.1 or 3.1.0
any time before 3.1.0 webhook.listener worked differently.
ah
mine is showing "@top-gg/sdk": "^3.0.9",
idk why it installed the old version, I just installed it 30 mins ago
How do I update the version
npm update @top-gg/sdk
So I know for a fact that my bot is in more than 1 server but for some reason, it's posting to top.gg like this
I just implemented this system the same with with one of my other bots and it worked fine. But for some reason, it's not working correctly with this one.
hmm it should be fine that code
I already did regen it the second I realized 
Ah cool
We all make mistakes, i uploaded mine to a github repo once lmao
Still appearing as 1 server though 
// Require discord.js package
const { Client, Collection } = require("discord.js");
// Create a new discord 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('token', client)
ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
})
I think it may be a top.gg side bug.
Or maybe it has to do with my webbrowser
Cause I just reloaded the other bot that had it working a few seconds ago and now it has the same issue.
This is my bot, what does it appear as on your screen? https://top.gg/bot/791829672852979713
if you read the code you will see the difference
Well other than the require area. Is there anything different?
I found it, nvm
Still didn't fix my issue btw, still says I only have 1 server.
const Topgg = require('@top-gg/sdk')
const api = new Topgg.Api('')
setInterval(() => {
api.postStats({
serverCount: client.guilds.cache.size,
shardId: client.shard.ids[0], // if you're sharding
shardCount: client.options.shardCount
})
}, 1800000) // post every 30 minutes
Actually, it's possible I am stupid.
Hold up 
Okay, it was partially my fault and partially not.
Fixed it now though 
It's still pretty dang glitchy actually. Idk
are you running this on a test bot?
I checked that. It's on my main server for the bot and still posting wrong.
@jaunty plank
so the code you are running is running on the actual main bot?
Correct.
100% certain of that because I accidentally made it go offline with messed up code 
what version of djs?
i typically check in the package.json
I mean, does it appear as 1 server for you? Perhaps it is a cache issue. https://top.gg/bot/739543993138020453#/
oh are you changing your code quite a lot? the example you gave wasnt the auto poster
Yeah
Cause I tried the other one and it didn't make a difference.
So I changed it back to the auto poster.
it takes some time for the site to update to new values. if your swapping code quite a lot it might not show up.
I think it may be being ratelimited because initially I accidentally had it on my testing bot.
ah then thats it
My Barnyard bot seems to be posting correctly.
Now that I fixed it
Does it say 100 for you?
shows as 1 for me.
Tf
It was just showing 100 for me and then I reloaded and now it says 1 
What is this 
like i said, it takes time for the values to update.
Accept the Barnyard one was only on the main
I didn't use any alt bot for that.
So idk why it says 1
I guess I'll just wait for it to update and hope it fixes itself π€
I think you just posted your test bots server counts, and haven't given it enough time to update.
if its not fixed in 30 minutes, try changing your code, and giving it another 30 minutes.
Alright 
Thanks for the help.
Now it's correct and then I will reload and it won't be correct 
Yep.
Strange weird caching.
i mean thats normal for pretty much anything with counting online
twitter, youtube both do it.
great video on the topic.
https://www.youtube.com/watch?v=RY_2gElt3SA
Sometimes, numbers on sites like YouTube and Twitter jump up and down; subscriber counts lag, like-counts bounce all over the place. Why is it so hard for computers to count? To answer that, we need to talk about threading, eventual consistency, and caching.
Thanks to my proofreading team, and to Tomek on camera!
The Cambridge Centre for Compu...
@jaunty plank hey I got a question, I'm using the Java API but my bot got 4k votes rn, does that mean I got to switch to the webhooks?
many of the endpoints are not safe past 1000 votes
I've actually been busy creating a webserver in Java, but I just remembered the rule about ratelimits, its been 4 days since I use the java API
would I need to take the API out of the bot immediately?
can i use autoposter if i dont have shards
if your not hitting any ratelimits, and not using any of the unsafe endpoints I dont think so.
its mainly just the /votes endpoint.
If you have over 1000 votes per month you have to use webhooks instead of polling https://docs.top.gg/resources/voting/
If you are using /votes, youll need to move to webhooks.
i dont see why not
I use the DiscordBotListAPI in java and all I do is check if someone voted or not
api.hasVoted().whenComplete
I'm not sure if that uses the /votes endpoint
should be safe. https://i.imgur.com/nVev3qJ.png
const api = new Topgg.Api(process.env.TOPGG)
setInterval(() => {
api.postStats({
serverCount: client.guilds.cache.size,
})
}, 1800000) // 30 mins```
so i have added this into my main.js
and the server count is not working
any ideas why
what is the requirement for dbl python
i tried topgg==1.0.0
dblpy==1.0.0
neither work
topggpy
thx i will try it
what's the import?
I tired Import dbl but i got this error
2021-05-17T22:30:16.842315+00:00 app[worker.1]: Traceback (most recent call last):
2021-05-17T22:30:16.842424+00:00 app[worker.1]: File "/app/RoasterRooster2.0.py", line 8, in <module>
2021-05-17T22:30:16.842854+00:00 app[worker.1]: import dbl
2021-05-17T22:30:16.843014+00:00 app[worker.1]: ModuleNotFoundError: No module named 'dbl'
there are docs about python...
i probably wouldn't be asking here if I hadn't already looked
technically the problem with top.gg caching has to do with implementation more than the limitations of caching itself
I'm confused what I'm supposed to put here, if someone could clarify that, that would be awesome
the endpoint for your webhook
so if you're hosting on your computer, it'd be http://PUBLICIP:PORT/
where PUBLICIP = your public IP and PORT = the port you select
ah alr
i just ran a test of it on port 22 but I'm a little confused on whats supposed to happen
go with port 5000
ok
just did it, is there something I'm supposed to look for?
well are you sending anything to the webhook?
if you're not sending anything to it it's not gonna do anything
is it this?
that would do something when someone votes for your bot
its these that are triggered correct?
I'm in the process lol
you gotta read it through
no, that's done for you with this lib
you can add more things to the end to specify where to send things
to organize stuff
like you could send bot votes to http://publicip:port/bot/
Hi i try to see when someone vote for the bot but it dont work :/ i have done as the documentation say but it dont want to work. here's my work
on the first screen the url look like : http://myip:myport/dblwebhook and the auth is the same things as the red rectangle on the second screen
Hi I need someone to help me make server count for my bot using api
I have no shards
only like 20 servers
Only server count is required
everything else is optional
Oh
@restive otter I don't know how to use top.gg api
It's like any normal API
You make a post request with JSON data
may I ask why I get 401 errors with the top.gg sdk even though I just updated my code and made a new token
seeing a lot of 504 Gateway Time-out when posting stats currently. ongoing issue?
any help on setting up the webhook in replit?? i know replit is not resommended for bot hosting but i don't have any other options. I am using discord.py btw
WebhookManager in a nutshell
LMAO don't expose my tactics of working code

SUCESSFULLY DONE VERIFING MY MUSIC BOT
gz but it is not related to this topic
why you dont have the badge ?
can anyone help me for the webhook that check when someone vote ? i try since a day without anything working
Because discord has stopped giving verified bot dev badge
really ? that's sad 
Discord has turned of the badge previous year
sad
I was lucky enough to get my bot verified on the first week the verification process came our
Fuckkk you
Not really appropriate.
please give me api for make this
I made a guide https://comhad.github.io/webhook.html
Good shit dude. Many people have had problems with this - clever
Aw ty :D
Why does someone post a lot of posts when they vote?
Like getting multiple webhooks?
top.gg api docs say to come here with questions why my code isn't working, but every time me or someone else don't have success with the api either someone links back to the docs or just ignores the question
What issues are you having?
nothing happens with the webhook
ive tried multiple codes
Thats very vague, are you not recieving anything?
Yeah
I host my bot myself, so on my home network
Ok, have you done port forwarding through your router?
I've tried but I'm not really sure what I'm supposed to forward
What port are you using for the webhook?
I haven't really decided yet, but I've been using 373 for my tests
and 80
and 8080
Then you need to open that port on your router and you might need to forward it to your local ip
what type of port should I open?
Tcp? I think, it depends what your options are
Should I open a custom port or http port?
Probably http
Should I have it doing TCP, UDP or both?
Tcp
idk if this is related but now my bot won't load when i try to start it using node
Ok, im not experienced in node so i cant help you here sorry
ima restart real quick
Ok
Yeah
Oh ok
would this code be good?
Yeah, thats been used by a few, it does the job just fine
alr let me test
nope
nothing
maybe should i set a custom port instead
like TCP?
Yeah, try that
How does one get started with logging whenever someone votes for our bot? (plan on making a voting top leaderboard)
Webhooks, use this guide : https://comhad.github.io/webhook.html
I should add a nice embed thing for that lol
Mint! thanks
i did the integromat thing on your guide
how do i make it output the id of the person?
if i can get it to output the id of the person who voted into a channel i can do the rest from there
Do you have the little window with the red buttons?
(this is for discordbotlist.com, it won't be the exact same)
Np
You need to click that little switch to keep it running at all times
In the bottom left
i have it on yet its doing nothing
i accidentally made two webhooks could it have something to do with that?
Yeah, just delete the disconnected one on the left
That should mean you only have one entry point
try it again after that and let me know if it works
Click on the 1 above the http, it might show an error
Is the webhook one or http one?
webhook
Ok, what's http say
the http one is also fine
i would send but it has webhook url
and im too lazy to block out
You sure? open all fields on the http, it should show an error if there is one
no errors
when i do run once its fine
but it just doesnt activate automatically when someone votes
That makes no sense, hmm
Make sure the switch is toggled on, and click back, it should ask you to save, maybe try that?
saved it
and the switch is toggled on
still nothing
wait\nevermind
it did it
i just had to save
Ok cool
It is a bit lol
I'm trying to build a bot specifically for this stuff, but i'm not entirely sure if it would collide with discord ToS so idk rn
if (message.channel.id == "the channel id"){
if(message.content){
voterID = message.content
const voter = client.users.cache.find(user => user.id == voterID)
console.log("New vote: "+voter.tag+" ("+voter.id+")!")
voter.send("Thanks for voting for Jimmybot! 20 Treats have been added to your balance! Vote again in 24 hours for more!")
.catch(() => console("The voter has dms off!"));
if(money[voterID] == null || !money[voterID]){
money[message.author.id] = 0
fs.writeFileSync(__parentDir+'/storage/money.json', JSON.stringify(money));
}
voterbal1 = money[voterID]
voternewbal = Number(voterbal1) + 20
money[voterID] = voternewbal
fs.writeFileSync(__parentDir+'/storage/money.json', JSON.stringify(money));
}
}```
thanks to you i finally have a working system
Nice :D
I'm considering making a site that pretty much does what the above site does, just automatically.
something simple like,
http://topggwebhooks/webhooks/844312677757222739/QRxNoCRQnU2zOc3fBKROC7e6W5XnXz-e3Ox1lMLODXB8li6LxgObR9uASh7MHGYppNmC/
and just reformats the request to discords webhook format and sends it.
could be an easier solution than making a bot, and should have no issue with discord tos.
Ah, that's simpler
My concern is would the site get rate limited by discord for sending to many webhooks?
the ratelimit for webhooks is quite high isnt it? lemme take a look
I was under the impression that bots were allowed to send more messages than webhooks per minute
I think they get like 100 a second, not sure for webhooks but in a script i had to space them apart a bit
for one webhook right?
Is it not rate limited by IP?
hmm, I was under the impression its per webhook.
otherwise how would large companies(like github) send all those webhooks without using hacky methods.
I think you're right
I had an idea of letting someone choose a path, say comhad for example and then having a bunch of options for stuff at the end of the url like
api.localhost/comhad/top_gg_bot and api.localhost/comhad/wordpress_comment
We could combine those like
/webhooks/844312677757222739/QRxNoCRQnU2zOc3fBKROC7e6W5XnXz-e3Ox1lMLODXB8li6LxgObR9uASh7MHGYppNmC/top_gg_bot?
yeah realistically would work fine
Nice
hmm, when do you declare your bot variable?
uh
Like the bot = commands.Bot line, you'll have to place the bot.dblpy line after that
Put the bot.dblpy code after that line
ok
so like this? bot = commands.bot bot.dblpy = dbl.DBLClient(bot, dbl_token, autopost=True)
Yeah
ok
it says
Traceback (most recent call last): File "main.py", line 14, in <module> bot = commands.bot NameError: name 'commands' is not defined
that's the error message sent to the console
Oh, i assumed you use commands framework, do you use the discord.Client thingy instead?
yeah
Oh yeah, i can see you do
discord.py to be exact
Same
ok
Put client.dblpy = dbl.DBLClient(bot, dbl_token, autopost=True)
after the line
client = discord.Client()
Yes
Np
my bot is saying it is on 3,000,000 servers but it is not even verified
l tried to reset my token
am actually working on making this, haven't gotten time the last 3 weeks to work on it 
being able to do https://hook.discord.re/webhooks?url=webhookurl
make another request to the api setting it to your current servercount
you, someone from your team or anyone who had your token set it to that
ok
@tasks.loop(minutes=30)
async def update_stats():
try:
await client.dblpy.post_guild_count()
print(f'Posted server count ({client.dblpy.guild_count})')
except Exception as e:
print('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
update_stats.start()
2021-05-19T00:05:39.968795+00:00 app[worker.1]: Failed to post server count
2021-05-19T00:05:39.968812+00:00 app[worker.1]: TypeError: object Lock can't be used in 'await' expression
any idea what caused that?
dbl_token = os.environ["TOPTOKEN"]
client.dblpy = dbl.DBLClient(client, dbl_token)
@rain heart?
you have to wait for a response from someone who can help you
ok
like this: client.topggpy = dbl.DBLClient(client, dbl_token)?
you need to import topgg
ok
whould the client.topgg be correct tho
ok, thanks
@loud token same problem
git repo^
i do, just did not get rid of the import
you did not
ik
just did not get rid of the import
folowing their docs
A simple API wrapper for top.gg written in Python. Contribute to top-gg/python-sdk development by creating an account on GitHub.
if you want it to do that
np
The authorization is a value you can specify to make sure the request is coming from topgg checking it in your script (like a general password check).
Itβs not necessary needed to use it.
Iβm being returned
<coroutine object DBLClient.get_user_vote at 0x7f55d00f9640>
instead of Boolean when I use
self.dblpy.get_user_vote(ctx.author.id)
How do I get it to send a bool? Please help
you choose your port
probably need to await it?
also use topggpy lib instead of dblpy
I checked the examples here and they're still using import dbl
I see await
Thanks
ik, the docs are scuffed
but use topgg
dblpy is deprecated
I belive rate limit is like 100 per second
but Im gonna go with its safe to try every 5 seconds
yes?
hi how can i make my scenario send a message to a channel without using discord webhook ?
what's the scenario also votes don't use discord webhooks
nevermind i found a solution x)
what happen if my bot recieve more than 1000 votes in 12h ? Does a user who voted between the 12h and now will be able to vote again ?
then you should use webhooks
How we can know who have voted for my bot and give him auto rewards
then, how to configure webhooks ?
I am making my bot in python btw
A simple API wrapper for top.gg written in Python. Contribute to top-gg/python-sdk development by creating an account on GitHub.
on_dbl_vote event, and you make the thing you want after the datas you got
yeah but how do I configure and know the webhook URL of my server ? (to send datas from top.gg)
it doesn't use discord webhooks
it sends it to your computer's port
You can use this https://comhad.github.io/webhook.html
yeah I know, but I said about my own server, not the discord's one
oh
just http://publicip:port/route
just follow the quick start and it should be fairly self explanatory
I got a dynamic IP address. Does it work if I use a domain name like for example with no-ip or dyndns ?
if your domain can listen for webhooks it should work
It works with domain names
the webhook URL I put on top.gg doesn't work for integromat. It only work with the discordbotlist website on the tutorial
Are you sure? I know if you set up a scenario for discordbotlist you need a different one for top.gg, they don't provide the same data
@ruby kiln
I tried with top.gg, no response. And I tried with discordbotlist, and it worked
What do you mean by tried? You need to setup up an entirely new webhook URL in a new scenario, you can't use the same one
I know, and when they ask to send a test webhook for the 1st time. When I put the integromat link on top.gg, it doesn't do anything
Did you click save?
I am on this, and nothing work when on top.gg I click on "test"
yes
Hmm, click copy address to clipboard and try with that address, its possible you missed a character at the end
I copied with the "Copy address to clipboard" button
That's weird, i'm not sure what's happening then
Make a request to the URL through curl or something, see if it responds to that
it worked, so the problem is from top.gg I think
Yeah, it looks like it
Have you pressed save before testing
then is checking if a user has voted every 5 seconds fine?
ok
i-
fine
I hate webhooks
good for you
Can someone tell me exactly how to upload the bot server count please?
Its dependant on what language you are using
I dont use node so i cant help you there sorry, but i think there is modules with sample code on the top.gg github
Alright thanks
Can someone tell me exactly how to upload the bot server count with node.js?
Using a library or just send a POST request to the topgg API, for example with "node-fetch"
Umm
Used the correct token?
Wut
You lost me at library
Hmm without a little knowledge I can't really help you.
Iβm better at understanding through pictures or videos
Sadly couldnβt find much on youtube
As I said you can use node-fetch or http or axios etc. to send a simple HTTP POST request, too
Like 3 videos but they have bad quality and they donβt make sense
understanding through pictures or videos
That's not really understanding. That's seeing code and copying it but okay.
Can I do it with heroku
I might have to copy since the computer Iβm using has top.gg blocked
I'm not familiar with that service but if you can install libraries to use in nodejs, yes you can
Alright
Can you like tell me step by step?
I do learn from examples
Fetch("https://top.gg/api/bots/" + <bot_id> + "/stats", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": <dbl_token> }, body: JSON.stringify({ "server_count": <guild.size> }) }).then((response) => { if(!response.ok) return console.log("Posting DBL statistics failed"); });
I do learn from examples
That's still copying not more... but that's not my issue, yikes
The example will require the package const Fetch = require("node-fetch");
Alright... there's nothing more I can do for you.
You can only use the basic JS methods which are existing or being able to download packages via. NPM.
I can use the js method but I donβt know how
Man I can code a bot but I canβt do this
Don't get me wrong but using djs or dpy doesn't mean being able to code a bot, just using existing libs/frameworks etc.
But that doesn't matter at this point.
I told you what you can do.
I can use the js method but I donβt know how
That's the reason I sent you the link.
It explains (with examples) how it works.
Alright thanks
anyone know can i specify type of data that i want in reddit json api. for example: https://www.reddit.com/r/aww/?t=image or something like that?
do I need to wait for my bot to be approved to start working on my Vote cog or can I get api keys and start now
Hello #topgg-api the brother of #development
You donβt have to wait to get the infrastructure, but you wonβt be able to test it
why am I getting this error
webhook.listener is not a function
const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express();
const webhook = new Topgg.Webhook('123456789')
app.post('/dblwebhook', webhook.listener(vote => {
vote.user.send('Test')
console.log(vote.user)
}))
app.listen(8000)
Because webhook isn't the expected data type
Looks like something has gone wrong while initialization new Topgg.Webhook('123456789')
Log the webhook var
what version of the sdk are you on?
i dont think is the latest
thats v3.1.0+ code
im gonna update it
π€¦ββοΈ
Hey Woo and Hope, i made a little Proof-of-concept for the site and put it on a heroku app https://github.com/comhad/webhook-forwarder/ it's disabled right now but i can turn it back on
How does the main top.gg site searching the bot/server list without authorziation token?
const { webhookPW } = require(path.resolve(path.normalize("./config.json")));
const express = require('express')
const app = express()
const Topgg = require('@top-gg/sdk')
const webhook = new Topgg.Webhook("authorization code")
app.post("/6f7XNQM9ds0Sad4jyTUoRaRN3K1zgBRvSI26JnQytpvsVefn8uKA4yrgJRTtvXrNKJLx", webhook.listener(vote => {
console.log(vote.user)
}))``` why does this not work? no console logging when I test it
What
is that code correct for top.gg voting
did you fill in the url and auth on your bots page?
http://PUBIPHERE:PORT/6f7XNQM9ds0Sad4jyTUoRaRN3K1zgBRvSI26JnQytpvsVefn8uKA4yrgJRTtvXrNKJLx
filling in the public ip and port
oh wait i thought you put the https://discord.com/api/webhooks/723984798327590/6f7XNQM9ds0Sad4jyTUoRaRN3K1zgBRvSI26JnQytpvsVefn8uKA4yrgJRTtvXrNKJLx liket that i there, how do I get that url?
the code is making an actual webhook receiver for top.gg to send webhooks to
so how would I make the url then?
sorry bout these questions
where are you hosting?
my own hardware
youll need to port forward https://portforward.com/, or use https://gist.github.com/comhad/bd42b56a0399dbfa645aa83fe3cf4c8a
the url in the case you port forward will look something like http://yourpublicip:port/path
Hey @jaunty plank, i made a proof of concept thing from what we discussed before https://github.com/comhad/webhook-forwarder/
yeah i just now opened it. looks pog
how long till you actually deploy it.
It's active now,
oh pog, ill have to take a looksie
My concern is it gives me a warning that its a dev server im using, but all the tutorials tell me to use that
I didn't disable logging, i'm split between security and privacy about all the discord webhooks tokens and IPs being recorded to the logs
as in heroku logging it?
Yeah, but i can have access to the logs
I can put a little snippet in the code so it will only record errors though
I really dont know heroku at all, so cant be much help there
It's more flask, heroku is going to record whatever python prints, its just what i stop python printing for the sake of privacy
I mean top.gg keeps all the webhook info, and that seems fine, so as long as i put it on the readme that it logs it, it should be fine?
Best to be on the safe side, added it in there anyway
I looked, that server i'm using is fine, it was just the debugging one i was using when i was trying to figure out how to use heroku lol
Ignoring exception in on_message
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 45, in on_message
vote = json.loads(r.text)
File "/usr/lib/python3.8/json/init.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
....
....
And what value did you try to load from a string
Now I get that the port is already in use
Use another port
Yeah
How do I see what ports I can use?
I just use a random number?
Try to guess what's available
That's the only solution? xd there's not a more common way?
If Google doesn't say anything then yeah
Unless your host occupied all ports except one
Ok thanks
How to make a message which is sent when someone votes? Discord.js
Create a webhook listener, listening to the topgg webhooks and react on the response you get - it includes the userid etc.
The actual timestamp is the moment you receive the webhook.
node-sdk should have doc on it
hi
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
ratelimit is 100/s 
also ;) why is it an option if they don't expect someone to do it.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
yes
but bleach CLENZE
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
100/s global and 60/min and that's not taking into account multiple users
You might as well just have a webhook listening to vote requests 
it's also possible to change role colors every 5 seconds on discord but it doesn't mean you're not gonna get banned for it
I want a chatbot api please
with the token I guess
hmm Somone pinged me 
wonder who
how can I help lol?
how do i make it so the bot will show how much votes it has in the current month
Wait I didn't
api.getBot('BOT_ID')
what
const YOUR_BOT_ID = '748160981766635540';
//My bot for example
api.getBot(YOUR_BOT_ID).then( bot => {
console.log(bot.monthlyPoints);
//monthlyPoints is actually monthly votes
})
thanks
^Β°^
how do i get it into an embed
You would save bot.monthlyPoints into a variable and then put that variable into an embed
const YOUR_BOT_ID = '748160981766635540';
//My bot for example
let votes = '';
api.getBot(YOUR_BOT_ID).then( bot => {
votes = bot.monthlyPoints
//monthlyPoints is actually monthly votes
})
let embed = new Discord.MessageEmbed()
.setDescription(votes);
msg.channel.send(embed);
alright
Does my bot have to be approved for me to use topgg api?
Yes
So can I use the api directly after my bot is approved?
Correct
A huge thankyou to comhad for providing us with this method.
Important links mentioned in the video
- Integromato :- https://www.integromat.com/en
2)Code snippet( add to your .py program) - https://github.com/asadparkar/Youtube-code-snippets/blob/main/vote rewards.py
Support me by upvoting my bot here :- https://top.gg/bot/8198388093186...
this should help you
for vote actions
at Api._request (c:\Users\Utilisateur\Desktop\Bot\node_modules\@top-gg\sdk\dist\structs\Api.js:76:19)
at processTicksAndRejections (<node_internals>/internal/process/task_queues.js:97:5)
at async Api.postStats (c:\Users\Utilisateur\Desktop\Bot\node_modules\@top-gg\sdk\dist\structs\Api.js:96:9) {name: 'Top.GG API Error', response: {β¦}, stack: 'Top.GG API Error: 404 Not Found
at Api._rβ¦modules\@top-gg\sdk\dist\structs\Api.js:96:9)', message: '404 Not Found'}
arg0:Top.GG API Error: 404 Not Found
at Api._request (c:\Users\Utilisateur\Desktop\Bot\node_modules\@top-gg\sdk\dist\structs\Api.js:76:19)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Api.postStats (c:\Users\Utilisateur\Desktop\Bot\node_modules\@top-gg\sdk\dist\structs\Api.js:96:9) {name: 'Top.GG API Error', response: {β¦}, stack: 'Top.GG API Error: 404 Not Found
at Api._rβ¦modules\@top-gg\sdk\dist\structs\Api.js:96:9)', message: '404 Not Found'}
message:'404 Not Found'```
When I start my bot
Can I make use of the api to post a message everytime someone votes for a specific server
?
with a coded webhook yes
how can i make the bot send a DM to users when they voted
using webhooks and getting the id from the webhook then fetching the user
you can only dm them when they're on a mutual server
@jolly hornet
man
do ur job
@restive otter no ads
fuck off cunt @jolly hornet
really dude
Smh
Banned ! aaScepticel#9797 (@fallen apex)
π
[https://api.affiliateplus.xyz/api/chatbot?message=$replaceText[$message; ;%20;-1]&botname=Add Your Bot Name&ownername=Add Your Name&user=1]
A working Chatbot API
no
Why does my bot not auto post the guild count?
The deprecated dblpy doesn't raise errors even if the posting fails, e.g., if you put a wrong token there, it won't tell you that the token was wrong. I'd suggest you migrate to topggpy.
can any one help me with the server count
?
It's the right token. What are the biggest differences in topggpy?
The breaking changes are that it has a separate class for handling webhooks, a renamed method, shard count auto post support, and auto post success and error events. For more information, refer to the docs https://topggpy.readthedocs.io/en/latest/whats_new.html

