#topgg-api
1 messages · Page 176 of 1
I have a solution
Maybe it will match to your problem
I dont have a problem. But you have one if I understood you correct
I can't apply to the site for a bot and I get an error. It seems like an error and a user.
Sry my solution doesnt match to your problem
Hi, is there any function on the @top-gg/sdk, to listen for votes without a webhook?
in short, no
Do you just want to see people who voted?
Well, i want to make like a "reward type thing" for people who vote
You don't need a website, just a webserver listening for the requests
Doesn't even need to be a public one as you can whitelist topgg
Oh alright
how to use webhooks for servers?
Lets say I wanted to check if a user voted without using webhooks how would I do that
Like grabbing info then searching for the user then using that info to determine if you voted in the last 12 hours
You can make a request to the voted endpoint, which is only a thing on bots though
So servers are forced to use webhooks
So I saw this thing on the docs that I can get the last 1000 votes? I tried getting it but it returns an error because the bot is apparently not "Authorised" so see this data. How can I make it see the data?
by passing the correct authorization, refer to the docs
but how the docs only says to pass it with a token in which I have but there is no library or anything to pass the token to access the info
I still dont understand why this is suppose to help there's no library still on how I can access that info?
What library are you looking for?
We do have a few, but it is an api you don't necessarily need one.
right so basically I used nodejs and fetched this link : https://top.gg/api/bots/:botid/votes and it worked for me but when I ran it on a server it says this : { error: 'Unauthorized' } I just don't know how to get authorization when I fetch for things
So the authorization token itself can be found on your bots edit page, in the webhook section.
It goes in an authorization header
What are you using to fetch?
node-fetch
const file = await fetch("https://top.gg/api/bots/:botId/votes").then((response) => response.json());
goes something like this
Thx now I understand
how to get left vote time
like this
client.topgg = new Top.gg.api("") i am trying to use this on index.js but it's not working
Tracking it yourself using webhooks, top.gg does not provide that data
client.topgg = new Top.gg.api("topgg token") error on console
what error ?
show me
how can you tell me in details
cant show you error because error have my token in it
ok 👍
help me
why its showing your bot token in your console
yes
can i see example?
what you are trying to making tell me clearly
dm
my dms are off
ok
how you know paras
i am trying to make vote only cmd like if you want to use this cmd you have to vote first
just for bot developer stuff
You gotta track the votes then, save the user IDs in your database and query it for a match once somebody enters a vote only command
ok
And if a match was found cache it to prevent another database request
ok
What are the rate limits updating server count?
thnxxxx broo
is API ok atm?
Hello I am using top.gg auto poster for node js like its said in docs
but I am getting 401 Unauthorized (You need a token for this endpoint)
are you providing a topgg token?
are you posting using the same bot(and token for said bot) as listed on topgg?
yes
yes
Try regenerating your topgg token(your bot page, webhook settings, regen) then using the new one.
?????
why does pip install topggpy download all discord.py versions in existence
Huh?
hey sometimes after like some time i get this error from posting stats to top.gg about a bot.
const topGGapi = AutoPoster(`token`, client)
topGGapi.on(`posted`, () => {
console.log(`Posted bot statistics to Top.gg!`);
});
[19:34:40] Posted bot statistics to Top.gg!
[20:04:40] Posted bot statistics to Top.gg!
[20:34:40] Posted bot statistics to Top.gg!
[21:04:40] Posted bot statistics to Top.gg!
[21:34:40] Posted bot statistics to Top.gg!
[22:04:40] Posted bot statistics to Top.gg!
[22:34:40] Posted bot statistics to Top.gg!
[23:04:40] Posted bot statistics to Top.gg!
[23:36:19] TopGGAPIError: 524 undefined
at Api._request (/froggie/bot/node_modules/@top-gg/sdk/dist/structs/Api.js:76:19)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Api.postStats (/froggie/bot/node_modules/@top-gg/sdk/dist/structs/Api.js:99:9) {
response: Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: { body: [PassThrough], disturbed: true, error: null },
[Symbol(Response internals)]: {
url: 'https://top.gg/api/bots/stats',
status: 524,
statusText: undefined,
headers: [Headers],
counter: 0
}
}
}
Sometimes the api is down for a bit. That's probably what that error is
oh okay so this is not something from my side?
Nope
oh thank you great to know
how do i get my topgg auth token?
Read pins
Are we able to make a command that requires to vote with python? How can we make a command like that?
Yes
You have to read the docs
Its so easy
Also depends on where you are hosting but you need to portforward
I think my brain level is not that high
I understand nothing from it
Which one
But I didn't mean this codes
I mean like
If you want to use ban command you need to vote the bot from top.gg
But I can't found a code does that
You have to make that.
Just make a role
That is given to the user after vote
And make the ban command need that role
AUTHIC (╯°□°)╯︵ ┻━┻
?
How to make vote only cmd
You store incoming vote webhooks in your database. When someone attempts to use a vote only command, you check your database for when they last voted.
If they voted within X amount of hours/days, grant them access

