#topgg-api
1 messages · Page 103 of 1
no..
lol mee6 muted
-API
how would i recieve webhooks on my vps using python?
do i need to download pgadmin4 to use it?
how would i recieve webhooks on my vps using python?
@novel moth https://pypi.org/project/dblpy/
do i need to download pgadmin4 to use it?
@pastel bloom i dont believe so, depends on what you're trying to do, but that doesnt seem like what you need
does its webhook server support server voting too?
yeah, https://discordapp.com/channels/264445053596991498/285458046006591499/752239408467673200
You can also integrate DSL roles yourself using the webhooks system.
@pastel bloom i dont believe so, depends on what you're trying to do, but that doesnt seem like what you need
@hearty lintel i want to create a db
@hearty lintel i want to create a db
@pastel bloom this doesnt seem related to top.gg api?
oh
if you want help pickin out one you can ask in #development
My code: ```py
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 = '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")
@commands.command(
aliases=[
"топгг"
]
)
async def topgg(self,ctx):
dbltoken = "token"
topgg = dbl.DBLClient(self.bot, dbltoken)
l = await topgg.get_bot_upvotes()
g1 = l[0]
g2 = l[1]
g3 = l[2]
g4 = l[3]
g5 = l[4]
emb = discord.Embed(title='Last Votes', color=0x147DFF)
emb.add_field(name=f"{g1['username']}", value=f"{g1['id']}", inline=False)
emb.add_field(name=f"{g2['username']}", value=f"{g2['id']}", inline=False)
emb.add_field(name=f"{g3['username']}", value=f"{g3['id']}", inline=False)
emb.add_field(name=f"{g4['username']}", value=f"{g4['id']}", inline=False)
emb.add_field(name=f"{g5['username']}", value=f"{g5['id']}", inline=False)
await ctx.send(embed=emb)
def setup(bot):
bot.add_cog(TopGG(bot))
My error: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f81ecab3e80>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x7f81dbdc79a0>, 26.822597434)]']
connector: <aiohttp.connector.TCPConnector object at 0x7f81f9069b70>
@sullen nymph
You're closing the bot while a request was being sent/handled
And what I should to do?
Feel free to ignore that. It's you closing the bot while a session is open
So I'd say wait instead of force-exiting from the bot process
@novel moth https://pypi.org/project/dblpy/
@hearty lintelthe discord.py lib doesnt seem to have webhook support for servers
it looks like it does? not sure i dont use dblpy
not yet, wink wink
oh
it has webhook support for bots not servers
is there an eta for when server support will be added?
Within a week or two, probably
You can host your own with aiohttp.web or Sanic for proper integration with d.py
i have no idea how to lol
Eh fuck's sake, scrap dblpy's source code and replace getting bot key from request.data with guild and you got yourself a server webhook
thx
Is there is something like
api.on('vote',async(user)=>{
console.log(user.username)
})
using dblapi.js there pretty much is yeah
Oki thanks
const DBL = require('dblapi.js');
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
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!`);
});```
from <https://top.gg/api/docs>
Thanks ,
What updated in new release on pypi?
wig wog see the changelog
:^)))
Now, excuse me, but why didn't it build the latest version
@oblique sluice it just sends a post request to the URL
{
"guild": "358630393869631498",
"user": "247741991310327810",
"type": "upvote",
"query": ""
}
```type difference stays the same as DBL webhooks
e.g. test / upvote
authentication is stored in the req headers
@rapid kettle do you know if isWeekend is present?
It isn't.
You'd need to make a get request to https://top.gg/api/weekend iirc
oh pog
docs that didnt exist when i was making my thing
It's not hard to get the weekend status
do weekends on dsl count as double?
Good question
Great question
Let me get my laptop :p
i wanna make a server webhook guide
lmao i inspect elemented dbl webhook and made pogdocs for server webhooks ez
but then again, people who want a server webhook probably won't have a clue how to follow it
so 
lets see your code
@oblique sluice
ok so express?
@oblique sluice you don't need to use http and express
try this js const express = require("express") const app = express() app.use(express.json()) // This allows you to see the post bodies app.post("/dslwebhook", function(req, res) { console.log(req.body, req.header("Authorization")) // This logs the auth and the body })
I can give role to someone who votes my server?
You can use top.gg's implementation of that feature or set up a webserver and do it yourself
with top.gg's webhook feature
yes
what?
@restive otter code yourself. We won't give you a code
If the dblapi.js library fails to check if a user voted will it return some kind of special object?
or just a null vote?
hasVoted returns Boolean. Do you mean that?
well guys, I don't know how to reward people by voting
cuz the bot isn't even responding when people vote for it
do you have a webhook setup
like: people when voting, if in a common server with the bot, the bot sends a dm
do you have a webhook setup
@rapid kettle I have, maybe there's something wrong with it
let me see.
const DBL = require('dblapi.js');
const dbl = new DBL(config.dblToken, { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', () => {
console.log('O webhook do DBL está ativo');
});
it does the console log
but then
where are you hosting
heroku
oh dear
have you set the webhook url
you need to set it to the heroku url
should be something like https:// botname .herokuapp.com/
depends
it's the only link I can access the app itself
thats what you need, yes.
since I don't have html
it send somewhat of an error
it can't display anything to the user
but this never did anything bad to my bot xD
there's no page, doesn't mean it can't be accessed I guess
it will recieve post requests, yes.
just put the heroku url into the url section
and the template made by the api developers have 5000
as i told you to
yes
it does not serve a page
so I did everything nice
how i can make a webhook on my vps for dblapi?
does the port automatically open for requests from outside?
the port is normally open @pearl ibex
so ip4_address_of_my_vps:5000/dblwebhook would work?
Oh man, IPv6...
ipv4
Ah, nice. Yeah
yes it would work
Remember to add http:// before that
^
Sure. Make sure your firewall won't be blocking requests to port 5000 and that it's forwarded to the right machine in your router settings
😂 you lazy bum
messing with my router ports always causes trouble
e
this happened
i dont know
"web dyno isn't on" happened
on node.js when i do dbl.webhook.on it says cant read property on of undefined
you need to define the webhook parameters in the options in order to make use of the webhook
oh
I did this
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
and i set the url to the result of that
where i replaced 0.0.0.0 with the ip
when i test nothing happens
the port is open
2020-09-12T21:46:54.542943+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/" host=gumball-and-penny.herokuapp.com request_id=a31c01c4-6f0e-48ae-a05b-0221be1002db fwd="can't tell xDD" dyno= connect= service= status=503 bytes= protocol=https
now the bot is fully online
this happens
when someone votes, it was supposed to send a DM
but it does nothing
forget I know what to do
it didn't work
I had set the procfile to web: node index.js
still, it now shuts down the app
2020-09-12T23:04:16.226379+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=POST path="/" host=gumball-and-penny.herokuapp.com request_id=14e327b6-d2de-4718-b0f8-77ce8869312d fwd="haha" dyno= connect= service= status=503 bytes= protocol=https
someone...?
?
Ya?
I don't have a website for my bot
is that it?
I just need to have a web dyno running
but it shuts down the whole app
cuz I have no website to keep it turned on
@rapid kettle
👏
hi pip install dblpy doesn´t work
How does it not work
ERROR: Could not find a version that satisfies the requirement dblpy (from versions: none)
ERROR: No matching distribution found for dblpy
The api doesn´t exists.
already used
Nope
oh, okay
@scarlet gazelle what does python3 -V return
python3 -m pip
Oh shit my cmd say it :
pip is not a command
python3 -m pip
@sullen nymph thx
is there api for server list
@full crow No
oof
This was answered literally a few messages above
oh
[9/13/2020, 5:12:50 PM] > top.gg webhook running at http://0.0.0.0:5000/dblwebhook
pressing test doing no thing
is it port forwarded?
js
Hiya I am using the API but how do I get the user object from when a user votes so I can make my own message something like {user} has just voted for Slio on Top.gg!
I have tried parsing username: str in an arg but that does not work. Discord.py
you could fetch the ID
so did you put
http://vps.ip.ipv4.address:5000/dblwebhook?
@rapid kettle yup
you're using vote webhooks? @compact creek
cuz u can just fill <@id> with the id from req.user
ok
@rapid kettle any help please
yee
you're filling 0.0.0.0 with your actual ip right?
yup
lets see your dbl.webhook.on code
and is the auth the same as it is in the code
yeah sure
dbl.webhook.on('ready', async (hook) => {
client.core.conlogger(`top.gg webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on("vote", async (vote) => {
console.log('new vote')
});
is webhookAuth is the same as the auth u put in your bot page right?
yup the same
are you sure the port is open?
if the porti sn't opened or in use the console will show an error
aha
wait
let me try
done
it was the firewall
@hearty lintel thanks a lot brother
Any idea why I'm getting this?
This worked just before, but now that I moved my stuff to docker it suddenly won't run 
This is failing on import, makes no sense...
maybe define it as dbl instead of topgg?
Tried that too, same thing
Tried importing it after Discord as is shown in the docs, same thing also
line 18 
Nope
Won't work
The issue traces into libraries though
As if the name client interferes or something
@vital anvil do you have any input here?
Imagine
Just imagine
line 32 - import discord
line 35 from discord import Client
🙃
sounds like a hotfix for 0.4.1
Would need to do a lot of importing, it's not just the client that I'm using, but sure I'll try that
I'm pointing out my own mistake
Do you have any files named discord.py?
Oh I do actually, that may be it hold up
Well thanks for help, this was stupid 
😂 you had me scared that it was a bug introduced in 0.4.0
Gotta love it
How do we connect our bot with top.gg so we know when a user votes
How do we get user ID of the user who votes
its in the vote payload
hello
Where's vote payload
How do I make a webwook for everytime someone votes my bot
Or you apply for api in ksoft api and let ksoft do the job
@restive otter so what exactly was your question in #development? Are you getting requests from top.gg at all?
im just confused on which channel i ask for help in
i wanna use my bot to send a message to users who voted
but i dunno how i get the user id
in the vote JSON, get user key
It will be a string, so you will have to probably int() it
Not file
Your webhook will be receiving POST requests. Such type allows to specify request body.
With top.gg, you get a valid JSON syntax in a string, so you'll have to json.loads the request body. Once you do that and assign the JSON (now it's a dictionary) to a variable, you can do your_variable["user"]
Could use the API but it's highly unreliable
not sure what thats supposed to mean
i mean i see bots sending messages when you vote
KSoftAPI provide webhook service for dbl
But its a pain in the ass to get approved
which one is easy to set up
KSoftAPI for easy, but unreliable
Your own webhook server for hard but reliable
how do we use KsoftAPI
You sure?
i mean either way i just want to send a message to user after they vote using my bot whichever works for best is fine by me
Thats what ksoft do so, go to their website thats all
alright lemme check
so i set up ksoftapi and message content as this
%userid%
%voteexp%
%votedate%
so like when someone votes a webhook will be sent to that channel?
You will only receive the last 1k votes
Votes matter and can be logged via webhooks
ik and thats the prblm i cant setup that thing theres not YT video for that too
no guide on internet
It's literally a webserver listening to POST requests
It's literally a webserver listening to POST requests
@sullen nymph I didn't get you?
open a port on your VPS
@unborn canyon whats a VPS?
my bot is made with bdfd
Turk mod varsa yardim edebilit mi
-notr
İngilizceden başka dillerde sohbet etmek için #general-int kanalını, top.gg hakkında (Türkçe olarak da) destek almak için #support kanalını kullanın.
Bu kanalda Türkçe konuşmayın.
-notr
who uses bdfd and knows how to make vote logs
@restive otter learn real coding
Not mobile coding
It will be easier to make voting log, trust me
i tried cant get it hosting @restive otter
Well
BDFD cant do webhook shit
So youre fucked unless you learn real coding
dont wanna pay cant get heroku working
😫
Instead of heroku, why dont you get a real vps (paid vps)
is skysilk the cheapest? @restive otter
Wait.... you guys pay to host?
its only 2$💁♀️
i dont pay
@mossy sonnet pay to host is better than free host
Let go to development
ok
Since this is officialy offtopic
A VPS or virtual private server is a virtualized server instance run in the cloud. It acts like a normal server, allowing you to remotely login and manage it just like a physical server or computer. If you're looking for a way to keep your bot online 24/7, a VPS is a great option.
Having trouble choosing a VPS provider or don't know where to start? Click here for a list of common and affordable VPS providers.
I should've known ACK
-vps
-vps
Stop
stop this
I don't pay for my hosting... I have servers out in England and America somewhere
huh hi
@sacred shell do -api
-api
TOP.GG API ONLY!!!
ANY OFF-TOPIC CONVERSATION WILL BE DELETED AND MUTED
This channel is only for SUGGESTIONS/HELP/BUGS to do with OFFICIAL API LIBRARIES and API DOCS found at: https://top.gg/api/docs
Ty
np!
-api
you need to call hasVoted with a user ID
show code
After a bot is approved how does it work to receive the api token and webhook information?
hello, where would i find the voting requirments API? i looked everywhere. am i being dumb?
you are being ratelimited
you can't

Me too man, me too
Also, how are you clustering yet you don't even know what a 429 error is, is there a github repo somewhere that makes clustering super easy for people now? I wanna see 
I don't know if this is by my fault or my host's fault, but after a couple hours of running my bot start to send server updates too often.
My code in my bot.js looks like this:
dbl.on('posted', () => {
console.log('[top.gg] Server count posted!');
console.log(`[bot] Bot is working in ${bot.guilds.size} servers with ${bot.users.size} users!`);
})
dbl.on('error', e => {
console.log(`[top.gg] Oops! ${e}`);
})
How do I fix this so it updates every thirty minutes again?
@frigid lantern can you send your code to post servers count
That's literally all the DBL code I have in my files other than the constants.
Should I put this in my file:
bot.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});
oh
use autoposter 
@restive otter wtf is wrong with you
@frigid lantern dont put an interval inside .on("ready")
either put it outside, or make it .once("ready")
.on("ready") can be fired multiple times, when your bot gets disconnected and reconnects for example, so the you have multiple copies of the interval running
That interval snippet is from the docs. Also I don't use that in my bot.
work
@client.event
async def on_dbl_vote(data):
print(data)
``` only with a discord.bot() ?
Hey guys, trying to get the vote events from WH using the JS lib but I don't seem to be receiving event. The doc is pretty scarce so I'd figure I'll ask here.
using:
dblwh.webhook.on('vote', vote => {
console.log(`${vote.user} voted`);
});
I never received either the vote event from an actual vote or from the test in the bot's page.
using ```js
const dblwh = new DBL('topgg token', { webhookPort: 5000 });
Yup, tried with both the domain and domain+path
show your current config
Ok, yeah
Was me
Just realized I forgot to add the port
Godbless what work does to your brain
I need help in how to create a webhook, i don't understand how that webhook works.
I wanna do a reward for the user which vote fo the bot... but I don't understand that webhook
Anyone can help me? '-' ping me if possible
why does using https://top.gg/api/bots/your_bot_id/check?userId=user_id return an int and not a bool? does it increase to more than 1? or just switches to 1 and 0?
0/1 only
alright
So basically a boolean integer
yep, i thought it increases so it was just weird
👍
Does anyone know if there is an api for top.gg/servers votes?
I don't know about webhooks, what I put here?
@white onyx no but you can use vote webhooks
Marco ban this fucker please
@split plinth shut the fucck up
or bean bean bean this child
hAcKeRpRaNk
hAcKeRpRaNk indeed
would it be possible to list everyone who has voted for bot in the last 24 hours?
<dbl>.getVotes() in js
returns array
how can i generate a token ?
i actually don't need a token to check who voted my server ?
then how ? 👀
i don't have my own bot
You can’t check who voted your server
Unless you setup a webhook
(Not a discord webhook)
about dblpy, does the lib handle the event for when someone votes?
can you guys give me idea how can i track if someone upvoted my server ?
setup webhook server
Does anyone know if there is a way to count votes using the dbd of the discord bot designer app? i need to know this dsclp ai ._.
my friend wants to know that too
dbl.getVotes().then(votes => {
const cEmbed = new Discord.MessageEmbed()
.setColor('#ff00ee')
.setTitle('Vote for the bot on top.gg!')
.setURL('https://top.gg/bot/705259016414298122/vote')
.setDescription(`Click the blue text above to vote for us!\n\n**Recent Voters:**\n ${votes}`)
.setFooter("Illusion v2.0","https://illusionbot.xyz/assets/BotLogo.png");
message.channel.send(cEmbed)
});```
would this work?
it said
Recent Voters:
[object Object],[object Object],[object Object],[object Object]```
I am not sure why its making us humans objecs
Does anyone know if there is an api for top.gg/servers votes?
@DeveloperDragon#3967 not yet
for the python lib, does on_dbl_vote require a webhook?
Hello everyone, is there any API docs for Discord Server List?
Like creating vote rewards with a bot?
@dapper relic Not currently, but I have worked with the DSL webhooks and their payloads.
The auth code is stored in the "Authorization" header
and the body is json { "guild":"guildID", "user":"userID", "type":"test / upvote", "query":"" }
the requests are made via POST requests.
Thanks a lot! It's a worthy information for me.
No problem!
How do I see how many servers my bot is on?
how do i do the vote webhook thing?
nvm
using the C# api and you're using AuthDiscordBotListApi it's you're bot's ID not yourselfs id right?
is there a query that will give me the users currently "live" in the voice channels of my server?
nvm
setup webhook server
@willow spindle would you tell me how can i do that ? 👀
do you know any programming language
js a little bit @willow spindle
What's the code for
Seeing how many servers the bot is in? Can any one tell
-api
TOP.GG API ONLY!!!
ANY OFF-TOPIC CONVERSATION WILL BE DELETED AND MUTED
This channel is only for SUGGESTIONS/HELP/BUGS to do with OFFICIAL API LIBRARIES and API DOCS found at: https://top.gg/api/docs
@restive otter cuz it's an object duh
stringify it
and console.log it
that'll show the contents of it
in normal object form inside the code you can do userObject.id to get the user id
-help
Hey! Bots aren't given permissions to send responses in this channel. Please use #commands or #265156322012561408 to run commands. In addition, bots with commonly used prefixes cannot read or send messages in any channel. This is done to prevent spam and bot abuse.
the api keeps sending random stuff like "AnJo, AnJo, AnJo, AnJo, AnJo", and "KatanaWolf, sigh, GUM GUM PISTOL, Haydes, do-not-know-what-to-type" instead of the actual recent voters
sometimes it correctly outputs it, sometimes it sends that random stuff
i have experienced this, yes
is there a way to fix it?
not that i know of
hello, please help me. where do i set up webhooks when someone votes fopr a server
please help
i tried top.gg/server/MYSERVEDID/vote
but it gives a 404
the pin said it was that
I don't think there is a server api
I think It might only be for bots
@elfin drift
look at the most recent pin @restive otter
ok i found the link
however
how do i make my bot react to this webhook
pelae
i need to know
what
@elfin drift there is an api but very limited currently
you can set up the webhook by going to top.gg/servers/serverID/edit and scroll down
how does my python code listen for it]
no dude
as they said
the webhook cant send a message directly
its not in the format for a disc message
its literally right there
see the pin
the format is not that which could go straight to a server
the same way you use the bot api is the same way you use the server api
how does my bot listen for it
idk
ok thanks dude
ask @vapid cape our saviour
if he knows how then thats great
wut
idk why he pinged you lmao
but do you know how to make a bot listen for the webhook sent when someone votes for a server?
yep
but i mean how does my python code listen for webhooks at all
the pin says the format these wil be in
but idek how my bot can listen for them
soon™️
^
Sanic or aiohttp.web
those are async and d.py-compatible
If you want to go separate sync process, Flask or Django
anything you want
can i write what i want
Yeah
You'd just need to have the same thing in your webhook settings on the bot's top.gg page
if I enter this
i'm kinda confused, i'm using aws as my vps and it's showing me two ips, one that i see from my cli, and one that i get when i try to curl http://httpbin.org/ip
which one should i use to get the data?
if you self host do you need to use the token option? Just because of the changing IP address?
but anyway, i tried both and didn't receive anything, so another question, how long does it take to get the data?
a few seconds or minutes max
if you self host do you need to use the token option? Just because of the changing IP address?
@mystic mural Self-host? Could you please elaborate?
running on my own server with my own router
i pressed the test button from the /edit of my bot's top.gg page 2 mins ago, should i still wait?
or i should assume that i'm not receiving said data
because every time that the wifi disconnects the IP address changes
token doesn't change even if ur ip changes
for the webhook option
the url or the auth one?
That's a hard one
You'd have to make sure your IP is static
or at best it's updated whenever your IP changes, which is rather a tricky workaround...
using the token option isnt a bad thing right?
what do you mean "token thing"
the voting api thats not the webhook
Well, it's unreliable but you can use it
is there any bad effects of using a static ip?
The ability of being DDoS'd? People pulling info up? If you expose it to the wrong people, that is
are webhooks the only way to connect votes now? I dont see in the api that doesnt use webhooks
https://top.gg/api/docs#bots Get Bot and Get Bot's Last 1000 Votes
yep, i tried both ip and didn't receive any. 22mins have already passed.
Are you sure your there's no firewall to block the requests
or that the port you are using is actually correct
or the URL
oh so theres only gets but theres no events for non webhooks?
yeah the problem is, i don't know which ip i should put on the url, but for the port, i think it's listening just right because i tried to netstat -anp | grep ':5000' and it showed me a python3 process that's listening to it
Can you send me all possible URLs via DMs?
alright
what if you create a server using express? Would that take care of changing ip addresses?
express would be hosted on a machine and attached to an IP address the machine is on
so I dont need to manually type in the IP address
and whenever it changes I can just restart and itll set the new one right?
express will, if you set the IP it will run on to 0.0.0.0, but that doesn't mean the external IP will be updated everywhere where you entered it
oh I forgot dbl needs to know the ip as well
what I do is use a glitch project as the URL and then the project sends to a discord channel and the bot reads from the channel. Thats my only way right now.
The only good side of that is it doesnt require having the package installed with the bot
why when im trying to get votes from my bot sometimes gives random numbers?
shouldn't the python api example include a def setup?
no matter shift f5 fixed it
I guess I have made a malformed request.
const fetch = require("node-fetch");
fetch(`https://top.gg/api/bots/405208699313848330/stats`, { method: "POST", headers: { Authorization: config.top_api_key }, body: JSON.stringify({ server_count: 2613, shard_count: 2 }) }).then(r => r.json())
The output is { error: 'Required parameter server_count or shards missing' }
So I'm confused as to how top accepts data.
nvm. I figured it out. Forgot to set the content-type header
Credit give meee
Is there a way I can have the server vote webhook data (DSL not DBL) sent as https://my.webhook/url?data=stuff
There's no setting for that. The data is always sent in the request body
@sullen nymph by request body you mean HTTP POST requestbody?
Correct
thanks
I just want to be clear, if I'm using discord.js I only need the client argument in the constructor, I don't need to do anything else?
Probably dblapi.js
@lone comet Could you clarify what you want to use the DBL constructor for?
To post server stats, sorry.
???
lmao 2 people just misunderstanding everything
Yeah, autopost will activate and post server count every 30 minutes if you pass the client in the constructor
Okay, good I see now.

how would I get the voting API to work with it connecting to a plain IP and port? I also dont know what to put for webhook Secret.
Is there a rate limit on setting your bot’s sever count via the API?
hi
my webhook for voting wont respond to anything when i test my code is
const Discord = require("discord.js");
const { prefix, token } = require("./config.json");
const client = new Discord.Client();
client.commands = new Discord.Collection();
const DBL = require('dblapi.js');
const dbl = new DBL('not-today', { webhookPort: 5000, webhookAuth: 'password', client });
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!`);
});
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})```
ok
@half cedar it the ip open to the outside?
may i ask what these are for?
[2020-09-18 06:59:47] [INFO ] aiohttp.access: [IP OMITTED] [18/Sep/2020:06:59:47 +0000] "GET / HTTP/1.0" 404 172 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3602.2 Safari/537.36"
[2020-09-18 08:14:09] [INFO ] aiohttp.access: [IP OMITTED] [18/Sep/2020:08:14:09 +0000] "GET / HTTP/1.1" 404 172 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3602.2 Safari/537.36"
[2020-09-19 00:07:21] [INFO ] aiohttp.access: [IP OMITTED] [19/Sep/2020:00:07:21 +0000] "GET / HTTP/1.1" 404 172 "-" "Mozilla/5.0 (compatible; Nimbostratus-Bot/v1.3.2; http://cloudsystemnetworks.com)"
Its a user agent
@median badger yes the ip is open to the outside im using glitch.com
gLITCH
Can someone help me, I cannot get the webhook to work when I use the webhook test. I have my server up and i know its working because I can see posts I send to it.
This is the code I am using, I removed the token and the full ip of my server, I cannot see the post from the test webhook on the discord site
import dbl
class TopGG(commands.Cog):
"""
This example uses dblpy's webhook system.
In order to run the webhook, at least webhook_port must be specified (number between 1024 and 49151).
"""
def __init__(self, boi):
self.boi = boi
self.token = 'token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.boi, self.token, webhook_path='http://ip-address.ngrok.io/dblwebhook', webhook_auth='password', webhook_port=5000)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
"""An event that is called whenever someone votes for the boi on top.gg."""
print("Received an upvote:", "\n", data, sep="")
@commands.Cog.listener()
async def on_dbl_test(self, data):
"""An event that is called whenever someone tests the webhook system for your boi on top.gg."""
print("Received a test upvote:", "\n", data, sep="")
def setup(boi):
boi.add_cog(TopGG(boi))
webhook_path="/dblwebhook"
so I don't need to put the full address just /dblwebhook?
wow im an idiot, I didn't know I need to hit save before test
use dbl.postStats()
What does that mean
dbl.postStats(<your guild count>, <current shard ID>, <total shard count>)
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});
this?
thats outdated
i
i just gave an example
dbl.postStats(<your guild count>, <current shard ID>, <total shard count>)
what is a shard?
#development will explain better
How Do i get a api
ok
Do I need to leave the webhook_path = "/dblwebhook" or change it to the actual server path like webhook_path='http://555555.ngrok.io/dblwebhook'
Does anyone have this working on python?
dbl.webhook.on('ready', (hostname: string, port: number, path: string) => {
console.log(`Webhook running with path ${ path }`);
});
dbl.webhook.on('vote', async (bot: string, user: string) => {
console.log(`User with ID ${ user } just voted!`);```
any idea why the parameters to the callback are returning undefined?
the listeners fire
but path and user are both undefined
any1 can give me code so the bot dm u
No
idk how yo explain it
Code it yourself
i don't how
Then learn
i have a stupid online class !
can I test votes without using webhook?
i guess thats dumb to say
maybe its a firewall thing
oh wait i was supposed to click save first...
bot now I'm getting this
line 275, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
File "aiohttp/_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: invalid HTTP method
dbl.postStats(<your guild count>, <current shard ID>, <total shard count>)
@quartz heron where are you hosting your bot on?
Welcome to programming
vote.user returns a ID of user ?
Ah
// VOTING PART //
const DBL = require("dblapi.js")
const dbl = new DBL("montokenwtf", { webhookPort: 5000, webhookAuth: 'password' })
dbl.webhook.on('vote', async vote => {
const { inventory } = require("./models/indexModels")
const userExist = inventory.exists({_id: vote.user})
console.log(vote.user)
console.log(client.users.cache.get(vote.user).username)
if(userExist) {
const data = await inventory.findOne({_id: vote.user})
data.vote.package ++
data.vote.cooldown = Date.now()
data.save()
client.users.cache.get(vote.user).send("Thanks for voting ! You won a package. See you next time ;)")
}
})
It's not detecting it :/
for some reason today by bot isn't receiving vote webhook
@rocky cape How can you check vote when someone does it ?
Because it's not working now 
theres a webhook.on thing for it
check that your auth is correct
and i recommend using an express server as the webhookServer
instead of the built in on
Heuu
I have done something fast
In glitch
When I'm voting (test)
It's sending a post request
So that should be fine ?
@rocky cape
Heuuu yes But I can't host it xD
@rocky cape Can you show me an exemple ?
If you can
not sure about how to do it on glitch sorry
use express
I have done this
const express = require("express")
const app = express();
app.use(express.static("public"));
// https://expressjs.com/en/starter/basic-routing.html
app.get("/", (request, response) => {
response.send("OK")
});
app.post("/dblvote", (req, res) => {
console.log("Post from dblist")
console.log(req.headers)
})
// listen for requests :)
const listener = app.listen(5000, () => {
console.log("Your app is listening on port " + listener.address().port);
});
It's all I done
And in my bot
follow the guide on the api docs page
Yes but the webhooks.on doesn't work
In my I have done this
// VOTING PART //
const DBL = require("dblapi.js")
const dbl = new DBL("montokenwtf", { webhookPort: 5000, webhookAuth: 'mypassword' })
dbl.webhook.on('vote', async vote => {
const { inventory } = require("./models/indexModels")
const userExist = inventory.exists({_id: vote.user})
console.log(vote.user)
console.log(client.users.cache.get(vote.user).username)
if(userExist) {
const data = await inventory.findOne({_id: vote.user})
data.vote.package ++
data.vote.cooldown = Date.now()
data.save()
client.users.cache.get(vote.user).send("Thanks for voting ! You won a package. See you next time ;)")
}
})
But still not working :/
I didn't understand what should i do exactly
in discord js if I fetch a message, as in get one not in the cache, will I have access to the reactions of that message?
how i found the "webhookAuth" ?
do i need a dbl token to recieve server vote webhooks
No
@novel moth Use a a web server inside your discord project to interact betwenn discord.js and your server
can i make a docs page for DSL api
there is no DSL api
where
top.gg/servers/id/edit scroll down to bottom
it is webhook, not api
my brain hurts
guys, I'm here trying to understand the api.
wanted to know how the bot sends in a channel to see who voted for the bot.
help me who can 
guys, I'm here trying to understand the api.
wanted to know how the bot sends in a channel to see who voted for the bot.
@silk echo
I want my bot to say in the dm... Example: Thanks for voting me: D
@silk echo detect who voted
Then dm the user
Done
The API provides a lot of info about who voted
the more she doesn't send.

can I send the open source, or do I send only the code?
@silk echo you send the part of the code that DMs the user when it detects a vote on DBL
const client = new Discord.Client();
const dbl = new DcBL(process.env.dbltoken,
{
webhookPort:5000,
webhookAuth: process.env.senhadbl
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted! `);
client.users.cache.get(vote.user).send("Obrigada por votar em mim!")
});
I forgot to say that I changed the Dbl to dcbl
don't ask me why i did it '-'
nope
@silk echo where is DcBl defined?
send it
const express = require('express');
const talkedRecently = new Set();
const DcBL = require ('dblapi.js');
const { Client, Collection } = require('discord.js')
const Discord = require('discord.js');
const client = new Discord.Client();
const dbl = new DcBL(process.env.dbltoken,
{
webhookPort:5000,
webhookAuth: process.env.senhadbl
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted! `);
client.users cache.get(vote.user).send("Obrigada por votar em mim!")
});
😂
imma head out
@vapid cape ask these guys
how to log who voted for server?
more wait ...
how to log who voted for server?
@slim hemlock have a server listening for POST requests.
yeah sure pls
ok
so you mean i need to make a bot?
yes with express integration
Glitch?
NO
idk how to host bot 24/7 online lol
using a VPS
whats VPS? ik VPN
it’s a virtual private server
ah gotta look for it on yt first
they go for about $3/month
wtf bro any free plan?
they aren’t expensive?
still
ok fine
at least use https://repl.it/
Repl.it is a simple yet powerful online IDE, Editor, Compiler, Interpreter, and REPL. Code, compile, run, and host in 50+ programming languages: Clojure, Haskell, Kotlin, QBasic, Forth, LOLCODE, BrainF, Emoticon, Bloop, Unlambda, JavaScript, CoffeeScript, Scheme, APL, Lua, Pyt...
it kinda seems known
So, you wanted code right?
yes
const Discord = require('discord.js'); // basic require statements
const client = new Discord.Client();
const express = require("express")
const app = express()
app.use(express.json()) // this allows you to see the DSL post requests
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
app.get("/", function(req, res){
res.send("Alive!") // This will send the word "Alive" if you go to the link in your browser.
})
app.post("/", function(req, res){
const Auth = req.headers("Authorization") // This grabs the authentication code sent with the request
if(Auth !== "Your Auth Password")return // This stops all false POST requests.
console.log(req.body) /* This should return {user: "USERID", guild: "GUILD ID", type:"test OR upvote", query:"dont worry about this"} */
})
client.login('token'); // logs the bot in
you can do stuff with the body.
you could send a DM to the user
you could send a message to a channel
If the API sends a POST request to my URL, what would the body be?
never mind its okay
@fiery pagoda which type of webhook?
bot
@rapid kettle
it should be:
{"user": "USERID", "bot": "BOTID", "type":"test OR upvote", "query": "something"}
right?
I think so yea.
lemme see
Hey so I have a question according to the api and the votes.
it says: Bots should not be rewarding users for voting for another bot
But it's ok the reward them with f.e. Coins when they vote for my own bot?
Let's say you vote for Bot 1.
Bot 2 can't give you currency for voting for Bot 1.
But Bot 1 can give it's currency for someone voting for Bot 1.
OK thanks
what is the response if a bot gets a vote?
wdym what my bot sends?
is there a way to like imitate a Vote to check if my code works?
the test button
Can someone help me with posting to webhooks with python?
what URL am I supposed to put in the "url" section on the webhook settings
http://yourVPSIP:port/dblwebhook
thank you
and if i wanted to test it on my local machine, i would just put in my public ip?
Yeah but you would need to adjust your router settings too
oof ok, ill just test it on a vps haha
at least use https://repl.it/
@rapid kettle that thing shows your code to everyone
Repl.it is a simple yet powerful online IDE, Editor, Compiler, Interpreter, and REPL. Code, compile, run, and host in 50+ programming languages: Clojure, Haskell, Kotlin, QBasic, Forth, LOLCODE, BrainF, Emoticon, Bloop, Unlambda, JavaScript, CoffeeScript, Scheme, APL, Lua, Pyt...
use heroku.
Repl will show your code, but if you create a .env file that you can hide your bot token in, you should be fine, as when other people acsess your repl they can't see .env files
alr but it doesn't stay 24/7
anyways, what vps hosting would you recommend
like paid one
for bot hosting
cuz I plan on buying one
oh
cuz i dont want any of us to be muted
alright.
hi. for some reason, I get a "cannot access client before initialization" error on the line where I put my DBL token. does anyone have any idea what's going on?
const DBL = require("dblapi.js");
const dbl = new DBL('token here', client);
where is client
client is your discord library
for me my client is client = new Eris(config.botToken)
is there an api to fetch all available emojis (custom and non)
speak spanish
How do you do voting detection when sharded?
@pearl arch you need to define client before you do new DBL(..., client)
nvm
I am having few commands in my bot which are only accessible by the premium members but i want the premium command to be available for those who voted for my bot on top.gg!
is it possible to do so?
@jaunty cliff use dbl.hasVoted(user ID)
anything change with the dblapi.js
is it dbl.postStats(servercount, [shard id], [total shards])?
bc mine isnt working
nvm its working now
I'm doing it on the phone and bot desinger for discord Can someone who knows me if they need codes to turn on music and come to the audio room in the app
BDFD 
J
ok
Wads dis?
an ANDROID APP
@restive otter ios to (;
WHAT
its on apple to
@fiery pagoda there's a additional weird field called discord_bot that's a repeat of the vote payload
had to add that in to my validator, but yeah its not exactly whats documented
client.on("ready", async () => {
client.shard.fetchClientValues('guilds.cache.size')
.then(results => {
let food = (`${results.reduce((prev, guildCount) => prev + guildCount, 0)}`);
setInterval(() => {
snekfetch.post(`https://discordbots.org/api/bots/stats`)
.set('Authorization', `${dblToken}`)
.send({ server_count: food })
.then(() => console.log(`Updated top.gg server count`))
.catch(err => console.error(`Whoops something went wrong: ${err.body}`));
}, 600000)
}).catch(console.error)
})
Does this not work anymore? Apparently my server count is 700, but it should be 3500.
@hasty mortar How many shards do you have
5
You're posting one shard's guild count as your bot's guild count
if you include the shard id+total in the post, dbl will automatically figure out the total for you
@hasty mortar
What the-
It said 700 servers with 5 shards before

This is weird
I know I'm not insane
I saw what I saw
Someone said it was cache related
@inner venture I am waiting 6 days to
@queen fossil please speed
I am not ful speaking English i am speaking kurdish
1-4 months!? It says 5 weeks
oh damn
@restive otter it says 5 weeks
So 1-4 months
https://top.gg/api shows {"hello":"world"}
so
idk
i submitted my bot like 11 weeks ago



