#topgg-api
1 messages · Page 127 of 1
it's Works Thanks So Much 🙂
Hi, I got an Unauthorised error when sending requests for posting stats on the website, error i haven't got any time ago. I haven't changed anything in my code, and the token is correct. I'm locked at 110 servers, and can't set the 160 count.
Can someone help please, ty :)
( and hi )
Please DM me, i'm not in front of my computer
or mention me
What’s the exact line causing it
I figured out the problem (just as a future reference), it turns out using localhost in web.TCPSite(runner, 'localhost', PORT) always causes problem, its best to use 0.0.0.0 instead of localhost
ah yes, makes sense. localhost only serves locally
weirdd, it works fine when i use it with the other library, just not aiohttp and all the dumb examples on their doc use localhost sighhh
also when i used localhost it turns out it was only working on my machine and not even on the local network devices
well, anyway, its fixed whewwww 2 days....
localhost is only itself, thats what localhost means 😄
You're sending the wrong header then
hey
``ReferenceError: Cannot access 'findVote' before initialization`
Wasnt aware that it had to initialise?? what do i do here?
check if the person who sent the message voted in the last 12h
nvm, fixed it
hi how to do vote webhook
Does client.getVotes in @waxen widget-gg/sdk return votes in the last 12 hours?
Yes
remember to use webhooks when you get more than 1000 votes, though i generally suggest you to do this now than later
Few
Well I'm just using it to check fro my daily command
if they've voted in last 12 hours they get a free 1000 coins
Just await api.getVotes() - when I get to more then 1000 votes I need to use a webhook for that?
use hasVoted instead then, to get the vote from that particular user that uses the daily command
yes, as mentioned on the docs
Okay, but that is also 12 hours
yup both are
sorry fo pinging, im still really confused... I'm making a command that checks if you've voted and im using .hasVoted, do I have to use a webhook for this? I have a webhook server setup for giving coins whenever they vote
Ah thanks
How do i do the servercount 
what do you use(js, py etc)
Js
look pins
What dbl token
._.
Tf
you get it at https://top.gg/api/docs
Tnx
The token?
yeah
Thnx
Any reason why when I make a post request to my webhook via postman it works, and pressing the test button on top.gg does nothing?
it's a web server, not a discord webhook
I think I found you have to be specific when entering your url on top.gg
Are you using this format:
http://<url>:<port>/<webhook-subdomain>
<webhook-path>*
Now it's kind of working, it's sending requests to my url, except they are GET requests?
I mean their site clearly says they'll send a POST so idk what kind of saucery is going on here
Might wanna ask one of the web nerds about that one
I mean, this is what i'm getting: https://img.emoji-bot.xyz/dtzMKs4A.png
and i've only ever entered the /webhook path into the top.gg page
So just to be clear, when you do a post from postman to /webhook it shows up?
That blows my mind
Idk then
When I do a get to my webhook from postman it says 404
But when I do post it says 403 which proves it's getting there
I'm gonna try only allowing POST requests, maybe that'll change something :p
now it looks like it's not making a request at all :(
i'll just wait like 5 mins, in case it's being slow
Are you using the dbl library or your own solution?
own solution
Ah I see
I think your webhook is cursed my friend
I'm gonna try changing the path
What port are you using?
80
I'm using 8000 don't know if that makes a difference
There could be some unforseen packet trickery going on without you knowing on lower ports
i'm gonna try a different bot
so I can see if when I vote it does it properly
bruh
even when I vote it's a get request
It shouldn't be a get request from my testing
Yeah even on the docs it says post but they are still getting get
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.middleware(), (req, res) => {
// req.vote is your vote object e.g
console.log(req.vote.user) // 221221226561929217
}) // attach the middleware
app.listen(3000) // your port
Example from the new docs - shows that it's expecting a post
What's actually in the body of the get request?
Discord.JS Sharding | Is it mandatory ?
discord requires sharding at 2k servers I think
yeah
You can use your own sharding manager if you like, and you don't need to use a certain library
But you do need to shard at 2.5k
are you sure
if you're not sharding it wont work
it's completely empty :P
you're the second person saying you're receving a get request
also there's no body in a get request
Who's the first?
I think, it happened after putting a secret token to authenticate requests
I get POSTs
Is your server behind nginx?
@frigid basin what lang are u using?
python
ok both python
idk what could possibly be causing it
it feels like a code issue but idk how that could just happen
^
guess not
nah
oh
r u sure u arent just going to the ip yourself?
nope
when I spam test webhook it appears to be all get requests in my logs
so its obvious they are made by top.gg
returns 405 because method not allowed
alright, im going to talk to veld and the python lib creator and see if we can get this solved for you guys, i've no clue what's goin on
thank you berry
call shiv a twat for me, will you berry?
@restive otter are you sure your webhook auth is correct?
So I spammed the test button a bit, https://img.emoji-bot.xyz/52BeNe7Y.png I changed the path to /wtf when i was debugging
you using the python library or are you using your own thing
my own thing
could you try using the library possibly?
Might take a while but sure
just to test
I think my server just crashed 
Hey! How do I to auto refresh the servers my bot is in?
I have this:
module.exports = {
loadListeners(dbl, GuildsNumber) {
dbl.postStats(GuildsNumber);
dbl.on('error', err => {
console.log(`Error in Top.gg API !\n\n${err}`);
});
}
}```
you do not have any bots under your acc
I'll let you handle this, berry
are you receiving an error?
what do u mean
I removed the token after this error started
the requirement for an auth header?
i would recommend updating to the latest library https://npmjs.com/topgg-autoposter
ok I will check it
also which http server library are you using?
So i got the top.gg lib to work kinda
it's hosting a web server rn, but I can only access it locally
i've opened port 5000
you can set the port if you want, setting it to the same port and just temporarily disabling whatever u have already would be nice
I set it to port 80, now it's saying that the web server is down
Don't set it to 80 when you have something running on 80 already
temporarily disabling whatever u have already would be nice
they know
can i see the code?
which part of it?
Why are you using port 80
oh well actually i think it does that since its just doing the one path
does testing the webhook work?
Nope cuz it's saying that the web server is down
alr send the code where you use dblpy
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=80)``` that's what I have
idk how python exactly works but can you show the full thing? check out the pypi for it the second example has a webhook thing
That's correct
why would it say it's down?
oh wait, I think I found the issue
ok I got it to work
just gonna test it on top.gg now
ok that worked
like you got the event?
yep
wth
so the lib works, doing it myself doesn't
what http library do you use?
quart
@restive otter you too
.com?
Why on my bot page does not showing bot shards & servers?
You need to post them yourself
did your bot was approved?
what lang do u use?
yes
yeah you need to post it yourself through the api
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
``` i need to login in client beafore i declare DBL?
line 4: "const dbl = new DBL('', client);"
const dbl = new DBL('Your Bot dbl_Token', client);
i know lol
so put it then
Hello

