#topgg-api
1 messages · Page 138 of 1
im trying to do the same thing, and I'm using the code provided in the pin
i'm trying to make it log the request, but when pressing "test" nothing shows up in my log
var express = require('express');
var Topgg = require('@top-gg/sdk');
const webhook = new Topgg.Webhook('bot-token-here')
var app = express();
app.post("/dblwebhook", webhook.middleware(), (request, response) => {
let authorization = 'authorization-token-here';
console.log(request);
response.sendStatus(200);
})
app.listen(5910);
did you save the webhook?
yes
send the url here if you want to
its running under my public ip address so i'd rather not
also replace bot-token-here with your bot token, unless you removed it for security reasons
yeah, i removed it just for the sample
if it is running on your public ip address, did you portforward?
it should work under 10 seconds, did you test it with a rest client such as postman?
to make sure it actually works?
i'm using a firefox extension called rester and posting to it logs it perfectly fine
otherwise, send the url here with replacing your IP with x so i can tell you if the format is correctly
for example x.x.x.x
alright, seems to have worked
yeah then the path was just missing
just one thing that i needed to change, you dont need to set your bot token in the Topgg.Webhook part
you only need to put in the authorization token you set
thank you though
the Topgg.Webhook is just for the middleware things, don't know what exactly it does either
it authorizes and checks if its formatted as expected
ohh
how do i use the voting credits?
thx
!aki
اوعا يسطا
انت مصري بقا علي كذا 😂
How's everything going with you guys in here all I'm asking you guys to do is the keep it appropriate if you guys can't keep it appropriate I have to stick to regulation and guidelines so therefore if I get another complaint of anything inappropriate on this sector here done
@umbral yacht what?
a
how do i get my api key? nvmnd pins
const api = new Topgg.Api('I put the top.gg token here')
setInterval(() => {
api.postStats({
serverCount: client.guilds.cache.size
})
}, 1800000)
Why it didnt post server count?
Did you wait 30 mins?
Latest
Also I use dbd.js as the programming language but I can use discord.js
Should I use the autoposter?
Minute I will do
api.on('posted' => {
console.log("Posted server count!")
})
@restive otter Will it work?
oof
use autoposter if you are not gonna do anything abt the top.gg api but only for server count
I will use the autoposter I really need to post servercount
Oof it says unsupported client
Hay
Hey @rain heart
This is not working for me
hey anyone please tell me why this is not working for me^^^^
pls help me
What is that?
sorry,i do not know java
an error message
For what?
when i lauch the api?
For posting your servercount?
no when i try to make the api that i can use it
sad
hi
/networth bralter watermelon
@proud cloud
?
ayo i got it set up
pog
now i just gotta figure out the vote webhook
hard cuz i host at home w/ a dynamic ip
😩
is there a way i can change the webhook ip through the api?
nope
😩
so i can put in a domain and just do that?
yeah, so itll change the domain to your ip even if it changes.
3 letter tlds are almost always taken
Did you mean 3 letter domains
top level domains?
second level domains 3 letters are easy to get.
before i die can someone confirm that reads one dolar per year
not 100
@jaunty plank
its $1
then icbot.xyz is what i would get
iseebot.xyz 👀
tbh im kinda partial to icbh.xyz but idk
nah i want it to be my main domain and then the webhook comes off it
then use what you feel is best
😩
at the end of the day you know best
what if i just didnt make a voting webhook?
the alternative is using hasvoted to check if they voted.
if your not giving rewards, you dont need either
hmmm okay
yea i just wanted it to send a message
ideally, you would use the webhook if you wanted that
then nothing happens when someone votes
just random users voting?
@nocturne dirge yeah please dont
Hi
hi
how did this get on the starboard lol
||i mean im not complaining...||
The fact that it is offline and still getting votes if funny
ah tru
ecks dee
maybe it's not offline but invisible
that's a whole new question

