#topgg-api
1 messages · Page 111 of 1
¯_(ツ)_/¯
should I change the port number?
idk
Anyway to trigger the dbl.on_dbl_vote without actually voting?
Yes.
@Calamardo Tentaculo#3163 There is only invitation on the site, how do I add the voting?
@oak estuary
Okay
@patent lintel u are missing the @commands.Cog.listener above the the event
@oak estuary There is only invitation on the site, how do I add the voting?
@earnest sapphire Is your bot approved?
also sorry Cala for the tag.
oh fuck
Also how do you get the webhookAuth pass?
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });```
you will only be able to obtain it after your bot has been approved
the password is defined by yourself i think
wdym
iirc you will have to host the webhook yourself, but i might be completely wrong with that
You define the password
how do we get the dbl token again?
Its whatever you want as long as its the same in your code and on the site
One sec
thanls
Anyone have an example for discord.py?
is there something wrong with servercount at the moment?
A simple API wrapper for top.gg written in Python. Contribute to top-gg/DBL-Python-Library development by creating an account on GitHub.
Woulda sent earlier but discord was down
hmm
what should i add here??
ur webhook url
where do i find that
i just paste that in there?
you paste your info in there
NOOOOO
No
i dont know where i find my info
http://ip:port/path
yeah
Please turkish language
wheres your code hosted @cedar blaze
Does DBL Java Library have events for even a user votes?
Heroku @jaunty plank
@cunning sonnet u need a webhook
i dont believe the java lib does. youll have to use a webhook library for that @cunning sonnet
Heroku @jaunty plank
@oblique axle ur url would be<app-name>.herokuapp.com/<path>
Oh nevermind I just realize I don't even need that
i dont know where i can find that url tho lol
dude i have put the name but i dont know what to put in path
if your not setting path, the default path listed in the docs
dude i have put the name but i dont know what to put in path
@oblique axle if u are not using a seperate path, i think you can ignore that
most libs have a default path.
i dont
r u doing it in your index path?
if u r, then u can ignore the path i think
what lib r u using
ok then no need to use path
discord.js
@oblique axle also, you mean node.js right?
the dbljs lib has a default path
r u using dbljs
u asked for the library i use
ur asked for the library i use
@oblique axle im saying for the webhook
dblwebhook is the default path if you are using the dblapi.js lib
yeah
yeah
yeah im using the dbljs
yeah
then the path is dblwebhook
🙂
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!`);
});```
i can run this code with removing webhook right
Removing webhook?
yes
the js dbl.webhook.on('ready', hook => { console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`); part @jaunty plank
The ready event isn't required.
ah, so do i just need to get my authorization & token that's all
Yeah. Then set the webhook url on the site.
Portforward if applicable. Open through any firewalls too
discord webhook url right?
ah, so what do i set the url to
http://ip:5000/dblwebhook
it can be a domain name as well right
Yeah if you have a domain
http://ez-bot.xyz/dblwebhook like this?
You'll still need to set the port since its on port 5000
it supposed to be dblwebhook right i sound stupid
also i'll do that now
Yeah, the libs default is dblwebhook
Dw about it. Some people have zero idea how any of this works. Atleast you have a general idea.
Ah, and webhook auth is my authorization right?
It can be anything you want it to be, as long as its the same as what you set on the site and code
Is this correct? ```
const DBL = require("dblapi.js");
const dbl = new DBL(topggtoken, bot);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(Oops! ${e});
})```
It doesnt log anything in console
yeah it doesn't console.log for me in vote either lol
i have it inside a bot.on('ready', () => {}) event
im trying to post server count with dblpy but it isnt working. My code:
index.py
import discord
from discord.ext import commands
import os
client = commands.Bot(command_prefix="$", activity=discord.Game(name="idk"))
@client.event
async def on_ready():
print('Online!')
@client.command()
async def load(ctx):
if ctx.author.id == 697628625150803989:
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
client.load_extension(f'cogs.{filename[:-3]}')
await ctx.send('Done')
client.run('bot token')```
`topGG.py` (in cogs folder)
```py
import discord
import dbl
from discord.ext import commands
class TopGG(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.token = 'dbl token'
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)
@commands.Cog.listener()
async def on_guild_post():
print("Server count posted successfully")
def setup(bot):
bot.add_cog(TopGG(bot))``` it doesnt give me any errors, doesn't post the server count, and never prints "Server count posted successfully". Can someone please tell me what I am doing wrong?
@patent lintel any errors?
Also u inserted ur token here self.token = 'dbl token' right?
@silk reef of course lol
and i said no errors
and i realized i forgot to pass in self on async def on_guild_post():
more like it's not added in the examples on top.gg/api/docs but those are planned to be rewritten at some point
@sullen nymph wait so what did i do wrong
and i realized i forgot to pass in
selfonasync def on_guild_post():
but it still doesnt work
Try to fetch the API data directly to see if it actually changed
¨hello how can i make that this count update without i have to restart the bot. I'm codin in Java with the JDa librarie
put it on an interval
hm
why my ip is 0.0.0.0
it isnt
thats not my ip
thats just a placeholder as in all available ip addresses to the machine
so just use your public ip instead of 0.0.0.0
if /bots/748670819156099073/stats is the endpoint, what is the base url?
top.gg doesn't seem to work
requests.exceptions.InvalidURL: Invalid URL 'https:/top.gg/bots/748670819156099073/stats/': No host supplied
lol
oh ty
im using python. After I POST the guild count, how do I GET the response? This is how I am POSTing it:
import requests
data = {'server_count': 58}
headers = {'Authorization': 'dbl token'}
r = requests.post('https://top.gg/api/bots/748670819156099073/stats/', data=data, headers=headers)``` (this is working completley fine, I just want to know how to GET the response)
When someone votes nothing happens
The code:
const DBL = require('dblapi.js');
const dbl = new DBL(process.env.DBTOKEN, { webhookPort: 5000, webhookAuth: 'password' }, bot)
dbl.webhook.on('vote', vote => {
let embed = new Discord.MessageEmbed()
.setTitle('A user just upvoted!')
.setDescription(`Thank you **${vote.user.tag}** for voting me!`)
.setColor('FF000')
.setThumbnail(vote.user.displayAvatarURL())
let votechannel = bot.channels.cache.get('775360008786280468')
votechannel.send(embed)
})
Hello everyone, I just wanted to share an article I wrote about hosting a Python Discord Bot that uses dblpy to Heroku. I had a lot of trouble figuring out how to use the dblpy web server in my Python project when I hosted it to Heroku because of dynos. Hopefully this helps anyone who encounters a similar problem: https://dekoza.medium.com/deploying-a-python-discord-bot-using-dblpy-on-heroku-259e48c873ec
¨hello how can i make that this count update without i have to restart the bot. I'm codin in Java with the JDa librarie
@restive otter it autoposts every 30 minutes
@subtle glade okay thank you 😉
np
at=error code=H10 desc="App crashed" method=GET path="/dblwebhook" host=khaira.herokuapp.com request_id=c6c46abe-c71a-48c1-bad2-d4f80aa48c7d fwd="165.22.130.154" dyno= connect= service= status=503 bytes= protocol=https
I am using heroku
anyone help?
@cold nimbus try #topgg-api message
Errors would definitely be helpful
@versed storm Error: listen EADDRINUSE: address already in use :::5000
Well that means you already have something currently running on port 5000
Either that or you're doing this in a sharded bot which means it's running this more than once.
I've been having trouble getting top.gg's library to work with discord.py, the events don't seem to be triggering. Anyone know how to do this?
Here is my current code
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = TOP_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("Posted to top.gg")
@commands.Cog.listener()
async def on_dbl_vote(self, data):
pprint(data)
print(dir(data))
@commands.Cog.listener()
async def on_dbl_test(data):
print("Test!")
pprint(data)
I know that it's posting, because top.gg always has the right guildCount, but it's not printing "Posted to top.gg", and when I vote or send a test webhook, the corresponding events aren't triggered.
The code above was copied directly from the documentation and put together.
IF YOU RESPOND PLEASE PING ME
I have this promblem too ^^ need a solution lol
p!daily
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!); });
Where do i find my DBLToken?
I dont understand the webhook setup very well. This is the first API i will use in my bot and I need some setup help
@keen pebble you don't need to replace anything
But you gotta replace this with your discord top.gg api token
webhook path seems simple, it’s just your webhook url
with /dblwebhook at the end
mhm
@patent lintel r would be the response
@glass bone am I allowed to yell "thank you" at you for that article yet? 😂
@jade moss make sure your port is forwarded and firewall isn't blocking any requests
@forest shard webhook_path is what comes AFTER the url and it's not about Discord webhooks
@silk reef see my message above
o ok
The example relies on making http://ip:port/dblwebhook accessible
haha I'm glad it helped :)
Are there other events with the api? can get it back when someone votes for example, but can we recover when someone puts a notice?
webhook_path is what comes AFTER the url and it's not about Discord webhooks
@silk reef see my message above
@sullen nymph So we need to make a web request?
: (
@sullen nymph So we need to make a web request?
@silk reef the opposite of sending
A webhook listens to requests and does something with the data once something is received
Hi there, may someone explain me how to set up the upvote command? i alredy read the weebhook thing on top.gg site
Either that or you're doing this in a sharded bot which means it's running this more than once.
@versed storm yeah, 3 shards
But have any way to fix that?
Pls help me with the top.gg api
i want to use it to give reewards to users
but i dont wanna use cogs
if u know how to do without cogs(in python of course)
pls ping
Can I make a vote in my bot using the module? (dblapi.js)
@gaunt root your code needs to be on shard 0 only, or in the shard manager.
I ill try
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
what does "yourDBLTOKenHere" mean
how to get it
is there a limit to post stats on the API?
Are there other events with the api? can get it back when someone votes for example, but can we recover when someone puts a notice
@restive otter the bot token is given to you on the top.gg api page, after the bot has been approved. You can't use the API until then.
oh, ok
@jade moss make sure your port is forwarded and firewall isn't blocking any requests
@sullen nymph Lol that never even crossed my mind, I just assumed that it would work because discord.py worked.
what do i place in the webhook url
@gaunt root your code needs to be on shard 0 only, or in the shard manager.
@versed storm I tried in shard manager, but dont work
how do i create an webhook?
Hello, I tried using webhook in top.gg and it show me this message:
by webhook, does top.gg refer to self hosted webhooks?
yea thats what im trying to find out too
The webhooks do not work with discords webhooks.
They will work with some services iirc, but it probably makes the most sense to host it yourself
Host the receiver yourself*
thats the only way?
it will work with some external services afaik.
Any general purpose webhook receiving service theres no reason it won't work.
m ok
Hey where can i get the api may i know?
Are you posting your server count via the api?
@jaunty plank help me pls
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(Oops! ${e});
is this the code?
yes, it's this code.
Run the bot with the code.
Sometimes you just gotta wonder how someone ever got to the point where they even have a working bot, amirite
@jaunty plank where to place the code ?!!?!?
in your bot
Anywhere after client is defined
wdym by anywhere?
Your actual client
wtf are you tring to say
Anywhere
.
Put it at the end of the file, how bout that? Lol
@eager anchor bruh you don't know anything bout that? 😂
And you shouting on him
Did you even write your own bot?
my brain dead
!api
-api
No bot commands in here
Then maybe get some rest, sleep, eat, grab a coffee, and then do the code shoveling.
-api
I'm wondering how u got one bot approved
Again no commands here
@restive otter what are you trying to do, honey, maybe we can help
Did you make a new file for it?
yes
You'll need to run it via an export then
Which is fine if you want to go that route.
do i need to write things in the code?
like the cilent id
the bot token
because i think i need to replace that
Your bot client(the one you are using to get events from discord) will need to be passed in your export function.
and also the token?
The token you can hard-code into your dbl init line.
any more changes?
Other than the export stuff. It should work fine.
onyl this much change?
if it is then let me start
now i just need to export the file right?
@jaunty plank
i did the code
Man you really should consider actually learning javascript instead of expecting everyone to do your work
:/
You`re being quite the help vampire right now
Yeah, I have said like 3 times now you need to export it.
Useful links for learning JavaScript and Node:
codecademy online course: https://www.codecademy.com/learn/introduction-to-javascript
Eloquent Javascript, free book: http://eloquentjavascript.net/
Some Node:\nhttp://nodeschool.io/
https://www.codeschool.com/courses/real-time-web-with-node-js
discord.js getting started guides:
https://www.youtube.com/channel/UCvQubaJPD0D-PSokbd5DAiw/videos
https://www.youtube.com/channel/UCLun-hgcYUgNvCCj4sIa-jA/videos
Javascript reference/docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference
they should make a dsl api
To do what?
so I can award members for voting the server (with my bot)
Webhooks
webhooks


does it work with servers tho?
Yeah, servers have their own webhooks
cool!
thx
now I need help setting up the webhook
cuz I have no idea how this works xd
I can help in a bit if no one shows. Making breakfast real fast.
okay
Are there other events with the api? can get it back when someone votes for example, but can we recover when someone puts a comment
no
I don't think reviews are received via webhooks

@ancient kindle so webhooks are practically just the reverse of a traditional api.
All you have to do is setup an http server that receives post requests and tell the website(in the webhook section) to post to that relevant http server.
uhh
slow down
im dumb xd
ok
im thinking the express could have something to do with this?
help me @jaunty plank xd
I'm here, just trying to get a link
ok thx xd
yeah, express would work fine. it might be easest to look at the dblapi.js's lib to look at how the webhooks actually work.
https://github.com/top-gg/dblapi.js/blob/master/src/webhook.js#L57-L105
the lib might even work with servers, no idea since ive never played with it like that.
hmm
🤷♂️ if you know express it should be really simple for you though
just an app.post which checks the auth header is correct. then do what you want with the body.
I only know a bit of express, but if you have any questions about the process i think i can figure it out. just lmk
How to code a bot?
@frigid pebble #502193464054644737 message
Hi -- I'm trying to embed my widget in my Discord bot (embed image). When I try to use it, the image doesn't show. I tried taking the image URL and uploading it to imgur and that worked. I'm also noticing that the image preview doesn't show for the top.gg widget. Is there some header or something on the widget that prevents it from being accessed by Discord?
Widget on top.gg: https://top.gg/api/widget/699844962057060393.png
Widget on imgur: https://imgur.com/a/f0VLFV6.png
from what i understand, you need to attach the image, not just set the image as the url
actually, voltrex did something similar. just a bit ago.
#commands message
Hi
I want to manage votes, but the problem is, my webhook is hosting on https://localhost:8000, i dont think top.gg can access my local host
do they?
No, they need to have a publicly-accessible URL
You can enable port forwarding through your router
If you have a VPS it has a publicly accessible URL
Ok thats perfect
Ah
not ssh
yea same thing
you would have been given a IP with your server
That is where your link would be
And just listen to a port and use that IP:Port in the top.gg webhook site
Oo
I got the IP
I will test it out
😄
Omg it works
if I type the IP
its accisble
for me
Is it dangerous to share the IP of your vps with someone?
Enjoy
Thanks
If you want to greatly simplify your life look up ngrok.io it makes this sort of thing much easier (though the free plan is limited)
They may ddos it
I think digital ocean has DDOS protection
But eh why do u even need to reveal your IP
I need to let someone test
If you are hosting a site, Just use a proxy and link a domain
if it works
Anyone has idea about this?
https://prnt.sc/vffyuz
please ping me if someone replies
@jaunty plank thanks for your help, I used voltrex's method and got it working :) #commands message
perfect!
Okay so i did found out what i did wrong @jaunty plank
I did something
Object=[message.guild.id]=something
Instead of
Object[message.guild.id]=Something
OH
at least it wasnt discord.
yes it was my dumbness that brought us all down
What role? "Indonesian"? lol
I need help with the top.gg dbl webhook
i reading the doc and tried the example and its showing
Webhook running at http://0.0.0.0:5000/dblwebhook
``` and is not receiving votes
the library is hardcoded to say 0.0.0.0
you need to set the url on the webpage to the proper ip
k
this chat is fot?
how can i make my bot reward users when they vote?
wEbHoOkS
how do i set those up
@placid peak any good tutorial for that? I'm quite new to coding
Hey anyone who knows how to use python library for voting rewards using top.gg API WITHOUT COGS
@vagrant oyster sure
@everyone
JS Eris
@thorny leaf nice try bud
I know js discord js, don’t think there is much of a difference other then what you do with the results
I don't even really know where to start
I create a server with http, right?
const http = require("http");
const server = http.createServer((req, res) => {
res.end();
})
server.listen(5000);
I use express to do it but yeah you can
Yeah that's why I'm here
It doesn't work
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
Did exactly this, console logged it as http://0.0.0.0:5000/dblwebhook
On vote I got an error saying something like already in use or whatever
So I passed the http server I created into dbl's webhookServer
Try a different port
Yeah
Noo
Replace 0.0.0.0 with your IP address
IP address of place where Ur bot is hosted
@vagrant oyster
And the code?
create server
dbl:
webhookServer: server,
webhookPort: 1234,
webhookAuth: "somePass"
Oh nice I just logged a vote
CREEPER
?
Stop
CREEPER
like your profile picture
keep this channel on topic please
ok but what is the subject of this channel?
-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
okay thanks
👍
The hasVoted method has not been working consistently. Even 20 minutes after voting the method still returned false for some members. (Javascript Library) Please ping me in a response, very busy.
I have heard of people having this issue previously but not very commonly.
I would look into using the webhooks to receive vote events and tracking them via a database rather than on Voted method.
Won't be tagging since I dont have a fix for the specific issue your having.
Im posting my server count using python: ```py
import requests
data = {'server_count': 63}
headers = {'Authorization': 'api token'}
r = requests.post('https://top.gg/api/bots/748670819156099073/stats/', data=data, headers=headers)
data = r.json()
print(data)```, but when I run it, it prints {'server_count': 59, 'shards': []}, and the top.gg still shows 59 servers, instead of 63!
why?
@random kindle you using eris or discord.js?
@steel terrace discord.js and on heroku
if you forgot about this, my question was "How do I send a message to a channel via the dbl.webhook.on function?"
alr, do you know where to start or are you just having error problems ? @random kindle
ping me when you respond lmao
A endpoint
That you are listening to
With http or express
It will send you a json response that you need to parse
I was trying to use the module dblapi.js
I've read that
Ok
const DBL = require(`dblapi.js`)
const dbl = new DBL('token', client)
dbl.webhook.on(`ready`, () => {
console.log(`Ready`)
})```
Somethin like that
Yeah
Like nothing sends
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});```
I have that
For your webhook part you need a endpoint
and it doesn't send
So
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!`);
});
const dbl = new DBL("MyDblToken", { webhookPort: 5000, webhookAuth: 'MyAuth' });
I got now...
[ip]:port/endpoint
And on the site you would input [ip]:port and then have a auth
and it still aint working
Which you put in your code
Yes Nutella I have the same issue
Am I able to use a webhook for an api?
http://0.0.0.0:5000/dblwebhook
That is what it logged
and I put that in top.gg
and nothing happens still
I replaced that 0.0.0.0 with my IP
so it would be
I have an app installed called HTTPBot and allows it to send requests like GET, POST, PUT etc for links, add params and headers etc too
how would I get my ip?
http://IP:5000/dblwebhook
Well
Idk
What happens if its on a vps?
What would I do then
My IP is accisble
from outside
Get ur VPS ip
as i did
Did that work for you?
No
It does not
Man why do they make this so difficult lmao
I think im just too stupid to do this
It's either difficult or we are stupidly dumb
It should not be difficult
Yes
I think we're just dumb
I tried it with express too
since a lot persons can do it
Nothing send
sends*
I know
i tried same
The api is more advanced and is more understandable for experienced developers in this region
I tried everything
It is hard give me a sec to try and find mine
Thanks for taking the same to even help us
Yeah thanks for the help Extremely Vibin, I really appreciate it.
I think people are laughing their asses of, of seeing us struggling
Probably
But its very hard for me
So what do you lot need
We want to make the voting system works
webhook stuffs?
Not make it work
what library are you using
ok so both dblapi.js?
can I see your initialisation line
new DBL() without token
I don’t want your token
const dbl = new DBL(token, { webhookPort: 5000, webhookAuth: 'pass' });
We want to receive
replace your IP with ip
I see an immediate problem
no it isn’t
One sec he will explain
it’s all IPs available to the machine
so basically any IP the VPS has access to, commonly the public IP.
yes, public IP, not private.
Where would I find a public ip?
I suck with pcs
lmao
My VPS has 8 ips
or smthing
lmao
how do I find the correct one
there is no correct one
just any that is public
Where would I find a public ip?
@restive otter should be on your VPS page
That's what I meant
lol mb
ipv4: <MY VPS IP HERE>
this is what it says
thats it
PUBLIC IPV4 ADDRESS
<VPS IP>
PUBLIC GATEWAY
I got all of these
what i need to pick
SUBNET MASK
also that
Holy
The public one
Anyway I could test it while running on my pc?
Before putting it back on the vps?
Would I just grab my public ip for my pc?
I’ve got an api working but it only sends files like index.html and not text?
If I try text it says it cannot send an empty message
I'm using the botblock API (with discord.py), but it doesn't seem to post the servers on the website for my bot :/
To my webhook
channel topic
alr, do you know where to start or are you just having error problems ? @random kindle
@steel terrace idk how to start
alr lemme get some of my code out lmao
do you know the ip for your heroku server?
@random kindle
this will prolly be easier if you just dm me 
Via the api
https://top.gg/api/docs
Hello so with the webhooks I wanted to make it so it shows in the console whenever someone votes User with ID ${vote.user} just voted! and someone voted and it didn't go in console. It is all connected since of it said in console when starting bot
oh nvm
Im posting my server count using python: ```py
import requests
data = {'server_count': 63}
headers = {'Authorization': 'api token'}
r = requests.post('https://top.gg/api/bots/748670819156099073/stats/', data=data, headers=headers)
data = r.json()
print(data)```, but when I run it, it prints {'server_count': 59, 'shards': []}, and the top.gg still shows 59 servers, instead of 63!
Few problems with ur code:
- Requests is blocking.
- You should put this in a loop so it auto updates every so often instead of just on bot startup. What if your bot is online for a month? It'll only update once in that time.
- I'm too fucking drunk right now so I sadly can't really tell if this actually works or not.
@sullen nymph Fellow Python guru, please help me answer here

@restive otter as a one-time thing it's fine, yeah
@patent lintel What do you get when visiting /api/bots/botidhere/
can someone help me to make vote receiver?
can someone help me to make vote receiver?
@sharp hollow Just ask your question
me :confused :
Hello so ever since I added webhooks into my bot the server counter aint updating on the bot page.
Ok so with the python dbl library, I saw this:
Do I still need to set the webhook field on my bots page?
@inner leaf So I set my servers ip as the webhook, do I need to set a port number?
and if so which?
The port number you setup?
oh nevermind
I completely missed the extra kwargs passed to the client
thanks
I've got it now
hi guys
how work the dbl.webhook.on('vote', vote => {
console.log(User with ID ${vote.user} just voted!);
});
i need get update from vote
but i dont receive the response from top.gg
0.0.0.0 is not your IP
is local
what is the options?
No idea, it's your IP not mine. Sorry :/
I'm talking about the parameter that I should pass to the function
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
No idea, it's your IP not mine. Sorry :/
@pallid forge i set port and webHookAuth same for the api doc
You are using 0.0.0.0
i need extra step?
You can't use that if you want to connect to something online
as I told you, in the api doc I don't get that I have to set the ip in the webhook options
@pallid forge
When you setup the webhook
You need to put a URL
You can't use http://0.0.0.0:####
@patent lintel What do you get when visiting /api/bots/botidhere/
@sullen nymph uh it still didn't update and it responded this: https://hasteb.in/fexonayo.bash
does someone knows why it doesn't notify me when someone votes my bot?
wheres your code being hosted?
heroku
what url are you filling in on the site? does it include the heroku url?
well, its the public url for heroku.
heroku doesnt provide IP's
they provide urls
so what should i put in there?
yourprojectshurokuURL/dblwebhook
uh guys there is something weird, my bot is in 59 servers but for some reasons it doesent show up in the website any clue why
are you posting your server count?
yes
Firstly, what language are you using @restive otter
@jaunty plank the url should look like this? --> dashboard.heroku.com/apps/testbot
i can only see an N/A in there not a server count that the thing
and the other thing is 'no views yet'
dont think its the dashboard url, but i am not a heroku user so maybe? not sure.
which is really weird
https://github.com/top-gg/dblapi.js you could read this github to understand or just do npm install dblapi.js and then copy paste
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})```
@restive otter
hmm
it's dblapi.js and np! @restive otter
does someone knows why it doesn't notify me when someone votes my bot?
@oblique axle did you get a solution? I have the same problem
unfortunately no..
s
@oblique axle
a heroku url usually looks like this
https://yourAppName.herokuapp.com
for example
mine is https://harugames.herokuapp.com
btw dont play the games
its horrible
I have my bot in a vps, normally I deploy locally. That is why it is not clear to me which url I should place in the webhook
@glad minnow the url will be
http://IPofVPS:port/path
@jaunty plankwith server param?
webhookServer: myip
right?
like a hostname?
like a hostname?
@jaunty plank yes
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!);
});
but i need set the ip in options
@ancient kindle nope. It's not telling me who voted. It pops up an error in the console.
oof
in the url you used, did you add your path?
^
me?
yes
yeah: /dblwebhook
this library listens on any available port.
@jaunty plank is that I need to understand how to place the url in the webhook client. It's what I don't quite understand
the webhook lib doesnt take in a url
wdym? 🤔
it takes in a port and optionally a path, or optionally a server.
some providers require the use of
process.env.PORT rather than a static port.
i dont think so
heroku, glitch repl, some require it, some dont.
yeah looks like they use env port aswell.
https://stackoverflow.com/questions/28706180/setting-the-port-for-node-js-server-on-heroku
so what can i do now?
swap to using the env port variable.
here?
with that I should already register the votes?
on the top.gg webpage, your bots edit page, in the webhook section you need to fill out the url and auth section
other than that, should be good to go.
I understand, that is the part that I was missing! I will do that and tell you the results
in this url i need my vps ip and path, right?
http://ip:port/path is the format.
good
Can i give a dbltoken to unverified bot?
@quasi rose it doesn't matter if it's verified or unverified, it still works
Hmm ok
@jaunty plank you are the man
Ay
thanks man!
No problem
Pls weekly
Hello so ever since I added webhooks into my bot the server counter aint updating on the bot page.
Anyway to fix that?
Does my bot need to be accepted before im able to use the webhook?
Yes @ancient kindle
can someone help me on how to find the total upvotes for a discord bot with discord.js
like with the command? anyone?
Is it recommended to post server stats using dblpy
I didn't know which channel to send it in
So, I just voted for my bot, and nothing happened in my code. This is the code that I have:
import discord
from discord.ext import commands
import json
import asyncio
import random
import dbl
class VoteCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.token ='TOKEN'
self.dblpy = dbl.DBLClient(self.bot, token=self.token)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print("received vote")
print(data)
def setup(bot):
bot.add_cog(VoteCog(bot))```
am I doing something wrong
ping me if you know
I wish I knew discord.py :/
@proper narwhal You didn't enter your token.
I did
I just took it out for the example
Cuz I don’t want y’all seeing it
Lol
Yes
Like in the declaration of the dblclient?
I tried that at fist
First
Then I took it out cuz it wasn’t working
It’s ok
does anyone know how to create a webhook or some websites that can help me? Im new to this stuff
Wut
Show code
and what does not work?
He typing bee movie script doe
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('||do not look at my dbl token||', client);
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(Oops! ${e});
})
client.login('||do not look at my token I||');
^
do you get and errors for example?
others said this code for showing server count in your bot page
it should show an error if it doesn't work
Yea
-_- ok
hm?
hy
k
verification
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});
at the top off all?
@rain heart ?
what is this
no
put setInterval inside your on ready
so
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});```
like this?
do you have a client.on already?
Where do I write this
write what?
best is to put the client.onready inside your index.js
just append the setInterval inside your onready
online
just append the setInterval inside your onready
@rain heart
can you show the code? i guess i putted ir=t wrongly
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('do not look at my dbl token', client);
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(Oops! ${e});
})
client.login('do not look at my token I');
holy
like this for example
thats your code from above
but i cant guarantee that it works because i have only basic knowledge of js
oh k
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('do not look at my dbl token', client);
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(Oops! ${e});
})
client.login('do not look at my token I');
@rain heart
when i putted this nothing happend
Where did you put it?
in the code
yes
which file?
please use common sense. You posted your main js file (index.js)
in there, you should put your setInterval
k -_-
you have a on('ready') according to your screenshot of your code because it tells you the username of the bot
is there any problem if i turn my bot turned off for now?
because if people use it they can find some werid things -_-
nope, shouldn't be
?
comud
Im confused, my bot doesnt get vote notifications, why?
const dbl = new DBL(topggToken, { 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', async vote => {
const user = client.users.cache.get(vote.user);
console.log(user)
// rest of my code
})
can someone help me on how to find the total upvotes for a discord bot with discord.js
@restive otter can someone help me?
give me a minute
I don't think top.gg is sending requests to the specified URL
@restive otter it should normally
yeah but what thing do you use @rain heart like [something].monthlyPoints What goes in that something
yeah but what thing do you use @rain heart like [something].monthlyPoints What goes in that something
@restive otter https://cdn.hopefuls.de/H156
i can only tell you the things from the apidocs
I can send requests to the same URL using https://reqbin.com but whenever I test the webhook with top.gg, the web server isn't receiving it.
@restive otter i'd say wait for someone who has a clue about webhooks
because I'm just the dude looking through the docs
like does your bot even get a request or doesn't top.gg send it?
i can only tell you the things from the apidocs
@rain heart because dbl.monthlyPoints is not working and vote.monthlyPoints is not working so im stuck on what to use before the period.
as unfortunate as it sounds, but I'd suggest waiting for someone who has some idea why that might happen
you can always direct message a Moderator/Team member, but they most likely wont respond
@Hoffnung because dbl.monthlyPoints is not working and vote.monthlyPoints is not working so im stuck on what to use before the period.
refer to the apidocs, there's an explaination of getting your bot
@restive otter
yeah but what do you use before that?
oohhh now i understand
use .getBot before that
so you can get your own bot's object in order to be able to get points and monthlyPoints
so for example dbl.getbot. etc
yeah that should work afaik
i dont code in js, just know the barebones, but that is what i understand from the docs
ok
because getbot returns your own bot object when no id is given
dbl.getBot() then maybe?
should i do dbl.getBot('mybotsclientid).monthlyPoints?
nope, didnt work, still says undefined
the parameter is optional https://cdn.hopefuls.de/VQfN
OH
one second
dbl.getBot("mybot'sid").then(bot => {
console.log(bot.montlyPoints) //
});
yep it works 😄




