#topgg-api
1 messages · Page 160 of 1
Should probably edit that
I'm not sure if a sane person would think this is comprehensible
Does anyone know how I can get the number of servers that my bot has on the page?
can i get who voted for my bot using an api instead of using webhooks?
How to use the top.gg vote api
Means when anyone vote our server the bot will embed the message
@violet sorrel djs or dpy
module.exports = (client) => {
console.log("-------------------------------")
console.log(`Logged in as ${client.user.tag}!`)
console.log("-------------------------------")
client.user.setPresence({
status: "online",
});
client.user.setActivity('e!help', { type: 'WATCHING' });
//topgg stats
const Topgg = require('@top-gg/sdk')
const api = new Topgg.Api('my topgg api token')
setInterval(() => {
api.postStats({
serverCount: client.guilds.cache.size
})
}, 1800000) // post every 30 minutes
}
any ideas why this isn't working?
topgg-autoposter won't work as well, it returns Unsupported Client
But where can i das which bot is mean by the vote
What exactly do you mean by that?
The payload has a bot field which is the ID of the voted bot, if that's what you mean.
The API will nim the Bot from client.run ?
I have a question:
const fetch = require("node-fetch");
let url = `https://top.gg/api/bots/${bot ID}/check?userId=${user ID}`;
fetch(url, { method: "GET", headers: { Authorization: `${your top.gg bot token}` }})
.then((res) => res.text())
.then((json) => {
var isVoted = JSON.parse(json).voted;
if(isVoted === 0) return message.channel.send("No");
else return message.channel.send("Yes");
});
How can I get my top.gg bot token?
Here
@sullen nymph 😦
just refresh it
how to get my topgg api?
How can I fix this?
has been resolved
hey how i can put the server count in my bot?
. fef
Pls help
I have the Same Problem
Thanks
I keep getting the error
AttributeError: aexit```
everytime I try to post the guild count
I'm using python wrapper of the api
and this is my code
dbl_token = tings
client.topggpy = topgg.DBLClient(client,dbl_token,autopost=True)
@client.event
async def on_autopost_success():
channel = client.get_channel()
await channel.send(f"Posted server count ({client.topggpy.guild_count})")
@client.command()
async def update_stats(ctx):
await ctx.send("triggered")
# try:
# a= await client.topggpy.get_guild_count()
# await ctx.send(a)
# except Exception as e:
# await ctx.send(e)
try:
await client.topggpy.post_guild_count()
await ctx.send(f"Posted server count ({client.topggpy.guild_count})")
except Exception as e:
await ctx.send(f"Failed to post server count\n{e.__class__.__name__}: {e}")```
my token was actually there lmao
You shouldn't try to fix a car if you don't know what an engine is
Update topggpy
alright bet
so to see a person has voted on top.gg, I should send a request to top.gg/api/bots/<bot_id>/check?userId=<user_id>?
nvm
Un
or you could tell him what an engine ise.
nvm
not sure if this is the place to ask this but,
i did this and it says "dbl-stat deprecated" on my website
This is what it what I did
<dbl-stat bot-id="bot-MyBotId" stat="guilds">Loading...</dbl-stat>
also, where do I find my dbl token
Not the place and u can find it at the bottom. Regenerate Token
Where's that
Oh yeah
it doesnt work anymore
That and this ain't the place, yeah
yea i was told

