#topgg-api
1 messages ยท Page 136 of 1
^
Scroll up a bit and read the chat
same too
"Error: 504 Gateway Time-out"
Yea
Top.GG is currently experiencing a few difficulties on a few of our routes on our pages. Do not fear, this is known issue and our internal team are investigating and the site should be up shortly - please do remain patient!
i keep getting 500 and 504 error codes so now and then
when either checking vote or sending bot stats
what am I supposed to do if it spits out this error:
<title>top.gg | 504: Gateway time-out</title>
my bot only posts it per 2 hours
nvm
Please just scroll up and read what the others said lol
why this error come ?
18.02 13:49:01 [Bot] (node:42) UnhandledPromiseRejectionWarning: Top.GG API Error: 504 Gateway Time-out
18.02 13:49:01 [Bot] at Api._request (/node_modules/@top-gg/sdk/dist/structs/Api.js:74:19)
18.02 13:49:01 [Bot] at runMicrotasks (<anonymous>)
18.02 13:49:01 [Bot] at processTicksAndRejections (internal/process/task_queues.js:97:5)
18.02 13:49:01 [Bot] at async Api.postStats (/node_modules/@top-gg/sdk/dist/structs/Api.js:94:9)
18.02 13:49:01 [Bot] (node:42) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 23)
๐ Thanks
<script>
var url = "https://top.gg/api//bots/754402720663732395/votes";
$.ajax({
method: "GET",
cache: false,
url: url,
success: function(data) {
document.getElementById('output').innerHTML = data.username;
},
error: function(error) {
//What do you want to do with the error?
},
});
</script>
``` im got "401" error in my website while using dbl vote api. what should i do?
same error
Literally read what i just said
change // to /
Still #site-status
k
how do i catch errors if i'm using the autoposter?
cant see anything in the docs and my console is dying every time it tries to post lol
Is the api down? It seems my vote command isnโt working atm.
Ty ๐
Where do I get my API Key again? I don't remember how to get it (Code is borked and I am nowhere near my home PC)
bot page settings -> webhooks
Thanks
API is returning 504 Gateway Errors, related to #site-status?
Yes
Sweet, ty
My dbl webhook server gives Unauthorized error but I'm sure I typed Authorization correctly
I guess that might be related to #site-status too
otherwise test your webhook with postman for example
ohh sorry i forgot about that
Would it be possible to get a user vote time/user vote expiry time with the individual user vote endpoint?
I imagine it's the same lookup internally
I know it's possible to do and track myself with webhooks, I'm just putting this here as a suggestion for the endpoint
The best way to do that is through https://github.com/top-gg/issues , making a suggestion there
embedding smh
aright sick
Still down
is there a issue with the page as im getting 505 - gateway timeout errors when my bot tries to update the servers in the bot logs
mb thx
the one pinned in this channel
ok thx
how do i get the top.gg token
https://top.gg/api/docs#mybots is blank
{"error":"Failed to lookup view \"docs\" in views directory \"/var/botlist/views\""}
is there any way through which i can make a timeout for top.gg api in case it fails to check vote for the user, try/except doesnt seems to be working. i use python
One message removed from a suspended account.
One message removed from a suspended account.
api is experiencing issues rn
One message removed from a suspended account.
new docs are at https://docs.top.gg but you can't get your token from there. go to the edit page of your bot and hit webhooks then you can copy your token (ik it's not webhook related but it's the general token)
tx
thx
hey is anyone having any idea how much time api normally takes to check vote for a user
ik abt that
im making a timeout in case this happens again
so i wana know how much time should i add in timeout
you shouldn't really make a timeout. you'd be better off erroring to the user and telling them to try again later
try/except doesnt seem to work if checking for votes is failed so i believe the best way to prevent the command from breaking is to make a timeout for checking the vote
@sullen nymph how do you catch an error with dblpy
sorry what
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Show your code
voted = await DBLClient.get_user_vote(self.dblpy, user_id=ctx.author.id)
except:
voted = True```
this is it.....
async with timeout(2.0):
voted = await DBLClient.get_user_vote(self.dblpy, user_id=ctx.author.id)
except:
voted = True```
will it be good to add a timeout like this
Put the try on the line after the first ```
voted = await DBLClient.get_user_vote(self.dblpy, user_id=ctx.author.id)
except:
voted = True```
uh
uhhh
I'll rephrase my point
Are the try and except indented with the same number of spaces?
well i wont make a mistake like that i believe
can u just tell me would it be fine if i use a timeout on the api and if yes what should the timeout be? @sullen nymph
use of async_timeout.timeout to throw a timeout error if the api fails to fetch vote in given time
API misbehaving? Getting a lot of 504s.
I guess it would be fine
so what time should i put
are 1.5 or 1 seconds enough for api to check vote when its functioning normally?
How do we check to see if the user has voted in the past 12 hours?
the thing is the command gets delayed coz of greater time and it isnt very good
so i wanna keep it at minimum
i dont have a webhook url, but when i voted my bot, i got a 504 and then later when i tried again a 502 so im curious if we dont need webhooks anymore?
thats what i thought but im surprised since i dont even have a url in there but my bot still reacted
i expected my bot to just do nothing and the error took me by surprise
Currently, I've been using a manual request:
voteParse = await got(`https://top.gg/api/bots/695011795110461520/check?userId=${message.author.id}`, { headers: { "Authorization": process.env.TOPTOKEN } });
But I have heard that using a webhook might be better. However, I was wondering if I need to store the data from the webhook, and/or make it automatically delete after 12h? Is there any guide to this?
Someone has answered ๐
How would I make that when someone votes bot sends a DM to person who voted?
vote webhooks and using your bots library
I alr know for this but how do I make it to DM someone and to dm them a specific text
const Topgg = require("@top-gg/sdk");
const express = require("express");
const app = express();
const webhook = new Topgg.Webhook("your webhook auth");
app.post("/dblwebhook", webhook.middleware(), (req, res) => {
// req.vote wil lbe your vote object, e.g
console.log(req.vote.user); // 395526710101278721 < user who voted
});
app.listen(80);
imma need some more explanation
does anyone know what this is?
Shards are basically multiple processes of the bot and each process manage a certain amount of guilds
using your bots library fetch the user, and use user.send on them
oh.
yeah but how to fetch it from top.gg api though
how many exactly?
how would i post shards correctly to the topgg api if i use internal sharding?
not sure how you can get shard id...
idk i am dumb
Hi i keep running into this error 2021-02-18T21:14:56.591712+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: Top.GG API Error: 504 Gateway Time-out 2021-02-18T21:14:56.591726+00:00 app[worker.1]: at Api._request (/app/node_modules/@top-gg/sdk/dist/structs/Api.js:74:19) 2021-02-18T21:14:56.591728+00:00 app[worker.1]: at runMicrotasks (<anonymous>) 2021-02-18T21:14:56.591728+00:00 app[worker.1]: at processTicksAndRejections (internal/process/task_queues.js:93:5) 2021-02-18T21:14:56.591729+00:00 app[worker.1]: at async Api.postStats (/app/node_modules/@top-gg/sdk/dist/structs/Api.js:94:9) 2021-02-18T21:14:56.591737+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4929)
wait would this work? nvm i dont have an idea how to do it
that I don't know myself but it is basically needed at a certain guild count
I read that already
you are not helping me by telling me to read news they did not direct my problem at all
the api is still iffy and times out
it`s annoying bc i get this error every secoend
looks like a proper webhook setup to me.
you will need to fetch the user using whatever bot lib your using, then send, but yeah, that works fine.
you will also need to fill in the url and auth on the website
dont use port 80
use a less common one
such as 5000 or 8080
ok
I'm trying to send a message to whoever votes for my bot and this error is happening (Cannot read property 'id' of null)
@spice merlin go where you edit your bot and go to the webhook and here is your token
Y do I get this
its a good idea to catch potential errors
Been getting 504 errors
#site-status related
this code should work for webhooks right?
i am not recieving anything in my console and am very confused, any help is appreciated
yes
apitester works
Did you add the webhook url?
yep
Did you save before testing?
tried using a bare express server as well, seems like nothing happening
yes
there's no reason why it wouldn't work with an AWS dns right?
oh I figured it out......
I never added http:// to the beginning of the webhook... feel stupid now lmao
Sorry about that
Vv
Does posting to the api still work the same as before?
Hey
anyone not able to test the webhook on discord servers
please check #site-status
what do I use then?
how do we use webhooks to send guild count ? Idk how webhooks works
help
Can i link to news website auto post in discord?
Yup still hasnt been fixed yet ig
const client = new Discord.Client();
const AutoPoster = require('topgg-autoposter')
const ap = AutoPoster('topggtoken', client) // your discord.js or eris client
Can this work?
try it and see
try it and see
Ok
I am using this
And it's not posting the stats
Is there any mistake on it?
this poor top dude 
api is getting trouble ?.
yeah i've seen
click it - if data is logged as expected it works
just to clarify what is written in #site-status, is the api still completely broken? it says that api/v0 is working, does that include server count posting?
votewebhooks are dead too it seems
(node:36) UnhandledPromiseRejectionWarning: Error: 504 Gateway Time-out
I Am Getting This Error
yes it is
TopGGAPIError [Top.GG API Error]: 504 Gateway Time-out
it is
Do you people think about reading #site-status
@gilded orchid @uncut lintel @restive otter
Hata var hata
APIda sฤฑkฤฑntฤฑ var
Turk -> #general-int
how do i add the servercount on the website?
how long will it take to display stats?
TopGGAPIError [Top.GG API Error]: 504 Gateway Time-out
just got this
nothing to worry about?
i keep getting this as well it hasnt gone away since sometime yesterday
not really top.gg api related
but the simple answer is some of them are broken and some of them are not
is it related to the top.gg api
Whats up sorry?
@restive otter they are aware of this issue.
If you take a look in #site-status it will cover the issues
im having issues with posting stats (js)
const DBL = require("@top-gg/sdk");
const dbl = new DBL.Api(config.top_ggToken);
client.on('ready', async () => {
dbl.postStats({serverCount: client.guilds.cache.size}).then(console.log);
}``` this results in a 504 timeout so is this a me problem or a topgg problem? the announcement did say everything *should* be fixed
server count if only server count is posted
because you can't post shard count without the server count
alright thanks
Hi, I'd like to make a command like this.
When you type this command, I want you to vote.
The api doesn't have votes like that. You can just link to the vote page
yeah you can't vote in behalf of the user
``const Topgg = require('top-gg/sdk')
const api = new Topgg.Api('you token')
module.exports = async (client) => {
setInterval(() => {
api.postStats({
serverCount: client.guilds.cache.size,
shardId: client.shard.ids[0],
shardCount: client.options.shardCount
})
}, 1800000)
}``
this would be the best way to post your status on top.gg
@lyric bay
im not sharding yet but thks
and i do have the interval i just didnt include it in my minimal example
also use
```js
//code
```
const Topgg = require('top-gg/sdk')
const api = new Topgg.Api('you token')
module.exports = async (client) => {
setInterval(() => {
api.postStats({
serverCount: client.guilds.cache.size,
shardId: client.shard.ids[0],
shardCount: client.options.shardCount
})
}, 1800000)
}```
๐ฎ
I prefer it so sincerely
you did two not three
@bleak canyon I have a question that I'd like to ask you in a DM
Is there any way to make a custom command that will trigger the bot to perform a command?
dont you just a command?
are you looking for webhooks?(receiving when votes happen)?
I'm trying to compile a random response command and I want the bot to perform one of its own actions and I can't get it to work.
I have a bot that does the vote logs for me but I do want to make a command for users to !claim 200 of this currency we use in the server after a succesful vote
you can just use the has voted method, or keep track of votes yourself.
huh thats cool
i havent heard being able to run bot commands in other bot commands
you might have to change the structure of your commands and make them all functions
and work from there
is there a api wrapper for python?
thanks
My webhook keeps saying 401 unauthorized.
Its not authorizing
Ping me if you know thanks c:
const Topgg = require('@top-gg/sdk')
const dblapi = new Topgg.Api(process.env.DBL_KEY)
dblapi.postStats({ serverCount: bot.guilds.cache.size})
its giving a error: Missing Server Count
ping me please
Are you using bot or client in your discord.js
In how many languages is vote counting api available?
Is there any way, i can log votes in any external space not in bot?
how can i get api key ?
Get a bot that's approved on top.gg first, then you'll be able to access its API key in the Webhooks section
@barren kestrel im using bot
And if im doing this same thing with eval that working without any error
you should probably use the topgg autoposter instead
What you'r mean ? @shy vortex
Ok let me see this
is it possible to make server count on top.gg with discord bot maker?
not sure what i gotta type into : Webhook URL
On the weebhook part of your bots edit page.
.route 24
My webhook keeps saying 401 unauthorized. I have the right authorization password but im not sure if my url is correct.
https://NewsAgent.develite.repl.co/dblwebhook
Thats what I put there. But how do I know?
Im using repl to host
The url seems fine
Your auth is the same in your code and in the bots edit page right?
@rain heart is issues has been solved?
#site-status not as of now
c'mon
wdym
In my code where do I put that url
and thats the url in my bot eedits page
No where
ok
I'm asking about the auth
Double check its exactly the same
It is..
Ill send code
Of the main part
and the eror
one sec
Error
Index:
https://gist.github.com/EliteHaxy/0217cbeb5e6656f85095ff78ce20cc77
config: (without the main stuff)
https://gist.github.com/EliteHaxy/dc5f839ce95bffa1db8edc915de7eb80
@jaunty plank
The error isn't with the webhook
Im using this
@signal hawk is this a known issue with the api right now?
401 Unauthorized with the correct token
not as far as im aware
TOKEN=fattoken
TOPTOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjgwMzk2OTQ5NDU4NTE4MDIzMCIsImJvdCI6dHJ1ZSwiaWF0IjoxNjEzODM0NjgxfQ.nx1Pk6TbKoad7QZgBpUIwPtBwhiIkafAR6fxIh6CWUk
WEBHOOKAUTH=bob```
the toptoken i have regened so that isnt my current
and my auth isnt the same
but thats how I formatted
Do I need to put a comma inbetween the lines?
its called
config.js
@jaunty plank
Yeah but you already are.
You have the string "topgg token" not the token
Lol, we both missed it
Again? Ok one sec
np
just to be sure, you changed
const ap = AutoPoster('topggtoken', client)
to
const ap = AutoPoster(config.toptoken, client)
and changed your env variable to the new token right?
Yes
Iโm on mobile but I did do that
@jaunty plank ping me if you find a reason. Appreciate the help!
c:
which is just two lines, so im not sure if the token is correct theres zero reason for it not to work
like checking if someone voted?
personally, I would track votes in your own database with the webhook, however you can use the has voted method to check if someone voted
Yes
Ok
@jaunty plank so it didn't send an unauth error but after I run my votecheck it does this
so, that error means the token is incorrect.
whatever is in your env variable is not right.
...
Ok
Let me show you everything
@jaunty plank not real tokens
so to me, everything looks right, the only thing I cannot validate is the token, which is what the error is about.
the auto poster isnt the problem, the token your using with the autoposter is
Im posting server count and I want a vote check command
const Discord = require('discord.js');
const client = new Discord.Client();
const config = require('./config.js');
const Topgg = require('@top-gg/sdk')
const api = new Topgg.Api(`${config.toptoken}`)
const express = require('express')
const app = express() // Your express app
const keepAlive = require('./server.js');
const webhook = new Topgg.Webhook(`${config.topggwebhookauth}`)
module.exports = {
name: 'votecheck',
description: 'Check if the user has voted for News Agent on top.gg',
execute(client, message, args) {
client.hasVoted(message.author.id).then(c => {
if(c) {
message.channel.send(`Yay ${message.author.username}! You voted for me on top.gg! Go tell all your friends to vote as well!`)
} else {
message.channel.send(`:o ${message.author.username} you haven't voted for me yet! Go vote for me now!\nn!vote`)
}
})
}
};```
Does this seem fine?
This votecheck
i dont need webhooks const tho
mb
Are you familiar with using request clients? Just to make sure it isn't a problem on your code
such as postman?
Is it just making the requests to get the vote?
alright lemme test on my end
ok
const Discord = require('discord.js');
const client = new Discord.Client();
const config = require('config.js');
const Topgg = require('@top-gg/sdk')
const api = new Topgg.Api(`${config.toptoken}`)
module.exports = {
name: 'votecheck',
description: 'Check if the user has voted for News Agent on top.gg',
execute(client, message, args) {
client.hasVoted(message.author.id).then(c => {
if(c) {
message.channel.send(`Yay ${message.author.username}! You voted for me on top.gg! Go tell all your friends to vote as well!`)
} else {
message.channel.send(`:o ${message.author.username} you haven't voted for me yet! Go vote for me now!\nn!vote`)
}
})
}
};```
and it does not work at all?
@rain heart my updated thing
like not even once?
yeah im testing it manually
k
i get no errors when I run the bot
@rain heart I get this error when I run
How do I find if the user voted
code
you seem to be using the wrong method
hm
what is client?
oh
then what do I use
it said htta inthe docs
im dumb
Idk what to put there
topgg
?
or api
op api
?
yeah i can confirm it is your code
api.hasVoted(id)
what is client
ok
check what you defined as client
I defined it wrong
const Discord = require('discord.js');
const client = new Discord.Client();
const config = require('config.js');
const Topgg = require('@top-gg/sdk')
const api = new Topgg.Api(`${config.toptoken}`)
module.exports = {
name: 'votecheck',
description: 'Check if the user has voted for News Agent on top.gg',
execute(client, message, args) {
api.hasVoted(message.author.id).then(c => {
if(c) {
message.channel.send(`Yay ${message.author.username}! You voted for me on top.gg! Go tell all your friends to vote as well!`)
} else {
message.channel.send(`:o ${message.author.username} you haven't voted for me yet! Go vote for me now!\nn!vote`)
}
})
}
};```
does this seem fine
te
Oh ok
does that seem fine
try it and see, if it still says hasVoted doesn't exist
ok
@rain heart @jaunty plank I get this error
Code:
const Discord = require('discord.js');
const config = require('config.js');
const Topgg = require('@top-gg/sdk')
const api = new Topgg.Api(`${config.toptoken}`)
module.exports = {
name: 'votecheck',
description: 'Check if the user has voted for News Agent on top.gg',
execute(client, message, args) {
api.hasVoted(message.author.id).then(c => {
if(c) {
message.channel.send(`Yay ${message.author.username}! You voted for me on top.gg! Go tell all your friends to vote as well!`)
} else {
message.channel.send(`:o ${message.author.username} you haven't voted for me yet! Go vote for me now!\nn!vote`)
}
})
}
};```
is your token valid?
don't have it load through your config
`${config.toptoken}`
ok
Yay! i thinkit works. let me check my webhook.
Ok my votecheck works
my webhook doesnt send data when I vote
Any idea? @rain heart
Yes
I want it to send a message through webhook to a channel
I have webhook done
ye
Ok
There
is that the right url?
oir do I need the actual discord webhook url
how do i get a api key
bot page settings -> webhooks
thank you
don't you have to set ports you want to use or something?
Ok
never used repl in my entire life
Hm ok
ye 3000
though i can confirm the webhook is running as by the response
The thing is where do I put my discord.com/webhook stuff in my code
on your app.post
But where in it
I donโt see the docs for it
I usually donโt use webhook through code so idk how to do that
discord webhooks have to go through your bots library
Ok
So can you guys give an example xD. Idk what to put there my webhook irl?
Url
From the interactions page in my server
depends on which bot library you use
Djs
Ty
Iโm using 3000 for my host on repl
So can I not use anything else?
i cant remember how many ports repl allows
There is such an error when I write the total number of servers on the site.
it might just be 1
Eek
i belive thats a known issue, #site-status
-9000 might work
ports dont go negative
9000*
if you absolutly need multiple things on the same port you can just put them on diffrent endpoints
Ok
just note you cant have multiple listeners
it kinda depends
K
the best way to explain it is building an api
Ok
And then for webhook show would I use them here I saw that website but I know that much so far
How would integrate it into top.gg
Thatโs what I need to know
Does anyone have an example?
Bruh Ik that but what do I put there
The djs code and that donโt seem to connect
Do I just send the variable?
you can send whatever you want, personally I would send an embed with the data I want to send
Ok
which is covered in the page i sent
K
@jaunty plank does this seem right
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
// req.vote is your vote object e.g
console.log(req.vote.user) // 221221226561929217
dwebhook.send(`${vote.user} has voted for News Agent on top.gg!`)
})
havent tested
did you initialize the webhook client anywhere?
the url isn't valid
trying to make a request now to your webhook just tells me Hmmmm.... We Couldn't Reach Your Repl
const dwebhook = new Discord.WebhookClient("812503692866748417", "ezduqzDkHNkfl-0E_0VWLzMTa3_2VKDNE3LKdRhKlDJniFBYdPgfvE6dKARdow6PnJrB")```
What's the new url?
wydm
one sec
not your discord webhook
your vote webhook
you can't use a discord webhook on top.gg
you need to have your own webhook that then sends data to your discord webhook
hes not trying to is he ๐
hes trying to forward the top.gg webhook to a discord webhook, which is what this code does.
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
// req.vote is your vote object e.g
console.log(req.vote.user) // 221221226561929217
dwebhook.send(`${vote.user} has voted for News Agent on top.gg!`)
})
which looks correct to me.
his webhook he has to enter on top.gg (the one they mentioned previously) does not work anymore
unless they changed something on it
Oh
Ok here
My webhook keeps saying 401 unauthorized. I have the right authorization password but im not sure if my url is correct.
https://NewsAgent.develite.repl.co/dblwebhook
Thats what I put there. But how do I know?
Thatโs my old message
Iโm on mobile
But there is the link @rain heart
the webhook is? or the vote is?
Wdym
hopefully the link works
whats your actual error
i'll see my way out now
getting the same issue as before, cannot post dblwebhook
port 9000 doesnt work, i think only 3000 works
repl as a free platform has a lot of restrictions
Ye
i dont think you get 2 ports
8080 should work
ok
so, whats the other thing that needs a port?
I changed my host port to 8080 and my webhook to 3000
but still when I go to
i get cannot get/dblwebhook
you dont visit the webhook url
Hi, Where go the votes rewards when the bot have 100 votes?
no, since something is listening on that port it wont.
the webhook is listening on that port
so whats wrong with my code then
k
did you test your webhook on the site?
did it long in the console?
bruh where I have 2 diff ports
so does it receive the request then?
then its not receiving the request
๐
it worked when you had only one thing on it
as tested by hope
lol
every time you changed the port it didnt work
every time you put it on the main port it worked
so ๐คทโโ๏ธ
at this point i cant just keep saying the same thing
the main port is 3000?
When did it work..
I also never had it on 1 port only...
its on 3000 rn
sec
im too frustrated to do it
cannot post
remove your other thing
adding 3000 to the request doesn't work either
ok
https://newsagent.develite.repl.co/dblwebhook tells me cannot post path
so if I want my webhook to work I need to not have hosting
what if I made a nother replit file with my webhook in that
sure
you can do whatever you want in that file
just copy everything except my discord bot token for my config.js?
Like how would I use a webhook in that?
cause then id need to login with my discord bot token
then login? you can login on a bot multiple times
it would be smart to disable most intents on the second instance.
ok
const fs = require('fs');
const Discord = require('discord.js');
const client = new Discord.Client();
const config = require('./config.js');
const Topgg = require('@top-gg/sdk')
const api = new Topgg.Api(`${config.toptoken}`)
const express = require('express')
const app = express() // Your express app
const webhook = new Topgg.Webhook(config.topggwebhookauth)
const dwebhook = new Discord.WebhookClient("812503692866748417", "ezduqzDkHNkfl-0E_0VWLzMTa3_2VKDNE3LKdRhKlDJniFBYdPgfvE6dKARdow6PnJrB")
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
// req.vote is your vote object e.g
console.log(req.vote.user) // 221221226561929217
dwebhook.send(req.vote.user `has voted for News Agent on top.gg!`)
});
app.listen(3000)```
This and my env and config is all I have
is that all I need
or do I need ot login with my bot?
@jaunty plank
Sorry for ping
if your just using a webhook you wont need to login iirc
index.js
ye so what should i remove then?
dont think you need to remove anythign
Ok
So I started my thing
it should work now?
Ill remove the webhook stuff in my main file?
update the url to the new one on the site
Ok
Nope nothing
wait
It sent an error!
@jaunty plank
const fs = require('fs');
const Discord = require('discord.js');
const client = new Discord.Client();
const config = require('./config.js');
const Topgg = require('@top-gg/sdk')
const api = new Topgg.Api(`${config.toptoken}`)
const express = require('express')
const app = express() // Your express app
const webhook = new Topgg.Webhook(config.topggwebhookauth)
const dwebhook = new Discord.WebhookClient("812503692866748417", "ezduqzDkHNkfl-0E_0VWLzMTa3_2VKDNE3LKdRhKlDJniFBYdPgfvE6dKARdow6PnJrB")
app.post('/dblwebhook', webhook.middleware(), (req, res) => {
// req.vote is your vote object e.g
console.log(req.vote.user) // 221221226561929217
dwebhook.send(req.vote.user `has voted for News Agent on top.gg!`)
});
app.listen(3000)```
Ok so I got it I think
Thats the user id right?
yeah
for it to work yes
ok
but the thing is
whenever i use my host
my webhook doesnt wpork
should I just use uptime robot to ping it every 10 min?
that would keep it online yeah
Would i just put this in my bot if i am going to be internally sharding? Or would I remove the serverCount line
yeah, just use that iirc
Im trying to say if the command contains a mention, find if the mentioend suer has voted
const Discord = require('discord.js');
const config = require('../config.js');
const Topgg = require('@top-gg/sdk')
const api = new Topgg.Api(config.toptoken)
module.exports = {
name: 'votecheck',
description: 'Check if the user has voted for News Agent on top.gg',
execute(client, message, args) {
api.hasVoted(message.author.id).then(c => {
if(c) {
message.channel.send(`Yay ${message.author.username}! You voted for me on top.gg! Go tell all your friends to vote as well!`)
} else {
message.channel.send(`:o ${message.author.username} you haven't voted for me yet! Go vote for me now at https://top.gg/bot/803969494585180230`)
}
})
if (args[1] === mentions.members.first()) {
api.hasVoted(args[1]).then(c => {
if(c) {
message.channel.send(`Yay ${message.author.username}! You voted for me on top.gg! Go tell all your friends to vote as well!`)
} else {
message.channel.send(`:o ${message.author.username} you haven't voted for me yet! Go vote for me now at https://top.gg/bot/803969494585180230`)
}
})
}
}
};```
But it doesnt work
how do I even get an api?
is there any other way?
no
๐ Hi, I'm waiting for my bot to be added but figured I'd set up my webhook endpoint in advance (using Postman to test it) and was wondering what body encoding the webhook uses?
I have the schema https://docs.top.gg/resources/webhooks/#schema - it just doesn't mention if it's application/x-www-form-urlencoded or multipart/form-data (or something else I haven't accounted for)
I'm assuming application/x-www-form-urlencoded for now and have it correctly sending a message to the user and giving them the 'reward' for it at least
it's neither of them. The data you're receiving is application/json
You would receive something like
{
"user": "12345",
"bot": "12345",
"isWeekend": true,
"type": "vote",
"query": "1=2&3=4"
}
Thanks - much appreciated โค๏ธ
Edit: it's now working with application/json so I'm ready when/if the bot gets approved ๐ Thanks again ๐
Follow-up question: are IP addresses supported as webhooks? I.e. mine would be something like http://X.X.X.X:6969/voted-for-bot currently as I don't have a domain for it
Thanks again ๐
does the webhook work with discord's inbuilt webhook feature?
like could i set up a channel for top.gg webhooks and itll be fine with that?
probably not 
on_dbl_vote get all new votes on my bot, right?
in real time, yes
Best way to do server count across multiple shards on different physical machines in python?
ig you can post the server count of a specific shard, not sure if you'll get ratelimited. If that's the case, why not fetch the server count from all processes and make a single request?
I'm trying to post server count to api with post request but even i give the server_count data, it saysjs {"error":"Required parameter server_count or shards missing"}
My data:
{
"server_count":100
}```
I'm using
https://apitester.com/
Python related question, how can I check if a user has voted on my bot?
I know how to print the info and store it etc.
So I've been thinking to stamp when this person voted then check if more than 12 hours has gone by, but it seems like there's an easier way.
But I am not sure what that is, help?
Webhooks
Yeah that helped me
๐ You're welcome

