#topgg-api
1 messages ยท Page 91 of 1
Yes should work
@olive arrow now i have the oppisite problem ๐
i did it when i did not vote it worked, then i voted and it said i still havent voted
const voted = await dbl.hasVoted(message.author.id)
if(voted) {//continue old code from here```
where do i put const voted = await dbl.hasVoted(message.author.id)
under first if on at ippy top
tippy*
or very id better word
ok i think it works now not sure tho
Who using BDFD
What
@topaz verge regen token
urwel
How bot get user vote
suchas
if have someone vote then sent message to channel (voteusername)
javascript
Webhook
Is it possible to have the username of the person when they vote? To avoid that when it is not on my server it writes "invalid-user" sorry my english is not very good
@faint phoenix code it to only work with your server id
How can i get user vote info?
wdym?
upvote info?
Is there any method..
How bot get user vote
suchas
if have someone vote then sent message to channel (voteusername)
javascript
what host are you use ?
galaxy gate..
I used this and voted
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print(data)
It won't get invoked..
I tried that too, I ended up using a separate bot for it
i have a question with shard&server post & kurasuta (a custom cluster & sharding manager for discord.js). where should i invoke the dbl webhook? I currently invoke it here in my main.js file, but idk if its the good place, because only thr server count is posted this way...
class DailyRewards(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'TOken' # set this to your DBL token
self.dbl = dbl.DBLClient(self.bot, self.token)
@commands.command()
async def daily(self, ctx):
check_users_votes = await self.bot.Users_Upvotes.find_one({"UserID" : ctx.author.id})
if check_users_votes == None:
check_vote = await self.dbl.get_user_vote(ctx.author.id)
print(check_vote)
if check_vote == True:
await self.bot.Users_Upvotes.insert_one({"UserID" : ctx.author.id, "Streak" : 1, "Last Voted At" : datetime.datetime.utcnow()})
check_users_votes = await self.bot.Users.find_one({"UserID" : ctx.author.id})
embed = await get_upvote_embed(check_users_votes)
await ctx.send(embed = embed)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print(data)
def setup(bot):
bot.add_cog(DailyRewards(bot))
Other not related to top.gg
This event is not working,
on_dbl_vote..
Let me check
(node:13) UnhandledPromiseRejectionWarning: Error: postStats requires 1 argument
at DBLAPI.postStats (/home/container/node_modules/dblapi.js/src/index.js:142:45)
``` Why i have that ?
Hi, I would like to put a more than simple voting system on my bot. The person votes and the bot stores in a .json the number of times they voted and sends him a pm.
I just have this error that I can't resolve.
Thank you !
TypeError: Cannot read property 'on' of undefined
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`Cette personne viens de votรฉ pour le serveur !
Son ID est : ${vote.user}
Son pseudo : ${vote.user.tag}`);
if (!votes[member.id]) {
votes[member.id] = []
}
votes[member.id].unshift({
reason: reason,
date: Date.now(),
mod: message.author.id
})
fs.writeFileSync('./votes.json', JSON.stringify(votes))
vote.user(`J'ai bien pris en compte votre vote et je vous en remercie !`);
});
I specify that I have installed all the npm modules*
?
@tranquil fox did u set URL and Auth?
yes
-api
THIS CHANNEL IS ONLY FOR SUGGESTIONS/HELP/BUGS TO DO WITH OFFICIAL TOP.GG API LIBRARIES AND API DOCS FOUND AT
https://top.gg/api/docs
is there a way to use API to update member count of a server that I own and have my own bot in
DSL doesn't have an API
You'll have to invite the bot to the server and edit the server page
the discord server list bot? cause its already there, you said I have to take steps on the top.gg website as well?
Yeah, on your server page basically press Edit and Submit
oh hey, that was easy, thanks
With this api, I can add money or something to a user if they upvote the bot?
Yes
Thought so, thank you
Can Someone Reply?
Reply