import dbl
import discord
from discord.ext import commands, tasks
import os
import logging
class DSLCount(commands.Cog):
def __init__(self, client):
self.client = client
self.token = os.environ["topgg_key"]
self.dblpy = dbl.DBLClient(self.client,self.token)
@tasks.loop(minutes=5)
async def update_stats(self):
logger.info('Attempting to post server count')
try:
await self.dblpy.post_guild_count()
logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
except Exception as e:
logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
def setup(client):
global logger
logger = logging.getLogger('client')
client.add_cog(DSLCount(client))```
does this work correctly? Like is this good?
This doesn't seem to return any stats (please ping me when you respond, thanks)
You never started the loop
how do I invoke the loop?
you can try putting self.update_stats.start() in your __init__
import dbl
import discord
from discord.ext import commands, tasks
import os
import logging
class DSLCount(commands.Cog):
def __init__(self, client):
self.client = client
self.token = os.environ["topgg_key"]
self.dblpy = dbl.DBLClient(self.client,self.token)
self.update_stats.start()
@tasks.loop(minutes=5)
async def update_stats(self):
logger.info('Attempting to post server count')
try:
await self.dblpy.post_guild_count()
logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
except Exception as e:
logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
def setup(client):
global logger
logger = logging.getLogger('client')
client.add_cog(DSLCount(client))```
this should work then right?
You might want to cancel the loop on cog_unload, but yes that should do ig
hmm
Now
where to find my bot's uptime
I mean stats
well it looks like the guild total is now up lol
but uh
I guess user count doesn't share then?
Only shard and guild count iirc
but it only shows up
on the bot search
which is annoying
but it did appear
wdym?
on the main bot's page
nothing about total
guilds
but on the search page
then there are
How do make my bot respond if someone votes her and give that user a role also , and I am using discord.js library , I am kind of new with this api
I need someone to help me setup the webhooks for my topgg bot
what part do you need help with @restive otter
what about it
i need help setting it up. when i add a webhook from my server and hit test, nothing is sent to the server
you cannot use discord webhooks
what should i use
a custom one, read the pinned messages
You need to setup a webhook service
where i will get webhook URL and Authorization ?
from your code, webhook url is your webserver and auth is something you define yourself
most common format is http://ip:port/dblwebhook
no you can't
i can't setup then damn
use a Bot that does it for you then such as Vote Tracker
oooo , btw what happens on Test button ?
okk
Is there any video which explains every step , because i don't know how to setup the web server now
Having an issue with voting, the vote command I am having gets stuck at this function when I'm starting up the bot, it queues and only actually properly checks after the bot is 'officially' up (i.e. out of the limbo state after on_ready is fired), but I do not have any on_ready event and my stuff like webhooks are all initialized within the cog so I'm very confused as to why it isn't working.
check = await self.dblpy.get_user_vote(ctx.author.id)
Does get_user_vote only works when the bot is fully out of limbo state?
Just checked the source code
apparently
async def _ensure_bot_user(self):
await self.bot.wait_until_ready()
if self.bot_id is None:
self.bot_id = self.bot.user.id
is what affecting it
i am using webhook for getting upvote , how to get all upvotes till then and how much votes have been done by that user ?
Hi, can anyone help me about api ?
All API methods that rely on client.user essentially wait until the client is fully connected (cache is fully loaded) so that dblpy can access client.user.id
get_user_vote, as you probably already realized, is one of them
Yup, _ensure_bot_user affects it
If you don't like it, you can go for a workaround with await self.dblpy.http.get_user_vote(BOT_ID, user_id)
Yeah, I went for that option instead after looking at the source code, thanks though!

