#topgg-api
1 messages · Page 184 of 1
You can set a response header using that, but an authorization response header wont really do anything with topgg webhooks.
so how does auth in sdk work
it checks the request headers
console.log(req.headers.authorization)
An official module for interacting with the Top.gg API - node-sdk/Webhook.ts at master · top-gg/node-sdk
so when toppgg send post request to the endpoint it sends auth header and sdk just checks if the auth header matches the one we put in the code?
yeah
a topgg announcement? nope
any plans for it
Not that I'm aware of
im getting this error
bot.topggpy = topgg.DBLClient(bot, dbl_token)
NameError: name 'bot' is not defined```
bot is not defined
bot is not defined
Is the a way to modify the data your sending on the @tacit elm/sdk package
Id like to change the server count as top.gg grabs the wrong one
The sdk gets it from your bots library, which is generally accurate.
If you need to post another count you'll need to post using your own method.
Oh wait, the auto poster pulls from the library.
The sdk takes whatever number you put in.
Documentation for @top-gg/sdk
Yea well i just implomented clusters and now the top.gg stats are cut in half
Works fine getting the guild count through the bot tho
It seems to work just fine on other botlists aswell
Simplifying top.gg webhooks for all users, allowing non-developers and developers to use webhooks for their bot and server without confusing configuration.
Does the remind me thing on voting have any linking with the API?
Like would top.gg send a request alerting you when a user could be reminded via ur end too?
I assume it's just top.gg based but would love to know
makes sense, ty
I just reset the token and it completely broke
I'm using the right token
token reset doesn't works at all
Reset the token, refresh the page, then use the one after the refresh
It is important to know that the first part of the token is similar, as that's linked to the bot its authorizing
Not working
i Idid it
I clicked 5 times reset and only the previous token is working
No one of the new tokens worked
Then you likely got ratelimited trying to reset the token, which I doubt
This token doesn't works but the previous yes
Can't help then if you've really pressed the "click here", refreshed and used the new one
yea i used that and with some tricks it works now
thanks alot
it chhanges to 0 after 12 hours, which iswhen a usercan re-vote
works fine on my end
what exactly did you use on your code? post your code that handles it
API
through /check
repost without your authorization on the first few lines
also reset that
looks fine to me, can you visit the check endpoint on your browser using the authorid that is running the command?
so for example on my test bot https://top.gg/api/bots/717091693786300496/check?userId=669452973755072524, replaying both ids of course
make sure you're logged in on top.gg
also again, replace the 2 ids with the corresponding ids that would've been used in your code
How often does the autoposter post stats to the api? i.e every 1 hour, every 2 etc
ig every 30 mins
I'd personally recommend every hour or two
no need to keep it that accurate with 30 min posts, especially with caching and all
@stable tide I'll look into this, thanks
no problem
is there a way to get the time in milliseconds that the user voted
Not per API, you'd need to store the Unix time of when a user voted yourself
How can I make my bot or a webhook automatically announce a vote for my bot? The library I use is Aoi.js
( @rain heart could you reply pls, sorry for the ping)
Documentation for @top-gg/sdk
but the api doesn't have events. right?
The API supports webhooks, from which you can tell when a user voted
You can use that to store the timestamp of the vote, then perhaps start a timer or smth
Is there a way to make this update itself?
Well, total votes can be tracked on your end using webhooks. https://docs.top.gg/resources/webhooks/
views isnt something we provide an api endpoint for, you could theoretically track it using an iframe(I'm not entirely sure if that will work).
Invitations can be tracked on your end, but it can be a lot of work to setup.
How can I find when the user has voted?
We only provide webhooks.
https://docs.top.gg/resources/webhooks/
once the webhook is set will it be ready?
Hi Can someone pls tlel me what im doing wrong, im getting code 401 payload = {"server_count": len(self.bot.guilds)} try: e = requests.post(url="https://top.gg/api/bots/943415820875354152/stats",headers = {"content-type":"application/json","Authorization": ""},json = payload ) except Exception as e: print(e)
@stable tide - I looked into the issue that you reported and that endpoint should return unauthorized if you do not provide the authentication set by the server owner.
So that endpoint only works if you have access
Hello, I have an express running locally on port 8080 hooked up with
const app = express();
const topggWebhook = new Webhook(process.env.TOPGG_TOKEN);
app.use(
cors({
origin: "*",
})
);
app.post(
"/",
topggWebhook.listener((vote) => {
console.log(vote);
})
);
app.get("/", (_, res) => res.send("Hello, World!"));
app.listen(8080, () => {
console.log("Webhook listening on port 8080");
});
whenever any request (local, remote) sent to / as a post requests it returns
{
"error": "Unauthorized"
}
I have made sure to copy my token from top.gg and use it inside the code. I'm just wonder what exactly is this error. I am assuming for some reason I'm not authorized with toppgg but not sure why.
this are the responses the server sends when i use the test button
so i checked locally with a normal post request and i received the same thing so that eliminates cors
this is the response the server gives to me when i send a request locally
nvm i figured it out i thought that the authorization string was the token not the shared seceret i give to topgg
🤦♂️
💀
I don't understand, was that correct?
You can do it for servers you have access to, but not for servers you dont have access to
its restricted
but I don't get error when creating an invite here
is this right?
yea
oh ok sorry for the inconvenience
I'll pass it along in case we dont want to allow that, thank you for reporting it to us 
ok, no problem 😄
Unable to test webhooks:
https://top.gg/bot/x/webhooks
Is your webhook an IP or domain
Note that you cannot use discord webhooks or localhost addresses
The domain is a production domain
Nop, its https://xx.com
Oula
sorry
no
lmaoo
so is it just a filler?
or is it an actual domain for your webhook
ohh nvm, since I asked what type it is nvm
make sure it has a protocol and stuff
you could otherwise DM me the url and I might be able to tell you what the issue is
@plain panther so are you seeing 403 errors?
If so, try going to the webhook section of your bot, click the regenerate token button link, after regenerating it, clear cache, reload the tab then copy the token you got into your code
Okay lemme try it
Hey did that but in my code it says auto-poster isn't function (pretty much sure problem at my end but can you guide me)
Would you be able to share the code snipped where you use the auto poster?
Make sure to remove any tokens/api credentials before sharing tho
import client from "./index.js";
//importing client from main file
import AutoPoster from 'topgg-autoposter';
const poster = AutoPoster('my token here', client)
poster.on('posted', (stats) => { console.log(`Posted stats to Top.gg | ${stats.serverCount} servers`)
});
Humm,,. That’s seem right at a quick glance. What’s the error your getting?
AutoPoster isn't a function
Mind sharing the full error?
Umm...okay
Stupid question, You made sure to install the autoposter npm module right?
npm i topgg-autoposter
Yeah did that perfectly
Error with same.code
Ah, try destructering the { AutoPoster } in the import
Don’t think it’s a default export
So:
import { AutoPoster } from 'topgg-autoposter'
Umm...okay
Yo that works but now it shows cannot access cleint before intiliazer
And my client statement is properly defined as ready event works
the client is used before it's being set
So you can’t run AutoPoster before you have defined client to be a DJS instance
As a example if you where to put your code below the client definition in index.js it should work
As i told did it alredy like imported client from Djs and it's intent and also it's after cleint defining
@dim kettle
From this code it seemed like you had it in a different file
Did you try moving the code below the client const in your new screenshot to see if that works
Yeah changed it to main file again because I think there was problem in importing so moved to main file
And the poster code is below cleint defined tho shows same error
Atalst solved thanks Johand#0001
what advantage does topgg webhook package provide instead of just listening for req.body on express, except checking for auth token?
None really, it is for developers who don't want to go through the hassle of building their own handler
You could probably just make one yourself through express and you're aight
The only thing the Topgg package does automatically is correctly respond to the requests to avoid retrial, aswell as handle the Auth as you mentioned
I see
how can i track votes for my server
Using Topgg webhooks
https://docs.top.gg/resources/webhooks/
Can someone help me with this
invalid or no token
regenerate token > refresh token > copy new token
Thanks
is there any way to get the amount of votes
I didn't see anything on the Java api
IDK about java but you get that after fetching the bot info
https://docs.top.gg/api/bot/#find-one-bot
https://docs.top.gg/api/bot/#bot-structure
Ok
Ok
yes but that is for bots - how do i do it for servers
Thats also for servers listed on topgg
If you're looking to just send messages on a vote you can use third party tools.
need more context
const { ShardingManager } = require('discord.js');
const { AutoPoster } = require('topgg-autoposter');
const Sharder = new ShardingManager('./src/index.js', { token: sometoken, totalShards: 4});
const autoPost = AutoPoster(token, Sharder);
autoPost.on('posted', (stats) =>{
console.log(`${red("[TOP.GG]")} ${blueBright("INFO")} | ${green("Creating")} - \n${cyan(stats)}`)
});
have you changed anything?
nope
even djs versions
It's possible something changed in discord that causes that issue.
Top.gg Auto-Posting made easy. Contribute to jpbberry/topgg-autoposter development by creating an account on GitHub.
Play music
what are the params for api.getBots(Map, limit, offset) just need a brief description of them
nvm
Not an official version btw

f
are you able to have people vote for your bot using the API?
you mean know when people vote?
Using Topgg webhooks
https://docs.top.gg/resources/webhooks/
You can also fetch the last 1000 users who voted for your bot
i think he meant sending a post request to vote endpoint prolly
like "is vote api endpoint public?"
that'd be illegal from every possible way I can think

huh
any changes made to the autoposter? it used to post my bots stats and update frequently but now the server count is stuck at a lower number than what it actually is — i haven’t made any changes to my code since adding the autoposter 
it hasn’t changed for quite some time and is ~500 servers short
Could you tell me the bot ID you're referring to?
Though shouldn't be made by changes as far as I'm aware
So it seems like it had stopped posting entirely since 2022-6-16 https://dblstatistics.com/bot/792443342926512128
An IPv6 directly won't work, you'd likely need a domain for that
I don't have a domain only a VPS :/
hmmm, i'll take a look at my commits during that time and check my end. thank you aurel !!
There are other solutions that could do the trick, such as an arpa reverse DNS domain, but I'm honestly not sure if it works or not
kk got it
There's some documentation on the RFC2732 on how to deal with IPv6 addresses with web requests, there's also tutorials on that too
Format for Literal IPv6 Addresses in URL's (RFC 2732)
is there an way you can check how many hours you have to vote again
Oh I see that someone else asked the same question to
const express = require('express')
const Topgg = require('@top-gg/sdk')
const fetch = require('node-fetch')
const app = express()
const webhookFirst = new Topgg.Webhook('mycode')
const webhookSecond = new Topgg.Webhook('mycode')
app.post('/vote', webhookFirst.listener(vote => { //ending url
client.channels.cache.get(`891366497258188800`).send(`User with id - ${vote.user} voted.`)
}))
app.post('/vote', webhookSecond.listener(vote => { //ending url
client.channels.cache.get(`891366497258188800`).send(`User with id - ${vote.user} voted.`)
}))
app.listen(3000)```
HI. My code is not working for me, can you guide me, what am I doing wrong?
I have two bots on topgg
Should I make it into two virtual servers or what?
So like I'm not using js myself so take my opinion lightly but
iirc you can't create 2 posts on express
Top.gg provides data in its JSON data for you to differentiate between bots so you won't have 2 endpoints
Also you won't need 2, one is enough
Since they're essentially doing the same
You can have two post endpoints they just need to be on seperate paths
The webhook part is supposed to be the auth
As far as I'm seeing you won't even need a second one
One post can handle it, you can just use the same settings on both bots
only that he wants to make logs with just one bot
if I have two endpoints do I need to do anything else or should I leave it as is?
doing it for the first time
you dont need to 2 endpoints is the thing
you only need one
you're essentially creating 2 endpoints for the same purpose
which is redundant
see here
oh ok
aka remove one of the post handlers, you can use literally one for both bots
no need for 2 webhook instances either
and it should not be your token but your authorization you define yourself
🤔
is that it?
Should I put this on topgg or where? Because I'm slowly not getting it anymore. One writes in docs, and the other writes in the npm library.
That looks like the headers for the api, webhooks are not using the api
Hello, I'm having trouble fetching your DBL-Java-Library dependency via maven, are you aware of issues?
The error I get:
Could not find artifact com.github.DiscordBotList:DBL-Java-Library:jar:2.1.1 in jitpack.io (https://jitpack.io)
Yeah, the top pinned message should fix it.
I have filed a PR to update the readme to make it clear in Github as well: https://github.com/top-gg/java-sdk/pull/15
need set the link of webhook here ?
auth of the webhook there
does not support discord webhooks
what that is is an authorization string like a password that allows your webhook to authenticate top.gg for example
that ?
If you are using py then i will help
Otherwise idk
js 😦
Then don't know
can we setup webhook/api for discord server vote logging
have you tried @top-gg/sdk package?
yes i don't know how to setup it withh heroku
I just want to know when someone votes
put heroku link
instead of the localhost:3000 thing
what link?
let's say your project name ppbot
in the webhook section of your bot put https://ppbot.herokuapp.com/YourCustomRoute
then put a random auth
then click save
in heroku change dyno type from worker to web
in your code put auth and deploy
and you should be good
The rest should be covered in docs
Yes
any docs
How to get token than
Servers don't have an api, so we don't provide a token.
We do have webhooks for servers though
now that you mention if you just want to log votes for your server
can't you just use the webhook topgg thing
Simplifying top.gg webhooks for all users, allowing non-developers and developers to use webhooks for their bot and server without confusing configuration.
@smoky marten ur pfp kinda sus 

you saw nothing
heh
vote.user returns me the user ID, how can I get the user username from this with a tag?
You can either use the Top.gg API to obtain their associated information or by just fetching their user-id through discord
I looked in the library and found nothing
username returns me the undefined.
idk why
topgg doesnt provide that in webhooks.
youll need to fetch that information from discord using your discord library.
I know, that's what I did. The mistake turned out to be that I didn't use the asynchronous function, everything works already.
that is the official library yes
I also want to count the votes of a member
Who voted and want to give role too for every time he vote
Use webhooks then
@jaunty salmon
👋🏽
no problem bromine
yep!
what does this mean? i filled everything
nvm fixed
import Topgg from '@top-gg/sdk';
const webhook = new Topgg.Webhook(`${process.env.DBL_BASEAUTH}`)
const app = express()
app.post('/dblwebhook', webhook.listener(vote => {
console.log(vote.user)
}))
app.listen(80)
isnt this right?
no 80 needed on the URL, http is by default 80
Is there something wrong in this code? I was seeing how to use the @top-gg/sdk library but when I try to vote (as a test) it doesnt return anything in my console
const Topgg = require("@top-gg/sdk")
const express = require("express")
const app = express()
const webhook = new Topgg.Webhook("auth")
app.post("/vote", webhook.listener(vote => {
console.log(vote.user + ' voted')
}))
app.listen(5028);
console.log('Your app is now running!')
Btw this code is from the guide
did you fill in your webhook url and auth on topgg?
yes i did
I'm using custom domain
But now the api cannot send req.vote anymore
Do I have to add any type of DNS to receive topgg request from API when someone upvote?
is there a listener for votes?
You need to create a (webhook) listener - in this case - if you wanna listen to incoming requests (messages when someone votes)
In order this works you need to tell topgg where to send their requests (messages) to
Which is you webhook listener aka. webserver

Simplifying top.gg webhooks for all users, allowing non-developers and developers to use webhooks for their bot and server without confusing configuration.
So… you got some trouble using it?
huh? no
Just ask whatever you're having problem with
No, its alright. Figured it out
hi uh is there a place where I could learn to make voting rewards for my bot like recieve the userid that voted and what time hey voted
i am using heroku to host
where would I find the auth token?
how do u make the Webhook URL if i am using heroku
should be covered by heroku's docs
Technical documentation that describes the Heroku platform.
huh
how do u get topgg voting events like it will do something if a user votes
webhooks
Hm
how do you make it so that it isn't just webhooks that send instead i want my bot to dm the user when they vote
- make a top.gg webhook (Not discord webhooks)
- when someone votes you'll get the user's id
- you can then send them a dm
(Note: you won't be able to dm all users so you better get some kinda error handler)
why doesnt https://top.gg/api/docs work
it's the same as docs.top.gg, there's no need for an archive
ok
looks very different
its a very old version of it and not used anymore
My stats are getting posted for single shard total servers are not getting posted
Hey guys hope all r dng grt... Need a assistance on get user id who is voted my bot... Tried all sorts of things webhook from topgg still am not able to figured it out can someone help me pls.
where are you having problem
From top.gg if I tried to fetch using dbl am not getting
Am using VPS
@smoky marten
dbl wut?
Dblapi.js
This one is deprecated since a long time now
I don't recommend using it but it works
For the post request how do i implement it in my application
is there an example
the server ip for localhost works?
i wanna test then figure out for heroku
yo
anyone know how to check if someone voted the bot on top.gg?
nah
figured it out
401, message: Unauthorized
DiscordBotListAPI api = new DiscordBotListAPI.Builder()
.token(token)
.botId(botID)
.build();
api.getBot(botID).whenComplete((bot, e) -> {
System.out.println(bot);
System.out.println(e.getMessage());
});
Is the Java library being maintained or why am I getting unauthorized? I tried to refresh the token on topgg webhooks, but even with that it didn't work.
Refresh the token then refresh the page, then copy it
did that, doesn't work
even cleared cache
are you using the most recent version of the java library?
<dependency>
<groupId>com.github.top-gg</groupId>
<artifactId>java-sdk</artifactId>
<version>2.0.1</version>
</dependency>
the 2.1.1 did not want to download through jitpack
on maven?
maven yes
read the top pin
just try PR14-SNAPSHOT?
yep
not found
so
<dependency>
<groupId>com.github.top-gg</groupId>
<artifactId>java-sdk</artifactId>
<version>PR14-SNAPSHOT</version>
</dependency>
isnt found?
🤔 strange
https://javadoc.jitpack.io/com/github/top-gg/java-sdk/PR14-SNAPSHOT
it should be found
for me that link goes to https://javadoc.jitpack.io/com/github/top-gg/java-sdk/PR14-fffb55d578-1/index.html
yeah, its a redirect to pull the most recent version of the PR.
for me its not found so 
for some reason when I do
<dependency>
<groupId>com.github.top-gg</groupId>
<artifactId>java-sdk</artifactId>
<version>PR14-fffb55d578-1</version>
</dependency>
it does seem to work
well thats good
lemme try run it again see if its just a version issue
2.0.1 doesnt work, its from 2018 and uses our old domain(iirc)
still getting 401 unauthorized
hmm
is it possible token isnt properly set?
ie that its just an empty variable/incorrect variable
I checked, that's not the case
its the exact same token as on the topgg webhook page
the only other idea I have is regenerating the token on topgg, waiting an hour and then copy it over.
wait an hour?
its possible server side cache is preventing it from updating
which shouldn't be an issue, but it theoretically could
wouldn't it work then to just wait 30 more mins now? cuz I updated it about 30 mins ago
yeah, that should work
if it doesn't I'll let you know
it still doesn't work even after having it updated over an hour ago
How can I get the topgg api?
const express = require('express')
const { Webhook } = require('@top-gg/sdk')
const wh = new Webhook('Top.gg webhook password')
const app = express()
app.post('/webhook', wh.listener((vote) => {
console.log(vote.user) // 172075838806818817
}))
app.listen(80)
``` i have trouble understanding the app.listen part
where should the bot be listening to
an open port
What is Network Port? - A port is a physical docking point using which an external device can be connected to the computer. It can also be programmatic docking ...
You have to host it on a server
so VPS, Docker, Kubernetes anything should work fine
your PC and mobile also works (technically)
Oh alright
hey
i have a command for when someone votes my bot on topgg
and sends them a dm and a message in my topgg vote log
but when someone votes it
it is like a loop
the bot continues to send from 5 to 9 messages in a row
anyone knows why?
the code is this:
const express = require("express");
const app = express();
const db = require("quick.db")
const TopWebhook = new Topgg.Webhook(process.env.auth);
app.listen(8080);
app.post("/webhook", TopWebhook.listener(vote => {
db.add(`Coin_${vote.user}`, 50)
let voteEmbed = new MessageEmbed()
.setDescription(`<@${vote.user}> voted DaKing`)
.setColor("GREEN");
let userEmbed = new MessageEmbed()
.setTitle("Thanks for Voting DaKing!")
.setDescription("You just received 50 coins by voting me!")
.setFooter("You can vote again after 12 hours!")
client.channels.cache.get('996352881294835752').send(voteEmbed)
client.users.cache.get(vote.user).send(userEmbed)
}))```
i use replit
this explains most of the problem
lmao
i mean i want vsc
but my computes wont let me install it
ma potato pc
Are you using premium or something like uptime robot to keep it alive
uptime robot
Welp that seems to make replit go brrrrrrrrr
It'll sometimes make 5-15 instances, assign different port but all if them to the original subdomain
just fork the repl
and create a new one
that one's pretty done
okay I saw the code again
and now I'm even more confused
How tf is it even working
lmao
weren't you supposed to do it like .send({ embeds: [embed]})
You didn't even import discord.js
app.listen goes in the end
it would otherwise not even reach the app.post, thus wouldn't have that endpoint work at all to begin with
it doesn't matter
yep
doesnt work
Try forking the repl
its an async function problem here
Then just try manually making a request to your webhook to see if it is even able to get requests
done already
It's the best I can think
it does
It does get request
The problem is
It executes 5-6 times per request
Would never have this error outside replit
make sure it isn't actually a network thing, try checking the IP the request comes from
and what was the problem?
so
i put my repl link in topgg
with https
now i edited it
to http
and it seems it solved it
🤔
ayo wut
lemme send an image
replit should support https
Replit issue then?
It's possible no response was being sent on https due to replit.
It does
well you know what we say
"If it works don't touch it"
lmao yea
thanks for your time tho
redirect
so apparently guessing it does a request nonetheless, even during the redirect to https
tf
ya
yo brotha, thanks for your time
ff wrong channel
In which version of py the api is available?
2022-07-13T20:57:08.340292+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=POST path="/webhook" host=xenondiscordbot.herokuapp.com
Sounds like a you problem
honestly I am very confused how to host this on heroku
-api
This channel is for suggestions, help, and bugs related to our official API libraries and documentation found at https://docs.top.gg/
If you need help with other development, please use #development.
-api
-api
-api
-api
-api
-api
-api
-api
-api
One message removed from a suspended account.
-api
is it possible to get a api for an server on the website?
If I remember correctly server API is not "officially" supported yet. Only webhooks for servers
-api
Oh okay👍
Does this always happened, or has it only done it once?
first time
Has it worked fine since that error?
Yep, but i guess send the report here, i can't control api code
You can safely ignore it. Network errors can happen every once in a while.
Sometimes it is due to Top.gg being down for a sec, maybe the host you where on had issues. Hard to say
ho, i got it
the API can send an error code following the error?
something like...
const errorCode = error.code
at footer example
You would need to wrap the await with a try/catch and catch the error
There should be an error object you can destruct the error code from
that's already done 
but no problem
thanks
const webhook = new Topgg.Webhook("your webhook auth")
is the webhook auth the auth i set on dashboard?
Yeah. That is the value you provided
alight
Why do I get this issue when trying to log votes in my server? It works for me on my client side, but doesn’t work for when someone tests the webhook
#site-status There is some issues with voting showing a client error
thank you
Is the test webhook button affected by this issue?
@signal hawk Can you confirm? 🙂
As when I click test webhook on my side it works with logs etc but when another admin tries to click the test button nothing logs
i am not sure if there are any issues with the test webhook button
i dontt hink it would be affected by the current errors

Do you know of any causes on why my issue might occur? It’s strange how I can successfully use the test button and everything logs, but when another admin uses it, nothing happens with my code or database
🤔 But yeah it makes sense on why the test webhook might not be affected
i am not sure. are the other users trying to use it on your bots team?
I’m on the same page, but I’m not executing anything, only me and that admin have access
🤔
That would be great

What do you mean by that?
Like it’s only responding when I do it?
Previously only the owner ever had access to the bot page and settings such as webhooks
im wondering if, when we added teams, maybe we didn't update that check to see if the user is on a team, and we're still only checking to see if theyre the owner

-api
This channel is for suggestions, help, and bugs related to our official API libraries and documentation found at https://docs.top.gg/
If you need help with other development, please use #development.
Thank you :)
you can use webhooks for that
discord webhooks are not supported
but who will say who voted for him will be the bot?
see above
do you know this bot?
that is not an official bot by top.gg, nor do we provide such service
that's likely a private bot made by someone that is using Webhooks in order to receive voting events
how do I do that?
read above
Where?
The docs already provide examples in different languages you can use which are pretty much a working solution
But still it requires fundamental knowledge on how webhooks work and what they are
Without that trying to set this up will be complicated
Also stay away from trying to host at home as I read that earlier
Thanks 👍🏼
How can I keep the widget image updated?
I just copied the link of the image but it doesn't update when someone votes
Pls help
the image (svg) updates instantly
Like it updated before my browser would
so I guess it's discord serving from cache
i guess invalid the cache
But will an .svg image work for a discord embed? I changed that to .png because thought that .svg won't work
I changed back to .svg from .png but the image doesn't appear in the embed now
dbl.webhook.on('vote', vote => {
logInfo('User voted', vote.user.tag);
client.channels.cache
.get('...')
.send({
embeds: [
new Discord.MessageEmbed()
.setColor('#12c4ff')
.setDescription(`${vote.user.tag} voted!`)
]
});
});```
This isn't working when someone votes
uh idk?
probably ip issues
@slate roost where do you host that
i am waiting a reply
discord caches the image
Replit
Sorry for late response i was trying to fix it
Any way to keep it updated?
likely not, maybe by adding random garbage into the query string?
What should I do then, can you give me an example
dbl.webhook.on('vote', vote => {
logInfo('User voted', vote.user.tag);
client.channels.cache
.get('...')
.send({
embeds: [embed]
});
});
Also, the vote tracker not working
if you send the url add random stuff
That's not the official lib if I remember correctly
so do you use some port
hm?
Yep
oh
For topgg right
try to remove it then
Removing the port gives this error
Hmm
Oh there, there I've put a discord webhook integration url
bru-
The whole code: ```js
const dbl = new DBL(process.env.topggToken, {
webhookPort: 5000,
webhookAuth: '...'
});
dbl.webhook.on('ready', hook => {
logInfo('Webhook', 'Connected');
logInfo('Webhook Url', https://${hook.hostname});
//logInfo('Webhook Port', ${hook.port}${hook.path});
});
dbl.webhook.on('vote', vote => {
logInfo('User voted', vote.user.tag);
client.channels.cache
.get('...')
.send({
embeds: [embed]
});
});```
I don't get any error with this but it doesn't work
because it probably doesnt get sent
idk
What do i do pls someone help
The vote updates don't work and the image too
Pls help
https://docs.top.gg for the voting
the image is not meant to be embedded into a cached field
consider using the api to fetch information about your own bot
I'll just remove the image
I just need it for voting
On webhook url there is the url of the discord webhook integration url
I'm simply using the event in the index.js it's ok right?
This is the whole code
You cannot use discord webhooks there
refer to this to learn what a webhook is
Oh, what should I put then?
Is there some way way to just get a webhook?
you can use https://webhook-topgg.com/ to only get logs
Simplifying top.gg webhooks for all users, allowing non-developers and developers to use webhooks for their bot and server without confusing configuration.
but not to reward users for voting
Oof ☠️
auto poster works with eris?
I’ve been getting a strange occurrence within my webhook logging. Is it possible when someone votes for a server twice, that the POST request and my app could misinterpret it somehow and run my code twice?
Or could it be because of my host (heroku) making a mistake.
That can happen if there's no response sent back by the webhook https://docs.top.gg/resources/webhooks/#retrial
its prolly cuz today is weekend
1 vote counts as 2

on weekends
Is there any way to prevent duplicates?
By properly responding to the webhook as described there
I don’t imagine this is the issue as it’s only happening sometimes, once in a while, not all the time
weekend votes are not sent as separate webhooks

they're sent as 1, but the value is_weekend will be true on that one request
how do i make my bot send in console.log when they voted for it?
how do i make this url?
oof, that one is a bit harder
you need to host it
i am using Heroku and it works fine
does this script do that?
yes, but if you are using heroku you need to change last line
and line 6 should be changed to smth secure
because I wanted my bot to warn itself
what exactly do you mean?
I wanted my bot to know who voted for him to give him coins (economy system coins)
vote.user returns user id so you can use it to award user
because but this script does not work
i know, i have one working for heroku i will send you it 1 sec
const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express()
const webhook = new Topgg.Webhook('password')
app.post('/vote', webhook.listener(vote => {
console.log(vote.user + " voted")
}))
app.listen(process.env.PORT)
console.log("Ready!")
This is the same but changed for heroku
you cant assign a port on heroku you need to use process.env.PORT
where it says password I put what?
whatever you feel like
do i put this?
yes, put same string there as in the script
and now?
now, you need to host it
I put it in the bot index
i am not sure if that will work but try
if you see ready! in console its working
?
i hosted my bot on square cloud
do you have an ip or domain?
and do you have env file?
bots have no domain
I will talk to host support
no need
go to your app on host web panel and ipv4 address should be there
what do you mean? Voting code is executed only once per vote
it can happen if there's no response sent back by the webhook
does not appear
I am not familiar with that host so ask support how to get ipv4 address
they answered:
why do you want an ipv4 dude? I just explained to you how to make topgg send you the webhook just upload the api as dynamic in square and there on topgg you put the website link
Yeah website link works too
I have a website but only a website with text
What does website says?
When u got to it
Friendly Bot é Um Bot Com Muitas Funções E Vários Comandos
Is it hosted on the same node as bot?
yes the bot and the website are on the same host
Do u have .env file?
no \😢
build what?
Just run it
https://friendlybot.xyz:3444/vote
so?
https://friendlybot.xyz:3444/vote
so?
you use Cloudflare so port 3444 is blocked
you could possibly consider disabling proxy so port 3444 is opened
what will happen?
In console you should get a message
If it isnt working @tidal idol told u y
nothing happens that must be the problem
click on your domain
click "Proxied" and it should go gray
you don't want to add a record
the top one yeah
there should be one under "www" too, if so then disable proxy on that too
just the top one then
click this on the top one
then click save
Discord being Discord
lol
give that a few mins and it should work
ok I'll wait
did you even setup ssl properly?
if not use http without secure protocol

Unable to access this site
What do I do?
hmm
for now just renable the proxy
i'm heading to bed so i'm unable to help any further for the time being
ok
thanks
wut are you trying to archive?
how do i make my bot send in console.log when they voted for it?
where is your webhook listener running? at home or on a server?
Hi
hey, need anything?
Sure, what do you need
What does the 503 status code mean when it’s returned to me?
service unavailable
how do i get the top gg api
k
sm endpoints can work without an approved bot tho right?
no, requires an approved bot entirely to use any aspects of the api
https://top.gg/api/bots/646937666251915264
this one works 
without auth or smthing
if you're logged into top.gg, then yes it does
as it is using your authorization to check the stats
o yeah
try it in incognito and you'll see what I mean
ye i get unauthorized
how can i get DBL token?
check the pinned messages
im trying to go to the website but cloudflare returns a error saying timeout, how could i fix that?
/api/docs#mybots
The web server reported a gateway time-out error.
alr thanks
also what package should i use there is two for nodejs
- top.gg
- @topgg/sdk
alright thanks
oh wait what?
always has been
const manager = new ShardingManager('./llama.js', { token: token });
manager.on('shardCreate', shard => console.log(`Launched shard ${shard.id}`));
const ap = AutoPoster('topggBotToken', manager) // error here
ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
})
manager.spawn();
This normally works but after adding the autoposter it gives an unsupported client on the autoposter declaration. What am I missing?
I also tried with my client on the llama.js (index but I'm using sharding) and same issue
How do you do a server count across all shards? Do I have to change how I shard my bot 
https://docs.top.gg mentions that on the docs
I set up my sharding how the djs docs have it but the topgg autoposter list it a different way and I'm not sure how to set that up. I also can't find anything about shard managers on the topgg js docs, is it under the posting bot stats section?
Ok so I had a que
User can vote more than once for the same bot every few hours
And I also used top.gg api to know if a user has voted so let's say user voted once and his time ended like he can revote now so if I render using api would it show he has not voted? Or if he just votes once it will show that he has voted (everytime I fetch)
the api shows if user has voted in past 12 hours. so if he can revote now probably the api will show 0 which means false
Its really easy you can make a session and provide auth in headers and then you will get the data 0 = Not voted 1 Voted and yes I'm also using this no need to install any wrappers
Because topggpy is not supported on 3.9
||English accha nhi mera manage kr lena||
Umm so the only way to keep track of him is by storing his data on db
?
yes
Can't you post status of each shard individually ?
Like instead of putting the posting thing in the sharder try putting it in main file
then post stats
also you can always do it manually
u can use setTimeout also after the user votes but it cease to exist if bot is restarted or crashed 
(if u are trying to make a vote reminder)
Aha Ig Ill only store it to db! Thanks btw

I can try that thx
Even with the normal client it says unsupported client 
Can you not use autoposter
I'm sorry if my reply pinged u i fixed it!!
that's what i was using :P its all good now tho
yesterday I had this same problem
will the stats be on topgg right away or do i have to wait a bit
So I copied the autoposter code without the type check
now it works fine
yayy im glad it works for u
You can check here
Pretty much real time (more like real hour) stats
https://dblstatistics.com/
View the historical performance of up to 35094 bots listed on Discord Bot List (top.gg). Updates hourly.
that's fair! ty
OK this might sound really stupid but I posted my stats, can I temporarily un post them? I commented out the autoposter but the old stats are still on the page.
My reason being the bot is only in 3 servers and I'm afraid people will not use it because of that
whoops oh well. Ill just auto post them then. Thanks! (again pretty dumb thing of me lol)
can someone here help me with getting the webhook for topgg? I use railway.app as my host
one question - suppose I'm gonna send a message to everyone who votes for my bot so how am I gonna fetch the ID from the webhook?
const userVoted = req.body.user
client.users.fetch(userVoted).then().catch()
if u are using discordjs and express
so I'm supposed to use express inside of my bot? atm I run it in a diff server
If you wish to fetch a user the ID the webhook has provided you, then you'll need a bot application within that webhook that is able to
you could also setup some sort of connection between your webhook server and your bot to then have your bot handle that mechanic
not necessarily
Yeah but i'm not sure how to do that XD
current I read the ID provided by the webhook by slicing message.content
best way is to have both in one like the example Glitter gave
yeah thats unefficient, works but unefficient
yeah i know
Or wait, what are you referring to with webhook
you have a webhook setup on another server that essentially sends another webhook into a channel right?
bit unefficient, but could work
yeah thats why i came for help
what I actually suggest is to send it in an embed instead so you could just fetch the nth field, one sec
wait, could you show me an example of how your webhooks sends that into the channel?
so you do have the ID through splitting the content with what I'm guessing "-"
yep
discordjs?
yep
what I actually want is to get the event triggered in my bot code so I dont have to listen for messages
yeah that would only work with having the webhook directly on your bot to "get the events of the webhook" to say
on webhooks you'd send in a channel it would need to listen to messages
so I have to get the express server in my event listener right?
You can either do what you have right now, fetching the ID from the webhook that was sent
because i dont know how to create a connection with the server lol
or directly go for webhooks that are sent by top.gg and implementing that mechanic into your bot directly instead
yeah that sounds good
jesus the discordjs docs are weird
only the user?
their ID, what bot they voted for (duh) and the query parameter
the ID is what you'd wanna go for
I meant like next vote time etc etc.
okay got it
easy to implement though, just store the timestamp of when they voted and compare it with the current time
yep
so currentTimestamp - voteTimestamp = time Remaining
Yeah, that wont bring you far, like i said it can work to just fetch the webhook messages from that one channel, but is often way more efficient to directly have top.gg request to your bot
I implemented in my express server, it was working fine then I gone to eat lunch then when I tried to test again idk for real what happend
I was getting the id by console log
but webhook was not working
have you checked if the requests were still coming through? It may happen that top.gg will resend stuff if it wasnt properly responded to
then some sort of mechanics to handle that ID failed at some point, debugging time
idk I wasted like 3 hours then moved on with the tool