Please Ping, if someone can Answer...
hello I have troubles with my autovote code..
can anyone help me?
(Please ping me if you can help)
Same, happening with me, but in python.. This thing not seems to be working
@mighty shuttle So sorry to bother you. but do you know how to fix this problem ^
@loud dust It is not invoking when vote is added right...?
correct. whenever I- or anyone else for that matter votes for my bot..
he doesnt even log it
yes under webhook events
API channel must be active, and they should answer
I have been waiting here since yesterday...
But No Answers at all.
I mean
I would dm Oliy
bc he said to
but im not sure
if it is the right thiung to do
@loud dust You can get some examples from web.. I think
I tried ngl
Me too, but got nothing
Docs are also not proper
I went for the dm
@twin hedge vc auuva re
@twin hedge
Localhost
@cursive geode Not seems to be working
you haven't configured your webhook properly
you need to set a webhookPort or supply a webhookServer to hook to
I have python 3.8.2, will the api work??
Yes
I tried many times not seems to work, can you help me..
What does your code look like
yes shoe cude
@sullen nymph I am just trying to give coins to users, when they vote our bot..
Please refrain from posting any unnecessary comments in this channel
@twin hedge Show me your top.gg cog
class DailyRewards(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'Token' # set this to your DBL token
self.dbl = dbl.DBLClient(self.bot, self.token, webhook_path = '/dblwebhook', webhook_port = 5000, webhook_auth = 'Test')
@commands.Cog.listener()
async def on_dbl_test(self, data):
print(data)
I am just confused with webhooks
IP:5000/dblwebhook
Add http:// before
It is there..
make sure your port is open and forwarded to the correct machine
send me the full URL, I'll get back to you after I'm done with my personal stuff
Ohkk,
Which url, that local host?
can someone pass me an API for creating bots?
-api
THIS CHANNEL IS ONLY FOR SUGGESTIONS/HELP/BUGS TO DO WITH OFFICIAL TOP.GG API LIBRARIES AND API DOCS FOUND AT
https://top.gg/api/docs
any way to check if a user has voted for the bot at any point? (discord.py btw) for like vote locked commands
database
I set the webhook URL but when I click the test button it doesn't do anything, can anyone help me?
port 11?
u sure that's right?
anyway, is the port fowarded?
also, if you're using nginx, is the port proxied?
I'm not using nginx
what about the other 2 questions?
ok, so I guess it's not fowarded
fowarding a port is allowing external connections to it (aka exposing it)
without that dbl won't be able to send http requests to it
well
where is your bot hosted?
i currently have it open on my computer but i host it on heroku or other hosting services
or dashflo
heroku uses port 3000 and links it with the default http/https ports via reverse proxy, and also provides you a public url for that
so when hosting in heroku, the correct webhook url is https://PROJECTNAME.herokuapp.com/dblwebhook
and you have to use port 3000 or process.env.PORT in your code
Okay, lemme try it out.
Ah doesn't work.
well now it says this as I changed it to process.env.PORT
do i need to use webhook?
depends what you want to do
only if you want "on vote" events
Just for upvoting
Tim, isn't there other way to do it than web dyno?
const { Client, MessageEmbed } = require("discord.js");
const DBL = require("dblapi.js");
const dbl = new DBL('x', Client);
var db = require('quick.db')
let cooldown = new Set();
let cdseconds = 43200;
module.exports = {
name: "upvote",
catergory: "misc",
description: "Vote once a day",
usage: "Upvote",
async run(client, message, args) {
if(cooldown.has(message.author.id)) {
let noembed = new MessageEmbed()
.setAuthor(message.author.username)
.setDescription("You may only vote every 12 hours!")
.setColor("#ff0005");
return message.channel.send(noembed);
};
let userBank = db.fetch(`bank_${message.guild.id}_${message.author.id}`)
dbl.hasVoted(message.author.id).then(voted => {
if (voted) message.reply("thanks for the upvote! here's $5000!")
db.add(`bank_${message.guild.id}_${message.author.id}`, 5000);
});
}
}``` Never used this before, nor used Javascript in a while, is this how i would do it?
no
if you just want to use dbl.hasVoted, you dont need client
just dbl = new DBL("top.gg token")
otherwise, it's all fine?
if you want your bot to show how many guilds its in in top.gg when you need to pass client, but your original bot client, not a new uninitialized copy of client
ah okay, that makes sense, thanks
yes
thanks
BDScript are not important for peoples...
-api
THIS CHANNEL IS ONLY FOR SUGGESTIONS/HELP/BUGS TO DO WITH OFFICIAL TOP.GG API LIBRARIES AND API DOCS FOUND AT
https://top.gg/api/docs
-api
hey so cna som,eone explain how do you just get the server ocunt working
do you haev to put a chink of code in main.py to make it work
im usng python btw
-servercount
To have your bot's server count displayed on DBL, please read the documentation on server/shard posting. Click here to see the docs.. You may also find #312614469819826177 useful; however it is strongly discouraged as most of the examples are extremely outdated.
yeah but like what do i do with it
i dont know how to implement in my code
@rough crater
i did this and ran it
nothing happened
server count doesnt display on the website
please @ me back
Just give it some time
Whenever CF cache changes
Or straight up use the /api/bots endpoint and fetch the server count from there
My code works fine, but after like half or day or more it just stops working. If i reset my bot it srtats working again. what didi i do wrong or how can i fix
Hello,
Do that python code supposed to show me the votes ?
@commands.Cog.listener()
async def on_dbl_vote(self, data):
logger.info('Received an upvote')
print(f' > DBL Upvote !\n{data}')
It will show when you got a vote
But it doesn't work even if the server count works
Does anyone know how to use a space after the prefix?
I've tried adding it like (prefix ) but it won't work
It should work
Hello,
Do that python code supposed to show me the votes ?@commands.Cog.listener() async def on_dbl_vote(self, data): logger.info('Received an upvote') print(f' > DBL Upvote !\n{data}')
@frosty quarry Not working for me, is this working for you.
If Yes. Please let me know
@twin hedge Nah, nothing on my terminal when I reveive an upvote
@frosty quarry Same, do u implemented webhook thing?
Nop, I did nothing except this code from the docs:
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")
@commands.Cog.listener()
async def on_dbl_vote(self, data):
logger.info('Received an upvote')
print(f' > DBL Upvote !\n{data}')
Can you help me ? ```js
(node:13) UnhandledPromiseRejectionWarning: Error: postStats requires 1 argument
at DBLAPI.postStats (/home/container/node_modules/dblapi.js/src/index.js:142:45)
Apparently the docs aren't clear enough to say "use webhook_x kwargs in DBLClient"
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/dblwebhook', webhook_auth='Pass?', webhook_port=5000)
webhook_auth is a password you create yourself and enter on your bot's Edit page
Other than that, the snippet you sent seems alright
Yea thanks, I did it and typed it on my webhook bot page with the URL http://IP:5000/dblwebhook
And I'm receiving the test webhooks
Where can I find the "Logger" ?
Hm? What do you mean by logger?
logger.info('Received an upvote')
These lines, where are they wrote ?
logger is defined as a global variable in the setup function
So I need to make a command that print the Logger content ?
Not really, the logger just prints stuff. You can remove anything related to it and make the on_dbl_vote function send a message in a channel if you want to
Ok thanks, I'll remove that Logger. But the on_dbl_vote doesn't work yet for me, I'm tryng to figure out how to do
Well if on_dbl_test works, vote event should too 
Hm.. I'll retry..
Is this line supposed to be shown every 30min ? python async def on_guild_post(): print("Server count posted successfully")
My suggestion is to test your code with the test event and once you are sure it works perfectly, put it in the vote event
Does the guild_post event have listener decorator?
Ok my bad thanks.. @commands.Cog.listener()
mhm
{
"bot": "705373559299637278",
"user": "326508798753636363",
"type": "upvote",
"query": "",
"isWeekend": false
}
Receiving it!
Splendid
Unclosed client session
How do I close client session ?
I have some long errors with that
oh dear God
Because I was in auto_post and I turned it into a manual server count post
I really need to get to it sooner
I'll try to fix it in next update
Thanks for the report
Strenght to you!
So I can't really do anything for that
Well, aside from editing the source code
๐
Can I let the auto_post and add the webhook after ?
Like ```python
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/dblwebhook', ...)
It seemed like I don't receive webhooks anymore when I turn on autopost
It's ok thanks, I'll continue to manage my code
@sullen nymph How i can patch that ?
What are your discord.js version and code?
discord.js (v12) and: ```js
bot.on('ready', () => {
setInterval(() => {
dbl.postStats(bot.guilds.size);
}, 360000);
});
guilds.cache.size
Ah, yes I just forgot the .cache ๐คฆ
hello, can anyone help me with discord.py?
I want to make a task loop to send message to specific channel every 30 minutes. I have set the channel_id I need on database. To access it, I need guild id to find the channel_id. The query looks like this:
select channel_id from configs where guild_id = ?
But @discord.ext.tasks.loop has no arguments. How can I get current guild_id to run query above without any arguments on @discord.ext.tasks.loop function? Thanks! problem solved
#development more than likely
@commands.Cog.listener()
async def on_dbl_vote(self, data):
user = self.bot.get_channel(721883157804220507)
await user.send(data)``` anyone have any ideas on why this doesn't work?
you mean other than those god awful var names?
yes lol
no idea you havent given an error or enough code soooooo
there is no error
What does your DBLClient look like
Gimme 2 secs
is that this line? py self.dblpy = dbl.DBLClient(self.bot, self.token)
You're not running the webhook at all
Refer to dblpy.rtfd.io, see the webhook_x kwargs
please i want game for my bot (discord.py) Give my idea
#development probably @restive otter
yes i do
๐คฆ
welp
@jaunty depot sorry for ping but its giving me an error for dblapi.js so maybe I need to use dbl-api, but im confused why there are two
its dblapi.js
unofficial package made by someone
ah ok
self.webhook_path = kwargs.get('webhook_path')
is the webhook_path the webhook url?
Why the self.webhook_path
Oh I see what you did
No, it's the endpoint thing after ip:port
Whats stopping someone to postStats with a random number
how do people command lock stuff to the votes endpoint?
Simple database boolean
i am getting this error how do i know what line to fix
not sure what my problem even is, did not edit code just started happing in middleof day
How to make guild count visible for my bot in top gg?
thanks
Oh God JavaScript
@proud flare javascrpit?
can you show full error
Gotta hate that syntax tho. All the unnecessary brackets
me? @willow spindle
Yes js
yes
Curlies
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26)
(node:990) 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: 845)
kk thx
just making sure @proud flare
Gotta hate that syntax tho. All the unnecessary brackets
@restive otter help you stay oginized. good for newbies like me
f
i am so confused
dose it want me to put .catch() somewhere?
@willow spindle figured it out
its caused by low connectivety
maybe
my vps must be craping out
ReferenceError: Cannot access 'client' before initialization
whats wrong?
const Discord = require('discord.js');
const DBL = require("dblapi.js");
const dbl = new DBL('MY API TOKEN', client);
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})```
thats my code
It throws me an error when trying to download the discord.js libraries in glitch: /
yes
but then
ReferenceError: Cannot access 'client' before initialization
@proud flare
const Discord = require('discord.js'); const DBL = require("dblapi.js"); const dbl = new DBL('MY API TOKEN', client); dbl.on('posted', () => { console.log('Server count posted!'); }) dbl.on('error', e => { console.log(`Oops! ${e}`); })```
@proud flare and thats the code
ask #development
k sure
Can anybody help me with getting a message everytime someone upvotes my bot?
Tag me please
guys this code does not run
I'm confused about the command locked stuff
so you can make it so certain commands will vote?
What version are you on? @tame marten
@tame marten v12?
yea its 12
use cache then
there is a windows problem as i know, localhosts won't work on external devices
wat
how to get dbl token?
oo
But you'll find yours once it's approved on https://top.gg/api/docs#mybots
Spice up your Discord experience with our diverse range of Discord bots
im waiting my bot approved
Ok
Can anybody help me with getting to know when someone upvotes my bot
ฤฐ tried this server-count-example and paste my dbl token to 'AUTH' but not worked and send me that error
Error: ```j
Error: getaddrinfo ENOTFOUND https://discordbots.org
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:64:26) {
errno: 'ENOTFOUND',
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'https://discordbots.org'
}
also use top.gg instead of discordbots.org
@wide nimbus Use "dblapi.js" module for post server count and other things
gotta try
Tried this and i got a error
Error: serverCount is not a number but a undefined instead at Client.postStats (/home/runner/PersaKdcBotHost123/node_modules/discord-bot-list/index.js:92:26)
can you read the code
@wide nimbus why you trying this?
use official library
^
im just trying #312614469819826177
Most of those are unofficial or outdated
oh..
I suggest just using the official library
official library has an autoposter. Use it
thanks ill try
PersaK
yea?