Isn't there an endpoint on the top.gg api to check if they voted or not? why not just use that instead?
Works too, unless they want realtime notifications
Though seeing from a practical perspective, collecting webhook requests and storing the vote status is more efficient than making a request to that endpoint on every command usage
But if your bot doesn't need a database it would be annoying to setup one just for votes alone
Either set one up or get ratelimited when your bots gets bigger
where to use?
You will receive that data using your own webserver listening to the webhooks coming from topgg
Once you told topgg where to send the requests (speaking about your endpoint)
im using it so a user can be given a role when voted
where would i get the webhook from
Heading on the topgg site > left menu > webhooks
also this is for server not the bot
what do i put link wise here
Once you told topgg where to send the requests (speaking about your endpoint)
Your endpoint
Of your webhook listener
First of all you receive requests , topgg send a request to your webserver telling you somebody voted
What do i put here what link
It can’t send a request without a link there so let’s do that first
The link to your webserver endpoint where you receive the requests from topgg
On your domain/server IP and path you have set up
I haven’t
Well you need an endpoint topgg can send it’s webhooks
First what do i need to do on discord
Like you need a mailbox to receive a letter
Nothing, this has nothing to do with discord webhooks
How else do I get the role to the users
A huge thankyou to comhad for providing us with this method.
Important links mentioned in the video
- Integromato :- https://www.integromat.com/en
Comhad github tutorial with code snippet:-
https://gist.github.com/comhad/bd42b56a0399dbfa645aa83fe3cf4c8a
Support me by upvoting my bot here :- https://top.gg/bot/819838809318621184/vote
Joi...
idk if it is still relevant
Thanks I’ll have a look in a second this is quite confusing for me though
Think of it as a url where topgg will POST a json request. So you need to give them a url where it can do it.
You need to open a port example port 5000
Then give them webhook as http://ip_address:5000/webhook and it’ll post your data here you will set the port 5000, and /webhook in your python script
Python script needs to be running in order to work
What do I understand English?
we need a host for the voting system?
If you wanna receive webhooks then yes, you need an endpoint
No matter it’s a (virtual) server or hosting platform
You need to setup any endpoint being able to receive those requests
alr
I need api of Spotify for my music bot
#development and you cant make a bot with spotify api
Thanks for helpful link, i really need it :)
Hi, i'm trying to get the dbl api library for dotnet but im getting this error:
use @surreal seal-gg/sdk
what
or if you are not using js https://docs.top.gg
I realized when I read 😄
i thought you were using dbl api js
im currently trying to use the official dotnet lib
i saw there is some others i might try if not ill have to write my own thing using rest i guess
Topgg.api is not a constructor ?
Show your code
Bro show your all code
I need a lil help regarding top.gg api integrating with discord.py
Topgg.Api(API_TOKEN)
you got any clue to this? 👆
anything
you set the password
make sure that password then matches the authentication field on the webhook page
oh okay got it
and how to get webhook url?
someone pls tell T^T
It's your domain or server IP your webhook listener is runnning on.
Incl. the port you defined
@plucky lance how can i make vote only command
my token is appearing empty and I can't type or paste anything here either
click "click here"
did
How can I send a client.dispatch, I mean from where can I get a sample_vote_data
I need to test my vote command
There's a test button on the topgg page
I make this but it doesn't send message when someone voted
const app = require('express')
const Topgg = require('@top-gg/sdk')
const { MessageEmbed } = require('discord.js');
module.exports = {
startServer: (authToken, client) => {
const hook = new Topgg.Webhook(authToken)
app.post('/dblwebhook', hook.listener(async vote => {
let chnl = await client.channels.fetch(client.config.channelToSend);
if (!chnl) return;
let member = await chnl.guild.members.fetch(vote.user);
let role = await chnl.guild.roles.fetch(client.config.roleId);
if (role && member) {
let doc = await client.tools.models.votedUser.findOne({ user: vote.user });
if (!doc) {
await new client.tools.models.votedUser({ user: vote.user, givenAt: Date.now() }).save();
} else {
doc.givenAt = Date.now()
await doc.save()
}
await member.roles.add(role).catch((e) => console.error(e))
}
let embed = new MessageEmbed().setTitle('Top.gg | vote logs').setDescription(`<@${vote.user}> | ${member ? member.user.tag : ''} Just Voted for Moozik!.You can Vote Us Again In 12Hours`).setColor('RANDOM').setFooter(`Thanks For The Vote`);
if (member) embed.setThumbnail(member.user.displayAvatarURL({ dynamic: true }));
return chnl.send({ embeds: [embed] })
}))
app.get('/', (req, res) => res.sendStatus(200))
app.listen(process.env.PORT ?? 8080)
console.log('Server online!')
}
}```
is the webhook also set on the webhooks section on top.gg?
Also try an actual vote than a test one
In topp gg what webhook should i set
Your webhook url containing the protocol, hostname and port if applicable, and the path
What is authorization key and where i get it
in simple non techy terms, you set the auth key
make sure that auth key matches the password you set in your code (not sure why 2 different terms are used)
data["user"]
does this give the user id?
yes
what language
then yes
Hi guys, im still having this issue where i cant install DiscordBotsList.Api to my project
Is thewre any way I can fix this, is there any other libs you guys can recommend for this or am i better off writing my own rest stuff to deal with posting server count and voting.
it says discordbotslist.api which isn't top.gg
no the dotnet one
yeah its just said discordbotslist api which confused me
cc @jaunty plank
wait for woo to respond, hes a know it all with the api 
ight thanks
Ignoring exception in on_dbl_test
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "/home/container/main.py", line 341, in on_dbl_test
votedata = await dblpy.get_bot_info()
File "/home/container/.local/lib/python3.10/site-packages/topgg/client.py", line 271, in get_bot_info
response = await self.http.get_bot_info(bot_id)
File "/home/container/.local/lib/python3.10/site-packages/topgg/http.py", line 165, in request
raise errors.Unauthorized(resp, data)
topgg.errors.Unauthorized: Unauthorized (status code: 401)```
What does this mean?
invalid api key
looks like you did not use your token right
you have ! in your name
haha ok
which hoists you to the top of the member list
another question since im pretty much set on making my own thing now
does this reset whenever the user can vote again?
so like if i vote will it return 1 until i can vote again and then return 0 until i vote again?
or will i need to track that manually on my end?
It's 1 if they have voted in the last 12 hours.
0 if they havent.
ok thanks
i wish i could use webhooks but my isp does not give me a real ipv4 address
i recommend using https://webhook-topgg.com
ah
i saw that but that just posts in a discord channel right?
if i want to do vote rewards off of that that would be a dumb ass workaround wouldnt it?
right now im just thinking of doing a claim rewards system where a user, once voted can claim the reward
so i just do a rest check to see if the user has voted and check with my db if he has already claimed the reward
can someone help me make the HttpContent object in c# dotnet for this? i cant figure it out
public static async void PostGuildCount(int count)
{
HttpClient hc = new HttpClient();
hc.DefaultRequestHeaders.Add("Authorization", auth);
HttpContent content = ????;
await hc.PostAsync($"https://top.gg/api/bots/{Defaults.CLIENT.CurrentUser.Id}/stats", content);
}
this is what i currently have
the stats are posted in json
ok so how do i create a json object? ive never done this before xD
also is the other stuff im doing correct? because im kinda just going off of asumptions
Should be correct, no clue about c#
basically yeah
got this now im gonna see if it works
btw ive been wondering how do they verify if the guild count you submit is correct?
smh im getting a bad request
response
maybe i should not use http i should use rest
thats probably the issue
ight i got it to work using restsharp
ill post my solution if anyone else needs it
since i think a lot of c# developers like me have no idea how rest requests work in c#
public static async void PostGuildCount(int count)
{
RestClient client = new RestClient(new Uri("https://top.gg/api/"));
RestRequest request = new RestRequest($"bots/{Defaults.CLIENT.CurrentUser.Id}/stats", Method.Post);
request.AddHeader("Authorization", auth);
request.RequestFormat = DataFormat.Json;
request.AddParameter("server_count", count);
RestResponse response = await client.ExecuteAsync(request);
if (response.IsSuccessful)
{
await Program.Log(new Discord.LogMessage(Discord.LogSeverity.Info, "DBLRestClient", $"Successfully posted guild count! ({count})"));
} else
{
await Program.Log(new Discord.LogMessage(Discord.LogSeverity.Error, "DBLRestClient", $"Posting guild count failed: {response.ErrorException.Message}"));
}
}
ill provide some more context... the bottom part is just logging success or error with custom stuff i have, count is the server count as passed into the function, Defaults.CLIENT.CurrentUser.Id represents the bot user id (i did this so my test bot that i use before deploying will not be able to post but im sure there is better solutions to this), auth is a string that contains my bots dbl token
how do i get a topgg api key
See pins
How can I connect that when one votes my bot in the # vote-logs channel in the support server it sends me the embed that I created programming it in node.js, because I didn't understand much in the top.gg docs
data["user"] displays the userid. but what displays the username and the tag?
you fetch the user yourself
i cant fetch the user, when my bot doesnt shares a server with the voter
is there a alternative?
@restive otter
you actually can
the discord api allows you to do that
python, ok
the discord api allows you to do that
Yes, you can indeed fetch basic user informations like the username, tag etc. based on the user ID
bot.get_user(x) or await bot.fetch_user(x)
Getting this error when someone voted who is not in server
You’re trying to fetch a guild member
An user does not represent a guild member
You need to fetch an (API) user
<client>.users.fetch(…)
(you gonna pass the user ID as argument)
Well it does require basic knowledge how to work with webhooks
It’s simply a webserver listening to post requests
Aka. webhook
Yeah the docs for the topgg API is pinned in this channel
The docs do explain which data is send with the webhook and how to interact with the API
How to setup a webhook listener (webserver listening to POST requests) is up to you
The URL is your endpoint, it’s IP/hostname (port) and path
Take at look at the docs if you don’t know where to start
Assuming you’re using JS
So I made a webhook on discord and another webhook and it seems to be working fine but the ID's that I am receiving are not the same as the actual user when voting how can I fix this?
Wut? Topgg sends a wrong user ID when somebody votes?
yeah
713445949439213640 this is the ID I got from top.gg vs. 522609261961019411 the actual ID
Well it isnt
I also just got another vote in
@shy hearth
It only works with a few people
310288931721576450 is the discord id
Ik but it doesnt exists that user
Ye but my friend voted and hes Id was 522609261961019411 and instead I got 713445949439213640
So why is it changing user thingy?
resolving the IDs you gave, https://discord.id/ is returning the discord user, the one that is on top.gg aswell
There's 2 IDs, a Top.gg based user id and a discord based user id
the webhook returns the discord one
whats the id of your friend
522609261961019411
And the name
Boullellama#7532
Top.gg provides the discord id is what I can only tell you, not sure why you have several different IDs
Ask them if they perhaps have voted with an alt account
because the ID it returns IS the user that is logged in and voting
Make sure port 80 isn't in use already
And opened up
Where do you run the code? On your local PC or on a server?
and :80 does not make any sense
80 is the default http port, aka does not require to be present since http:// is the protocol
Well that's your issue.
You would have to open up your local firewall for the request, set up your router to forward requests on the port to your PC and it also requires a real public IPv4 address.
If you wanna test something, then on a server.
Yeah
hey, when i install dblpy it mucks up my pycord for some reason which means my bot doesn't run, is there a way to fix this?
install latest version of topggpy from GitHub
alrighty
with pip3 install git+https://github.com/top-gg/python-sdk/?
alright
Last time I did Python was when dinosaurs were hanging out just outside my window
lmfaoo
can confirm thats it
it works
for listening for upvotes does it have to be in a cog?
is discord.py required for topggpy?
no but you will need another lib to replace it like nextcord or pycord or something
i had problems doing it so i did pip uninstall py-cord and uninstalled dblpy cause i already had it installed then i installed dblpy with pip install dblpy then i made sure i didnt have discord.py with pip uninstall discord.py then i reinstalled pycord with pip install git+https://github.com/Pycord-Development/pycord
:))
it was working for me without discord.py
everytime i try to start my bot it says:
Requirement already satisfied: discord.py in ./.local/lib/python3.10/site-packages (from dblpy->-r requirements.txt (line 2)) (1.7.3)
try
do
pip uninstall dblpy
then do
pip3 install git+https://github.com/top-gg/python-sdk/
you will need git
ok
I keep getting: 'topgg' has no attribute 'endpoint'
when trying to use @surreal sealgg.endpoint
On python btw
Am I missing something
Is the API supposed to return an empty object when I update a bot's stats?
What code are you using?
I see
uninstall discord and uninstall discord.py
No if I’m not wrong the status code is all you get to see if a request was successful or not.
Thanks!
@restive otter @violet sun the current package is topggpy not dblpy
Make sure no files of yours are named as topgg and your version is up to date
To connect top gg to the bot with the cog what do I do
since discord.py is discontinued
how can I do this with discord.py forks?
et!eval const fetch = require('node-fetch');
fetch(https://top.gg/api/bots/880317355627016232/check, { headers: { 'Authorization': "MY TOKEN IS HERE" } }).then(res => res.json()).then(data => {
if(data.voted == true) {
return message.channel.send("voted")
} else {
message.channel.send("not voted")
}
}).catch(console.error);```
This sends not voted even tho i voted for it
why can't I search for my bot on the website
To me, It looks like you aren't supplying the userId query.
Also the URL needs to be a string
And make sure node-fetch is on version 2.5.x
Or you will have to include the package asynchronous
Oh… and you’re missing the content type
Can you use the API to listen for Guild votes instead of bot votes?
Awesome, thank you!
Error handling request
Traceback (most recent call last):
File "/home/Discord/.venvs/discord/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
resp = await self._request_handler(request)
File "/home/Discord/.venvs/discord/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
resp = await handler(request)
File "/home/Discord/.venvs/discord/lib/python3.8/site-packages/topgg/webhook.py", line 161, in _handler
await self._invoke_callback(
File "/home/Discord/.venvs/discord/lib/python3.8/site-packages/topgg/data.py", line 136, in _invoke_callback
signatures[k] = self._resolve_data(v.type)
File "/home/Discord/.venvs/discord/lib/python3.8/site-packages/topgg/data.py", line 145, in _resolve_data
return self._data[type_]
KeyError: <class 'nextcord.client.Client'>
When trying to do:
@topgg.endpoint("/dblwebhook", topgg.WebhookType.BOT, "secret")
async def endpoint(vote_data: topgg.BotVoteData,
Client: nextcord.Client = topgg.data(nextcord.Client),
):
(I also tried to pass my bot.client)
Is the client initialised already?
yes
how to do it properly?
nope
By providing the userId as query argument and reading what I wrote as comments below his message
still getting the same error
I have tried just using Nextcord but without any result
You could try this: ```js
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://top.gg/api/bots/<BOT_ID>/check?userId=<USER_ID>',
'headers': {
'Authorization': 'Bearer <TOP.GG_TOKEN>'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
Your authorization header is wrong.
And you might wanna add the expected content type
Why?
I did, and this works for me. I see no issues with it.
Just use topgg-autoposter its very simple to set up
Btw request was deprecated a long time ago. May want to start looking to use something else 🙂
?
Oh wait ik what you need
That's right. Could use Axios instead:
const axios = require('axios');
axios({
method: 'get',
url: 'https://top.gg/api/bots/<BOT_ID>/check?userId=<USER_ID>',
headers: {
'Authorization': 'Bearer <TOP.GG_TOKEN>'
}
}).then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});```
const fetch = require("node-fetch");
var headers =
{
"Authorization": "Something hear not token"
}
const file = await fetch("https://top.gg/api/bots/<BOT_ID>/check?userId=<USER_ID>", { method: 'GET', headers: headers}).then((response) => response.json());
file["voted"] //This is the amount of votes
Something like this
Oh wait
Go to edit - webhooks
Np
node-fetch has a longer require code now, its not based for commonjs anymore.
Yeah, for those of us using Java (JDA) still tryna figure out how to intercept that data. 
@rain heart sorry to ping but you seem to be the one to go for this: I followed your bot's tutorial for making the webhook listener (https://github.com/Hopefuls/LoggersBro-ExampleBot). When I run the test webhook event using Postman it returns the 200 code to the program but does not fire an event in the code (same result when I try to send a test webhook push from the top.gg settings page).
Is there some obvious step I am missing? or-
I tried to collect as much of the relevant code I use and send it, if there's something you're missing to make an informed opinion lmk...
Try an actual vote instead of a test
Alright- when it resets in the morning or sometime I’ll see if it accepts a vote. Cause for the life of me I cannot figure it out.
Even if it was a rest one, I figured it would set off the event in some way. But maybe not.
Is this site legit? https://webhook-topgg.com/ I feel like there is a catch somewhere?
is this even top.gg
You could use v2, which still has the most number of downloads, of node-fetch instead. It is still CommonJS compatible.
Since the public URL of your project is reverse proxied to any port you bind; Just put in the public URL of your project.
so is the current version, its just a longer require line
Yes, you can require it a synchronously to use the latest versions or simply going with 2.6.x
It’s still a maintained version
Whatever you prefer
YOO it actually works for actual events (not tests of any kind). Thank you!!!
Made my day.
i dont undestand fully how can i do authorization thing with java
anyone can help me
public static boolean isVotedToBot(String id) {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder().uri(URI.create("https://top.gg/api/bots/mybotid/check?userId=" + id)).build();
JSONObject json = null;
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
json = new JSONObject(response.body());
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(json);
assert json != null;
int value = json.getInt("voted");
return value == 1;
}```
always getting
{"error":"Unauthorized"}
looks like you are not including the authorization header
how can i include it
i am not good at rest apis
just googled around for a bit(not a java dev)
.header("authorization", "tokenHere")
see https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html
oh i tried to google it but i have bad english so i cant find 😄
should i do this authentication in eveytime ?
yep
Related to your own connection likely
hmm
i have bad connection 😄
i want give my method to here
if you want pin it for other peoples
public static boolean isVotedToBot(String id) {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://top.gg/api/bots/yourBotId/check?userId=" + id))
.header("Authorization", "topGgToken")
.build();
JSONObject json = null;
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
json = new JSONObject(response.body());
} catch (Exception e) {
e.printStackTrace();
}
assert json != null;
int value = json.getInt("voted");
return value == 1;
}```
this for java developers
There's also a Library for that so you don't have to go through the hassle of that
which library
An API wrapper for https://discordbots.org/api/docs that works in Java - GitHub - top-gg/java-sdk: An API wrapper for https://discordbots.org/api/docs that works in Java
Yes
thats better way than mine thanks
Should work, try it
dont working
Hover over the red
Unexpected return value
An API wrapper for https://discordbots.org/api/docs that works in Java - GitHub - top-gg/java-sdk: An API wrapper for https://discordbots.org/api/docs that works in Java
i saw this part
but i want do it with easy method
Can't help then
okey
why java
How do I send a message to a channel when someone votes for my bot?
Is there something like user.isVoted or hasVoted that can tell me if a user has voted in last x hours
Only voted in the last 12 hours
Ohokay, thanks
also is there a problem with TOPGG@SDK npm module
https://github.com/PGamerX-Legacy/muser/blob/production/bot.js#L57
Here is my code and it is completely fine, The portal has correct authorization,port and IP as well. But it doesn't work when a user votes
Is it a testvote or an actual vote?
Try using this should help https://webhook-topgg.com/
thanks
if anyone wants the code for top.gg webhook, can check my Github repo, from my discord profile; it works completely fine.
Hi!
Well, i implemented the Topgg api into my bot's code.
I'm using an interval to use the api api.postStats() function every 2.5 hours. It works just fine for some hours but then suddenly the console logs this error.
throw new ApiError_1.default(response.status, response.statusText, response);
TopGGAPIError: 524 undefined
at Api._request(/app/node_modules/@top-gg/sdk/dist/structs/Api.js:76:19)
at runMicrotasks(<anonymous>)
...... and lots of lines more
I already tried with the { AutoPoster } example but it is the same after some hours.
This is my the section i post the bot's data
setInterval(async () => {
try{
await Data.TopGG.postStats({
serverCount: Client.guilds.cache.size,
shardCount: 1
}).then(stats => { console.log('Top.gg Stats Updated | %i Servers.', stats.serverCount) });
}catch(err){
console.error('Topgg API Error: ' + err);
}
}, 21600000);
is that from today? you might have run into downtime we had, as that's a cloudflare error code
Oh yah, it was from today
discord was down for a bit too 
Yeah i had some problems because i was updating my bot when that happened lol
Okay then, thank you for the help and support! :)
Yeah, i was thinking the fail was mine but then i realized the discord api status
Good night! :)
Can you help me in #support
just use the npm module topgg-Autoposter
And set it up as it says to setup
much easier and post frequently
is there a way to get the number of votes from the api? I used this but the number is not the same as on the top.gg website
let vots = await api.getVotes()
console.log(vots.length)
oh know why... on weekend votes counts double and a single user can vote multiple times

I just wanted to display some stats but I leave out votes ;)
From the docs:
const webhook = new Topgg.Webhook("your webhook auth")
what is my webhook auth?
the long token thing or the webhook pass?
damn im stupid
nvm
is there data sent in the body
So does anyone have an alternative from www.integromat.com where it can generate a free webhook! But I also want it to work on other platforms and not just top.gg (ping when respond)
Pretty much any bot host works with webhooks anyway.
I'm not sure of any alternatives but I would expect they exist
How so?
Webhooks on bots only work with localHost which makes it not being able to make a connection with top.gg
localhost only means "me"
everything has a localhost, its not something that matters when using webhooks
all you really need is a public url, or ip.
ik how to make a public IP but I am using replit as a host
is there a webhook npm package that you can recommend me?
replit comes with a public url
it does with express yes
but idk how you could use that link in order to receive info
express is just a webserver, it can be a webhook, or any http stuff
yes ik I use uptimerbot to keep it running but how can you receive info and what info would it look like? And how can I use it to post?
its pretty much the exact same to receive a webhook, just a post request which you look in the body.
"just a post request which you look in the body" and how exactly do I do that?
assuming you are getting json
https://expressjs.com/en/api.html#express.json
I need to do research cause half of the words your saying dosen't make since to me 😅
Hey so
how can I get the Webhook url?
in example it's like ```bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password")
Hi, how can I create an vote tracker with discord.js when someone voted a server?
same webhook code
But what's the webhook URL?
do you have a way of hosting the code?
yes
In heroku.
http://<heroku url>/dblwebhook
oh ok, let me try it
What will be the port?
It's not working
Can someone help, How can I create a vote tracker with discord.js when someone voted a server?
no port
I tried it, but it didn't work
I'd recommend just using https://webhook-topgg.com
its simple to setup, no hosting required
how to get a token?
nvm I got it, my bot just got approved so
thanks tho
Oh wow, it works. Thank you so much for this!
how to like send a message to the user who voted?
Use webhooks, use the id to fetch the user
Remember you cannot DM users that the bot does not have in mutual
How do I find out if the user really voted for my bot?
you can use the check endpoint.
https://docs.top.gg/api/bot/#individual-user-vote
How Can i Apply For Bot Reviewer
Cant I access the webhooks before my bot gets approved?
Nope
hey, how do i make a webhook?
Programming language?
python
ive seen the doc, just cant figure out hot to make a webhook
like what should the webhook be
Like the url?
just to the server or the topgg bot?
Nope, it needs to be the url to your bots host
alr ty
Typically http://yourbotsserverip:port/path
ok tysm!
hey, how do i make a webhook?
language?
Js
ok boys
i need help
or girls
i've now tried for 5+ hours to get the vote receiver to work
but it doesnt
would this work without the express part?
What is the error you are getting?
You could configure any other web server
Are you testing it by sending a POST call to the running web server?
There is a service created by a community member if you want to try https://webhook-topgg.com
Not officially endorsed tho
Made by Woo :)
Could you try creating another POST route to check if the server accepting any calls?
this worked
but i kinda need my bot to register the vote
but how, Ik about that but what event and how????
I accidentally added this now i can't remove it
how long does it usually take for topgg to approve a bot submission
Remove it and save
it says invalid
2 to 3 weeks
Where does it say that
Try putting something random then idk
bruh
let voted = 0;
await fetch(`https://top.gg/api/bots/905134681199104020/check?userId=${message.author.id}`, {
Headers: {
"Authorization": "myAuthToken"
}
}).then(res => console.log(res))
Getting unauthorized
Make sure you are checking your bots id
Not another bots
yep, it's mine
And the token being valid as well? Regenerate it and try again
oh damn thats a long time
i just need a dummy bot so i can try out how the api wrapper works
hi
i really hope you replaced "myAuthToken" with your actual auth token
Of course lol
So how do I use the API to increase the number of users/servers my bot is in?
-servercount
To have your bot's server count displayed on Top.gg, please read the documentation on server/shard posting.
-serverinfo
hello. I wanna switch from discord.py to nextcord. But this doesnt work because I import topggpy and this import requires discord.py and discord packages
is there a alternative? PING ME ON REPLY PLS
easy
do pip install --no-deps topggpy
that will install topggpy without needing to install discord and discord.py
And will it work too?
try it lemme know if there is an error
💀
ofc if you have nextcord or pycord installed
np
Noted.
const Discord = require('discord.js');
//-----------------------------------------------\\
const client = new Discord.Client({
intents: [new Discord.Intents('32767')],
allowedMentions: { repliedUser: false }
})
client.conf = require("./config.json");;
client.login(process.env.token || client.conf.token);
const { AutoPoster } = require('topgg-autoposter')
const express = require('express')
const app = express() // Your express app
const Topgg = require('@top-gg/sdk')
AutoPoster(process.env.topggToken || client.conf.topggToken, client).on('posted', () => {
console.log('Posted stats to Top.gg!')
})
const webhook = new Topgg.Webhook(process.env.topggAuth || client.conf.topggAuth)
app.post('/dblwebhook', webhook.listener(vote => {
console.log(vote.user.id);
let embed = new Discord.MessageEmbed()
.setColor("BLUE")
.setTimestamp()
.setFooter({ text: client.user.username, iconURL: client.user.displayAvatarURL() })
.setDescription(`**Thanks for the vote now you are boosted for 12 hours!**
\n[Invite](https://discord.com/oauth2/authorize?client_id=${client.user.id}&permissions=1342185502&scope=bot%20applications.commands) ${client.user.username} to your server!`)
vote.user.send({ embeds: [embed] }).catch(() => { })
}))
app.listen(8000)
why it doesnt work
what do you mean
whats not working
Everything but autoposter works
any errors?
It doesnt send me voted user
because vote.user is a id
not a d.js user object
you have to fetch them
It doesnt send me even undefined
remove the .id from there
ah
where do you host your bot?
In my computer
you have to port forward
and test it somewhere else
Cannot Get /
localhost:8000
thats not port forwarding
google it™️
Can i ask where are you from?
turkey?
Türkçe anlatsana şunu :D
well cant speak turkish here so
dms
Test webhook does not seem to be working
is your webhook a discord webhook by any chance?
No
oh ok good
const webhook = new Topgg.Webhook('**code is here**')
app.post('/webhook', webhook.listener(vote => {
bot.logWebhook.send(`${vote.user} has voted!`)
console.log(vote.user)
}))
app.listen(80)
My code
make sure you did http and not https on the topgg page
It is http yes
Port is correct. Ip is correct
Try sending a request through Postman or something
Postman?
If using VisualStudio, try Thunder client (free extension)
test vote may not work, try an actual vote
I don't have anyone to test 💀
I did new request but i just bring up a blank screen
It is working now all of a sudden??? Oh well
Does the bot only ever send the post for a vote once?
it only sends the request on unique votes
it counts as 2 during the weekend, but still makes only one request
Ok so it is fine to send rewards for voting off the webhook post?
thats what the main intention of the webhook is, yes
Also whats the weekend boolean stored as
Or is it not part of the post data anymore
it is, just not on the test votes
Is it vote.weekend?
i just want to ask who had the great idea of installing dpy automatically with topgg package on python ver, all my files getting mixed with the fork and original dpy , now the question is how to install the topgg alone (i installed it first via pip)
—no-deps I think
i'm pretty sure it's not working in req.txt as far as i know
k thx
hello how can i post the guild count for my bot to my bots page
is there library or can i use the raw api
there is


