#topgg-api
1 messages ยท Page 82 of 1
vote != test in dblpy
@commands.Cog.listener()
async def on_dbl_test(self, data):
print("test vote")
did this, didnt work
wait now its unauthorized
brb
okay still doesnt work
do I need to set my port to listening or something? @sullen nymph
Well it needs to be open 
@last cedar are you sure?
i thought i updated it....
@wide sigil is your port open...
@vapid cape i had to refresh the client so ye it worked thx
Yeah @green mantle I believe so
check
I;m trying with 5000 now
Still doesn't work
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True, webhook_path='/upvote', webhook_port=5000)```
@green mantle any ideas?
Would a VPN generate a problem with that? Or is that just based on the VPN's user policy?
@wide sigil test it with reqbin
Send HTTP requests to the server and check server responses.
try sending a POST request to yourself, no need for authorization or content
if you are accessible, it will show unauthorized
if it shows any other error, then you are not accessible in that address
Getting 1007
oh wait
im getting 404 when im running mu code
@sullen nymph what do you do when you get 401?
now its working
hmm
401 means the request has found its target and successfully delivered the request
but when I click on test, it doesnt print anything
add your Authorization in custom authorization
when I do it from my computer
Oh
But on reqbin I get 401
405 is wrong method
curl does GET by default i believe
If you get a 401 response when sending a request to dblpy webhook
ah maybe because it's get
Your auth isn't setup properly
try adding an auth do your webhook
But I don't know the auth code
Does AWS have default authorization?
it has nothing to do with aws
its only an authorization between top.gg and your webhook listener
Auth is done in request headers
you define the auth where you create the dbl listener
so my auth should just be a string?
yes
okay one moment let me do this
Does the order matter?
no
self.dblpy = dbl.DBLClient(
self.bot,
self.token,
autopost=True,
webhook_path='/upvote',
webhook_port=5000,
webhook_auth=self.bot.PASSWORD)
then in reqbin add it as a custom auth
you should now get a bad request instead of unauthorized, if it works
then there is an issue in your code
or maybe py doesnt throw a bad request like js does
anyway add this
then check your logs
even with the content added?
still jsondecodeerror?
Huh what
That's fun
It's... internal but
it shouldn't even appear in the first place
Ah
There's no type key in the received JSON
lmao
I think it was my event
gotta try with a real vote now
They didn't have type in the JSON when testing with reqbin
Probably
But I remember seeing application/json
iirc the lib is loading the json'd response
so when it doesnt get that
it raises a json decoding error
I mean all I do is
type = request.headers.get('type')
if type == 'upvote':
event_name = 'dbl_vote'
elif type == 'test':
event_name = 'dbl_test``` which is why event_name can just not exist if there's no type or its something else
10/10 coeding skillz
so it expects a type parameter in the headers?
:^))
Might just throw everything into one event and make people check vote['type']
aka the way dblapi.js does it
dblapi doesnt even do that
it just gives you the content
doesnt check any header besides auth
i mean, the data apparently does contain type
but its in the data, not in the headers?
how do you add shards to the bot page?
check api for posting guild count, shard stuff should be there
it is for python anyway
i use autopost
some1 help
$.ajax({
method: 'POST',
url: `https://top.gg/api/bots/${clientId}/stats`,
data: {
server_count: ''
},
headers: {
authorization: token
}
});
server_count must not be empty
also you probably need to add contentType application/json
contentType: "application/json; charset=utf-8"
must be a number or null iirc
what are you trying to do?
i want the servers count ?
you want to set it or get it
you want to get it or to set it?
lmao
damn, beat me to it
i want it in webpage
considering they're using ajax
give me example pls
$.ajax({
method: 'GET',
url: `https://top.gg/api/bots/${clientId}/stats`
});```
i dont even know if the GET request requires authorization
it does
then add js headers: { authorization: token } again
๐ค
$.ajax({
method: 'GET',
url: `https://top.gg/api/bots/${clientId}/stats`,
headers: {
authorization: token,
contentType: "application/json; charset=utf-8"
}
});
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.4.1.min.js"></script>
make sure you use $.ajax only AFTER you load jquery
@vapid cape
<script>
$(function(){
$.ajax({
method: 'GET',
url: `https://top.gg/api/bots/${clientId}/stats`,
headers: {
authorization: token,
contentType: "application/json; charset=utf-8"
}
});
})
</script>
@gaunt quail
Hi, is there any way I can embed gifs from either imgur or gfycat and send them via a bot message? I'm working with the discord.py rewrite branch (v 1.4). I tried pasting the link into the url attribute of the Embed.set_image method but all it gives is the default discord poop sign after failing to load
Do I post this there as well?
Oh okay, apologies
all good
most websites don't allow requests from other websites
Well, I use discord.py. What data comes from the data parameter in on_dbl_vote?
I wanna get it right instead of having to test with friends voting for the bot.
Autopost in dblpy doesn't post shard stats ๐
I am confused, where do I put the API key?
Refer to examples
To get top.gg token, you scroll to the bottom of your bot's Edit page
if your bot isn't approved, can you still use the api?
no, you need a token
ok ยฏ_(ใ)_/ยฏ
I didn't even know there was an unapproved status
Ignoring exception in on_guild_join
Traceback (most recent call last):
File "/home/trackrunny/.local/lib/python3.7/site-packages/discord/client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "/home/trackrunny/LinuxBoi/cogs/TopGG.py", line 45, in on_guild_join
await self.bot.dblpy.post_guild_count()
AttributeError: 'LinuxBoi' object has no attribute 'dblpy'
Ignoring exception in on_guild_join
Traceback (most recent call last):
File "/home/trackrunny/.local/lib/python3.7/site-packages/discord/client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "/home/trackrunny/LinuxBoi/cogs/TopGG.py", line 45, in on_guild_join
await self.bot.dblpy.post_guild_count()
AttributeError: 'LinuxBoi' object has no attribute 'dblpy'
[NODE-us-127.0.0.1:2333] Unknown event received: TrackStartEvent
Ignoring exception in on_guild_join
Traceback (most recent call last):
File "/home/trackrunny/.local/lib/python3.7/site-packages/discord/client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "/home/trackrunny/LinuxBoi/cogs/TopGG.py", line 45, in on_guild_join
await self.bot.dblpy.post_guild_count()
AttributeError: 'LinuxBoi' object has no attribute 'dblpy'
Why do I get this when trying to update my guild count?
import os
import dbl
from discord.ext import commands
from logging_files.top_gg_logging import logger
class TopGG(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.token = os.environ.get("top_gg_token")
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)
@commands.Cog.listener()
async def on_dbl_test(self, data):
print(data)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
user = await self.bot.fetch_user(int(data['user']))
logger.info(f"TopGG | Vote From: {str(user)}")
@commands.Cog.listener()
async def on_guild_join(self, guild):
await self.bot.dblpy.post_guild_count()
@commands.Cog.listener()
async def on_guild_remove(self, guild):
await self.bot.dblpy.post_guild_count()
@commands.Cog.listener()
async def on_guild_post(self):
logger.info(f"TopGG | Posted Updated Guild Count")
def setup(bot):
bot.add_cog(TopGG(bot))
cuz thats not how oop works?
youre doing self.bot.dblpy
which isnt a thing
also dont post guild count on every join and leave
thatll just spam the api
My bot server number isn't showing up its saying 0 I know its in more then that but idk what to do, its supposed to show up in presence
nah that looks right in terms of getting guild count
Its saying 0
tho youre using an f-string yet not using any of its functionality
are you by any chance setting that activity before on ready is called...
whats your full code
async def on_ready(**kwargs):
print("Bot Online!")
print("Name: {}".format(client.user.name))
print("ID: {}".format(client.user.id))
print("------------------------------------")
client.remove_command("help")
print(discord.__version__)
activity = discord.Game(name=",cmds for commands! | Currently defining words on" + (str(len(bot.guilds))) + "Servers!")
await client.change_presence(status=discord.Status.online, activity=activity)
print(str(len(bot.guilds)))```
oh then that makes life easier lmao
notice how youre using client not bot
as your var names
Does that really mess everything up
yes
because you then have two bot objects and only one logging in to discord and getting guild count
๐
(node:32309) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token u in JSON at position 012:17 PM
at JSON.parse (<anonymous>)12:17 PM
Jump Toat dbl.hasVoted.then.voted (/app/komutlar/country.js:24:21)12:17 PM
at <anonymous>12:17 PM
at process._tickCallback (internal/process/next_tick.js:189:7)12:17 PM
what ?
you appear to have a syntax error
This channel is english only
yes
hmm ok
Hello! I have a little problem using the webhook system: I don't receive any post request
I got the problem too, I use dblpy, so python
self.bot = bot
self.token = 'token'
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)
Just did this on Cog init^
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print(data)
``` then I have this for the webhook
Do y'all read docs btw
https://dblpy.readthedocs.io/en/latest/api.html#dbl.DBLClient
**webhook_port (Optional[int]) โ The port to run the webhook on. Will activate webhook when set.
Nah I just copy the examples because I should think examples work
is the port open...
Does the thing automatically host a webhook when I configure it like dis:
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000, autopost=True)
Yes
your bot is hosted in a vps?
check if your vps provider requires ports to be opened in their firewall
for example, GCP/GCE does
did you restart the bot?
Yes
try sending a test request on reqbin
Send HTTP requests to the server and check server responses.
send a POST request to your url
Mhm
@vapid cape remember me asking about api and webhook and stuff and how it works?
I still haven't figured out how to use it properly... I did everything you said and when i test the url it just says could not connect in that reqbin.com
How do i pass the password @vapid cape
paste it into custom Authorization
wdym
but you dont need the password to test if the IP works
it will show unauthorized if it works, or connection error if it doesnt
Hmm
@restive otter where is your bot hosted?
Nothing in my console
@vapid cape i self-host it remember?
@thorny horizon that means the IP is working
Yes
Wait we need to provide the password when we are testing the POST in that website?
(The password we created in the Authorization)
Might use logging module for webhook requests tbh...
what's that now?
@thorny horizon
@restive otter if you get connection error, then the problem is not the authorization
Time to open issues on own repo
check your logs
Nothing
Hmm so the url is like this?:
https://MYPUBLICIPADRESS:MYPORT/dblwebhook
@vapid cape
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print(data)
anyway, the IP is working, so double check your URL and Authorization in top.gg
add the test listener: ```py
@commands.Cog.listener()
async def on_dbl_test(self, data):
print(data)
press save in top.gg and press test
Ohhhh
@vapid cape hmm what can i do when the error i always get is could not connect?
then your ip address/port is wrong or blocked
Still nothing on_dbl_test doesn't work too
you need to unblock it in your firewall/router
Yeah got a weird error
An error occurred while processing your request. Error code: 10035
@vapid cape Got it working ๐ I made a https req instead of http LMAO
And putty froze
so I couldnt see logging
here you can make requests if anyone knows of any API?
@sick stag
so what do you need to do?
you ask, he wants to check current votes, and votes per month
are you using dblapi.js?
im unable to return whether a user has voted for my bot or not - im using the .net lib for this as i cant find the url endpoint for voting
the userid parameter is currently set to a discord userid - and im thinking that may be incorrect
regardless, its returning false for a user that has voted.
The voted function only works asynchronously. @restive otter
I believe.
Can we see some of the relative code?
i believe ive fixed it - just testing it out currently, but i was using the bot's id from discord and not from the site
regardless, its stopped throwing a nullref exception and is allowing me access things
i also am running it as an async operation lol^^
example:
bool UserHasVoted = await Program.topggBot.HasVotedAsync(arg.Author.Id);
topggBot is of type "IDblSelfBot", and "arg" refers to a SocketMessage
I think you might need to catch the callback via a function
I don't know your alternative for JavaScript's ".then" function, but .then works
My explanations suck because I don't know a lot of terminology, sorry for the little help
it would declare correctly, it just wouldnt log in with the userid and token for some reason .. but like i said, i was using the bot's discord id and not the topgg id
but no its okay, thank you for the help lol
i wasnt able to, but ive resolved it
Do you have the error event listener available?
login function required two parameters
AuthDiscordBotListApi(bot_id, topgg_token);
i just misplaced "bot_id" for discord's id
but ye, like i said - ive fixed it, ty though
yup! and thank you
webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000
Using the python library, what is the significance of each of these webhook arguments?
webhook_path = the endpoint of your webhook server, for example /dblwebhook means your URL field will be mywebsite.com/dblwebhook or myIPaddress:PORT/dblwebhook
webhook_auth = authentication for the webhook, must be the same as what you put in the Authorization field in top.gg
webhook_port = port to run your webhook server on
So it hosts a webserver?
Very cool
they have nothing to do with discord webhooks
ty
Remember to set a auth field
To prevent unauthorized requests being processed by u
๐
Does the DBL python lib include functions for donatebot api?
Html and CSS in the long description, if you need help ask in #development
K
I need help with api. I'm lost what I need to paste into URL and Authorization into bot's edit page (basically webhooks). Not sure if it matters, but bot is hosted on windows
So if it's localhost I'd need to type in myip:port/dblwebhook?
Don't forget http/https before
Oh well I guess I just won't log votes, cause it doesn't work.. Thanks
And you're not going to try and actually fix it?
when self-hosting you need to portforward in your router
because ports are blocked by default in most modems/routers
:nekothinking: And you're not going to try and actually fix it?
I've been trying that for 3 days already, maybe somewhen in the future I'll re-try
because ports are blocked by default in most modems/routers
wouldn't I get error, that connection was blocked?
no
because the connection never arrives
top.gg will receive an error that your connection was refused or did not respond, when they try to send it to you
but top.gg internal errors and logs are not public of course
how do I portforward then
you can however use a service like reqbin to test webhooks yourself, there you will see all errors
you need to access your router's configuration panel, usually at 192.168.1.1 (varies depending on router model)
an look for port forwarding or virtual servers
and set your webhook port to be sent to your internal/local ip address
192.168.0.1 it was, unfortunately idk the password, and the passwords internet provides are incorrect. So I guess I'll need to test webhooks myself
check the router's box or the router itself, sometimes the password is written in the labels
unfortunately it's not
then you'd need to contact whoever configured it
(or push the reset button, but it will likely break your internet connection until reconfigured)
I'll just do it whenever I'll receive new router, thanks 
have you tried admin?
You can set it
ANYONE WANT TO BE my dou I have a mic and have 2fa and in diviosion 5 only because I don't play that much
arena
i play every day
Read this channel's topic.
you can put whatever you want, it's just a secret key that has to be the same on dbl and on the webhook backend
Hi guys, I'm not quite understaning how this API works, does the top.gg website update everything by himself or do I have to send him datas like server count and he will then update the bot page with that data?
you have to post server count
uhm ok I'll look that up
Ignore everything, was a silly mistake lol
is there a way to use the api in discord.py without cogs?
There is, you just attach the created DBLClient to your bot variable and use it 
yea
oh thanks
I need to put this in my code so that the bot page get's updated right?
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});
```Nothing else?
you dont even need to do that
dbl has an autoposter
you just need to give it your client
ie: new DBL(dbltoken, client)
you only need to use postStats if you use DBL(dbltoken) without client
Alright in discord.py
I am trying to get when ever on_dbl_vote triggers it prints the vote data in a specific channel But it never works I think it is because i don't know how to connect the token in that event.
If the user role has changed, would it be under PRESENCE_UPDATE?
GUILD_MEMBER_UPDATE i believe (offtopic)
so I'm trying to make a lower cooldown for people that have voted, Im using
dbl.hasVoted(id).then(v => {
if (v) {
// voter cooldown stuff
} else {
// nonvoter cooldown stuff
}
})
I'm not really sure what I've done wrong, if the person HAS voted, then it just skips everything and has no cooldown, but if they haven't voted then they have the normal cooldown for nonvoters. If it helps at all, I used the djs guide for the cooldown functionality
^^ and thats all in my message.js event
thanks
How long (usually) does it take for server count to update?
Pretty sure the default is 30 minutes, but I might be wrong
Instant usually, cache might get in way it viewing from browser
Ive cleared my cache, regenerated my token, im not getting any errors from dblpy, but it hasn't updated
you sure it's actually posting? Might wanna fetch the data from API
https://discordapp.com/channels/264445053596991498/412006692125933568/702595421263888454
nvm, idk what i did wrong, but its working now lol
@sullen nymph im getting a empty dict as the response.
import dbl
import discord
from discord.ext import commands, tasks
from basebot import Guardian
import logging
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, client: Guardian):
self.client = client
self.logger = logging.getLogger("guardian.topgg")
self.client.task_manager.create_loop(self.post_stats(), 60*60*30, "top.gg-stat-poster")
async def post_stats(self):
self.logger.debug("Posting stats to top.gg")
headers = {"authorization": self.client.config.dbl_token}
data = {"server_count": len(self.client.guilds)}
r = await self.client.session.post("https://top.gg/api/bots/676448082556354583/stats", headers=headers, data=data)
self.logger.debug(await r.text())
def setup(client):
client.add_cog(TopGG(client))
Shouldn't the auth header be starting with capital A
api hakkฤฑnda yardฤฑm edebilecek bir tรผrk arkadaล arฤฑyorum
import dbl
import discord
from discord.ext import commands, tasks
from basebot import Guardian
import logging
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, client: Guardian):
self.client = client
self.logger = logging.getLogger("guardian.topgg")
self.client.task_manager.create_loop(self.post_stats(), 60*60*30, "top.gg-stat-poster")
async def post_stats(self):
self.logger.debug("Posting stats to top.gg")
headers = {"authorization": self.client.config.dbl_token}
data = {"server_count": len(self.client.guilds)}
r = await self.client.session.post("https://top.gg/api/bots/676448082556354583/stats", headers=headers, data=data)
self.logger.debug(await r.text())
def setup(client):
client.add_cog(TopGG(client))
some python UwU
heeelp
``const botconfig = require("./botconfig.json");
const Discord = require ("discord.js");
const bot = new Discord.Client({disableEveryone true});
bot.on("ready", async () => {
console.log('${bot.user.username} is online!');
});
bot.login(botconfig.token);``
uh, this probably should be in #development
hi
Guys.....
@cosmic fog #topgg-api is not the place to say hello. Please move to #general or #memes-and-media
Hi I have just added Causym to my server. Can anyone tell me how to use it as translation bot? Thanks
-wrongserver @scenic vigil
@scenic vigil
Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Support Server" button on the bot's page, not the "Join Discord" button at the top of our website. If there isn't a button that says Join Support Server, then we can't help you. Sorry :(
Also please talk in #general or #memes-and-media ๐
Is it possible to make it where certain roles have access to certain emojis by using an api?
Hello, I have a problem with webhook. When I click in test buton on the site I don't have any logs... If someone can help please
const DBL = require('dblapi.js');
const dbl = new DBL("MyToken", { webhookPort: 5000, webhookAuth: 'MyPassword' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log("Tested")
var user = client.users.get(vote.user)
if (!user) return;
if (vote.isWeekend) {
client.channels.get("702531867617919006").send(`Thanks to **${user.username}** to have voted for me on https://top.gg/bot/BreakLink/vote ! `)
} else {
client.channels.get("702531867617919006").send(`Thanks to **${user.username}** to have voted for me on https://top.gg/bot/BreakLink/vote ! *(X2 Week-End Bonus !)*`)
}
});```
@fiery sun are you running it on your server?
Yes
Yes unbuntu
run sh sudo netstat -peanut | grep 5000 for me pls (in a different window than your bot)
sudo apt install net-tools```
you can use this tool to see which ports are used on your system btw
I'm trying to see if your bot got bound to the port
yup, that mounts
๐ค can you DM me the server IP to check if the outer world can accesss the webhook
I can dm you with server domain name if you want
yeah, that works
but... I'll need you to add me as a friend
since my DMs are closed
yeahohboi
-api @restive otter
@restive otter
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
do not ask2ask
Can I setup a webhook with my IP address or do I need a domain?
Just an IP address is fine
Thanks, it works perfectly 
Can I post a suggestion here?
Add the request info from DBL when clicking on Test would be great
request info? 
The data is almost the same, only the value of type key in returned JSON is different
@lone sun #development Read topic
is there an api for voting?
get notified when someone votes? yes
head over to
https://top.gg/api/docs
no I mean voting from a command
ah ok
Anyone know how to do modified emojis
wdym?
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
is the server count on top.gg supposed to update immediately after posting a new count? for some reason my count seems to be stuck even though it's pretty surely posting new counts.
it usually updates within seconds
-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
please move to #development
ok
wait, is the old https://discordbots.org/api/bots/<id>/stats still valid? just realised that this bot is still using that url
discordbots.org redirects to top.gg currently so it's not too bad
still odd, for some reason it didn't work. i just changed it to the implementation with the dblpy package so it's working now
@dusty fulcrum u have almost the same pfp as me, I was thinking "oh im green" for a sec
๐ฆ
LOL. a friend of mine edited these