so I have a restful api running on ngrok, but when I sent a test payload to the api I get nothing, any help?
wait a sec
itโs done it just not logged it
My error, just started in the middle of the day yesterdat, iread that it was connection error from my vps. but has not stopped. what do i do (what code do i provide)
can someone tell me how to get started
i already read the docs
but like is there a batch of code i can just chuck in my main.py to make it start working
thatโs node js
but like is there a batch of code i can just chuck in my main.py to make it start working
@restive otter What are you looking for? Server count posts?
no
just want my server count to show up on the top.gg
i am getting this error, i think i am being rate limited by top.gg what do i do, i was getting this error a whole bunch before this startes (maked with red is the old error)
not 100% sure what that means. i do this to post server count. and i use it other place if i need to show i can https://media.discordapp.net/attachments/412006692125933568/723229225276145694/image0.png
oh
do you do dbl.postStats() anywhere?
no
you just do dbl = new DBL(token, client)?
do you put client/bot at the end?
show more code
where
its new DBL() in the beginning or the file? or inside client.on("ready")?
begining
also, is dbl.hasVoted directly inside client.on("message")? or inside something else?
its in
ye directly. and by that you mean all the code inside it?
thats like 1500 lines soo b eprepared to see the worst code you ever have seen
put it in a hastebin or similar
https://hastebin.com/yurijasata.js line 1832 i use dbl but thats the whole block
you werent kidding lmao
nope i as not
but all jokes aside, the problem is that you're creating an API request to top.gg on EVERY SINGLE MESSAGE you ever receive from discord
so if your bot is in 50 servers, and in each server someone posts 1 message, you isntantly create 50 requests to top.gg
which is basically an instant ban from the top.gg api
you get unbanned after 1 hour afaik
so how do i fix that
you fix it by always checking for the command before attempting any kind of action
the same thing applies to all your database calls
every heavy computing, disk access or network request should always be done only AFTER checking which command was used
otherwise you're performing those actions on every single message even if the message doesnt contain any actual command
which makes your bot extremely slow and resource-heavy
(i am new to this as you can most likly tell) so i how do "checking for the command before attempting any kind of action"
like cmd ===
you're already doing it
how to you check which command was used?
message.content.startsWith
ye
you have lots of those in your code
so put all your heavy code inside those
never outside
so i should put the voted var inside it?
yes
you should always check which command was used, ie if message starts with some command
before doing anything else
only after you verify that the message did indeed start with some voting command, only then will you create a hasVoted request
same thing will all your database code
and almost everything else
the order in which things are done are extremely important in this case, because your bot is processing potentially hundreds of messages per second. one thing in the wrong order can basically destroy your bot
but what if i wanto use a idk = db.fetch(whatever_${blah blah}) in multiple if(message.content.startsWith
basically, you put a copy of it in each of them
for example
db.fetch(1)
if(message.content.starsWith(a)) {
db.fetch(2)
}
if(message.content.starsWith(b)) {
db.fetch(2)
}
lets examine this
if your bot receives 100 messages
db.fetch(1) will be executed 100 times
if one of those 100 messages contains "a", db.fetch(2) will be executed only 1 time
if the message contains "b", db.fetch(2) will still be executed only 1 time
but regardless of what the message contains, db.fetch(1) will still be executed 100 times
database operations tend to be slow, so you can imagine the performance difference that makes
oh so in every message. content starts with re featch in the same var?
that uses it
its never a refetch
because only one of them will be executed at any given time
unless you have multiple copies of the same startsWith for some reason
i mean like to it twice
yes you do it twice, once inside each
but that doesnt mean it will be executed twice
it will only be executed once, depending on which command it was
ok i will do that some time later cause i dont have that energy rn. but thank you for helping me. i am going to test the voted var in the if message.startsWith in a hour or so when im unbanned
alright
If I set the webhook URL (for bot) as a website, will the index of my website be able to receive the requests?
your website needs to listen to a POST request to the index page
as opposed to a GET request, which is the default that websites use
other than that, yes
Cool, would a if (request.method == 'POST') of sorts work, just listening for POST requests?
are you running express.js?
Yup
then you can do app.post("/",(req,res) => {})
I see, well thanks a lot!
const DBL = require('dblapi.js');
const dbl = new DBL('auth', { webhookPort: 5000, webhookAuth: 'password'});
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
app.post("/",(req,res) => {
console.log(`Received post request!`)
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
})
Received post request! triggers, but the user ID for the vote doesn't. Do I need to place the vote listener outside of the POST request? (Sorry, I'm a big newbie with how post/request works. After some research and reading docs, this was the best I could come up with.)
Youre not supposed to create a express server to handle post requests, because the dbl webhook do it itself
And in your bot settings on your dbl page you have to do the rest est to /dblwebhook instead of /
if you use the express method you dont need dblapi.js at all
How do I post the total number of servers to dbl when I have a shard in my bot
Pls help me
which library and language?
@vapid cape Discord.js
@restive otter, top10 komutunu sil.
zd
dรงs
@hollow temple if you're using the sharding manager, just put new DBL("top.gg token", bot/client) in your shard file, and it will do it for you
what is this language lol
Is there supposed to be a delay between a user voting and a bot being able to check that they did? My bot has to wait about 3-5 minutes to allow access to a vote-lock feature after voting
omg
i copied wrong thing
sorry wait
Error: 503 Backend fetch failed
yeah this
error
A common error with the website, usually fixed within 12 hours ยฏ_(ใ)_/ยฏ
@toxic niche The API endpoint has a delay, yeah. That's why we recommend using webhooks
I need to figure out how to do that with python
dblpy has official webhook support
i got webhook for node js https://www.npmjs.com/package/node-webhooks
you can own web hook
(node:13) UnhandledPromiseRejectionWarning: Error: 503 Backend fetch failed
at IncomingMessage.<anonymous> (/home/container/node_modules/dblapi.js/src/index.js:118:25)
``` Wit ?
hello
im trying to connect my python bot to DBLs api
but im a bit confused
i thought i would just start of with the example:
import dbl
import discord
from discord.ext import commands
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'dbl_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")
def setup(bot):
bot.add_cog(TopGG(bot))
but im not sure what value im supposed to provide for setup(bot)
i tried client and client.user and neither worked :/
What
What do you even mean with client.user
The setup function is automatically called by d.py in external files
If you are adding the cog (class) to your main bot file, you don't really need it
EDIT
The issue was that the firewall was blocking the port.
Thanks to Shiv, I fixed it by creating a new firewall rule:
TCP > Port 5000 > All Connections
~~The webhook doesn't seem to be working for me, I'm not getting any response when running the test in the bot's edit page.
Here's my code:
class MyCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.token = "TOKEN"
self.dbl = dbl.DBLClient(self.bot, self.token, webhook_port=5000, webhook_path="/dblwebhook", autopost=True, webhook_auth="test_auth")
@commands.Cog.listener()
async def on_dbl_test(self, data):
print(data)
And on the bot's edit page I have:~~
does anyone here have an example of them implementing this into their bot?
@sullen nymph The actual problem is dbl not working on Public Ips... (Maybe Windows Problem)
is your ip static, is your firewall on? if so, does the port allow traffic?
Is there any quick way to check if any of the servers my bot is in is on the server list?
no
Hi guys. Any idea how could I check if user voted for my bot, using webhooks and .NET Core? Are there any examples?
Do you mean this?
https://top.gg/api/docs?#webhooks
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.7/site-packages/discord/ext/commands/core.py", line 72, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ApiResponseError: {"error": "Rate limit exceeded.", "errorCode": 457}
How to fix this problem any one can help me
const DBL = require('dblapi.js');
const dbl = new DBL('auth', { webhookPort: 5000, webhookAuth: 'password'});
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
app.post("/",(req,res) => {
console.log(`Received post request!`)
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
})
?
password and auth , where exactly do I set these parts?
thank you. I'm trying
and btw
that code is still not going to work as expected i'd say
since the first post request you get from dbl won't be received by the vote handler

huh, I couldn't find that anywhere
awesome, thanks so much for the help both times ๐
Any ideas on how to get total/monthly bot votes with the API on discord.py?
does dblpy not cover the get bot endpoint?
It covers all endpoints
then just use get bot
can i ask? how to make like this. at my bot is N/A
-servercount @dull rune
@dull rune
To have your bot's server count displayed on DBL, please read the documentation on server/shard posting. Click here to see the docs.. You may also find #312614469819826177 useful; however it is strongly discouraged as most of the examples are extremely outdated.
okay thanks
@abstract cave #development
i realized lol
why there is not an api for top.gg/servers
i just trying to test the auto count, but it keep outputing this:
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x000001D0AACBE460>
python 3.8.3
how to get the id of the person who just voted?
I have dumb question. Can I use API before bot was approved?
tl;dr: no
as I see I can't get their API key. Ok
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/bot.py", line 608, in _load_from_module_spec
setup(self)
File "/home/narmy/cogs/topgg.py", line 69, in setup
bot.add_cog(TopGG(bot))
File "/home/narmy/cogs/topgg.py", line 11, in __init__
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/dblwebhook', webhook_auth='dblhook1234', webhook_port=1556) # Autopost will post your guild count every 30 minutes
File "/usr/local/lib/python3.8/dist-packages/dbl/client.py", line 86, in __init__
self.task2 = self.loop.create_task(self.webhook())
File "/usr/lib/python3.8/asyncio/base_events.py", line 429, in create_task
self._check_closed()
File "/usr/lib/python3.8/asyncio/base_events.py", line 508, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "main.py", line 90, in <module>
bot.load_extension(extension)
File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/bot.py", line 653, in load_extension
self._load_from_module_spec(spec, name)
File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/bot.py", line 613, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.topgg' raised an error: RuntimeError: Event loop is closed
main.py:93: RuntimeWarning: coroutine 'DBLClient.webhook' was never awaited
traceback.print_exc()
```so I always get printing this
who can help me?
whats you code
g
You put whatever you want there
And check that "whatever you want" in your code
To see if the request is coming from DBL or not
ok
what about the token @jaunty depot
wait
so is it like
https://LINKolink$(#3/dbl<token>
@jaunty depot
what