You can use aiohttp.web or dblpy to get a webhook running. Top.gg will send you vote data when someone votes to your webhook if you set everything up correctly
Yes I know that, but.
Let's say I have a command, and I want to check before the command if the user has voted? Is there an easier way for me than "So I've been thinking to stamp when this person voted then check if more than 12 hours has gone by, but it seems like there's an easier way."
https://docs.top.gg/api/bot/#individual-user-vote, though ig it's better to track it with webhook to reduce outgoing requests
it can be used for something like where the user voted from
you could for example have a notification reminder, redirecting the user to https://top.gg/bot/botid/vote?votereminder, with which you can determine that the user voted through the reminders
if you dont need that, you can safely ignore it
well tbh, i do need it, i was just wondering if there was a way to correspond the webhook data to the api call of if someone voted (through some id mapping)
so i was wondering if the notrandomnumber was like an id i can verify to see if there was a way to fetch a vote_id of some kind for the last person that voted through the api and verify if a webhook data corresponding to it has already been stored, etc.
but, anyways, thank you
you can use whatever you want, you just need to send the user the url with the query
then getting the query through the webhook data
So is there going to be a v1 of the API? If so, do you know of any major differences to v0?
also reviews API endpoint when
im tired of scraping
review endpoints are possibly going to be a part of it, yeah
though there's no eta on when v1 gets released
rip
You could make a cooldown when the vote is done
Save it into a database and make a cmd called vote and shows how many time left for next vote
Do you do python and databases?
-botinfo 796490771452788736
That bot wasn't found
-botinfo 796490771452788736
That bot wasn't found
-bots @graceful merlin
both
@rain heart any progress?
Has anything changed on the pinned messages or is there anything new in #site-status?
ok
Do you have your own mysql database or? If so or whatever you use can you learn me please?
I have a server and wish to give the voters some extra features. So i added a reward role but whenever i try to submit it the page reloads and shows this message. The bot is above all the other roles and has manage roles turned on, but my voters aren't getting the role.
#site-status and pinned messages in #support
Ah thankyou