Because when the bot becomes too large (mines in over 10k) it takes forever to set up so it wasn't sustainable >_>
/wifu
Hi there, i want to use:
const AutoPoster = require('topgg-autoposter')
const ap = AutoPoster('Your Top.gg Token', client)
ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
})```
Is there any way to store only server count and not shards?
Sadly no
Okey, ty for the answer
so it has these many dict values, but what url do i have to GET request to access these?
the bots endpoint, should be mentioned above
and which endpoint is that
nevermind, that's the bot object
you can get it by using the /bots endpoint for example
when i request https://top.gg/api/bot/mybotid it returns {'server_count': 95, 'shards': None, 'shard_count': None}
but thats not what i want
it is /bots
just /bots?
mkay thanks
though you seem to be making a get request to stats
how do i make it so when someone votes it comes up in a channel i have setup (ping me)
by using webhooks
sorry if i'm missing something, but is top.gg supposed to say that my bot is offline when it's always up? I get that the bot isn't on this server anymore, but virtually ever other bot says "online"
that is intentional, there is no way to tell top.gg that your bot is online
it was a thing when @abstract moth was able to get the presences, but due to all bots being removed here, it isn't possible anymore.
are there any plans to remove the icon or something? because it might confuse people and lead them to believe it's offline
there's possibly going to be a new system that allows you to set your presence on the site
or it will just be removed yeah
ok thanks
@rain heart ?
I couldn't find what I'm looking for
read the one for your library, that would be easier
i did not understand anything, can this be simplified
Api
It's as simple as possible. You just need to learn the basics. Take a look how to do HTTP POST requests. As the docs says you just have to POST a simple JSON string, e.g. { "server_count": 999 } to the endpoint of Top.gg. That's it.
@shell steppe what language do you use
=2022 fartdarling bw
@deft anvil #memes-and-media
?
I want to make my webhook server on replit, since I just want to append the count on db. How do I get the ip of the replit server?
its https://replname.username.repl.co
what happend when my hacker plan expire, will the repo get public?
yes ig
lmao that sounds like ransom ngl
dms open
and why is that relevant?
@jolly hornet hey not to bother you but this anna person sent "dms open" in all channels
we're aware
sus
sus
My bot isnt autoposting the server count anymore
check your code then
self.dblpy = dbl.DBLClient(self.client, self.token, webhook_path='/dblwebhook', webhook_auth='', webhook_port=8175, autopost=True)
I had the autopost=True
thing
it suddenly stoped
for some reason
I used the api to post
Hello
You make it yourself
where ?
There's no where, you can create it yourself
that's like a password, it has to match the one you entered in your webhook auth on your code
i have here my webhook
You cannot use discord webhooks by the way
wich webhooks can i use
so i use AutoShardedClient and set the shard count to 2 but when i request the shard count via the api, it reurns None please help
\
The vote webhook isnt working
I never changed my code
My code worked, and it's just not working anymore
@ancient plover
Because its still BROKEN
um how can i post the shard count to top.gg since when i GET request it , it just returns None even though ihave 2 shards
@rain heart please help >~<
oh wait
nevermind thanks!
GET gives you the stats of the requested bot id
POST posts the stats given in your post body when correct authorization is given
oh
Classic.
anyone have a head pat api just like lying around
File "/usr/local/lib/python3.7/dist-packages/aiohttp/web_protocol.py", line 418, in start
resp = await task
File "/usr/local/lib/python3.7/dist-packages/aiohttp/web_app.py", line 458, in _handle
resp = await handler(request)
File "launcher.py", line 30, in viewpost
headers = await request.headers()
TypeError: 'multidict._multidict.CIMultiDictProxy' object is not callable
``` aiohttps confused about this error
you also dont need to await it
it's given as the initial response
only things you need to await are the initial request submit and then any body interactions
the HEAD of the response will always be loaded the body will not
the dbl-api on npm posts a server count 1 less than true
Hey, i'm french user (this a cause for my english is bad)
How configure api for the vote in your site web ? 😕
write your question in french
Salut, comme je peut configurer les webhook pour que les votes fait sur ma page soit signaler sur mon serveur Discord
ahh you want upvotes on top.gg sent to a discord webhook
You can't send it to Discord webhooks but to your own webhook service to receive events like upvotes.
technically you could, you'd have to send the webhook to a web server and that web server sends it to a discord webhook
reformatting it
for the dbl API (I am coding with python) does it works if we post guild count on_guild_join and in on_guild_remove events ? to avoid using the tasks.loop
Yeah that'll work.
But there is the possibility of rate limiting
Although I think the official lib handles that (not sure ask the developer or look in the source)
i generally suggest not having the post stats on guild_join/remove
have it trigger every 30-60 minutes or so
But why? What if joins and removes are slower?
Ah
can't speak for others, mine doesn't.
I wrote my own thing for this since my python version was having issues with the official one and I figured I'd handle rate limits myself.
rate limits are hard to enforce through a library unless you're constantly running everything in a continuous asynchronous loop
my bot joins 1 or 2 guild per day, and the next day it is kicked in 1 or 2 guilds 🤷😂
I think the current api/v0 is synchronous based, I see no mention of async stuff besides the libraries that incorporate those methods.
Just autopost to be safe
idk how webhooks works. I will stay in the tasks.loop
I don't know if I can recommend my own implementation because it's not official. I'd listen to mods advice.
Webhooks and the stats posting are different.
yeah but I can autopost with webhooks on top.gg
I don't get what you mean.
You don't want to use a tasks.loop you're saying?
Its an API request regardless so it counts to the rate limit bucket. Its better to stay within it by doing this periodically every half an hour or so.
I would like to post automatically on top.gg when I join a guild, for example with webhooks or in on_guild_join event
I can't get the bot webhook working in any way using dblapi.js for some reason
I did port forwarding firewall off everything
dbl.webhook.on("vote", async (vote) => {
console.log(vote.user)
})```
the event doesn't run
bc it is simple. And use another way to post guild count will help me to familiarise myself with dbl api (for example make a command like upvote)
did you add your webhook url to your bot page settings?
you cannot use https
even with http it doesnt work
I recently switched it after 2 hours of testing and googling to https only to see if it works
http doesn't work, tried it again rn
Don't think you can vote your bot using the API if that's what you're trying.
It uses oauth for that.
test your webhook with postman
if it doesn't work, your code might be bad/wronly portforwarded if hosted on your home network
ohw... okay, sad
can I use other webhook testing tools?
I don't even know how to use it
Do I have to check for new upvotes myself or is there something that will tell me when there is a new upvote (using python)
my discord bot has been added to the server i want it to message the server owner and a random room on the server
Is there a tutorial a little more in depth? Im having trouble getting really anything done with the current instructions and documtations. For example: Everything says "set this to your dbl token" but, im not finding any way to get it not even with a google search.
What about a tutorial, like on youtube? Do you know of one?
not that im aware of. its just a basic rest api.
@jagged escarp you made a get request, not post
the response tells me that you made a get request
Here's all the data I got
Thats all except the api key
Maybe this is what my issue is lol
My page is bugged or something
non-capital a in authorization right?
I'll check
the docs say capital a, but ive only ever used lowercase 👀
It was caps, but I did it with a lower case a and still got the 400
dont think it matters then
Authorization with a uppercase A should work too
mhm
shards is supposed to be an array apparently, https://docs.top.gg/api/bot/#post-body
yea wasn't quite sure how to interpret that since it's just a count
shards_count for the count
Ah
what the fuck is this api
ill take a look at one of the libraries and see what they are using i guess 👀
I use the C# one for whatever that's worth
got it
not using Content-Type: 'application/json'
im just spitballing ideas at this point
what doesn't work
Like the Content-Type header is there I just can't change it lol
It's being stubborn
i hate the postman website, the app works really well for me
click on "hidden", then uncheck Content-Type
Ok, I had to uncheck it and then recreate it lmao
Aaaand anotha 400

sec lemme blur the key
oops
same thing, but do raw as you have set your headers to application/json
screenshot your whole postman, censor your token
¯_(ツ)_/¯
again screenshot your whole postman, with all the things you have set
Will do
Try to post without shard_count
Auth header is under the "hidden" section, everything under hidden is disabled except for the postman token
وێنەی ئەکاونتەکەت ئەوەیە☟: https://cdn.discordapp.com/avatars/146092837723832320/6bf103b28e18b6fa7c761ad99caf2cc2.png?size=2048
Banned <A/M> | Narox#5808 (@frosty tiger)
👋
what the hell happened here
nothing intresting
this dude kept doing selfbot shit
remove the token from the Authorization and only add it into your Headers
kk
400 again
How
ngl I'm about to just say DM me the token
but actually don't
haha
lemme get your bot id one sec
np
can you give me, the api to check the user is voted or not? I forget that one
Right I assumed so

ok thank you
@jagged escarp you also don't have any errors through the libraries?
Correct I only handle exceptions, everything seems to run smoothly
I'd definitely get an exception for an invalid api key or something
try this one
Cool this looks easy lol
set your headers to this https://this.cringe.dev/KJym
do they need to be in quotes or na
Ok that time I got a 200 OK code
ok thank you
then something in your code is shitty 
holy fucking shit
Dude I swearrrrr
I'll have to check on it... if it goes away in 15m something's wrong with the lib haha
Thank you for your help ♥️
otherwise just make manual requests from time to time if you don't wanna mess with posting stats through your code
Just use a different lib, like node-fetch for example
oh yeah you could just use request libraries instead
Oh nvm js
I actually thought about rewriting the lib in C# cuz it is lowkey neglected 
Still called Discordbotlistapi smh
so is the java library
well, guess I can close the git issue lol
Here's my code for updating the stats btw https://github.com/kaguyabot/Kaguya/blob/v4-open-beta/Kaguya/Kaguya/Internal/Services/Recurring/TopGgStatsUpdaterService.cs#L89 if anyone sees anything that I don't lmk
yeah already went through your code, can't really find anything

hey can someone help me with the python api? im having a lot of issues
that dosnt help, why i came here
wdym database
I mean there are 2 ways of handling votes
One only works reliably with up to 1000 votes
read pins
ok
like i dont even know what im supposed to have as the self argument
and the docs dont even have self as a required argument, and it dosnt tell me what i should put in there anyways
@rain heart fun fact. my code is the problem. that or the C# lib, it just re-updated in code and it made all the values disappear again
yuuuuuuuuup
welp
Guess its time to lose my lib virginity
now i cant even get help here, might as well give up.
Ugh, cloned a forked version of C# lib only to find it's horribly incomplete lol
Hello
Sounds like you need to learn how classes work
Doodoo boop that's not an argument you pass always
Read more about Python OOP
correct, sort of why im asking for help
This is a whole concept. And there's plenty of resources on the internet. This is one of those situations where you can Google to get better help than from someone explaining in a discord channel
i dont understand why this complicated stuff is needed when all you are requesting are a bots votes or who voted, also why arent there any tutorials, im a more visual learner
I mean is it that hard of a concept
Instantiate DBLClient, use the method get_bot_upvotes of the instance
this dosnt work for me
Doesn't work, as in?
OOP is a fundamental python concept you should ideally have under the belt before you even start off with a project as complicated as a discord bot. Its not that hard to do.
If you want visual aid, there are probably video tutorials explaining classes. And instances.
required argument 'self' undefined
Show your code
well its gone rn, hold on
The reason why there's no tutorials for this library is because you are expected to have experience with OOP in Python beforehand
Ideally, the documentation is sufficient
@Client.command(aliases = ['upvote'])
async def vote(ctx, mode = mode):
client1 = db.Client()
botlist.DBLClient(client1, "<myToken>")
userlist = await botlist.DBLClient.get_bot_upvotes(self = client1)
print(userlist)
vote = await botlist.DBLClient.get_user_vote(self = self, user_id = ctx.author.id)
if not vote:
voted = False
await ctx.send("You have not Voted! ", voted)
else:
voted = True
await ctx.send("You have Voted!", voted)
#Other, embed
Yeah no chief
That's more wrong than my code back when I started using d.py, I swear
believe it or not, thats what i got from reading the docs
You instantiate DBLClient and save the returned object in a variable, preferably one that persists between multiple methods
aka
best i could
x = DBLClient(...) and then use x later in your code
yes
Well that's not how docs describe it
... though they don't describe this part at all
Hey shivaco while I have you, is the 3.9 compatibility issue fixed?
It is, in v1.0.0
Just need to polish the docs about the new webhook system and I believe we'll be good to go
Also does the library wait out rate limits before retrying, or is that left to the user to implement?
I'll have to migrate some stuff too so expect a few "breaking" changes 😛
I implemented (more like fixed, actually) a ratelimiter that will only allow 59 requests within 60 seconds
if you have a bot that uses this can you show your code? id like to get this over with.. if not can you try to explain
That's the most reasonable and uncomplicated way I thought of to go about this until APIv1, which will very possibly support ratelimits officially
Okay I'll consider switching back to this lib now
If you're coding your bot in one file, you might want to instantiate DBLClient and attach it to your Client object as a property
Also any plans to expose the internal Webserver?
aka
Client = commands.Bot(...)
Client.dblpy = dbl.DBLClient(...)
@Client.command()
async def mycmd(ctx):
votes = await Client.dblpy.get_bot_upvotes() # votes is a list now
Hmm. Not sure tbh. Is there any purpose in exposing it?
what would i put as arguments in those first 2 lines
I thought you'd know since you already have your Client object done already?
To repurpose it for other endpoints since it's already instantiated and ready.
Command prefix?
What i have:
Client = commands.Bot(command_prefix = commands.when_mentioned_or('CB '))
``` Not sure abt the second line tho
Hm. I see where you're getting at, but I'm contemplating the reasoning for making it an accessible middleware
for DBLClient the first optional arg is top.gg token, the other is your client object
How about an optional webserver kwarg?
no, the other way around
For example bots with dashboards in place that want to use the library
Say I'm more comfortable with quart than aiohttp web
Technically they could be handling all that stuff manually, but
sounds like an interesting feature
It would be unofficial and hence unsupported here correct?
So you can't leave it for manual implementation cause it might have some side effects
I could be missing something but at first glance this shouldn't be hard to patch
import dblpy as botlist #btw
botlist.DBLClient("<my-token>", db.Client)
#this?
x = botlist.DBLClient(...)
x.yada_yada()
I'll see about exposing the webserver tbh
It's just that the system I already have in place in v1.0 is tricky and was done in a "if it works, it works" way
Mind submitting this idea on the GitHub repo?
Sure thing. Thanks 👍