For example, I was using the url part like http://myvpsip/vote
And had something in the auth key part
Which I used too confirm the requests coming from DBL
..
the thing I get is the DM from the bot
which gives me link and the token
the vps link
I don't get what you mean
I am using a vps for my bot, and I event is not getting invoked on_dbl_vote event invoked...
With the http://VPSIP:5000/
What is this bot
DBL Vote
@rich furnace Thats just a random token, not connected with dbl
What do I do?
this is for ur webhooks
isn't this the support server?
hmm wym
That bot is NOT an official bot made by DBL
That bot is NOT an official bot made by DBL
@jaunty depot lol
sorry for wasting your time
and url too and thats not official bot of dbl
ok
No you don't paste your token to auth btw
I am using a vps for my bot, and I event is not getting invoked on_dbl_vote event invoked...
With the http://VPSIP:5000/
@jaunty depot Can u answer this please
You can use express to get the request
And I suggest you to add something like /vote at the end
btw python doesn't have express
Instead of doing just the url
You open express as another project
On your vps
Not inside your bot
Python has Flask and Django
Server not reachable I tried Flask
It is not made by us but it was working last time I checked
2 yrs ago, will this work
Well, i tried samething with flask, it works with gunicorn
but not on self hosted IP
Note : Working with repl.it
But neither with vpsIP nor with mypublicIP
are you putting the text vpsIP and mypublicIP
or the actual ip?
because you listed both, but both are just placeholders for an IP adress
What URL should I put for the WebHook of my bot?
would it be dbl.post(client.guilds.cache.size) to update server amount?
postStats
26 servers working thanks!