I do this thx ;P
My code for webhooks (votes) does not seems to work
const DBL = require('dblapi.js');
const dbl = new DBL('mySUPERextraTOKEN', { webhookPort: 5000, webhookAuth: 'AndSUPERsecretPASSWORD', webhookPath: '/'});
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
top.gg webhooks are not compatible with discord webhooks.
also dblapi.js is deprecated.
so what i must paste in webhook url?
but this is on express, this is not public lol
ip port and path need to be filled in with the valid information
webhooks have to be available remotely
otherwise they dont function
wtf?
how do you think webhooks work 🤔
thats how discord webhooks work too.
well all webhooks work that way.
If you're probably confused by that, you're not ready to do it yet
meh
So i must do it on domain?
my local adress too? 😄
the public ip, not local.
how to check if someone is a voter?
get request to /bots/{bot-id}/check?userId=some-user-id
const fetch = require('node-fetch')
module.exports = {
name: 'voer',
description: 'e',
async: run(message){
const json = await (
await fetch(`https://top.gg/bots/${message.client.user.id}/check?userID=${message.author.id}`)
).json()
if(!json) {
return
}
}
}```
would this work?
well the full route has an /api first
yea
oh and
you have to check for the voted property in the response
it'll be either 1 or 0
https://top.gg/api/bots/270904126974590976/check?userID=679867543066116169
displays {error: 'unauthorized'}
You need a dbl token
In the authorization header
like this? ```js
const fetch = require('node-fetch')
const { MessageEmbed } = require('discord.js')
module.exports = {
name: 'voer',
description: 'e',
async execute(message){
const json = fetch(`https://top.gg/bots/${message.client.user.id}/check?userID=${message.author.id}`, {
headers: {
"authorization": "dbl token",
}
})
if(!json) {
return
}
}
}```
ok. lmao
i think its top.gg/api/bots/ rest of stuff
const json = fetch(`https://top.gg/api/bots/${message.client.user.id}/check?userID=${message.author.id}`, {
headers: {
"authorization": `eIkasUugDAiLauysahGFiadhjOLAydbakjJGCDTkHAJydyoajGIUVJJHdgyjbOIuagdhVII`,
}
})```
idk where to put voted property
its a fake one
i just randomly typed
is there a way to access the servercount with javascript from another website?
HiauhsdUIHYIRbfkjdbisfhbsiGVJMusibisjhvdugj````
make api backend on your server and request that endpoint from le website
to what url?
so do u know where?
see if they voted or not
i made nsfw for only voters
cant find it. i only see how to track votes and send it thru webhook
none
it will say i did vote
on my alt
when i didnt
how do i make it return those??
its for my bot tho
i found the answer to my question 😄
if they didnt vote = no nsfw command
i did.
i said
if(!json) {
return message.channel.send('no')
}
if(json) {
return message.channel.send('ok')
}```
its the authors id
and im on my alt
okay i am to stupid to do this, can someone send me back the url to get servercount?
https://top.gg/api/bots/{bot.id}/stats
ah yeah, common mistake :p
const fetch = require('node-fetch')
const { MessageEmbed } = require('discord.js')
module.exports = {
name: 'voer',
description: 'e',
async execute(message){
const json = fetch(`https://top.gg/api/bots/${message.client.user.id}/voted?userID=${message.author.id}`, {
headers: {
"authorization": `eno`,
"response": "voted"
}
})
if(!json) {
return message.channel.send('no')
}
if(json) {
return message.channel.send('???')
}
}
}```
@shut flume i can do ```js
const somethinganything = fetch()```
fetch is async isnt it?
yeah, you never do that.
so json is just a promise
then like init said, your just checking if it exists, not what it contains
these are actually kinda newer
It's WIP
the docs.top.gg is the place where v1 (the new api with the review endpoints) is going to be documented iirc
so current api is v0?
that's the new api docs, I just haven't finished it
the old docs are absolutely cringe
What
@tall pelicanGamer_bot
https://github.com/top-gg/rust-sdk When this will be released?
Top.gg Rust SDK. Contribute to top-gg/rust-sdk development by creating an account on GitHub.
when someone feels responsible and has the know-how to contribute to it
anyway I can use the API without getting my bot verified?
alright ty
Who knows? You could contribute to it 
Welp
You too 
Never!
Aww, but...
webhooks.
you can host a webhook on your bot
You seem to be confused about what a webhook is. I suggest reading through this https://sendgrid.com/blog/whats-webhook/
ok
and a little bit simplified https://zapier.com/blog/what-are-webhooks/
thanks!
you wont be able to get it yet because your bot is not approved yet
okay
Yeah so I've read some about the API, and it says that by voting on Example:- If you vote on Bot A you can't make Bot B give you fictional currency, it has to be Bot A.
But lets say that Bot A has a premium version.
And they share the same currency system, can you then get currency by voting on either bot?
Vote for bot A: get rewards for Bot A and Bot B/only Bot B 
Vote for bot A: get rewards for Bot A 
currency or votelocked command, it does not matter
it can also be a command locked behind voting, rewarding users for voting for another bot is not allowed
@commands.Cog.listener()
async def on_dbl_vote(self, data):
"""An event that is called whenever someone votes for the bot on top.gg."""
voter = await self.bot.fetch_user(data['user'])
users = await self.get_bank_data()
votereward = 500
channel = self.bot.get_channel(794536699246018571)
await channel.send(f'{voter} voted for the bot!')
print("Received an upvote:", "\n", data, sep="")
embed=discord.Embed(title="Thanks for voting for Labor-Bot!", description="At the moment you won't get any reward, but there will be rewards soon.\n\n -FateAssassin#0001 :heart:")
try:
msg = await user.send(embed=embed)
except HTTPException:
pass
await msg.add_reaction('✔')
await msg.add_reaction('❌')
while True:
try:
def check(react, user):
return user == voter and msg == react.message
react, user= await self.bot.wait_for("reaction_add", timeout=700, check=check)
user = user
if str(react) == '✔':
await user.send('Alright! I successfuly transfered 500 coins to your account. Thanks again. :)')
users = await self.get_bank_data()
await self.open_account(user)
users[str(user.id)]["wallet"] += votereward
break
if str(react) == '❌':
await user.send('As you wish! I will cancel the transaction, remember, you can always change your mind, when you have voted again. Thanks again. :)')
break
except TimeoutError:
break
File "/home/container/cogs/economic system.py", line 73, in on_dbl_vote msg = await user.send(embed=embed) UnboundLocalError: local variable 'user' referenced before assignment
Anyone sees a error?
But can I make it so you vote for Bot A
But you get rewards from both Bot A and Bot B?
oof that's lowkey sad :p
a bit of console logs would help
so whats the issue
It doesn't give the 500 coins into the wallet
as in the entire event doesnt happen at all, or its just not doing 500 coins into the wallet
Its only not giving the 500 coins into the wallet, also not opening an account
then your question is more of a #development and less about the top.gg api.
what is not working
its not showing the server count and i did a print() To see where its not working and it stops working on the @task.loop
on the manual server count api code
@rain heart
and its not showing the server count in the website
N/A
do u use python 3.9 or 3.9+?
no
hmmm
I use this and works for me
wait
class TopGG(command.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'bot token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes
async def on_guild_post():
print("Server count posted successfully")
client.add_cog(TopGG(client))
just for servers count
Is it possible to add discord.js-commando as a supported libary in the js libary or do i have to just code my own interval thingy to update the server count?
Edit: I just use this code peace:
setInterval(() => {
dbl.postStats(client.guilds.size/*, client.shards.Id, client.shards.total*/);
}, 3600000);
Yes, shard commented out because i don't use shards right now.
||[@mention me if anything]||
is the new SDK node module a drop-in replacement for dblapi.js or do i need to change some code around?
you probably need to change most of the implementation
the webhook runs as express middleware
so i set up a script to push my bot's count every hour or so, but on my top.gg bot page the server count keeps fluctutating between 3-12 servers even after my POST requests, is this supposed to happen
does it take time to update?
it takes a bit of time to update, does it look good now @green wharf ?
Hmm not yet, this is strange
I'll let it run overnight and see how it goes
can i see the code?
not at pc right now
if its not updated by now its prollly broken
but it's just a node script that sends the server count via http
I get code 200 so I suppose it's working? Not sure
I'll do some troubleshooting
help
i dont really understand the new api very well
i want to put it in ready event to know if it is working or not
api.on('ready', () => {
console.log(`Server Count Posted!`)
setInterval(() => {
api.postStats({
serverCount: client.guilds.cache.size,
shardId: client.shard.ids[0], // if you're sharding
shardCount: client.options.shardCount
})
}, 1800000)
})```
is this correct?
trying to make the auto server count poster
and putting it in a ready event
it didnt long in the console
i wanna post it automatically :/
?
yea
wait FRICC
I WAS USING THE WRONG NPM PACKAGE
@hidden wave you were it's the new package
i would recommend using https://npmjs.com/topgg-autoposter
Yea ik
dblapi.js is deprecated and no longer supported
@hearty lintel what does the req and res mean in topgg/sdk package?
im trying to make voting logs
discord.py RESOLVED: It was an API issue I guess because it's back to normal now without changing any lines of code
Does anyone know why this code only returns one user? It used to return all the members who react with ✅ but suddenly it only returns only one user
msg = await ctx.channel.fetch_message(msg_id)
reaction = discord.utils.get(msg.reactions, emoji="✅")
users = await reaction.users().flatten()
Berry?
I don't use py so sorry I can't help
WARNING: Illegal reflective access by com.google.gson.internal.reflect.UnsafeReflectionAccessor (file:/home/infinity/LambdaBot/LambdaDiscordBot-1.0-SNAPSHOT-jar-with-dependencies.jar) to constructor java.lang.Void()
WARNING: Please consider reporting this to the maintainers of com.google.gson.internal.reflect.UnsafeReflectionAccessor
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
``` I always get this WARNING when posting stats to topgg
umm ?
pls reply
¯\_(ツ)_/¯
looks like something with your code, considering you posted no context of where this is coming from
i dont know where it came from
but i just used topgg sdk .. it's java
i had that issue too, make sure you're in java 8, and that your gson isn't outdated
though i think that can generally be ignored
that makes my bot slow , and very slow
reply time goes 10 seconds+
and i am using java 14...
use 8, as java versions over 8 causes that error
i have many features that i use from java 14..
should i use Unirest or something to post ?
I mean you could also post it manually through requests if you wish
did the same thing when i realized that there's still an open pr on the repo that is there since 2018
when i wanna access the stats of my bot with my website i get an unauthorized error, how to fix
how to add it
is it a good idea to implement my token in the frontend js of my website
how to add the api for DBL in python
U can’t
U bless u have a token
what if it is already approved
the vote thingy
i wanna reward them for vote like dank memer
It is not approved, you would have your bot developer role
but you wont be able to use it without a token
I send a guild/shard update every 15 minutes, is that within the rate limits?
yeah that's fine
i can use it without it being approved.
I was not referring to you with that
was able to send requests before it was verified.
that’s the difference between a 403 and you can’t send requests without being verified.
Point still stands, your requests don't do shit without an authorization token as the entire API relies on it
Correct, you need it for bots webhooks though
I want to make a command that works with voting how can I do
guys how do i make a system like dank memer that if anyone votes for the bot, that person gets economy game money ( if the bot has economy )
that is literally what you're asking

One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Can someone help me with the voting webhook
Lemme get the code
if (client.uptime) {
client.users.fetch(req.user).then(user => {
user.send("Thanks for voting!! your vote means so much to us! <771257257371500544>")
client.channels.fetch('785362716906225675').then(channel => {
channel.send(`Thanks for voting!! ${req.tag} your vote means so much to us! <771257257371500544> you can also vote us at https://top.gg/bot/752384586398302279/vote`)
})
})
}
})
app.listen(2022)```
This is my code
What's the issue?
When I try to test webhook, it won't work
The auth and webhook URI are correct
I'm using the @topgg/sdk npm package btw
Yea that's what I wanna do
I wanna do POST request
But the api docs says that
I use express to make the webhook
You can even see at the bottom of the code that it says "app.listen(2022)"
The post request seems to be a receiving endpoint, not a sending.
For the webhook
The url and auth are filled in correct?
http://ip:2022/dblwebhook
?
Filling in ip with the public ip.
I have a server which is on top.gg and I code with discord.py I want my bot to do stuff when someone votes my server how can I make something like that?
You can use the webhooks. https://top.gg/api/docs#webhooks
There are a few differences listed in pins
Lemme check
So it's given the format like https://top.gg/bot/:ID/webhooks, if I want it for the server, will it be like https://top.gg/server/:ID/webhooks ???
You can just go to your server click edit and scroll to webhooks
Can somebody help me? I do not know why I give "test" and it does not go :c
Ok ty
Thats not how webhooks work. The url is a url to your webhook receiver.
This part? (this is a test webhook)
I don't understand what to do. I'm sorry 😔
And what should I put in port and path?
The public ip of the webhook receiver.
Typically the public server ip your codes running on
It's normal I think
Yes all of them are correct
Is your code running on a home network or a server which requires port forwarding?
Or do you have a firewall blocking said port
server which requires port forwarding
0.0.0.0 means any available port
so...
Did you port forward it?
Then what do I do .-.
Use your public ip as its available
Did you put the full url?
Is this on a home network?
yes
Portforward port 5000
What is that
Home routers block specific ports, portforwarding allows those ports to go to specific devices.
oh thanks
le pins #topgg-api message
right
my server count still not showing.. sigh ((Python, and yes i did pip dbl.py))
is this done right?
import dbl
import discord
from discord.ext import commands
import datetime
from discord.utils import get
from urllib import parse, request
import re
import random
import asyncio
class TopGG(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.token = '[REDACTED]' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes
async def on_guild_post():
print("Server count posted successfully")
def setup(bot):
bot.add_cog(TopGG(bot))
how can I set webhook server in my bot (node.js)
You can use the sdk, top pin.
can the middle ware from the top.gg sdk be used with other http frameworks like
fastify
Worth a try.
Probably not then.
to me the middle ware just looks like it extends both objects
or the first one
actually
do u use python 3.9 or 3.9.+?
can anyone show me how to display on top.gg the servers my bot is in
if you do answer ping plz
use either one
@restive otter What about dblpy
ahh ok
Well it’s mixed I have 3.6 + 3.8 if I need to upgrade to 3.9 ya I’ll give it a shot
fuck discord bot let make a telegram bot
no
dont use 3.9 or more
Pyfthon 3.9 isn't supported by dblpy yet
I do this and it works, try it
class TopGG(command.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'bot token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes
async def on_guild_post():
print("Server count posted successfully")
client.add_cog(TopGG(client))
Tht is literally what I’m using ~ and it’s not pickin up the DBL lib installed no errors no trace backs no nothing
Can someone help me use dblpy
I dont use cogs btw
@fast agate how can i do that without cogs
This
Isnt these cogs
my code be like
client = commands.Bot(command_prefix='//', intents=intents)
prefix = "//"
Client = discord.Client()
@client.event
async def on_member_join(user):
bla bla bla
@client.event
async def on_ready():
@client.command()
async def lang(ctx, lang=None):
@client.command(aliases=['helpme'])
async def help(ctx):
guild_id = ctx.author.guild.id
@client.command(aliases=['8ball'])
async def _8ball(ctx, *, question = None):
client.run('dasdasdadas')
and I put it here and works
Oh
client = commands.Bot(command_prefix='//', intents=intents)
prefix = "//"
Client = discord.Client()
@client.event
async def on_member_join(user):
bla bla bla
@client.event
async def on_ready():
class TopGG(command.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'bot token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes
async def on_guild_post():
print("Server count posted successfully")
client.add_cog(TopGG(client))
@client.command()
async def lang(ctx, lang=None):
@client.command(aliases=['helpme'])
async def help(ctx):
guild_id = ctx.author.guild.id
@client.command(aliases=['8ball'])
async def _8ball(ctx, *, question = None):
client.run('dasdasdadas')
Do i need to add any extra things to this
I want like whenever someone voted for the bot the bot woll dm them
@client.event
async def on_dbl_vote(self, data):
voter = await self.client.fetch_user(data['user'])
await voter.send('Thanks for voting for the bot!')
Do you think this will work?
@sullen nymph
What’s this?
Seems so
Next time just send manual requests to the machine your bot is hosted on lol
lmao why on earth you instantiate 2 different clients and a cog inside the main file
I'm not gonna question that part
And let them suffer the consequences of bad management
wise decision
also shiv, isn't the guild_post dispatched using dispatch method? That way you need to register the function as a listener, don't you?
Hi,so how do we use the top.gg api to remind a user to vote after 12 hours!
webhook, once top.gg's made a post request, sleep for 12 hours, then remind the user 
and how do we setup the webhook? like with js or top.gg api
You can either use the official top.gg lib to set it up or set up a webserver that listens to post requests yourself I suppose.
oh ty
Yeah
Hence needed decorator but I missed it when docs were updated
the docs would confuse newbie then kekw
Yeah, I'm working on adding more details such as examples and detailed explanations for docs
(P.S. I'm not, but planning to)
It should be self-explanatory by reading the source code anyway 
alright
for the POST bots/ID/stats, can I post shards count and server count without shard id?
im getting 200
const req = await fetch(`https://top.gg/api/bots/${message.shard.user.id}/`, {
method: 'POST',
headers: {
Authorization: process.env.DBL
},
body: {
shard_count: this.client.options.shards,
server_count: this.client.guildCount
}
})``` this.client.guildCount is 74, yet its returning a json saying server_count is 76 still
@jaunty plank
alright
shouldn't I get an error if I post 2x in a row?
wait
/stats endpoint 
const req = await fetch(`https://top.gg/api/bots/${message.shard.user.id}/stats`, {
method: 'POST',
headers: {
Authorization: process.env.DBL
},
body: {
server_count: 73,
}
});``` its working but im getting 400, `Required parameter server_count or shards missing`
@jaunty plank is body incorrect?
headers wrong
posted correctly
content type was needed
yeah, you need a content type right?
yep
thats what I did lmao
you know what they say about great minds
How do we setup webhooks for our bot?
you can use one of the libs listed on the docs(some dont have webhook support), or make your own webhook receiver
posting your server count using the api.
Ok... But I don't understand how to make a webhook
I mean, to setup the webhook
Ok, then could u tell me how to setup server count?
depends on your bots lib and lang.
Where it should be done?
in your bots code, outside any irrelevant functions or events.
Okk Thank U
you need a content type.
kekw
Can I see who voted for my bot?
How to make webhook to get votes ?
it tells you in the docs
i didnt know how
and i didnt know who vote to my bot
i generate an API what now ?
@rain heart
If you regerated a token, read the docs
i am read but i do not know English well
Use a Translator
With adding a Authorization header to your request
The Header should contain your dbl token
anyone can help with bal command
thx
not webhooks in Authorization
If you're not understanding anything from the docs, i cannot help you and you're not ready to do that yet
The docs literally give you the code you need except for the webhook itself
I taked the api key but how Authorization
like i said...it literally gives you the code and tells you word for word what to do
I'm not giving you the stuff that the website has...what library is your bot in?
ok so go to the website...and choose your library...
then read what the website says 🤦♂️
I don't need pictures...my code works
const dbl = new DBL('Your top.gg token', client);
i must add this to the bot project right ?
and bot my bot token yes ?
can i get who vote to the bot in discord channel ?
dbl.webhook.on("vote", (vote) => {
^
TypeError: Cannot read property 'on' of undefined
@rain heart Can you help?
const webhook = dbl.webhook;
webhook.on("vote", vote => {
console.log("");
console.log(yellowBright(`VOTE INITIALISED | By: ${vote.user}`))
const VoterMessage = new Discord.MessageEmbed()
.setTitle(`${vote.user} Just Voted`)
.setDescription(`*Want to vote for lovell? [Click Here](https://top.gg/bot/ ID /vote)*`)
.setColor(0x82D6FD)
.setFooter(`© MY BOT | Prefix: ${prefix} `)
.setTimestamp(Date.now());
const webhook = new Discord.WebhookClient(" ID ",
" TOKEN ");
webhook.send(VoterMessage);
})
@willow spindle would this work?
nah nvm it don't work
Can we do that on servers vote?
check their api
There's no api for top.gg servers, but there's webhook support for servers @devout pelican
Unfortunately that is not documented, but the concept is pretty much the same, just different data format you get from the webhook request
where do i put the webhook
on your bot page settings under "webhooks"
Ok thx
?
srry
regenerate the token right now
but where do i put the webhook
Already done that
Yes
one second again
Ok
on your "Server Info" Section, scrolling down should bring you to this
replace it to whatever you want to use to make sure that the request is indeed coming from top.gg
you can change it to whatever you want
As long as it is the same on the Authorization field
discord webhooks do not work
oh-
you need to make your own one
wow
or use a discord bot such as DBL Vote
to check if a user voted or not?
If you just want a notification (such as a thank you message in a channel) you could use a bot such as DBL Vote. For rewarding your users with a currency, you will need to make your own one