hi guys
i am adding a webhook to my bot, but
when i click test webhook
the webhook doesn't actually go through
i tried it with postman, and it worked so its not the fault with the webserver
ok now it worked
where is webhook password stored ?
link to the page please
import discord
from discord.ext import commands
import topgg
client = commands.Bot(command_prefix="--",member_cache_flags=discord.MemberCacheFlags.none())
# This example uses topggpy's webhook system.
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("/dblwebhook", "pass")
# The port must be a number between 1024 and 49151.
client.topgg_webhook.run(5000) # this method can be awaited as well
@client.event
async def on_dbl_vote(data):
"""An event that is called whenever someone votes for the client on Top.gg."""
print(data)
if data["type"] == "test":
# this is roughly equivalent to
# `return await on_dbl_test(data)` in this case
return client.dispatch("dbl_test", data)
print(f"Received a vote:\n{data}")
@client.event
async def on_dbl_test(data):
"""An event that is called whenever someone tests the webhook system for your client on Top.gg."""
print(f"Received a test vote:\n{data}")
client.run("token")``` is anything wrong here ?
Aah
Ig it should work I am also trying to work on this now
it isnt working
Hmm
Euh is it known that the webhook menu of the edit page is broken?
And widgets
and announcements
and analytics
try logging in and out
F5
F5?
refresh the site while being on the broken page
how do i get the headers from the vote webhook post request?
the auth token or whatever it is
@dapper copper
nvm found out how
Do the test webhooks work?
import dbl
import json
with open('config.json', 'r') as config_file:
config = json.loads(config_file.read())
class Vote(commands.Cog):
def __init__(self, client):
self.client = client
self.dbl = config["dbl"]
self.token = self.dbl["token"] # set this to your DBL token
self.dblpy = dbl.DBLClient(self.client, self.token, webhook_path='/dblwebhook', webhook_auth=self.dbl["password"], webhook_port=self.dbl["port"])
@commands.Cog.listener()
async def on_ready(self):
print(dbl.__version__)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print('Someone voted')
print(data)```Because this isn't triggered
yes the do you get a event on the provided endpoint with you userid
Because this isn't triggered
This is the third time I am trying to figure this out
As always I barely get help here which leads me to abandon it for another month
Does it show 405 when you do a GET request through your browser? Is the port open? Does the auth match the one on the site? Also, it's advised to migrate to topggpy.
where i find my api?
It doesn't show how many servers my bot is on, why?
-servercount
To have your bot's server count displayed on Top.gg, please read the documentation on server/shard posting.
Alguien me pasa la api de topgg
Can anyone help me to do this in my bot?
Here's a documentation about posting server count in to your bot's page https://docs.top.gg/libraries/javascript/#posting-bot-stats
how i can get dbl api ?
I have read it but can not understand how to do work?
can you help me?
you're just gonna have to copy what's in the documentation and run the file
You already have the code snippet
bro i did b8 the whole coding gives error
@restive otter Here's a documentation about posting server count in to your bot's page https://docs.top.gg/libraries/javascript/#posting-bot-stats
Ty
You're welcome!
if you know to make a http post request, dont use libraries. it just makes it more complex
https://top.gg/bot/BOT ID/webhooks
Error: Cannot find module 'topgg-autoposter'
you don't read my messages, do you?
@fallen nymph
Sorry i am Just Kinda Feeling not Good rn
You need to host your own webhook service in order to receive webhooks from topgg.
Discord webhooks has nothing to do with that at all.
can someone help me with webhooks
if im using the example on the python page
do i have to make a webhook on the admin dashboard for my bot
over here
What is my webhook url
Do I have to host smtn
Is there any easier way to do this
but idk my ip
And what if it change
My rpi
How
Ok wait
I have a domain
How can I use that shit
@shut flume
nw
Thanks
I think imma just use the manual req/post stuff
umm....i can't understand where am going wrong abt it
🚨ALERT🚨 watch out! ford Fiesta 2018 is on the run killed 1guy 🚨🚨🚨
you will copy the 2. one.
then you can use that to post stats
do u use d.js?
you can use node-fetch
const fetch = require("node-fetch");
await fetch("https://top.gg/api/bot/yourbotid/stats", { method: "POST", body: JSON.stringify({ server_count: client.guilds.cache.size }), headers: { Authorization: "your topgg token" } });
known issues at #support pins
I want to use the API for my bots vote. After going to the page I can't access the widget page,Webhook page.
How can I get the api for vote?
This error always showing
the fuck do you read anything on that page?
What are the api option? or how can I prevent rate limits?
Hi
how to get autoVote instance?
how do i check if the user has recently voted my server?
Js or py
js
const { Webhook } = require('@top-gg/sdk')
const wh = new Webhook('Top.gg server webhook password')
const app = express()
app.post('/webhook', wh.listener((vote) => {
console.log(vote.user)
}))
app.listen(port)```
There
that doesn't explain hasVoted method or that just doesn't exist
Oh sorry
const Topgg = require(`@top-gg/sdk`) const api = new Topgg.Api('Your top.gg token') if(message.content == "test") { const userid = message.author.id; if(api.hasVoted(userid) == true) message.channel.send('voted') else { message.channel.send('not voted') } }
Here
the token will be my auth right?
Yes
also how long will that be disabled??
Wdym
like after a 3h hasVoted will be false
12 hours
oh 
sad that server webhooks r down tho
wait does that only apply to real votes
not just test?
Pls don't copy paste it
i wont
since that wont work cuz message aint defined
the only thing I'll "copy" is the api

I think so
Try it
Or give me your server link i will do it
The voting this
im gonna test it myself 
Check dm@safe comet
pls just leave it to me 
so i have this now so how can i get it to send the server count
The webhook service won’t post your server stats.
Aye
i literall figured it out a second before u said that lol

I'm so confused with webhooks, is it not as simple as installing the api and copying the code?
or do I have to set up server stuff?
does this update everytime someone adds the bot to the server or does it only update when the bot starts
The auto poster should run an interval which updates the guild count every X minutes
Think it’s 30 mins but dunno anymore
You can but that’s not needed.
doesnt use discord webhooks
the webhook url is a url to a webserver you host
that expects a POST request and returns 200 OK
.nw
@shut flume
what is 403 actually
Post stats
Well my bot posted stats without any error
But it gave error now
wait a sec
lemme grab ss
Hmm i am using autoposter to post stats
yep
its top gg token yes
not client
my code btw
const { AutoPoster } = require('topgg-autoposter')
const ap = AutoPoster(process.env.TOP, client)
ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
});```
Ok lemme do it
well i am sure my token is correct. I double checked it
Should I try regen the token?
That's 401
403 is forbidden access
ah ok it worked after regenerating my token lol
ag again erro
error
403
????????????????????????????????????????????????????
it showed me "Posted stats" and again it returned error
Have you tried updating topggjs
yep its 3.1.2 right
@waxen widget-gg/sdk
oof
ping
nvm
This is weird
Does autoposter got any update?
Fuck knows ngl I don't keep up with the JS stuff
You could just report it as an issue on the GitHub repo for the autoposter
ok
Can someone help me with top.gg api? With the webhook hosting thing, im not sure where to begin
same
whats the best way to find out if a user has voted for my bot and then store it to a database? I want some specific commands to work only when the user voted
Dm me
Anyone know about the webhook?
const Topgg = require("@top-gg/sdk")
const api = new Topgg.Api(process.env.APIKEY)
client.on("message", message => {
if (message.content == "+control") {
const userid = message.author.id;
if(api.hasVoted(userid) == true) message.channel.send(':white_check_mark: Voted.')
else message.channel.send(':negative_squared_cross_mark: Not voted.')
}
})```is it true?
code
i voted 15 minutes ago and it still says "not voted"
it is a command>
i found it stackoverflow and never changed
{...} ?
noo
Console:
Promise { <pending> }```
The promise will always log pending as long as its results are not resolved yet. You must call .then on the promise to capture the results regardless of the promise state (resolved or still pending):
userid.then(function(result) {
console.log(result)
})```
umm...resolve promise then??
so how can i use
uhm you need to resolve the promise
Use the variable result
userid.then(function(result) {
^
TypeError: userid.then is not a function```
no
A Promise is an object representing the eventual completion or failure of an asynchronous operation. Since most people are consumers of already-created promises, this guide will explain consumption of returned promises before explaining how to create them.A Promise is an object representing the eventual completion or failure of an asynchronous o...
u need to make a promise there and do .then
learn basics of js before making a bot
Why do you say learn something instead of showing you how to do it?
cuz it doesnt need those .then
api.hasVoted(userId).whenComplete((hasVoted, e) -> {
if(hasVoted)
console.log("This person has voted!");
else
console.log("This person has not voted!");
});```?
because you're just asking code
don't spoonfeed
I tried it and worked lol
ahk
thank you
If you don't know even a simple thing (promises), you have to learn
not asking for code
i deleted await because it gives error
😩
use async in message event
@verbal locust
shut up
oh really
you would have to add more to this code
@rain heart spoonfeed case
It's more than that ok thanks bye
Bruh sorry
you don't even know what you did eyuq

yes because i am 65% mentally retarded
Aurel sorry for spoonfeed
not my problem
and if you're over 8, stop making fun of people with disabilities
your disabilities??
Can we drop it please, thanks
lmao are you serious
Sorry yeah will drop it.
Thank you 

Thanks
Can someone help me with top.gg api? With the webhook hosting thing, im not sure where to begin
I went through this like a 100 times now
Yes
so whats your problem
tried reading pins?
Im still confused where/how to host a webhook
do you use js
Yes
And where do i get the webhook?
https://top.gg/bot/BOT ID/webhooks
how can i use "if someone people voted" event
when someone people voted, send message to #channel
api.on(...) ?
i m on py
js
Ok
while running my bot I got this error
TopGGAPIError [Top.GG API Error]: 403 Forbidden (You don't have access to this endpoint)
how to resolve this?
where in the code do i have to add the thing that shares the server number and shards?
Usually means missing/incorrect API key, invalid endpoint, or not logged in with API
Same I got the same error too
Where i get my bot's api?
do u mean top.gg or discord token?
how to get shard count?
Before there was a thing were I hit submit were is that now?
In webhooks
pls help
Why is it that when someone votes, it is issued several times?
When someone votes, the API sends me 10 requests. Why?
HELP!
i keep getting this error for some reason
You literally cannot GET your webhook
GET is a http method
so what should i do?
Do a proper request if you wish to test it
const client = require("../other/client.js")
const {Webhook} = require("@top-gg/sdk")
const voteWh = new Webhook(process.env.serverWebhookToken)
module.exports = {
run(app){
console.log("Listening to votes.")
app.post("/webhook/vote",voteWh.listener(async(vote)=>{
console.log(vote)
}))
}
}
is this correct :hmm:
Hey, I'm pretty confused with the API, how can I track User ID's of people that vote for the bot? I just want to make a command so that people can claim things if they voted for the bot on that day.
Regarding the port of the webhook, I'm hosting my bot on a hosting service and the server's port is 1111. Is that the port I should use?
You can use requests to check how many votes this user has. Example : /bots/bot_id/check?userId=user_id
would that get the total times they have voted or just check if they voted on that day
Total times they've voted
m well im tryna make it track if theyve voted on that specific day
You want to reward them when they vote or you just want to know when they vote?
reward, but not right when they vote
it'll be a command called vote, and when the person says it, itll either give them the reward or say that they need to vote
Well, you can get the amount of times they voted using this and check if it's 0 ask them to vote, otherwise give them the reward.
The only problem here is that you cannot decrease the amount when they redeem since this is data given from topgg's database itself.
Dude this is frustrating. I've been trying to make it just print the ID of the voter for 2 months now. And there's barely any support or answers when I ask.
What is that exactly?
@hidden crow can you please help me?
Wait for someone to assist you, I’m busy Rn
Okay.
Can anyone give me api to see who had voted to your bot
I cannot access the Webhook section of my bot? Is this because it has recently been accepted?
I join to question
Oh ok thanks
What is the webhook_path?
How to use this?
https://top.gg/api/bots/:855375485529227276/votes
If the command isn't used frequently, sure
Wdym?
What's not clear about my answer?
If you fetch directly from that endpoint, it's gonna get your bot ratelimited if the command is used too often
Ok
can i use middleware like IFTTT with the api?
Doubt ifttt can do it alone as you need to provide authorization etc
I really suggest either using a bot or coding your own
okay, imma just make my own one then
why does it doublesend the vote webhook?
You're probably not acknowledging the request through a 2xx
It retries when it doesn't get one, check docs
it does send a 200 empty body res
- it would retry more than only once if it didnt succeed
it does 204
does it retry bc its 204?
204 should work too
Are you properly closing the connection too?
It also retries when timing out
hold on
i like that ur url is "weebhook" lmao
the heroku app went to sleep and it took some time to get it back online and in the meantime the request got sent again i assume
yep that was the issue
i set uptimerobot to ping the app so it doesnt go to sleep
You don't
when appending the auto-poster to discord's sharding manager, do i append it after the spawn() or before
in topgg py how to message people that "thank u for voting"?
Hello how I can make if someone make vote to bot bot send in room and give him voter
my bot gets ratelimited coz of get_user_vote being used too often, is there any other way to check votes other than this and on_dbl_vote
Caching results
My bot keeps crashing with Error: 520 Origin Error, any way I can avoid it crashing when the site goes down?
Hello, I am trying to use top.gg webhooks, am I doing this correctly?
import discord
from discord.ext import commands
import dbl
class TopGG(commands.Cog):
def __init__(self, Client):
self.Client = Client
self.dblpy = dbl.DBLClient(self.Client, "token", webhook_path="/dblwebhook", webhook_auth="auth", webhook_port=5000)
@commands.Cog.listener()
async def on_dbl_vote(self, Data):
print(Data)
@commands.Cog.listener()
async def on_dbl_test(self, Data):
print(Data)
def setup(Client):
Client.add_cog(TopGG(Client))
But nothing is printed when I test the webhook?
am I supposed to put the IPv4 address in the "Webhook URL"?
hey can anyone help me with the webhook of top.gg for getting vote notification when someone voted?
I have tried a lot but nothing is working
I solved it by using ngrok.
Your webhook URL will be http://your.ipv4.address.xxx:port/dblwebhook
I know, I had to port forward but I am too scared to do it, so I just used ngrok
Ah well if it works it works
HELP!!
You don't respond to the webhook requests
how can we do n/a to server count
You can't
why
Because God knows
Oh fuck's sake
pls do not abuse here
i cant know so i ask na
no
You can refer to official Top.gg documentation if you want to use the API directly yourself (docs.top.gg), or use a library that simplifies the process for you
can any tutorail
aviable
docs have full tutorial
you can check it
off now kholi kam mean 6 laga ga
can you pls give me exact link @restive otter
docs
stop going off-topic first
How lazy are you
shivaco literally gave link here docs.top.gg
Literally go to https://docs.top.gg and find it yourself for whatever programming language you use for your bot
lol
it to easy
sos
const fs = require("fs");
const keep_alive = require('./keep_alive.js')
const { Collection, Client } = require("discord.js");
const client = new Discord.Client() // Your discord.js or eris client (or djs ShardingManager)
const { AutoPoster } = require('topgg-autoposter')
const client = new Client();
const ap = AutoPoster('Your Top.gg Token', client)
client.commands = new Collection();//Making client.commands as a Discord.js Collection
client.queue = new Map()
require('discord-buttons')(client)```
is this right
or wrong
Try it
asddh how am i supposed to send the userID and not the word snowflake...
In a string
like "snowflake"?
What are you trying to do is my question
oh
so basically I'm appending snowflake onto herokuappname/webhook/discord/serverid/token
and it's not sending the userID, instead it's sending the word snowflake
like: herokuappname/webhook/discord/serverid/tokensnowflake
what's a middleware?
import topgg
This example uses topggpy's webhook system.
bot.topgg_webhook = topgg.WebhookManager(bot).dbl_webhook("/dblwebhook", "password")
The port must be a number between 1024 and 49151.
bot.topgg_webhook.run(5000) # this method can be awaited as well
what password do we need to add here ?
While registering a webhook url, we have to make a route on our server for example say /webhook and then listen to whenever a request is made to this endpoint, right?
Correct
Any you want
oh okok thanks
Is on_dsl_vote triggered on voting bot or server?
server
dsl = discord server list
I see, I guess I found some errors in docs then
DO I HEAR MISTAKES IN DOCS
A?
What do you mean?
Yeah a small typo, I made a PR for that already
Wtf how tired was I when writing it
can we not use webhook for the on_dbl_vote event to trigger?
or do we need to have a webhook
Well without a webhook there's no receiver
You may be sending crap like wherever but it needs to be received and processed
Sooooooo
No webhook no vote events
You can use the API yourself but make sure you follow ratelimitz
ye
@sullen nymph how do i set up my bots webhook?
WebhookManager.dbl_webhook weeeeee
i mean how do i make my webhook url?
http://your.machine.ip.address:port/route
I need help with webhook
Don't we all
ah
Show code
The code is in the pins of this channel. I got no err... But it is not giving the info of who is voting
can we use a discord webhook?
alr
raise ValueError("path should be started with / or be empty")
ValueError: path should be started with / or be empty
``` @sullen nymph idk im confused
Don't set your route to the complete URL
It's the /route at the end of the URL after ip:port
||***```js
throw new ApiError(response.status, response.statusText, responseBody);
^
TopGGApiError: 520
Hey
What if someone posts wrong server count?
like someone abuses the api and posts 10000 servers
count
Get 🔨
does anyone know how to make a webhook url with heroku for top.gg? I'm kinda completely lost
Edit channel > Integrations > Create Webhook
from there, you'll see copy url for the webhook
and then what do i have to do after that?
just post that url in the webhooks section of top.gg?
Uh I'm trying to get voting to work. I'm a bit stupid when it comes to these things lol
Like a voting log?
You app should have an URL along with something.herokuapp.com
Oh, I should also mention that I'm using it for the discord bot section
yeah that's what my webhook listener has, although can i just add the parameters at the end or do i have to add that dbl thingy?
Make sure your web dyno is on and that you added the route you use specifically for bot votes to the URL
Im using this but still not getting any response on testing
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("http://my_vps_ip:5000/dblwebhook", "password")
dbl_webhook("/dblwebhook") please
You set up a route on the machine the listener runs. That means you don't set your URL there
oh ok i'll try that
i tried
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("/dblwebhook", "password")
and http://my_vps_ip:5000/dblwebhook in webhook url on site
getting this on reboot:
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f460642a908>
That's just a warning and not related to WebhookManager.
ok but its still not working for me
Are you running client.topgg_webhook in the first place
client.topgg_webhook.run(...)?
Interesting
dbl_token = "xyztoken"
client.topggpy = topgg.DBLClient(client, dbl_token)
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("/dblwebhook", "password")
client.topgg_webhook.run(5000)
@tasks.loop(minutes=30)
async def update_stats():
try:
await client.topggpy.post_guild_count()
print(f"Posted server count ({client.topggpy.guild_count})")
except Exception as e:
print(f"Failed to post server count\n{e.__class__.__name__}: {e}")
update_stats.start()
@client.event
async def on_dbl_test(data):
print(f"Received a test vote:\n{data}")
this is the exact thing im writing there
Where's your on_dbl_vote event
on_dbl_vote is now used both for test and upvote types
It's up to you to handle them differently now
ok i'll try with that brb
it works when i add both test and vote for some reason
i tried removing test part thinking vote one worked but then it didnt so i added it back and now it return me info like id and stuff
and the output is from the test event
@client.event
async def on_dbl_vote(data):
if data["type"] == "test":
return client.dispatch("dbl_test", data)
print(f"Received a vote:\n{data}")
@client.event
async def on_dbl_test(data):
print(f"Received a test vote:\n{data}")
output -
Received a test vote:
| {'bot': '759758239109087252', 'user': '710497600431849545', 'type': 'test', 'query': '?test=data¬RandomNumber=8', 'isWeekend': False}
Cuz you dispatch it manually 
It's same as documentation 
ah thanks shivaco and grimm, i got my code working looking at your convos here
How i make vote for coins in my bot?
My bot keeps crashing with Error: 520 Origin Error, any way I can avoid it crashing when the site goes down?
nice so are u also using both events ?
im just using on_dbl_vote
||***```js
throw new ApiError(response.status, response.statusText, responseBody);
^
TopGGApiError: 520
Woah
throw new ApiError(response.status, response.statusText, responseBody)
^
TopGGApiError: 520
Woah
~ye~
yee
?purge 27
Hahaha
const Discord = require('discord.js');
const client = new Discord.Client();
const { AutoPoster } = require('topgg-autoposter')
const ap = AutoPoster('Your Top.gg Token', client)
ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
})
client.once('ready', () => {
console.log('Ready!');
});
client.login('your-bot-token-goes-here');
@devout cairn
^ example js bot using the library
what does client look like
thats all client is. or do you want it logged?
its just an object
{
id: 412006692125933568,
name: stuff,
//a ton more methods and variables
}
the library is VERY specifically for discordjs and eris. it wont help you with making it for ruby.
Anyone?
I mean it's for help with the API, as the channel description says...
catch the error, kinda all you can do.
this is the channel for support with the api. its a lot easier to ask for support with the api here.
All I'm really doing is posting my servers, ok
hey how do i know if the user has voted for the bot
you can use webhooks to get events when someone votes.
or check if someone has voted in the past 12 hours with the has voted endpoint.
I couldn't understand something when I looked there, can you tell me?
well, there is two methods, are you looking for an event(you getting told when someone votes) or are you looking to check later if someone voted.
check if you have voted
what programming language?
nodejs
so how do i pass it to command
not sure what you mean by that, just in your commands file.
const Topgg = require(`@top-gg/sdk`)
const api = new Topgg.Api('Your top.gg token')
const voted = await api.hasVoted(USERIDHERE)
// voted = true or false
const Discord = require("discord.js");
const db = require("quick.db");
module.exports.run = async (client, message, args) => {
const Topgg = require(`@top-gg/sdk`)
const api = new Topgg.Api('')
const voted = await api.hasVoted(763700505280118805)
message.channel.send("you voted")
return message.channel.send("you didn't give")
}
module.exports.conf = {
enabled: true,
guildOnly: false,
aliases: [],
permLevel: 0
};
module.exports.help = {
name: 'voted',
description: '',
usage: 'voted'
};
If she hasn't voted, how will I respond?
just a basic if statement
Is it valid for all users?
yep
I don't quite understand how to do the if thing
can you post a sample of it
or will this code work
if(status === "true") {
message.channel.send("you gave")
}
if(status === "false") {
message.channel.send("you didn't give")
}
yep should do, if status is the variable you put it in
what can i put in variable
let status = message.mentions.users.first()
is it possible
What
thats just a user, you need to use the actual hasvoted method.
await api.hasVoted(useridhere)
bu konularda kötüyüm
What makes you think I'll understand whatever you tried to explain in Turkish now
api.hasVoted iirc returns a boolean value
Please indent your fucking code..
voted here is a variable of type boolean, meaning true or false
You can use it in an if statement
Hey there, if my bot is offline and someone voted during that time, will on_dbl_vote miss the vote?
Hi! I'm using python. I saw that there's an event reference in the docs called on_dbl_vote which is called when a user voted for a bot. Does an event like this existing for servers? Something like on_dsl_vote?
or do I have to use on_dbl_vote at dsl_webhook() too?
Yes ig so 
i see
ok thanks
Hi again. At the WebhookManager, when I do that:
client = commands.Bot(command_prefix="-", case_insensitive=True)
topgg_webhook = topgg.WebhookManager(client).dsl_webhook(route="/dsl", auth_key="")
topgg_webhook.run(5000)
@client.event
async def on_dsl_vote(data):
print(data)
How can I track the votes of my server? Don't I have to put the server ID somewhere or something like that?
and here is the full: https://topggpy.readthedocs.io/en/latest/index.html
Link your webhook in the server webhook settings on top.gg
you can supply your IP address, i believe
webhooks not working properly this week?
Send Test =>
An error has occurred while processing your request```
Have already tried refreshing the page, logging out, logging in, clear cookies, turning on and off beta mode
can someone tell me step by step how to set up the servers counts for bot widget
Hi, I don't understand what value i should indicate
Obviously a password (you can choose).
Okay
Which needs to match the one on topgg if you even need one.
How can I get the webhook link which I have to put on top.gg
It’s the IP/DNS of the host system the webhook service is running on
(and port of course)
Yeah as the placeholder 0.0.0.0 will be bind to your public IP assigned to the machine
Get the public IP of the system and there u go
If ur on a vps, go to your control panel where you bought it and get that ip, and then it should work :)
Don't worry, it's working 😉
nice congrats
can someone tell me why on_dbl_vote is not working?
client.topggpy = topgg.DBLClient(client, dbl_token, autopost=True, post_shard_count=True)
@client.event
async def on_dbl_vote(data):
"""An event that is called whenever someone votes for the bot on Top.gg."""
if data["type"] == "test":
# this is roughly equivalent to
# return await on_dbl_test(data) in this case
return client.dispatch('dbl_test', data)
votes_channel = client.get_channel(861992864162643998)
print(f"Received a vote:\n{data}")
await votes_channel.send(f"Received a vote:\n{data}")
@client.event
async def on_dbl_test(data):
"""An event that is called whenever someone tests the webhook system for your bot on Top.gg."""
print(f"Received a test vote:\n{data}")
votes_channel = client.get_channel(861992864162643998)
await votes_channel.send(f"Received a test vote:\n{data}")
Where's your WebhookManager
oh, do i need a webhook manger for that?
Yeah, because on_x_vote events rely on a webhook to be invoked in real-time
Instead of using the webhook, can I make the data send to a domain route? like to www.botname.com/top.gg/voted
or smth like that
is that possible?
that's what a webhook is
is it possible for me to access another bot's vote count?
ok, ty
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook("/dblwebhook", "password")
client.topgg_webhook.run(5000)
``` would this work? i doubt it cuz its the same thing from the pypi example.
It would work
Will the votes be reset after new month ?
So i have been playing around with top.gg's stuff and it's been like 2-3 days of a bloody struggle
I changed hosts and everything, how do i get this to work?
which language are you using?
what do you want to achieve?
whats the excepted behavior
show your code pls
Javascript, I'd like to use my web server to work with the top.gg POST requests and- is it okay if i dm you since i have to share code?
This Channel was made for this xD
uh it's not open-source so i prefer if people don't see it but okay if it has to be shared here
we not 1% of it, the Webhook Event and the Part, where you create the new constructor
const setupVote = require('../events/new_vote');
module.exports = {
name: 'ready',
once: true,
execute(client) {
setupVote(client)
console.log('Ready to serve!')
}
}``` this is the function being called in my ready.js
probably will want to reset your token
uff, regenerate your token
yeah, just remove the token..
So this is in my events folder ( where ready.js & message.js goes). I'm trying to get it to get the userID and then send a dm telling the user what they got
@vocal robin is that better?
are the bool values stored in " " in node?
" console.log(Webhook running at path http://${hook.hostname}:${hook.port}${hook.path});""
Does this part come? @worldly reef
could you log out voteInternal and run a test vote
Thx
yes that part gets logged
and the second one?
adding that rq
so this logs 0.0.0.0 instead of the actual host ip
where do you host the vote tracker?
it doesn't log out voteInternal
so you want me to go to that http link?
I dont think i understand what you're trying to say
okay so it seems the web hook path is working when i went to the http thing because it gave me a 404
this link is the link you will insert in the box on your vote settings page
without /dblwebhook?
It will of course throw a 404 as it’s just listening to POST requests
When you use it as path yes
And the path doesn’t physically exist
so i need to insert this only on top.gg?
I've done that rn but without the ``
yes
https://top.gg/api/bots/clientID/check?userId=authorID;voted;;Authorization:
Why this is not working?
okay, what do i need to do now?
Because you didn’t add an authorization
I added top.gg bot token
To the header as mentioned in the docs?
Use the test Button
Header?
Request header
That’s not the way to send the authorization header
Appending it to the query string will not work
btw, dbpapi.js is depreceated
Can you tell me the correct way?
use npm i @top-gg/sdk
Sure, just take a look into the docs, pinned in this channel
getting started is the right page to begin with
so i need to rewrite anything?
everything*
there are some minor changes
me?
yes
Save the changes before hitting test
still didnt do anything in the console
Then make sure the port you choosed is accessible
how do i do that?
Depends on the OS
uhh i'm not sure what os my host uses
Well if you don’t host it on your machine you need to study your hoster’s docs
Can’t help you with that
The port you specified needs to be opened up for incoming TCP connections
So pterodactyl is what the host uses to manage servers
and the os is Linux Ubuntu 20.04
The http header is for HTML
:/
Hee what?
Leave that but how to add http header in js file?
How do you send the request? Using cURL or XMLHTTP requests?
That's a question or an answer? 
Answer xd
Do you use plain JS or a library?
A library
Which one?
Aoi.js
hmm never heard that one
That thing is a lib for Discord bots not sending http requests
So what should I do?
We can create any djs command in that library
Yeah you're confusing me even more... your bot command has nothing to do with a http request
Or should a command trigger that request?
I've got no clue what u actually wanna do.
You should try to explain what you wanna do exactly and within which environment
okay so my ports seem to be open
How can I let send a message when a user upvotes my Bot?
if my console logs 'You need a token for this end point' do i use the bot token from top.gg or the auth token which we make up
nvm i fixed the error & yes i realized that was a dumb question
client = commands.Bot()
topgg_webhook = topgg.WebhookManager(client).dbl_webhook(route="http://MY_PUBLIC_IP/dbl_webhook")
@client.event
async def on_dbl_vote(data):
print(data)
I put http://MY_PUBLIC_IP/dbl_webhook to my bot's webhook on top.gg.
It doesn't print anything when I click on Save and then Test
recently started getting this error. how can i fix it?
Caught unhandled exception in <Task finished name='Task-12538296' coro=<WebhookManager._run() done, defined at /root/redenv/lib/python3.8/site-packages/topgg/webhook.py:139> exception=OSError(98, "error while attempting to bind on address ('0.0.0.0', 5400): address already in use")>:
Task exception was never retrieved
Traceback (most recent call last):
File "/root/redenv/lib/python3.8/site-packages/topgg/webhook.py", line 145, in _run
await self._webserver.start()
File "/root/redenv/lib/python3.8/site-packages/aiohttp/web_runner.py", line 121, in start
self._server = await loop.create_server(
File "uvloop/loop.pyx", line 1740, in create_server
OSError: [Errno 98] error while attempting to bind on address ('0.0.0.0', 5400): address already in use```
was working fine uptil a few days ago
route should only be the part after the MY_PUBLIC_API/
yeah and I didn't run the webhook lol. So route should be only dbl_webhook?
/dbl_webhook yes
ah yeah. Thanks
np
okay I have now:
import discord
from discord.ext import commands
client = commands.Bot()
client.topgg_webhook = topgg.WebhookManager(client).dbl_webhook(route="/dbl_webhook")
client.topgg_webhook.run(5000)
@client.event
async def on_dbl_vote(data):
print(data)
And on the top.gg Webhook URL: http://MY_PUBLIC_IP:5000/dbl_webhook. Still doesn't work...
dk then. i use cogs
also if anyone knows whats wrong
do I have to use the top.gg token? It says that I have to use the token to check who has upvoted the bot. But at the webhook example at the docs it hasn't a token in the code
yes it does
Make sure the auth key you set matches the one on Top.gg for the DBL webhook endpoint
Make sure your ports are open and no firewall is blocking incoming requests to port 5000
Make sure you're not re-running the webhook is all I can say
i made sure to allow the port with sudo ufw allow 5400
Because that's the issue
rerunning as in?
both are empty. So the code is exactly the code that I have (except of the IP of course) on top.gg auth key is empty.
maybe I have to check that.
instantiating it twice?
As in somehow running WebhookManager(...).run(...) more than once
or that if you're using dblpy still...
Make sure you close the webhook when unloading the cog and run when it's loaded
i have to close it too?
didnt know that lol
self.topggpy = topgg.DBLClient(self.bot, self.token, autopost=True, autopost_interval=3600)
self.bot.topgg_webhook = topgg.WebhookManager(self.bot).dbl_webhook("/dbl", "password")
self.bot.topgg_webhook.run(5400)```
this is waht i have
Well it's an HTTP listener running on a port and you can't reuse a port while something is occupying it
kk np
okay so i swapped over to using top-gg/sdk
A simple API wrapper for top.gg written in Python. Contribute to top-gg/python-sdk development by creating an account on GitHub.
It does have a .close() method
oh fuck's sake it's a coroutine
i use d.js not py lol
yea umm no worries i have a workaround for that
oh nvm
i nest an async task within the cog_unlaod 
Ah good, so long as you know what you're doing 
yea i do ||mostly||
Mmm beautiful
I don't remember you or the fact that I helped you ever but
@sullen nymph I deactivated my firewall now. It still doesn't work..
so console.log() worked until I added my vote rewards...
now nothing works, am i supposed to add anything else?
yea that was over a month ago lol. dont expect u to remember
If you're hosting locally, make sure your router forwards port 5000 to your device
how can I check that? And yeah I host it locally
It's probably for the better, really. I would remember you if you were exceptionally dumb
Your router settings! Google time!
okay xD
Uhm, can anyone tell me how should i make something like when the bot is upvoted, it will dm that user
uh where is the middleware supposed to go, is it supposed to be after the })) ?
const express = require('express')
const Topgg = require('@top-gg/sdk')
const app = express() // Your express app
const webhook = new Topgg.Webhook('topggauth123') // add your Top.gg webhook authorization (not bot token)
app.post('/dblwebhook', webhook.listener(vote => {
// vote is your vote object
console.log(vote.user) // 221221226561929217
})) // attach the middleware
app.listen(3000) // your port```
for reference
@sullen nymph It seems that the port is forwarded. But I get that error:
Error handling request
Traceback (most recent call last):
File "C:\Users\andri\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\web_protocol.py", line 314, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
File "aiohttp\_http_parser.pyx", line 546, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'invalid HTTP method'"
It's weird because a few seconds before it got sended but now I got this error.
Whatever that is, I think we can ignore it if it works with test requests
mh wdym?
first I thought it's because of the "https" instead of "http" but it doesn't seem like that.
Oh wait did you set HTTPS instead of HTTP in the URL
first yeah. But I updated at that point already. Maybe it was delayed. Or the bot was running twice idk. Now it works fine
thanks for your help
ummm shivaco the close method no work 
Show code I'll be right back
def cog_unload(self):
self.task.cancel()
async def stop() -> asyncio.Task:
await self.config.userdata.set(self.data)
await self.bot.topgg_webhook.close()
super().cog_unload()
return asyncio.create_task(stop())```
this is it
Eugh hold on
Either I do something stupid or Python is weird
Maybe I do, can't test it right now. Try doing await self.bot.topgg_webhook.webserver.shutdown() along with await self.bot.topgg_webhook.webserver.cleanup()
umm k
first before second
both right?
Yeah
yea wait lemme try
yea taht dont work either
nvm i think i fixed it-
tied the variable to the class instead of the bot and then did webhook.close
im trying to vote rn if the vote is recieved then im good to go
Use the test button ezpz
Weird
I have no idea wtf just happened
but if it works I'll have to take a closer look at what I'm doing in topggpy
well basically. here insteal of self.*bot*.topgg_webhook i changed it to self.topgg_webhook and everywhere else. that somehow fixed the issue idk
python acta weird sometimes
why does get_user_vote(user.id) return false even when a user has voted
and also, how can i test vote?
Test button in Webhooks section on bot's Edit page
Top.gg's fault, give it up to an hour or a few to update
whenever i vote or test vote for the webhook, i get AttributeError: 'DBLClient' object has no attribute 'dispatch'
i can send the code im using for the webhook if needed
send it
yes you will receive votes in real-time
it would be up to you to either store them or do whatever
dblpy = topgg.DBLClient(self.bot, "DBL TOKEN")
topgg_webhook = topgg.WebhookManager(dblpy).dbl_webhook(route="/dbl_webhook")
topgg_webhook.run(5000)
async def on_dbl_vote(self, data):
"""An event that is called whenever someone votes for the bot on Top.gg."""
if data["type"] == "test":
# this is roughly equivalent to
# `return await on_dbl_test(data)` in this case
return self.bot.dispatch("dbl_test", data)
print(f"Received a vote:\n{data}")
async def on_dbl_test(self, data):
"""An event that is called whenever someone tests the webhook system for your bot on Top.gg."""
print(f"Received a test vote:\n{data}")```
this is all the code related to dbl things
oh God I see
WebhookManager constructor takes a discord.py Client instance, not DBLClient
oh
when i replacedblpy with self.bot for WebhookManager im still getting the exact same error, tbh im not 100% sure that bot is the same as client for red, but if it isnt shouldn't i be getting an attribute error but for something other than DBLClient if that was the issue?
yeah even just using discord.Client() directly still gives the same error
wait dont you need an ip address or smtn
the ip address just goes in the top.gg webhook portal thing
under Webhook URL
if im self hosting my ip how does that work?
cause it changes right
if my router restarts/
like what does self.bot itself return, or what is the error that comes when i use it?
the former
<redbot.core.bot.Red object at 0x7f74f07071f0> when i print it
wtf
i also get this with just discord.Client(): <discord.client.Client object at 0x7f74c5dee3d0>
im pretty sure this is what im supposed to be using inside of WebhookManager but i still get the same AttributeError: 'DBLClient' object has no attribute 'dispatch'
Do you have the full traceback?
│ /home/Fear/.local/lib/python3.8/site-packages/aiohttp/web_protocol.py:422 in _handle_request │
│ ❱ 422 resp = await self._request_handler(request) │
│ /home/Fear/.local/lib/python3.8/site-packages/aiohttp/web_app.py:499 in _handle │
│ ❱ 499 resp = await handler(request) │
│ /home/Fear/TerminalGlobal/cogs/Downloader/lib/topgg/webhook.py:130 in _bot_vote_handler │
│ ❱ 130 self.bot.dispatch("dbl_vote", data) │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'DBLClient' object has no attribute 'dispatch'```
formatting is very weird, idk why it was changed to be like this since... who cares how errors look in console just as long as they give info
i can take a screenshot of the traceback if the formatting is off for you
I'll take a closer look tomorrow
alright, thanks
and how do i do it
Why does it show me this when i open webhook
yep done

Hey everyone,
I currently setup the server count for my Discord Bot on the Top.gg website and it's showing the invalid Server Count of my bot, how could I fix this?
@dense basalt
please don't ping random staff 😦
It depends on what API wrapper/library you're using
1, I didn't ping "random staff, the person who I pinged was online at the time."
2, Your able to ping 1 staff member ( that I know of. )
which API wrapper/library are you using?
js
are you using autoposting or manually sending information?
auto posting.


ok

will it not work without it