okie
can someone help me with vote webhooks
python and discord.py
btw
ping me when u reply
webhook still cant function right now?
-botinfo 804295231838355466
That bot wasn't found
-bots 804295231838355466
This user has no bots
-bots 668740503075815424
This user has no bots
hi can someone help me with vote webhooks for my bot
just ask your question
dont ask to ask
lol
-bots 812217484970557451
This user has no bots
can someone help me with vote webhooks
python and discord.py
btw
ping me when u reply when a user votes how do i make it show on the command 12h is left like dank memer but in python
-bots @vapid scaffold
-bots @fickle hemlock
This user has no bots
-bots
aa
@rain heart can you please tell them not to use commands here
apparently they don't understand
it happens more then u think
yes
@fickle hemlock @restive otter
sorry
Its fine, just for next time
why should i upgrade to the auto poster?
Still read #site-status
since it handles the stuff for you and you just need to give it the top.gg token and the client
makes it easier
and also because it works with sharding
remember this
HI
thx
for my PHP friends, I have an API wrapper in the works for top.gg using PHP 8 that I hope to publish next month, currently tied up with other works.
If I query /api/bots without a search string, just limit=1 then why do I only get a total count of 710?
hello, how do i get the api
-bots
-api
-bots
-botcommands
@restive otter
Hey! Bots aren't given permissions to send responses in this channel. Please use #commands to run commands.
next person to run commands in this channel will be muted
-botinfo 711934102906994699
@trail sigil claim your free mute
pog
Itโs like someone disabled read message history for that dude lmfso
-m @fickle zealot running bot commands in #topgg-api (the last message in the channel says 'next person to run commands in this channel will be muted', but still they ran a command) | 3 days
๐ค Muted justjude#2296 (@fickle zealot)
sure you can
How i can get the Logo?
https://top.gg/images/logo.png though just ask in #general next time
I have but there are to many people
And thank you
when does the api/bot/id/votes reset
Need answers for the administrator perm users to my server who cannot edit the server on top.gg, is it still due to the current API from the recent update.. 
Just wait for it
Okay
do you need to auth yourself first before sending requests, or is auth required per HTTP req?
per request through the Authorization header
thank
I assume this requires requoting the URI path so that it's format-safe in a URL response, correct? https://i.imgur.com/fLnIXHB.png
additionally, for when you input value is this for a singular instance being passed, or can it handle multiple instances under 1 field? can I declare a list through this search feature as well?
Hey there! Wich protocol is needed for vote webhook ?
UDP prob
most of the api reqs seem UDP based
ok thanks, will try wit udp then 
WTF are you lot on
you want TCP not udp
How so I should use TCp ๐ญ
yes you should use TCP
hm ok :3
Hi! I have a question. Can I use the API from Top.GG in one bot, to record the votes from another bot? (Both bots are from my property)
You are allowed to do that, as long as you're not rewarding users for voting for another bot
Okay. And if I want to reward the users for voting the other bot, from my property? That is not allowed, isn't it?
Okay, and if the reward is some money, from a fictional economy system, that will be the same?
I want to be sure to not break the rules, I'm sorry if I'm a bore
Is it only me or the API is not working?
it used to work, but now it isnt
it doesnt give my bot votes
just stopped doing it
how can i show the guild count on the overview
So does the /check endpoint display total votes or just daily votes?