okay my server count posting works, but on the website its not visible. can i do anything, that it is visible?
wait up to 30 mins
prolly server cached
yes now its there
Can you get how many votes your bot has?
In code as a variable
just fetch that endpoint and store data in a variable?
when using this
dbl.postStats({
serverCount: client.guilds.size,
shardCount: client.shards.size
});```
is it with the token from https://top.gg/bot/BOTID/webhooks
Yes
ok, guessing it takes sometime to update then? getting 401
anyone else noticed certain votes registering twice? ever since the API became unstable we've been receiving double vote events randomly
is it possible you are not sending a 200 response code sometimes?
nah we post the code response and end the request on our end, i can do some debugging tomorrow to see if i can find what causes it
it's not like it's a common thing
most of these aren't duplicates, i just found it strange so i figured i'd ask in case anyone else had noticed it
its possible the response isnt being received in rare cases? not seen it happen before.
yeah that's really weird, thanks regardless though
how long does it take for top.gg bot tokens to be valid and not get a 401 response, after verification?
i didn’t have to wait for anything personally
try regenerating the token and using the new token
yes
ok, is there a way I can check if the user voted and maybe send a message on a specific channel?
thanks
what do i have to put on your webhook auth?
webhook or
const TOP_GG = require('@top-gg/sdk');
const TOP_GG_API = new TOP_GG.Api('YOUR-TOKEN');
async function didUserVote(USERID) {
const voted = await TOP_GG_API.hasVoted(USERID);
return voted ? 'Thanks for voting!' : 'Please vote';
}
https://top.gg/bot/BOTID/webhooks
the token in there
you decide that, as long as its the same between your code and the website.
How you did can you explain me
I need to set vote log and reminder for my bot too
i might as well post a template on github for people to use
i'll do it when i have the time
Oh sure
it's on my to-do list now, i'll post it here when i do it
We do have examples on the docs too
^^^^
did you provide your topgg token?
Yes
are you posting stats for the same bot you got the token from?
try going to your bots webhook page and regenerating the token and using the new one
How to regen?
O ic
well, let me know if you have any questions. pretty sure we have copy paste examples for the most common programming languages.
👍
Now it posted successfully but still not updated on top.gg
it can take some time to update
30 minutes to a few hours is typically how long it can take to update
what is the http link for this?
See the title of the code block
i see it. but the link brings an error. could you post it here please?
Ello I am having a little issue with vote webhooks.
I coded it and when i used the "send test" button, it logs the test vote object but when a user actually votes, it doesn't log anything.
tried to vote several times asking different users. But no luck
trying to make the bot give rewards when a user votes automatically
Have you tried saving the webhook?
Like when you sent a test and the button right beside it "Save"
You clicked that to apply the webhook to your bot
How can I fix this error
Error
at Api._request (D:\Downloads\Rovotic\Rovotic v13 orignal tester\node_modules\@top-gg\sdk\dist\structs\Api.js:76:19)
at processTicksAndRejections (node:internal/process/task_queues:96:5)```
**code in a command file**
```js
let voted = client.topgg.hasVoted(message.author.id);
if(!voted){
message.channel.send({content: "You need to first vote me on top.gg"})
} else{}```
**Index.js code**
```js
const Topgg = require ("@top-gg/sdk")
client.topgg = new Topgg.api("top.gg token here")```
Did you put your topgg token in the spot it says "top.gg token here"?
yep
after putting and when i run my command it shows this error
Try regenerating the token and using the new one.
i did like a 100 times still shows same
u there?
I'm not sure why it would give a 401.
My experience with the sdk is out of date, so I'm not really sure how to help further.
I couldnt get what I supposed to put in here
It depends on your host
it depends on ur host
I made the bot on glitch?
Hosting bots is against glitch tos
no no i mean i coded the bot on glitch not hosting
my hosting site is named goveri
so what am i going to write there
Like a vps? Which you get a private ip?
Or is it a webhost
webhost
Do they provide a public url to your project?
I am not sure need to ask
It's probably going to be 'projecturl/path'
Do you guys know what the http link for this is?
yes I did
sorry for the delayed response~
A copy url button exists above that part
Here’s what I see when I search for « Luca »
the search via api is probably just not reliable right now.
hasn't been for months
i remember a few months ago trying to use, still same results
what is the voting api?
The API docs are pinned in this channel
const express = require('express')
const { Webhook } = require('@top-gg/sdk')
const wh = new Webhook('anyPassword')
const app = express()
app.post('/webhook', wh.listener((vote) => {
console.log(vote.user) // 172075838806818817
}))
app.listen(80)
is there any way to put token and send a test
wdym?
I am unable to get vote user id in console log
where do you host your bot?
youll need to port forward then
if have a port?
what
then do your testing in your vps
oh and then?
put your vps ip and port
like this: http://ip:port/dblwebhook
and put the password in too
after that ?
then test it...?
i didn't get it voter id
did you even save it first
did you even put your webhook code in your vps
can you give me your vps link in dms?
what's the api limit for vote checking
how can i get a user details by discord api?
Use your bot library
Is there a way to catch the api errors outside functions? Like, i know i can catch errors when posting or requesting some data, but what about cloudflare errors and stuff. Is there a way to catch them on like, an 'error' event?
I looked around but couldn't find anything on docs
The API doesn't have that iirc, do that yourself by making your own API wrapper and checking if the status code is alright
You can save the number of people who voted for your bot in db
how do I do that
i cant read
voting system
Hi @grizzled wasp ,
You can learn how to do this here: https://docs.top.gg
Trying to setup the api on my bot, when I try to get my token from the webhooks page there is no token when I click reveal
Is the token my bots token from the dev portal or does top.gg have their own special one
click regenarate button
I have
Refresh after doing so
v1 isnt released yet
Oh
Oky
when release v1
hello
I want help with the top.gg API
can we change the API cooldown
like changing 12-hour vote to 24 hour?
nope
umm ok
Is there an évent emitted when someone's vote expires ?
?
Vote works on mobile right?
Yes
Ok it worked
test your webhook by using a request client such as postman
the test vote button may not work or get through very late
how can i get the vote count of my bot?
can i have the example POST data sent to a webhook?
perfect, thanks
so what are you lost on?
webhook url is the url to your server
http://yourIP:port/path
^ if your hosting on a vps or home
or anything that provides an ip
thats the code for a webhook listener yes
ohhhh
so what does that do
xD
it checks the user voteedd
and sends user has voted
oh ok