@sullen nymph mb, something else broke ofc. "AttributeError: type object 'Client' has no attribute 'loop'"
Show your code
client1 = botlist.DBLClient(db.Client, "<my-token>", db.Client)
userlist = await botlist.DBLClient.get_bot_upvotes(self = client1)
print(userlist)
vote = await botlist.DBLClient.get_user_vote(self = self, user_id = ctx.author.id)
if not vote:
voted = False
await ctx.send("You have not Voted! ", voted)
else:
voted = True
await ctx.send("You have Voted!", voted)
anything?
One message removed from a suspended account.
👌
@sullen nymph object Client dosnt have attribute 'loop'
MyProblems = int(♾️)
welp ig thats it.. gn
Wtf is db.Client
import discord as db
Okay that explains it. This is another class vs instance issue
You should already have a Client/Bot
wdym
Again I suggest understanding OOP
ok
Hi, I just published a bot on top.gg and wanted to create a webhook for the votes.
I don't really know how they work: does anyone know what URL am i supposed to use?
Thanks
http://{your_public_ip}:{your_port}/{your_webhook_path}
Hallo
cringe
haha
Wait an hour, if it doesn't do anything, full 24 hours
oke
lucky me bcuz when i applied it was broken
so i can resubmit and it get fixed 😂
Also, accessing the api isn't possible without being approved anyways
how to send webhook to a discord channel when someone upvote my bot?
you will have to receive the webhook then send a message via a bot, or create another webhook and forward it.
top.gg webhooks are not directly compatible with discord webhooks
ok and how to do that?
Hey, why do I get an error talking about "WARNING: An Illegal reflective access operation has occurred"
using the Java version
With the webhook API, does top.gg send the 'next vote' time across at all? (i.e. when the user can vote next) or shall I just do 'now + 12h'
(note - for both server and bot)
the webhooks don't send anything about when the next vote is
Thanks - I figured as much, will just do now+12h then
still wondering why the C# lib is acting up or if I am doing something wrong
read pinned messages
ok
no need to ping
ok thanks
are you posting your server count still?
no
so its on what you last posted
it only updates when you update it
using the api, or whatever library you where using.
Okay thanks .
topgg-autoposter this one right?
yeah
const AutoPoster = require('topgg-autoposter')
const poster = AutoPoster('topggtoken', client) // your djs client/shardingmanager or eris client
ok thanks
when i regenerated my webhooks token then what that error is came Unauthorized (You need a token for this endpoint)
@rain heart
When I regenrated it then i got that error
replace your old token with new token