My bot shows on the website still the old Profilimage. How can I fix it?
sorry for my english
this is not related with API @sturdy fern
where should I ask then?
Is there any way to find how long until a user can vote again?
Take a look here https://top.gg/api/docs
Is there any way to find how long until a user can vote again?
@restive otter no
request info?
@sullen nymph I mean, I would like to get the status code returned by DBL
either if it's a 404 or a 403 or if it didn't work at all
Ah
I mean you can edit the internal code to return the request response
There's exceptions for 403 and 401, don't remember about 404 as it shouldn't ever happen with dblpy
yea that's a good idea, I don't even know why I didn't think about it
i'll make a fork of the lib, thx
Or you can just create your own lib from scratch for all you know
true
How do I actually POST to webhooks.
I'm trying this
local url = "https://discordapp.com/api/webhooks/ID/TOKEN"
local res, body = http.request("POST", url, {content = "test"})
๐
if(dbl.hasVoted(message.author.id) === true) {
message.author.send("You have already voted")
}
it skips through the if statement. Doesnt dbl.hasVoted(message.author.id) return a bool?
If not, how should I be checking if the author has voted in the last 12 hours?
I think hasVoted method is async?
so I think it's probably if (await dbl.hasVoted(id))?
Or .then
ok thanks
Does the webhook for voting arrive on port 80/443?
it arrives on what ever port your run the webserver on
You can define the port on options with webhookPort: 300 (for example)
does .hasVoted return if they've voted in the past 12 hours or if they've ever voted?
The former
12 hours
that's literally stupid > the api for an nsfw command im using isn't meant to provide loli but it does. imma have to remove it
How do I stop the API contsantly reposting the stats
hello
const { request } = require('https');
const update = () => {
const data = stringify({ server_count: client.guilds.size });
const req = request({
host: 'top.gg',
path: `/api/bots/${client.user.id}/stats`,
method: 'POST',
headers: {
'Authorization': 'API TOKEN',
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(data)
}
});
req.write(data);
req.end();
};
client.on('ready', update);
client.on('guildCreate', update);
client.on('guildRemove', update);```
help me
what does this do?
updates bot stats server count
ha okey thanks @hollow raptor
const postData = JSON.stringify({
server_count: client.guilds.size
});
const options = {
hostname: 'https://discordbots.org',
path: `/api/bots/${client.user.id}/stats`,
method: 'POST',
headers: {
'User-Agent': 'DiscordBot (https://moustacheminer.com/) Discord Guild Counter',
'Content-Type': 'application/json',
'Content-Length': postData.length,
Authorization: 'AUTHTOKEN'
}
};
const req = https.request(options, (res) => {
res.on('data', (data) => {
console.log(data.toString('utf8'));
});
});
req.on('error', (error) => {
console.error(error);
});
req.write(postData);
req.end();```
what does this do?
Same thing but this is old version
hmm ok
s
Hi, i want to register vote of members but when i make
if await get_user_vote(ctx.author.id): in my command,
I get the error : discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'get_user_vote' is not defined
I don't understand, can you help me? (Python
)
because that makes no sense...
i highly doubt you've imported the py lib and extracted just that function
tias
Did you read any examples or the docs
Yes, but I don't understand because, the get_user_vote requires one argument; so await dbl.DBLClient.get_user_vote(user_id) (user_id = ctx.author.id)
And i get the error TypeError: get_user_vote() missing 1 required positional argument: 'user_id' 
๐ Because you havent init the object
Classes exist and because its not a static method you have init the client object and pass bot and token
How i create a vote system ? ( the guy vote un my bot and automatically receive a prize) ...
ping me if you answer me
@midnight garden you'll need to use the vote webhook and then go from their
@green mantle But I have init '-'
send your code
[...]
import dbl
class TopGG(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.token = "TheToken"
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)
print('Cog "TopGG" ready.')
@commands.command()
async def vote(self, ctx):
user_id = ctx.author.id
if await dbl.DBLClient.get_user_vote(user_id):
await ctx.send('You have arleady vote.')
else:
await ctx.send('You can vote')
[...]
thats....
not how objects work
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)
hm?
you set the init client to a attribute there
you cant just call the lib again and expect it to remember
Uh yes
thats not how objects work
So i have to do await self.dblpy.get_user_vote(ID)
@restive otter yes
@midnight garden you cant fix
thats just how it works
you have to handle interactions with discord yourself
the site wont do it for you
Ok so, what i have the error Command raised an exception: Unauthorized: Unauthorized (status code: 401) ๐
and what i do , for the bot send message when someone vote ?
unauthorized
Yes but why?
im from portugal
i mean, coding language
ow
tb sou tuga lol
do you have dblapi.js?
i don't have installed yet
But my token is good here :/
@midnight garden check the webhook example
@restive otter shouldnt you use the dbl instance you created?
ie self.dblpy.get_user_vote instead of dbl.DBLClient.get_user_vote
idk how python works
@midnight garden yes
@vapid cape thanks , can add ??
yes
Yeah, Tim. That's how dblpy works. dbl.DBLClient stores no token in this case while self.dblpy does
also iirc no method in dblpy is a classmethod :^)
:^)
@vapid cape hmm
@vapid cape I have regen token, it's ok
@midnight garden you dony have node.js installed? how do you run your bot?
where is your bot hosted?
i think i unistall the node.js lol
tokens are strings, not variables lol
also, if your bot is self-hosted, you will need to port forward your modem/router
hmm
i need host him in a heroku
because , the bot have too much users , and the host them i pay , can't turn on because the ram
which host is that?
DisCloud
gratuito or carbon?
yes 128mb is not enough for a node.js bot
uhum
node.js by itself with 0 users, already wastes 50mb ram
oh
heroku and glitch both have 512mb ram i think
hmm
I will try host in heroku
and if i host in heroku i don't need change the port right ?
@vapid cape
in heroku the port needs to be webhookPort: process.env.PORT
then in the top.gg website, in URL you put MYPROJECT.herokuapp.com/dblwebhook
@vapid cape how Many is the limit time of heroku ?
@midnight garden unverified accounts have 550 hours per month
verified accounts have 1000 hours per month
my dblapi doesn't seem to be working properly, anyone else having an issue with theirs?
my dblapi doesn't seem to be working properly, anyone else having an issue with theirs?
@limpid vector me too
some votes just aren't being registered
getting complaints about it from my bot o.O
vote webhooks are delayed?
yeah it seems like it
@silent pilot if running your bot works, then dbl should also work
Ok ty. There isnt a library on repl.it do i install it onto my computer and just run from there?
I believe so
I have it
Ty for ur help
@vapid cape i put the code in. It runs but it still says N/A for a server count. How do i go around this?
Sorry. I mis read the command
my test vote took 28 minutes 
@arctic arch are you aware of the vote delays/outages on the vote webhook? I'm getting tons of DMs of users which doesn't receive their vote rewards.
can confirm, looks like that some of the requests are not being sent ^
what i need configure here to my webhook work? ( my host is the computer )
@vapid cape sorry ping
nothing
if your host is your computer, then in the top.gg website, in the webhook URL field, you need to put http://YOURIPADDRESS:YOURPORT/dblwebhook
and port forward the port in your router/modem
where i find the id adress and port ?
google "what is my ip" and you can pick your own port
hi what will i do webhook
pick a port you wish to use, just make sure it's open on your router
just don't pick a port like 123 cos that's reserved for time
or port 666 cos thats reserved for Doom
I think the default for dbl is port 5000, you may aswell use that
URL...
http://"YOUR_EXTERNAL_IP_ADDRESS":"YOUR_CHOSEN_PORT_YOU_CONFIGURED_ON_YOUR_ROUTER/FIREWALL"/dblwebhook
Authorization...
"A SUPER SECRET SUPER PASSWORD YOU WISH TO USE"
in Authorization you put this password
if you don't know what "port forwarding" is then you may want to google it
thank you
add your token there and remove below line
yes
error is clear
"dbl" is already declared
^
bla this is a variable
"bla" this is a string
'bla' this is also a string
`bla` this is also a string
pls learn programming
:C
if you put new DBL(abc)
it will try to look for abc = something in your code
but if you do new DBL("abc") it will use the words "abc"
understand?
anyone got an idea for debugging
why the webhook has just stopped working
when port is open and working with test
people were saying webhooks were delayed by up to 30min a while ago
idk hows the situation now
im so glad i dont use vote rewards on any of my bots lmao
Hello, I want to throw those who vote for my bot into a channel.
ordan baktฤฑm olmadฤฑ bulamadฤฑm yani @willow spindle
english only
Im using dblpy and i want to know what decides our webhook_path. Is it meant to be anything we want or does it have to be a specific thing??
I looked at the site but I couldn't understand anything
check examples
@oblique turret webhook url?
that is http://server ip:port/dblwebhook
I proceeded with examples but my ip address was always 0.0.0.0
oh thank you
@restive otter Replace 0.0.0.0 with your machine's external IP and you get a URL to your webhook
how
Copy the URL, replace 0.0.0.0, use the edited URL? 
Yes. 0.0.0.0 there simply says "your IP"
no my ip 172.blah blah blah
How do I change the ip is impossible