can someone help me with dblpy
just ask
self.token = 'dbl_token' # set this to your DBL token
what do i put in 'dbl_token'
@rain heart
set this to your DBL token
Still, don't share it
👍
enter that token inside your self.token of the dblpy instance
in other words, replace the dbl_token with it
the authorization of the webhook you wish to use. If you do not use voting-webhooks, you can ignore that
im tryna make it so whenever someone votes for my bot the bot will dm them
def __init__(self, bot):
self.bot = bot
self.token = ''
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
voter = await self.client.fetch_user(data['user'])
await voter.send('Thanks for voting for the bot!')
and thats my code
what do i have to fix
Remember that the user needs to share a server with that bot
yup
also, then you will need to replace the webhook_auth with whatever you want to use as the webhook password
any password?
yup, it has to match this field
ok
it is generally just for you to identify that the webhook request is coming from top.gg
your webhook url
which should be the ip/domain of your server the webhook is running on
oh
so for example with your current code, it would be http://yourserverip:5000/dblwebhook
so the webhook dont wotk anyone know why```python
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'Nope' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='https://discord.com/api/webhooks/Nope', webhook_auth='Nope', webhook_port=5000)
# The decorator below will work only on discord.py 1.1.0+
# In case your discord.py version is below that, you can use self.bot.loop.create_task(self.update_stats())
@tasks.loop(minutes=30.0)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count"""
logger.info('Attempting to post server count')
try:
await self.dblpy.post_guild_count()
logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
except Exception as e:
logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
# if you are not using the tasks extension, put the line below
await asyncio.sleep(1800)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
logger.info('Received an upvote')
print(data)
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))
that's not how it works, re-read the docs
Idk how it works i havent even used python before lmao
And there are no vidios on yt that tells how to do it
I'd say get more experience first
Or as recommended, use something like DBL Vote if you only need the Notification
Hmm k thx anyway
is DBL vote good? I Use this? https://top.gg/bot/753688662449061919
Respond in #general
you cant use discord webhooks in that you need to set one up by yourself
Ok
how do i setup wwebhook
how to I get the server counter to work??
read the docs
есть русс
what does the bot verification process consist of?
One message removed from a suspended account.
alright cause my bot is private and made specifically for one server, can it still get verified so I can use the API?
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.
how can i make a vote message in my server
with webhooks
ok i look
Will probably rename it to webhook_route at this point
İm turkey
cool, #general-int
hey i made webhook server but server dont send messages how do do that
I am writing with discord.js and I can see that dblapi.js has its own events.
const DBL = require ('dblapi.js')
const dbl = new DBL ('dbl token', client)
dbl.on ('vote', vote => {
})
but I can show you how it's time to vote again
or is there such an event?
you would have to make that event yourself.
ok thanks i understand

Hello, is the webhook test a vote?
a test vote
it doesn't count towards your actual votes
it just sends a request to your webhook with the type "test"
I know, I was just wondering because the event didn't work
make sure to press save before being able to test it
Ah, I thought to test was not to save
that's what i thought so at first too
It seems that it didn't work here, I think it's the URL of the webhook, how do I put it in?
inside the webhook url field
also make sure it is not a discord webhook, they're different
Of that I know, but how do I need to put it? I don't have a website
If you created the webhook through your bot, your webhook format should be something like http://yourserverip:port/dblwebhook
can the port be 5000? If not, how do I get the port?
I tried everything and still won't
How can I be creating a server? I don't understand that
python
Do I really need to do this? I just want the voting event to work
I'm using the dbl lib, this would be if I hadn't been using it right?
I will take a look at the doc
hm
ok, thanks
use aiohttp as it's async and one of d.py's dependencies, so you can have it in your bot
otherwise flask with threading, probably.
الوو
How i can make api vote?
how do i make a bot
Go to Discord Developer website
whatcha mean?
hm
it ```const DBL = require('dblapi.js');
const express = require('express');
const http = require('http');
const app = express();
const server = http.createServer(app);
const dbl = new DBL(yourDBLTokenHere, { webhookAuth: 'password', webhookServer: server });
dbl.webhook.on('ready', hook => {
console.log(Webhook running with path ${hook.path});
});
dbl.webhook.on('vote', vote => {
console.log(User with ID ${vote.user} just voted!);
});
app.get('/', (req, res) => {
// ...
});
server.listen(5000, () => {
console.log('Listening');
});```
idk how to use api vote
it my first time use it

yeah, old lib is deprecated
they should update the docs smh
???
the new docs are still a work in progress
im confused
they did update the github link at least 
that library is deprecated
check the docs for top-gg/sdk
and is no longer supported
oh
https://npmjs.com/@top-gg/sdk or pinned messages
And i dont know what is top-gg/spk
okay what im doing agian?
check the docs for @top-gg/sdk
i did
that's the new lib
im still confused lol
there are examples over there
?
is there something specific you want to do with the api? or
i just want make api vote in my support server
as in you want to receive an event when someone votes?
yeah
that would be the webhook section of the library.
https://www.npmjs.com/package/@top-gg/sdk
bottom section
i really dont know how use a webhook of javascript
well, the library does most of the work for you.
you add it as middleware to the route you want
then you can use req.vote to get stuff about the vote
hi
thats not a question, we cant read your mind on what you want to know
i really dont know how to use webhook but what i ned do?
what are you even laughing at
their own incompetency ig?
thanks