I replaced
but then after it still not working
Rip
Hey I have a question while using /bots/:bot_id/check does it check for if a user voted after 12 hours or if a user just voted once ever like a week ago
in the past 12 hours
Hello, can someone help me with vote-logs for my bot, I tried by best with the webhook but nothing worked!
What happens when you try to use the /votes endpoint with >1000 votes/mo? Does it 40[1|3] you? Or just return the first 1000 votes?
Returns last 1000 votes
cheers

does the bot test webhook button work?
Yea
I don't get anything in console
@jagged escarp can you help me with the vote-webhook?
did you forward your port
Ah cheers guys. That was super simple to setup
Probably not. I only know the ASP.NET implementation. You make a rest api and have a POST endpoint for your web hook. Parse the payload according to what the API docs says is in the POST payload. Validate authenticity via the authorization header. Boom
ok
Give rewards to user ID at that point
Can I use the api token of my bot in another bot to test code before uploading it to the original bot?
As long as you don't accidentally post the wrong count
🤔
Because that's... Not where you install from
I am surprised you developed a bot without knowing how to install packages tbh
Do you have pip installed?
Mate you're not even in your terminal.
Lovely.
Anyway you should know how to install packages. This is not in scope of this channel.
I’ll do that
I know
Windows
So I tried the dblpy thing to get vote webhooks, but it doesn't seem to respond. I took this from the Github README, is there some glaring error here?
Thanks!
(btw, dbl_token and TOKEN are not placeholders)
If they're not placeholders then change them lol
Dont say lol pls
lol
Hello
hey whenever i save my webhook i get an error pop up saying There was a problem saving the webhook :Thonk: Any solution?
const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express()
const webhook = new Topgg.Webhook('topggauth123')
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
console.log(req.vote.user)
}) app.listen(3000)```
Where should i add the voting rewards here^^^?
where console.log(req.vote.user) is is the location you can give rewards
I have to do db.add?
if thats what your db uses yeah
Oh ok
Can i replace console.log(req.vote.user) to
client.channels.cache.get(channel id).send(req.vote.user)?
sure, or put it above it.
Btw i got channel with [Read Message History] = false, my bot/me cannot add reaction to new message even i set [Add Reactions] = true, it still error "Missing Access"
Is this bug?
no. pretty sure bots without read message history cannot add reactions.
Not just bot, me too cant add reactions
I see
you lose access to the message, its only cached and thats it
nothing you can do with it
I was thought it only lose cache for past message
its kept in cache, but discord doesnt know whats cached
so its instantly a past message
only thing you can do is delete it
So for bot invitation i should add role for Read Message History right? Not just Add Reactions
yeah. it will be given it anyway unless the staff of the server specifically removes it
Thanks for the info
Any idea how are votes rate limited?
I'm getting hella ton of memory leak because of the vote backlogs
if your ratelimited, you should stop sending requests
i'm not sending the requests
my users are the one sending the requests
I only have a vote command that checks if someone has voted or not
I don't believe I'm misusing the API until the point where it gets rate limited
it's been happening only recently over the last couple days
ideally youd have a built in method for preventing requests being sent at all until the ratelimit ends(which is sent with each request)
I'd ask what the fuck but even that doesn't describe my confusion
How are you getting users' votes?
after a certain point you should also be saving users vote status's in a database and using webhooks to receive when they vote.
Yeah I'm saving their vote status in a database
I'm only checking if they're not in the database (basically when its expired)
are you using the webhook?
I'm using this
check = bool((await self.HTTPClient.get_user_vote(self.bot.user.id, ctx.author.id))['voted'])
so, the ratelimit is 60 requests a minute for that
To be fair, it was never an issue until very recently like since last week, hence my confusion
did your active member count go up?
Do you have anything that prevents users from using the command multiple times at once?
its been increasing steadily yes
yes there's built in cooldown
You can try logging the command usage and see how many times it's used per minute
Yeah I kinda figured that's the issue, but my question is how does the bigger bot handle this? Mine's in over 10k for perspective and it starts acting up
They use webhooks and store them locally
I've been storing locally as mentioned above, so guess webhook is the one I'm missing then
How do you even store the votes without webhooks
HTTPClient/DBLClient.get_user_vote is an API request at all times
guessing its requesting every time unless they are in the database
How does one use a database with /bots/id/check is my question
-api
TOP.GG API ONLY!!!
ANY OFF-TOPIC CONVERSATION WILL BE DELETED AND MUTED
This channel is only for SUGGESTIONS/HELP/BUGS to do with OFFICIAL API LIBRARIES and API DOCS found at: https://top.gg/api/docs
Ask in #development
I need help with api because I never use
It before
technically yes
const webhook = new Topgg.Webhook("I put my auth here");
app.post("/dblwebhook", webhook.middleware(), (req, res) => {
// req.vote wil lbe your vote object, e.g
console.log(req.vote.user); // 395526710101278721 < user who voted
});
app.listen(80);```
this is giving an error
I just used the code in the Docs
use another port , use 3020 or 3000
where are you running this bot?
Use a different port
wdum
#topgg-api message what I suggestet lol
ah
const Topgg = require("@top-gg/sdk");
const webhook = new Topgg.Webhook("I put my auth here");
app.post("/dblwebhook", webhook.middleware(), (req, res) => {
// req.vote wil lbe your vote object, e.g
console.log(req.vote.user); // 395526710101278721 < user who voted
});
app.listen(3000);
Everytime I see your name, I question it myself 
it worked now
@vestal field use this
port 80 is mostly reserverd
can anyone vote for my bot to see if the Webhook is working?
you can test it
you can use the "Test" button on the webhook page
Was this Advertising o.o 
how long does it takes usually?
cause it didn't sent nothing
uhh should be almost instant?
make sure you added the port in the webhook url too
how do you get the token to post stats
oh
http://<address or ip here>:3000/dblwebhook
in repl you do not have to specify the port
you can find it under edit bot page, in the webhook part
oh?
thanks
wdum
I didn't find any 80 on the link
You are usinf repl?
using? yes
this
lol ⏫
yea make sure your webhook url is correct
bruh I don't understand. Is my repl link my webhook link??
y e s
wdym put there
like:
https://thisismyreplname.thisismyusername.repl.co/dblwebhook
I should leave dblwebhook or I have to put anything there?
leave it there
ok, then I just wait for it to change and it should work?
also be sure that webhook auth is not wrong
I checked it
ok then save it
bruh
;-;
const Topgg = require("@top-gg/sdk");
const webhook = new Topgg.Webhook("Topgg authorization key");
app.post("/dblwebhook", webhook.middleware(), (req, res) => {
db.add(`balance.${message.author.id}.money`, amount)
console.log(req.vote.user);
});
app.listen(3000);```
Is this correct?
for giving rewards lol
message.author.id should be req.vote.user
that means js db.add(`balance.${req.vote.user}.money`, amount)
yes
i want to log the event to a dedicated channel to my server.What i have to change?
you need to get the user through your discord library
use the ID in the req.vote.user for that
you mean req.vote.user.tag?
no, user returns a ID
oh ok
Hope is this correct?
don't know js, can't tell you if that works
Hmm Ok
dbl has golang api wrapper?
balance[userid]money
${} just works in a string
req.vote.user = userid
Ohk
can i do like this js client.channels.cache.get("CHANNEL_ID").send(`${req.vote.user} has voted to the bot`)?
@rain heart Can you tell me where can i find my webhook auth key?
@restive otter i so t think s9 1 is beeded for discord
wdym?
Hello anyone tell me where can I find my webhook auth key?
You need to post servercount
@gloomy fractal
wym
If you are using discord.js i can help you
unfortunately I am using discord.py
Hm i cant help sorry lol
Your DBL api token can be found when you edit your bot
I think there’s a section on the sidebar for it
Not token bro for votes
What
webhook
weary
This one bro
I really don’t know, I don’t use the API
you set it yourself
In the future, please just drop your question here and don’t ping moderators
More than likely community members like frog man berry can you help more than I can
you can set that field to whatever you want and you can use the request headers to verify it's from top.gg
so i can keep only one letter also?
i mean u can make it nothing if you wanted but i would recommend using an actual password
Ohok
if anyone found your endpoint they could abuse it without a password
ohok
Not working
const Topgg = require("@top-gg/sdk")
const express = require("express")
const app = express()
const webhook = new Topgg.Webhook("my api key");
app.post("/dblwebhook", webhook.middleware(), (req, res) => {
db.add(`balance.req.vote.user.money`, 5000)
console.log(req.vote.user);
});```
you dont put in your api key
I kept lol
you put in the authorization header that u put in that field
I kept man
i dont wanna leak
its supposed to be what u put in this field