have a video about it?
http://<your-IP>:<port><webhookPath>
It will never change there
All it's supposed to do is tell you which port and path it's running on
just wondering what people use for webhooks on the .net side? MVC ? Or is there anything simpler
do the webhooks need port forwarding to work??
Yes
Depends on your network setup but if youre behind a firewall its like any other server
Last question: since i have a dynamic IP instead of a static one wouldnt that cause a major problem since i'd have to manually change it every so often?
Uhh
On what end?
Locally?
You might be able to do it by MAC depends on your firewall
If you mean on the internet you can get some DNS setup to configure when you ip changes I guess?
Not 100% how youd do that
No worries
My hosting provider (amen.pt) told me I can keep my e-mails and webmail hosted with them and host the website elsewere. For this to work I need to change the DNS A record 'www' to the IP of the other
How would I allow await to be used on DBL's vote listener?
Can't find an answer to my question
which programming language do you use
you have to create webhook server
Shouldn't they actually be async? 
I already have all of that set up but I'm rather new to await's usage
When attempting to use await to get something from my database, it's telling me I can't do it in a non-async function / listener
Yes that would work @distant trellis
If you put that into an async function make sure to await it.
I am
I can't test it at the moment due to only being able to vote every 12 hours and it calls for member data which the test vote can't really provide so I'll wait it out
Ask a friend?
๐๐ป
Thank you
can anyone tell me what changed in the api between version 0.3.3 and 0.3.4 as 0.3.4 isn't mentioned in the docs?
for python*
hi everyone
i just tried dashe bot but the tasks didnt work, can you help me plese???
@austere coyote is that relevant to the DBL api
did i need to run an additional webhook server on my server or does the dbl libary handle this?
dblpy and dblapi.js host one for you if you provide at least a port when creating a client
@sullen yoke support for discord.py 1.3 was added in 0.3.4 since dependencies for it were changed
i use node.js and set a port but i did not get any test ping from the website when making a test. (i use the code from the example page but added a console print for the type)
port is open in the firewall
it prints this Webhook running at http://0.0.0.0:5000/dblwebhook
@dense shale What's the URL you entered on the website
hmm now i think its working get now a 404 instead of a timeout
The URL is fine
ok its working now thanks for trying to help me
Oh
n!istatistik
@restive otter #commands or #265156322012561408 for bot commands
@willow spindle soryy
show the function
its me or dbl.hasVoted is broken
try (await pm.getVotes(userID)) + 1
You need to host a webserver yourself
what token? 
for the webook
That doesn't help at all, please elaborate
you set the authorization
It's a webhook running on a server, not a discord webhook
when doing dbl.webhook.on("ready", hook => {...}) i keep getting "cannot not read property 'on' of undefined"
any ideas why?
Hi, is it possible to test async def on_dbl_test(data): without have to wait for someone to vote?
I just want to make sure my code is working
But is hard to test cos i have to wait every 12hrs
on your bot page if you click edit and scroll down to API Options -> Webhook theres a place where you can test it
Oh ok thanks
yeah np!
alrigth so simply the api just went crazy with my server count and shards
am i supposed to give the total server count or the server count on the specific shard?
you make the password yourself
@green mantle where?
on your bots edit page
yes
and URL section?
the url of your server listening for the post request
put i want if anyone vote, get to my channel
or more commenly
dbl.webhook.on('vote', vote => {
let embed = new Discord.RichEmbed()
.setDescription(`User with ID ${vote.user} just voted!`)
client.guilds.get("ID").channels.get("ID").send(embed)
});```
do you mean that? @green mantle
yes
and can i connect it to my channel?
but 0.0.0.0 being your public ip
public ip
okay now what can i do to connect when person vote, bot or webhock send to channel?
dbl.webhook.on('vote', vote => {
let embed = new Discord.RichEmbed()
.setDescription(`User with ID ${vote.user} just voted!`)
client.guilds.get("ID").channels.get("ID").send(embed)
});```
like that?
tias
i'll try it, wait.
@green mantle i tried it and don't send anything :(
seriously :D?
is your url still 0.0.0.0
What are you using for host @restive otter
@restive otter can i talk you in DM?
@restive otter why not here?
okay stay here.
const DBL = require('dblapi.js');
const dbl = new DBL('', { 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!`);
});
dbl.webhook.on('vote', vote => {
let embed = new Discord.RichEmbed()
.setDescription(`User with ID ${vote.user} just voted!`)
client.guilds.get("701054225571905636").channels.get("703454462681022564").send(embed)
});```
that's my code correct? @restive otter
yes but your Auth can seenable
xD sry.
you need to just put correct url
in?
are you using glitch?
nope
windows host
Then i dont know D:,sorry...
:C
if i using glitch? @restive otter
Hi guys I got this error when try to setup the webhook upvote test:
raise Unauthorized(resp, data) dbl.errors.Unauthorized: Unauthorized (status code: 401)
Token and password looks good
Reset your token
You do http://your IP:your open port/webhook usually