I saw a Turk!

What's the problem bro?
Trying to set webhooks for dbl to get notification when someone vote for the bot
I don't even know if I should set up webhook for this feature but still
Can't set webhook get server's IP
Its normal bro
Also, getting 404 page on ip:5000/dblwebhook
Well it doesn't listen for GET requests
I didnt understand the webhook thing.
Wait
Does top.gg send a post request?
In the webhook?
to the webhook
Yeah
For people asking about voting webhooks, I watched this video https://youtu.be/fgTGADljAeg and then hosted it with ngrok and it all works fine. You will have to code a bit to get it so it deletes after 12h etc
In this video you will be building a fully functional REST API in under 30 minutes. You will learn how to setup a Node.js server with Express, how to connect that server to MongoDB through Mongoose, and how to setup a REST API with MongoDB and Node.js. This video is for any sk...
I put the link ngrok gave me into the webhook box and the test payload works
And if you do NodeJS for your bot, you can use superagent and use a get request to the api
Hope this helps people who need it
What URL should I put for the WebHook of my bot?
the url your webhook server is on
What URL should I put for the WebHook of my bot?
@graceful abyss http://<yourserverip>:5000/dblwebhook
And forward TCP|UDP port on 5000 with your server
Thanks
(node:21) UnhandledPromiseRejectionWarning: Error: 522 Origin Connection Time-out
at IncomingMessage.<anonymous> (/home/container/node_modules/dblapi.js/src/index.js:118:25)
at IncomingMessage.emit (events.js:228:7)
at endReadableNT (_stream_readable.js:1185:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
(node:21) 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(). (rejection id: 1)
(node:21) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:21) UnhandledPromiseRejectionWarning: Error: 520 Origin Error
at IncomingMessage.<anonymous> (/home/container/node_modules/dblapi.js/src/index.js:118:25)
at IncomingMessage.emit (events.js:228:7)
at endReadableNT (_stream_readable.js:1185:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
(node:21) 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(). (rejection id: 2)
(node:21) UnhandledPromiseRejectionWarning: Error: 522 Origin Connection Time-out
at IncomingMessage.<anonymous> (/home/container/node_modules/dblapi.js/src/index.js:118:25)
at IncomingMessage.emit (events.js:228:7)
at endReadableNT (_stream_readable.js:1185:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
(node:21) 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(). (rejection id: 3)
It's ok ?
No
i'm having trouble with putting this command into my bot () ```py
import dbl
import discord
from discord.ext import commands, tasks
import asyncio
import logging
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='Password', 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))```
Hi, i have a problem
after a "post" stats dblapi.js return's "400 Bad Request"
code:
const servers = await client.shard.fetchClientValues('guilds.cache.size').then(r => r.reduce((a,b) => a+b));
DBL.postStats(servers, client.shard.ids[0], client.shard.count);```
wat is this
patrick
(node:21) UnhandledPromiseRejectionWarning: Error: 522 Origin Connection Time-out
at IncomingMessage.<anonymous> (/home/container/node_modules/dblapi.js/src/index.js:118:25)
at IncomingMessage.emit (events.js:228:7)
at endReadableNT (_stream_readable.js:1185:12)
at processTicksAndRejections (internal/process/task_queues.js:81:21)
``` Can you help me ,
Why does the client give me null?
Is it possible to use client inside dbl.webhook.on?
(node:36) UnhandledPromiseRejectionWarning: Error: 524 Origin Time-out
Is the vote webhook not working? Not sure if i'm tripping
So I have this setup:
import dbl
import discord
from discord.ext import commands
import os
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, client):
self.client = client
self.token = os.getenv("DBL_TOKEN") # set this to your DBL token
self.dblpy = dbl.DBLClient(self.client, self.token)
async def on_guild_post():
print("Server count posted successfully")
@commands.Cog.listener()
async def on_dbl_vote(self,data):
print(data)
def setup(client):
client.add_cog(TopGG(client))
but when I receive a vote, nothing happens. The data is not printed.
So I double checked API and it says it should be @bot.event but I get an error for ```swift
NameError: name 'bot' is not defined
I tried client as well
HOW CONNECT uh
That error isn't from that part of the script, as I don't see 'bot' anywhere
Anyway just define bot and done
How can i check if someone has voted in python with webhooks
@maiden sierra the decorator for events in cogs is commands.Cog.listener()
Make sure you actually set webhook kwargs in DBLClient (refer to dblpy.rtfd.io)
https://dblpy.readthedocs.io/en/latest/api.html#dbl.DBLClient.get_user_vote @restive otter
As for webhooks, store the user's ID from vote data in a database
Why doesnt this work?
@commands.command()
@commands.cooldown(1, 43200, commands.BucketType.user)
async def claim_vote(self, ctx):
x = self.dblpy.get_user_vote(ctx.author.id)
if x == False:
ctx.reset_cooldown
e = discord.Embed(
colour = discord.Colour.green(),
title = "You haven't voted today!"
)
await ctx.send(embed=e)
if x:
Define doesn't work
wdym
Any errors you're getting?
well it checks if the user upvoted your bot in the last 12 hours
Ye but my alt hasnt
And the API doesn't seem reliable for that so I would recommend using webhooks
How webhooks work?
set up a webhook, make top.gg send requests to a URL once someone votes, store votes in database, see if last upvote was within past 12 hours
Wdym by to a url
A webhook is an application that listens to certain requests sent to the machine. In order to send the request, the sender must know where to send one. A URL containing your machine's IP and port address will be needed for top.gg to know that it needs to send the vote data.
Not really, if it can listen to requests, it will work
Just idk how
There's a guide on https://top.gg/api/docs#pylib
Spice up your Discord experience with our diverse range of Discord bots
That's the event used to handle actual votes, yes
its actually not that hard
Where can i find this data webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
You set it in DBLClient
Open port 5000, go to your bot's Edit page, see the webhook URL field. There, you enter a link like http://ip:port/dblwebhook where ip is your public IP and port is 5000
There's probably a setting somewhere that allows- yeah
Mhm
And no port in the link right
You do set the port in the URL
?
Your port is in the wrong place
Lol
Also nice ip you got there
?
It would ip:port/dblwebhook
ohk
Also would suggest deleting the message with the ip
Its not my ip
i changed it a bit
How can i find the what data it sends ? dbl.on_dbl_vote(data)
Ok found it
Can i use any other port than 5000?
Yeah as long as it's not used
I still keep getting error
^C^CTraceback (most recent call last):
File "main.py", line 710, in <module>
client.run(token)
File "/home/markustraus/.local/lib/python3.7/site-packages/discord/client.py", line 637, in run
_cleanup_loop(loop)
File "/home/markustraus/.local/lib/python3.7/site-packages/discord/client.py", line 92, in _cleanup_loop
_cancel_tasks(loop)
File "/home/markustraus/.local/lib/python3.7/site-packages/discord/client.py", line 77, in _cancel_tasks
loop.run_until_complete(asyncio.gather(*tasks, return_exceptions=True))
File "/usr/lib/python3.7/asyncio/base_events.py", line 582, in run_until_complete
raise RuntimeError('Event loop stopped before Future completed.')
RuntimeError: Event loop stopped before Future completed.
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f49f9481518>
```'
you didnt control + C so yes
that pretty normal when not shutting stuff down properly
With tests it still doesnt work tho
can i get high five api
Still cant get it to work
So when I try to use dbl.webhook.on('posted', () => {}) it never updates
So it shows that my bot is always offline
your bot is offline coz its kicked out of here
the offline status is different from dbapi
Oh
I kicked it myself but ok
lol
How would I add it back then? Lol
ask a mod
Wrong
@fair herald no
Look in the docs
dbl.webhook.on('posted', () => {
console.log('Server count posted!');
});
The autoposter has nothing to do with webhooks
Why does it say dbl.webhook then? Just a question
An official module for interacting with the top.gg API - DiscordBotList/dblapi.js
Most likely a mistake
done
โค๏ธ
how do i change the background colour html <body style ="background-color:lightblue"> this doasnt seem to work
-api
THIS CHANNEL IS ONLY FOR SUGGESTIONS/HELP/BUGS TO DO WITH OFFICIAL TOP.GG API LIBRARIES AND API DOCS FOUND AT
https://top.gg/api/docs
thanks
-api
{
"recipients": [
"Only iterables may be used in a ListType"
]
}```
where is your bot hosted?
AWS EC2
check if they require you to allow ports in some firewall
but i was testing just on my PC
in the admin panel
your pc needs port forwarding in the router
for it to work in your pc
oh let me read up on that, thanks
What?
you cant
top.gg webhooks are not compatible with discord webhooks
you'd need a middleman to convert from one to another
A webhook in web development is a method of augmenting or altering the behavior of a web page or web application with custom callbacks. These callbacks may be maintained, modified, and managed by third-party users and developers who may not necessarily be affiliated with the ...
How to send a message to a specific channel when voting for my bot?
@left egret
this kid advertising his roblox clothing group in api lmao
hmmm. Maybe @craggy sentinel is here
lmao i already had the ban prompt open as you pinged me
oh lmao just the slow phone typing
I'm slow
it's ok, we still love you
Slm
I want my bot to approval now please check it
Hum
Ah yes approve my bot that i deleted today
self.dblpy = dbl.DBLClient(self.client, self.token, autopost=True)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print(data)
You're not setting webhook arguments
Well yeah
Without knowing at least the port, the program doesn't know where to host the webhook
Unless it'll try to use the first available port in a certain range, which is... bad
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print(data)
it is never calling this function
self.dblpy = dbl.DBLClient(self.client, self.token, webhook_path='/mypath', webhook_auth='mypass', webhook_port=5000)
anyone
What have you entered on your bot's Edit page?
what?
You need to enter a URL on your bot's top.gg Edit page
Hence the port and path, http://ip:5000/mypath where ip is your public IP
scroll all the way down once you press Edit to see webhook options
ohhh
my bad
ok I've entered
now it may call that method automatically when user vote
how to make discord bot
-faq 3 -c
it's currently down
ยฏ\_(ใ)_/ยฏ
How do I make a test vote?
Test button on your bot's Edit page
Thank you
I'm getting 500 server errors too
oof
time to stop making my game and actually handle that error
Is there a example code for dblapi.js with the kurasuta sharding manager?
Doubt it, you could probably just set up an interval and manually post with postStats
yeah, just have no idea where to put it
should be the same
you basically have 3 options:
- put it in the manager and postStats with broadcastEval/fetchClientValues
- put it in the shard, and make it run only in shard 0, then use postStats with broadastEval/fetchClientValues
- put it in all shards and use the autoposter (if you dont need webhooks or you run a separate webhook elsewhere)
@vapid cape the webhook thing is the problem, although I think i solved it. Thanks :)
how do I check if the message author has voted for the bot? I can't figure it out
Why does the Ready event work and the vote is not?
@tardy elm which lib
Why does the Ready event work and the vote is not?
@tardy elm which lib
@willow spindle discord.js guess I should have said that
check hasVoted()
I looked and I canโt figure it out
i need to have a web server to run a webhook?
@graceful abyss the vote event has other requirments
you need to input correct information in your top.gg edit page under the webhooks
what is "correct information"
a correct URL and Authrization
the URL depending where your bot is hosted
and Authorization being what you write in your webhookAuth password
ok but what URL do i use?
the URL that points towards a webserver you run
or a service that you want to receive webhooks in
if you're using javascript and node.js, the dblapi.js module sets up a webserver for you
@vapid cape Probe with the URL ProjectName.glitch.me/dblwebhook and with ProjectName.glcy.me:5000/dblwebhook and it does not work
glitch cant be used to host Discord bots anymore anyway
it can
no they released a thing saying that you cant have a pinging service ping your project
there are other ways to ping it and keep it alive, besides they said that restriction was only temporary
Honestly, I wouldn't be surprised if all the free online hosting methods for bots go away in the next year.
Glitch is gonna lose a ton of users
good riddance honestly
Yeah I donโt know what to put after dbl.hasVoted
@tardy elm user ID
its a ton of users who basically waste tons of resources and pay no money
@tardy elm user ID
@willow spindle so would I do command.author.id?
im doing something wrong i think
where is your bot hosted?
local networks usually require port forwarding in your router
so if i placed the bot on my host it will work?
what URL do i use if the webserver comes from dblapi.js?
anyone know how to get the Api to send who Upvoted into the server? it's not working,
im trying to figure that out too
yehhh lol i got server count working but-
@bold gulch your vps ip address and the port you define
@restive otter did you set your URL and Authorization in your top.gg edit page?
is there a path i set or no
the default path is /dblwebhook
@vapid cape yep it's as my ip and port 5000,
self
self hosting usually requires opening ports in your local modem/router/firewall
aka port forwarding
i need to get @burnt aspen hosted -- she's breaking my laptop lmao
use intents
hm?
discord intents
fixes most resource usage issues
unless your bot needs stupid stuff like presence updates
nope, my bot's Presence is fixed,
apparently yes
@restive otter intents are for inbound payloads
nope, my bot's Presence is fixed,
he meant users presence updates
hey i need help with DBLPY



