#topgg-api
1 messages Β· Page 77 of 1
and your webhookPort should be webhookPort:process.env.PORT
yes
ie: webhookAuth:"blablabla"
Authorization - blablabla
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1270:14)
at listenInCluster (net.js:1318:12)
at Server.listen (net.js:1405:7)
at DBLWebhook._startWebhook (/rbd/pnpm-volume/abe93bf7-11f2-4401-b448-53ba2fc1f4f2/node_modules/.registry.npmjs.org/dblapi.js/2.4.0/node_modules/dblapi.js/src/webhook.js:45:18)
at new DBLWebhook (/rbd/pnpm-volume/abe93bf7-11f2-4401-b448-53ba2fc1f4f2/node_modules/.registry.npmjs.org/dblapi.js/2.4.0/node_modules/dblapi.js/src/webhook.js:27:12)
at new DBLAPI (/rbd/pnpm-volume/abe93bf7-11f2-4401-b448-53ba2fc1f4f2/node_modules/.registry.npmjs.org/dblapi.js/2.4.0/node_modules/dblapi.js/src/index.js:69:22)
at Object.<anonymous> (/app/server.js:82:13)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
Emitted 'error' event at:
at emitErrorNT (net.js:1297:8)
at process._tickCallback (internal/process/next_tick.js:63:19)
at Function.Module.runMain (internal/modules/cjs/loader.js:757:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
@vapid cape
look
i have exprres for the uptime
app.listen(process.env.PORT);
setInterval(() => {
http.get(http://.glitch.me/);
}, 1000 * 60 * 3);
const dbl = new DBL(
`${config.dbltoken}`,
{
webhookServer: listener,
webhookPort: "listener",
webhookAuth: "blablabla"
},
client
);```
remove webhookPort
then you're still using process.env.PORT somewhere else
or you didnt remove the old one
yes, i told you to remove the old
thanks
@topaz verge working?
no
why
its not send anything when i testing in top.gg/bot/id/edit
do u tried client.fetchUser ?
no
any error?
yes
does anyone know possible reasons for counting servers on the top gg site not updating?
because it says that my bot is on 6k of servers but it is already with 8k and a half
@restive otter up-to-date library? is your method being called?
I think it was the version really, it was in 3.3 and now I put it in .4
Hi ! I have a problem with your NPM package
dbl.webhook.on("vote", vote => { ^ TypeError: Cannot read property 'on' of undefined
@distant oak you need to add the webhook configuration, check the webhook example
Ok thanks
But before fiiixx that !
It's ugly
We are in 2020 not in 1999
I can't search anything because the GUI is break
It's the same on desktop
@arctic arch? 
i found out why
cloudflare anti ddos thingy
the docs page bypasses it, but the css files do not
if you access the css file directly, it takes you to cloud flares 5 second check
after you pass that check, the docs page will load correctly
cannot reproduce
I don't understand how webhook works
@arctic arch try opening the docs page in a new incognito tab, directly from the url
What we have to write on URL and on Authorization
URL should be your bot's server address, such as vps ip address and port, or glitch/heroku project url
authorization is whatever you want, as long as you put the same thing in webhookAuth
Ok thanks
There is no port and path on glitch ?
the default path when using dblapi.js is /dblwebhook
glitch's port is process.env.PORT
so your url should be MYPROJECTNAME.glitch.me/dblwebhook
and your webhookPort should be webhookPort:process.env.PORT
show your code
im sure this is a stupid mistake but when i have
// using glitch
const dbl = new DBL(blahblahtokenblahblah, { webhookPort: process.env.PORT, webhookAuth: 'password'});
it says my token is undefined
should it be in '' like it has in the other example on the api page
why glitch
thats just what im using for my host
ill try a third time
nope
the code should be in my index.js towards the top right?
not inside anything else
idk i dont do js
ah, well thanks anyways
Fyrlex
i'd recommend to choose a different port
because if you use the same for express and something else the app won't start
Hi ! Why webhooks do anything
I have a problem
Error: listen EADDRINUSE: address already in use :::3000
But why ?
Ow express
Webhook running at http://0.0.0.0:3000/dblwebhook hmm that not normal
that is normal
Oof
Is test webhook broken or something? I tested from my PC rather than using the test button on the settings page and it works, but when I try to test it there I get nothing logged.
how did you test?
I used a Chrome App to make a post request (only with type: test as JSON) and printing the result on my bot, which worked fine
Heya, I'm having an issue with my bot right now for a reason I can't understand. Suddenly it cannot log in (via client.login), it just hangs there without throwing an error or continuing with success.
The only error I got was this generic thing:
Error: Something took too long to do.
What's weird is that I have two versions of the bot made, one for development and one that is actually used (prod), and if I just switch the token to the dev-version it logs in fine
...now I realize I've posted it in #topgg-api when I should've used #development
So after resetting the bot multiple times it did manage to log in, but I didn't change anything, so I still am wondering what went wrong...
@hot stratus what version of Discord.js are you using? (fuck I thought this was development)
Yeah, sorry about that. We can move this chat there.
is there any way to update the bot description using the api?
no afaik
ok
I still don't get anything printed or any errors showing.. I have no idea what I'm doing wrong to set up votes
import dbl
import discord
from discord.ext import commands, tasks
import asyncio
import logging
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='DBL_PW', webhook_port=5000)
# The decorator below will work only on discord.py 1.1.0+
# In case your discord.py version is below that, you can use self.bot.loop.create_task(self.update_stats())
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print("voted")
logger.info('Received an upvote')
print(data['user'])
user = self.bot.get_user(data['user'])
try:
await user.send("Thanks for voting!")
except:
pass
@commands.Cog.listener()
async def on_dbl_test(self, data):
print("voted")
logger.info('Received an upvote')
print(data['user'])
user = self.bot.get_user(data['user'])
try:
await user.send("Thanks for voting!")
except:
pass
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))
does this look fine?
I'm hosting it on a VPS
have you checked if port 5000 is open @craggy anchor ?
and ur webhook auth is ur token etc.

@restive otter wdym by that? port 5000 is open yes
webhook_auth='DBL_PW',
do I need to use my token as my webhook auth? the dbl token
No?
iirc
i thought it could be anything
The auth is not the same as the tokeen
auth for the webhook should be ur api token right
just a pw

The token is a specific thing you get generated by on the site
The auth password can be anything you set it to
besides from that, does anything else look wrong here?
i dont speak any of that language
Is it actually logging anything
I take it your token var is set
But you just haven't added in for security
If not
Then might be a good idea to add it
no doesn't seem to log anything
wait actually it does
nvm
it would also be like this right?
yes, case sensitive
still don't get any output when I try to use the test thing
did you save?
@commands.Cog.listener()
async def on_dbl_test(self, data):
print("voted")
logger.info('Received an upvote')
print(data['user'])
user = self.bot.get_user(data['user'])
try:
await user.send("Thanks for voting!")
except:
pass
``` yeah I saved,
I'm using print and checking if it shows anything but
it doesn't show up anything
just voted by myself too and didn't show up anything 
turn ur bad request into a good request
@loud gulch how ??
idk lmao im shittposting in the wrong channel
@restive otter if you're using discord.js v12, you need to update dblapi.js
@vapid cape after update v2.4.0 showing this error
Hi if I use discord.js@11.4.2, which version of dblapi.js I have to use ?
try 2.3.0 or 2.4.0
can someone help with my webhook? Tried to use this code but the webhook is not working. It worked before i restarted the bot. And i didn't change any of the webhook settings.
Can anyone provide me a script of python to update servers in TopGG
U tried a lot but not worked
So
What exactly have you tried
Hello, it's possible to help me I want to use the API voting system ?
I have a question. I have an express server for my bot. but can i use different port for my webhook?
nope
but you can use the existing server in dblapi.js
instead of webhookPort you use webhookServer: listener
If i try to use listener it just gave me the EADDRINUSE error
Hi if I use discord.js@11.4.2, which version of dblapi.js I have to use ?
@distant oak any
ok
Do I need a different port for different webhooks on different shards?
(and yes i know thereβs too many differents)
if you're sharding, you should ideally listen to the webhook in your sharding manager, not in individual shards
@vapid cape How should I get the user in a ShardingManager?
@restive otter check our docs
import dbl import discord from discord.ext import commands class TopGG(commands.Cog): """Handles interactions with the top.gg API""" def __init__(self, bot): self.bot = bot self.token = 'dbl_token' # set this to your DBL token self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes async def on_guild_post(): print("Server count posted successfully") def setup(bot): bot.add_cog(TopGG(bot))
This is in working condition or no sir
@left egret
Yes
let dbl = new DBL(client.config.apiKeys.dbl, { webhookServer: app.listen(process.env.port), webhookAuth: client.config.votes.password });
can someone help with this code? Its giving me the eaddrinuse error
@restive otter depending what you want to do with it, most likely broadcastEval
ok thanks
Your module is drunk π
might be because hes trying to run it on a android python emulator
yes
K
Webhook running at http://0.0.0.0:0/dblwebhook
Why does the port not working?
did you pass a server?
wdym?
let listener = app.listen(process.env.port);
let dbl = new DBL(client.config.apiKeys.dbl, { webhookServer: listener, webhookAuth: client.config.votes.password });
Yeah when you pass an already made httpServer it defaults to 0
should be whatever port your listener uses
ok but how do i fix the eadrinnuse error
by passing the httpServer you already have, which is what you did.
Should work
Just the port shows 0
but it should be whatever your port for your listener is, it just doesn't log it
well it doesn't handle gets, it handles posts
go to your bots edit page and put http://ip:port/path and whatever your webhook auth is then save and test
bruh but i already have an express server
so thats why im using webhookServer instead Port
Then it'd be listening on https://your-project-name.glitch.me/dblwebhook by default
Ah
should i use it on different project?
It should work, I'm not sure if it doesn't. It does remove all request listeners though.
i removed the listener on my dashboard file
If i dont its giving me the eaddrinuse error
or should i merge both of the files together?
ok i moved it to another project and it works
Why would I receive a code 1006 when attempting to post server count?
it's literally an object returned with a message of code 1006
You're missing something, that's not an HTTP Status
that sounds like a custom discord api error code
it's a http status used by cf
Ah yeah cloudflare stuff
just looked at it, apparently my IP is banned?
Weird, what do you host with?
a vps
who would I ask?
I would dm oliy or tonk, but I've never seen it before
I'd like a mod to confirm that I can dm an admin though, don't want to annoy them
@craggy sentinel would that be ok to dm Oliy about my IP being banned from posting?
oliy is slow to respond occasionally, i'd recommend asking tonkku
alright
Hello. Can someone give me a simple voting system where when someone votes it sends it to my guilds vote channel?
Such as if you seen Circle, it has that.
which lib do you use
d.js
Thanks my good sir.
When it says to put your DBL token here, does it mean to put your bots api token there or ?
So for this line of code,
const dbl = new DBL(yourDBLTokenHere, { webhookAuth: 'password', webhookServer: server });
WOuld I put the dbl token where it says?
Because when I do it throws up a refrence error that it's undefined
.*
you put it as a string
For this ```// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(Oops! ${e});
})``` Where do I put to show the servercount?

@livid hound those are optional. They are used to inform you if the count was posted correctly or not
Oh.
why
I am sending {"server_count": count, "shard_count": shard_count, "shard_no": shard_id}, from all my shards, however it's not updating on the bot page. It looks like it only picks up a single shard and the api doesnt add the rest all up.
shard_count would be 6
server_count varies between shards
shard_no would be 0 to 5
Thanks
How long do they update? I believe that I resolved it, however they're still not updated on the bot page.
dbl.webhook.on('upvote', vote => {
const hook = new Discord.WebhookClient('690965417132425236', 'Te1mQMeYJJEmY2xyiSbhoFuiQLxtBxcrt9-kcSF3qUcYUizmAQ3GXLyiQ_3oIpaD7AJp');
hook.send(`User with ID ${vote.user} just voted!`);
});
Would that work? for the webhook. Cause it doesn't
you shouldn't leak the webhook token
anyone could send messages with it rn
dbl.webhook.on('upvote', vote => { const hook = new Discord.WebhookClient('690965417132425236', 'Te1mQMeYJJEmY2xyiSbhoFuiQLxtBxcrt9-kcSF3qUcYUizmAQ3GXLyiQ_3oIpaD7AJp'); hook.send(`User with ID ${vote.user} just voted!`); });Would that work? for the webhook. Cause it doesn't
@restive otter isn't the event called upvote instead of vote
uh
i meant vote instead of upvote
@restive otter not use python on Android
dbl.hasVoted doesnt work, always return false (js)
dbl.getVotes() broken too
it shows a list of random people who have NEVER voted for my bot
Port is already used by something else
idk.. I think it has something to do with the fact that I'm switching the bot usage between my pc and vps
might overlap or smth dunno
import dbl
import discord
from discord.ext import commands, tasks
import asyncio
import logging
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'token_here'
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='DBL_PW', webhook_port=1337)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print("voted")
logger.info('Received an upvote')
print(data['user'])
user = self.bot.get_user(data['user'])
try:
await user.send("Thanks for voting!")
except:
pass
@commands.Cog.listener()
async def on_dbl_test(self, data):
print("voted")
logger.info('Received an upvote')
print(data['user'])
user = self.bot.get_user(data['user'])
try:
await user.send("Thanks for voting!")
except:
pass
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))
``` is there something that looks wrong here? Nothing seems to work

Why is it trying to use port 5000 when you're specifying the port as 1337 
Is it starting just fine?
Did you try to load the extension multiple times?
what do you mean by that? sorry
Are you using load_extension multiple times on the file that runs the webhook?
or reload_extension
no.. don't think so
#Loading Cogs on Boot
path = ["cogs", "stagecogs"]
for i in path:
for file in os.listdir(i):
if file.endswith(".py"):
name = file[:-3]
bot.load_extension(f"{i}.{name}")
that's the only load
and your not using reload_extension anywhere in your code?
when it starts
oh I am yeah
@commands.command(aliases=["r"])
async def reloadall(self, ctx):
""" Reloads all extensions. """
path = ["cogs", "stagecogs"]
for i in path:
for file in os.listdir(i):
if file.endswith(".py"):
name = file[:-3]
try:
self.bot.reload_extension(f"{i}.{name}")
except:
return await ctx.send(f"Failed to reloaded extension **{name}.py**")
await ctx.send("Successfully reloaded all extensions")
did you run that?
no, I don't think it changes anything if I run it or not
I'm using the test thingy for the webhook
doesn't show up anything
If you reload the extension, does it show the error
hi
yeah, this error only occurs once I close it
close bot
after I leave it on for like 10+ mins or smth, idk, but sometimes it doesn't show up if I start/close bot right away
only shows
when I close quickly
Are you doing anything in teardown or really anything after your bot closes
bot = commands.AutoShardedBot(command_prefix = get_prefix, case_insensitive=True)
full code
wdym by that? that's pretty much it I think..
Your main file
import os
import discord
from discord.ext import commands
from discord.ext.commands import AutoShardedBot
import asyncpg
import asyncio
from pathlib import Path
from collections import OrderedDict
import logging
from os.path import dirname, abspath
from utils import util
logging.basicConfig(level=logging.ERROR)
directory = Path(abspath(__file__)).parent
os.chdir(directory) #changes directory to be of file parent cwd
print(Path(abspath(__file__)))
#sends prefix to bot
async def get_prefix(bot, message):
try:
return bot.guildlist[message.guild.id]['prefix']
except KeyError:
await bot.pg_con.execute("INSERT INTO guild (guild_id, prefix) VALUES ($1, '.') ON CONFLICT (guild_id) DO NOTHING", message.guild.id)
bot.guildlist[message.guild.id] = {}
bot.guildlist[message.guild.id]['prefix'] = "."
bot.guildlist[message.guild.id]['redirect'] = None
return bot.guildlist[message.guild.id]['prefix']
else:
return (".")
bot = AutoShardedBot(command_prefix = get_prefix, case_insensitive=True)
token = open("token.txt", "r", encoding = 'utf-8-sig').read()
db_pw = open("db_pw.txt", "r", encoding = 'utf-8-sig').read()
bot.pg_con = asyncpg.create_pool(database="db", user="postgres", password=db_pw)
...
@bot.event
async def on_ready():
print("Logged in as")
print(bot.user.name)
print("------------")
await bot.change_presence(activity=discord.Game(type=1, name="Bot"),status=discord.Status.online)
#Creates database connection
async def create_db_pool(bot):
bot.pg_con = await asyncpg.create_pool(host="..", database="db", user="postgres", password=db_pw)
...
#Loading Cogs on Boot
path = ["cogs", "stagecogs"]
for i in path:
for file in os.listdir(i):
if file.endswith(".py"):
name = file[:-3]
bot.load_extension(f"{i}.{name}")
bot.loop.run_until_complete(create_db_pool(bot))
bot.loop.async_caches
bot.run(token)
some things in between but all of them are just caching stuff when bot loads
where r u importing the dbl module
in a cog
import dbl
import discord
from discord.ext import commands, tasks
import asyncio
import logging
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'token_here'
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='DBL_PW', webhook_port=1337)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print("voted")
logger.info('Received an upvote')
print(data['user'])
user = self.bot.get_user(data['user'])
try:
await user.send("Thanks for voting!")
except:
pass
@commands.Cog.listener()
async def on_dbl_test(self, data):
print("voted")
logger.info('Received an upvote')
print(data['user'])
user = self.bot.get_user(data['user'])
try:
await user.send("Thanks for voting!")
except:
pass
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))
``` This is the only place where I import dbl

have you tried changing the port
yeah
I have
changed it from 5000 to 8080 to 1337
hosting it on VPS if that matters
(DigitalOcean)
@silent orbit ye lol I was seeing what happened
alright
@little dew https://top.gg/api/docs#jslib
i found out how to do it but it doesn't work
I need help
I have this api
But the data received goes to the console.log
But I want Json to go.
<@&405483030275424257>
I need help
dbl.hasVoted('user ID' ) ALWAYS return false, even if the user HAS voted
Same thing with dbl.getVotes()...
How can I solve that?
My code is the same as the api templates
I've take a look at dbl.getVotes() output, and that's weird, it shows a list of ppl who has never voted for my bot
@true talon If you input any type of id make sure its correct format, and if youβre using in a command (i.e. d.votes <user mention|user id> ) make sure you grab it correctly
And make sure you are using the correct bot id cause I believe you need that to, to search a bots votes
hey can someone stay here and stick with me so I can figure out what's wrong with my code π I've probably asked the same question 5 times now here with people just disappearing and I have to ask the same thing all over again
@craggy anchor #development and when I am home so not too long
it's related to the API - I can't seem to figure out why my webhook isn't responding
Me too
ah.. alright π I'll wait for someone else then, thank you for offering though
Don't ping tonkku
bruh
@true talon If you input any type of id make sure its correct format, and if youβre using in a command (i.e. d.votes <user mention|user id> ) make sure you grab it correctly
@restive otter I'm not stupid, I know how to grab id
That's not what I was getting at, but okay
@true talon the most accurate way is w/ webhooks
i tend not to use the api methods as they take a while to update
my Bot was just approved, what does the webhook URL field make? Do I need it?
the webhook url is where vote events should be sent
hmm ok, so what can I fill in it?
if you want to do something everytime someone votes for your bot, make a webserver or use a dbl library to make one, and put your machine's ip address in the url
or project url if using glitch/heroku
And if I just want to send the user a message and reward him?
literally what tim just said, make a webserver
ok thanks
hey can someone stay here and stick with me so I can figure out what's wrong with my code π I've probably asked the same question 5 times now here with people just disappearing and I have to ask the same thing all over again. It's with the webhook, I can't seem to find out what's wrong with my code; it doesn't seem to respond. If someone could just stick with me for 10 minutes while I post all relevant code, thank you so much.
Try to print everywhere and see which part is being called twice
Also put one in the topgg cog's init
it's not really calling twice I don't think, it just doesn't respond, but I'll print on cogs init and see if the cog is being called at least
oh nevermind it definitely is actually
guess not then π
if anyones willing to pls ping me, just need 10-15 minutes and then im doneπ
@Lumap the most accurate way is w/ webhooks
@humble bison I'm using webhooks
future: <Task finished coro=<DBLClient.webhook() done, defined at C:\Users\legoe\AppData\Local\Programs\Python\Python37\lib\site-packages\dbl\client.py:417> exception=OSError(10048, "error while attempting to bind on address ('0.0.0.0', 1337): only one usage of each socket address (protocol/network address/port) is normally permitted")>
Traceback (most recent call last):
File "C:\Users\legoe\AppData\Local\Programs\Python\Python37\lib\site-packages\dbl\client.py", line 436, in webhook
await self._webserver.start()
File "C:\Users\legoe\AppData\Local\Programs\Python\Python37\lib\site-packages\aiohttp\web_runner.py", line 104, in start
reuse_port=self._reuse_port)
File "C:\Users\legoe\AppData\Local\Programs\Python\Python37\lib\asyncio\base_events.py", line 1361, in create_server
% (sa, err.strerror.lower())) from None
OSError: [Errno 10048] error while attempting to bind on address ('0.0.0.0', 1337): only one usage of each socket address (protocol/network address/port) is normally permitted
this is the error I get when someone votes I think
something else is running on that port/exact ip
so the webhook isn't ever able to run
I am sending {"server_count": count, "shard_count": shard_count, "shard_id": shard_id}, from all my shards, however it's not updating on the bot page. It looks like it only picks up a single shard and the api doesnt add the rest all up.
shard_count would be 6
server_count varies between shards
shard_id would be 0 to 5
https://github.com/TitanEmbeds/Titan/blob/master/discordbot/titanembeds/poststats.py#L10
https://lumap.is-inside.me/Zhq7hXx3.png i'm searching the method to use hasVoted() with webhooks, I cant find it. do u know a solution? @humble bison
fuc
its not that bad to sort out
just have a db where all votes are stored with a time stamp and just use a cron system
Anyone is here
What is a snowflake?
How do I use it to get a user using client.users.cache.get()?
yes
its just normal discord.js
how to active π
Post your server count
Are you using dblapi.js?
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
webhookAuth: 'password' = webhookAuth where is?
done it
Seems like some votes aren't firing the webhooks?
Hello, how can I make the weebhook work with shards?
if you're using the shard manager, put the webhook in the manager
Okay ty ! But where i put the vote weebhook ? On main file ? @vapid cape
I just put the webhook vote in main file but i have a error : cannot read property "on" of undefined
show your code
which part ?
I dont understand, the webhook connects well in shards.js but when I want to put the webhook to vote on my main file it blocks
wdym it blocks?
It send a " cannot read property on of undefined"
show your webhook code
Its resolved ty !
Whats the optimal choice for java api?
hello there, I have a problem, I post my bot guild count, the status is is 200 ok but it doesn't update on the site
could be because of caching
Hi dude I would love for help if you can I would love how you did it in the bot list
did what?
that's the 2nd place you've said that @opal parcel wut are you talking abt
what language are you using?
im close to finishing my pinbot, a bot that reposts messages when theres a certain emote number reached, but I ran into a problem where it reposts a normal message but if its an image file it just leaves it blank
this is the code that reposts it
help?
@magic oriole #development for this
los!help
dbl.webhook.on("vote", async vote => {
manager.broadcastEval(`this.handleVote(${vote.user})`);
});
``` Can someone tell me why this doesnβt work?
discord.js v12
this.handleVote works if I execute it with the eval command using message.author.id
@vapid cape yes
when I did ;eval client.handleVote(message.author.id), it worked
sorry for replying late
then you would probably change this to client, depending on the way you do commands, unless im mistaken
is there a dbl api for bigger bots?
its the same libs
why would it be unreliable then?
Depends on how you have it set up π€·ββοΈ
if you're using fetch votes when you're getting over 1000 votes then you need to use webhooks
it barely even works on the .on( vote method
Might be dbl latency
i waited 5 minutes before giving up
you could always build your own webhook server and use that
asking this again because it still hasn't been answered π :
hey can someone stay here and stick with me so I can figure out what's wrong with my code in regards to the webhook π I've probably asked the same question 8 times now here with people just disappearing and I have to ask the same thing all over again. It's with the webhook, I can't seem to find out what's wrong with my code; it doesn't seem to respond. If someone could just stick with me for 10 minutes while I post all relevant code, ping me, tyvm
what is ur code atm
@green mantle
import dbl
import discord
from discord.ext import commands, tasks
import asyncio
import logging
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'token'
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='pw', webhook_port=8080, autopost=True)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print("voted")
logger.info('Received an upvote')
print(data['user'])
user = self.bot.get_user(data['user'])
try:
await user.send("Thanks for voting!")
except:
pass
@commands.Cog.listener()
async def on_dbl_test(self, data):
print("voted")
logger.info('Received an upvote')
print(data['user'])
user = self.bot.get_user(data['user'])
try:
await user.send("Thanks for voting!")
except:
pass
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))
From what I get at, the autopost seems to work
but that's not webhook related
but it's being initialized and recognized I guess
no errors are usually shown on the bottom
can i see what you have on the site?
sec
e.g
yes
π€
still doesn't seem to print anything when I vote.. hmm :/
on the test vote thing
lemme try a diff port
is your port open on that port?
is there a way I can tell?
The port forwarding tester is a utility used to identify your external IP address and detect open ports on your connection. This tool is useful for finding out if your port forwarding is setup correctly or if your server applications are being blocked by a firewall.
if your webhook server is running and the port is open it should say its open and be green
I see, give me a second
was closed, and then opened when I started it
doesn't seem to work still, nothings printing
oh nevermind, I think its always open
to @self.bot.event instead
that'll override anything if its going somwhere else
altho it shouldn't change anything
replace listener to that?
it says self not defined
it also gives me this error seemingly randomly:
not when I init it, not when I vote, just sometimes appears when I close the script
it says address already in use but I've been using other addresses and
oh wait yh
same thing happens, I don't think it's a coincidence
ngl i just moved my events out of the class
and moved to my main file
and just used @client.event (Im client not bot)
which just overrides any existing vote listener should you randomly have it there
hm alright I'll try that
thanks for the help!
ohh actually I might know - is it because I'm switching from my comp to VPS for running it?
e.g. I sometimes run it on PC, sometimes on VPS
ERROR:asyncio:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x0000024EE65E52B0>
ERROR:asyncio:Task exception was never retrieved
future: <Task finished coro=<DBLClient.webhook() done, defined at C:\Users\legoe\AppData\Local\Programs\Python\Python37\lib\site-packages\dbl\client.py:417> exception=OSError(10048, "error while attempting to bind on address ('0.0.0.0', 1337): only one usage of each socket address (protocol/network address/port) is normally permitted")>
always gives me this error too I think
well, always randomly
that vps?
mm it's on PC but I think I've seen it on VPS too
if thats the case then there is somthing else running on that port
hmm okay I'll try things out tyvm
says its listening to python so im assuming thats my script ig
do I have to close the session or smth every time I close the script?
tried moving it to main file and didnt seem to work either :(
https://i.ghastcreeper28.nl/Ysfi1Ak.png I have to do it like this?
yes because he defined client
i have a folder with al my modules this is in the index.js require("./modules/topgg.js")(bot, con) and the code is in the folder and then in the file
how long it normaly take to work on the site?
have u set the lib up?
why
you are creating a new discord client
this new client is not connected, nor logged in, it has no information about anything
you need to use the client that your bot uses
and give it to dbl
But what i have to put all in to get the server count on the site
you just need dblapi.js and new DBL(token, client/bot)
as long as the client you put in the DBL options is the correct client, it should work automatically
it autoupdates every 30 minutes
Who knows where should learn js for api in discord or maybe python ?
wut
wut
const DBL = require("dblapi.js");
const dbl = new DBL(config.dbl_api, { webhookPort: 5000, webhookAuth: config.dbl_auth }, client)
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
When i use this, nothing happens when called...
How i can conect a page with a webhook? Discord.js 11v
Hello, how can I set up the dbl webhook to get vote and guild information?
How i can conect a page with a webhook? Discord.js 11v
help?
Hi guys I have a question. When I make a Streaming Status on my Bot on PC then theres Playing but on Mobile theres Streaming.
Can someone help me?
I have a question can i have the url for the API Endpoint to send Guilds from my bot?
base url: https://top.gg/api/docs#reference
bot endpoints: https://top.gg/api/docs#bots
what language?
are you using dblapi.js?
you need a webserver to receive vote events, you can use something like express.js or similar, or you can use dblapi.js which includes a built in webserver
alright
dblapi.js is top.gg's official javascript library
check the webhook example
thanks
then you need to go into your bot's edit page and fill up the webhook URL and Authorization
URL should begin with either your machine/vps's ip address, or your glitch/heroku project url, or whatever public address your webserver will be running on
i got the server count posted
@vapid cape sorry, ive done what you said but i cant figure how to connect the votes
I Know This A Dumb But How Do I Connect My Top.gg Api With My DiscordBot So When He Vote He Get Money Or Credits From Bot Economy
Read Docs
you're being rate limited
oh for some reason I placed postStats in client.on("message") ohgosh... that explains xd
Lol
is using the webhooks more effective performance wise than compared to direct API calls?
according to what people say, yes, by a large margin
is there a way to check if some1 voted in the last 12 hours?
and not if he voted
like in all times
A specific endpoint to see if a user voted actually does that
Though it won't mention when exactly they voted
yes i know theres an option to check for votes but like i wanna gain votes quick when my bot will get approved so i was just wondering if its possible to check if they voted in the last 12 hors cuz you can vote once in every 12 hours
imagine having ur bot name in the api docs https://imma-steal-ur-girl-nig.ga/ss/rofp0tpf
/bot/<id>/votes is the needed endpoint for you
For dblapi.js, see getBot
@green mantle sorry to bother, but when you moved everything outside of a cog into ur main file, you would put the functions as a listener event, and then run self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='DBL', webhook_port=5000, autopost=True) into an async function which u call on after with run.complete right?
May I know who has the ID 312559122144821250 that is returned from webhook tests?
Quite the wrong channel to ask ig
?
dbl voted resend channel message example ?
hey is this how u would do it if you were to drag the events out of the
cog and into the main file
@bot.event
async def on_dbl_vote(data):
print("voted")
logger = logging.getLogger('bot')
logger.info('Received an upvote')
print(data['user'])
user = bot.get_user(data['user'])
try:
await user.send("Thanks for voting!")
except:
pass
@bot.event
async def on_dbl_test(data):
logger = logging.getLogger('bot')
print("voted")
logger.info('Received an upvote')
print(data['user'])
user = bot.get_user(data['user'])
try:
await user.send("Thanks for voting!")
except:
pass
No need to create another logger
hm okay
everything else looks fine? I still don't understand why my code doesn't respond at all 
Create an instance of DBLClient right after you create an instance of commands.Bot
Nah, everything will run by itself
okay, lemme try
still doesn't show up anything; I'm trying to use the print function and the testing thing on top.gg website and it doesn't print anything when i click on test
I'm using my PC to run the program that has the webhook using an IP on a remote VPS; not sure if that would affect anything but
Restart the machine and try to run it again ig
hm alright
oh u mean restart the vps?
hmm ok
BRUH
that was my problem
all along
all I needed to do was restart it
and it was causing me a headache
tyvm

also, is it possible to pass bot through the voting?
async def on_dbl_test(data):
logger = logging.getLogger('bot')
print("voted")
logger.info('Received an upvote')
print(data['user'])
user = bot.get_user(data['user'])
try:
await user.send("Thanks for voting!")
except:
pass
``` e.g., I want to add bot here cuz I need bot to update my db
so I can reward them
But bot is accessible there already
:p
It's alright
my brain
4 am
I still get this warning though; it might be why it's causing the error in the first place
Ehh
You're force closing aiohttp sessions, that's not exactly an error
I suggest you keep d.py updated
has the dblapi.js been updated to support discord.js v 12 yet?
i see there is an available update for it, wondering if its for that π
Yeah
yeah it's really a nice version ^^
Aha
hello, how can i'get votes of my bot
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'm using this but idk where add the webhook token
webhook token?
maybe
anyone can help me
?
@willow spindle you just change yourDBLTokenHere to your token on line 2
dbl.webhook.on("vote", async vote => {
console.log(vote.user);
});
``` Why does vote.user returns the ID 312559122144821250 no matter who voted the bot?
only on tests
its the same when i voted the bot myself
that's your id btw 312559122144821248 but 2 off
tests are your id
your vote is your id
why does it minus 2 the ID?
you probably converted it to an int somewhere
Which is why in js the ids are strings
That wouldnt be the reason
it would round an int because it's too big of a number for js
@restive otter wrong ping bro..
sorry
I don't know then. It should return the correct id. I've never seen that problem before
ok thx anyways
i use module export with my bot
and when i do this
hmm
um
when i run the command (prefix)dbl
it dont do nothing
cause you aren't runnin it by typing dbl
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('My token here xdd', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
module.exports.help = {
name: 'dbl',
aliases: []
};```
i put my token
im stupid
okay so
and how i do it?
do
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('My token here xdd', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
this should be in index
Example:
config: {
name: "website",
description: "DogBots Website.",
usage: "db!website",
category: "miscellaneous",
accessableby: "Members",
aliases: ["dogbotwebsite", "thewebsite"]
},```
I don't believe that has to do with module.exports = {
config: {
name: "website",
description: "DogBots Website.",
usage: "db!website",
category: "miscellaneous",
accessableby: "Members",
aliases: ["dogbotwebsite", "thewebsite"]
},.
I thought you were fully talking about the api mainly, however for this go back to #development
i use this
module.exports= {
config: {
name: "addrole",
description: "Adds a role to a member of the guild!",
usage: "!addrole",
category: "moderation",
accessableby: "Moderators",
aliases: ["ar", "roleadd"]
},
what i do?
??
Is this even related to the api anymore
@restive otter uhm, you should use props.config.name instead of props.help.name
the command info is in module.exports.config, not in module.exports.help which is undefined
-botinfo 672883668594720773
it dont say the server count
dont work
ok
but the api dont work
idk why
message: (bot, utils, config, discord) => {
const Discord = require("discord.js");
const DBL = require("dblapi.js");
const client = new Discord.Client();
const dbl = new DBL('MyPrivateTokenxdd', client);
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
bot.on('message', async message => {
if (message.author.bot) return;
if (message.channel.type === "dm") return;
let prefix = config.prefix;
let args = message.content.slice(prefix.length).trim().split(' ');
let cmd = args.shift().toLowerCase();
let command;
utils.load(discord, bot, config, message, args, message.guild);
if (!message.content.startsWith(config.prefix)) return;
if (bot.commands.has(cmd)) {
command = bot.commands.get(cmd);
} else if (bot.aliases.has(cmd)) {
command = bot.commands.get(bot.aliases.get(cmd));
}
if (config.commandNotFound == true) {
try {
command.run(bot, message, args);
} catch (err) {
if (err) utils.timed_msg(utils.cmd_fail(`Command \`${cmd}\` is not found! To see commands type .z help`, `${prefix}play <MUSIC/URL>`), 2500);
}
} else {
try {
command.run(bot, message, args);
} catch (err) {
if (err) return undefined;
}
}
});
}
}```
i need help with that code
it dont post the server count
idk why
why do you have this as a module.exports?
because i use a handler
yeah this is wrong I think
how i fix it?
maybe it would work if you changed client to bot
but you should put this in your index.js
:/
const dbl = new DBL('MyPrivateTokenxdd', client); => const dbl = new DBL('MyPrivateTokenxdd', bot);
because it seems to be like you use a message handler and just copy pasted it there
you should move it to a different file though
@craggy sentinel
My bot is in 25servers, but on Top.gg says that it's in 0 servers π€
Read the documentation on how to update your server stats
why would u ping a mod for that
Documentation?
owh thx
How i use a webhooks to do Upvote Logs?
first, where do you host your bot?
@restive otter how do you do that 5 users in 12 channels of 1 guild?
?
This
it was the prob bot
thats just logging stats
^^
how i can do a log of users when he do a upvote?
@restive otter are you using dblapi.js?
he is yes
yep
did you setup the webhook options?
idk how to use webhooks
did you look at the webhook example in dblapi.js?
yep
so did you set it up like that?
yep
where is your bot hosted?
is it a full vps?
nothing
you need to fill that in
URL should be YOUR.VPS.IP.ADDRESS:WEBHOOKPORT/dblwebhook
Authorization should be the same thing you set up in webhookAuth:
how i get all of this to do it?
you got the API set up ye?
yep
his api setup is strange
you need your vps's external/public IP address, which you should be able to get from your provider's control/admin panel
ok
this?
so it would be IP:port/dblwebhook
ok
also, is your code what MILLION sent?
it is
yep
the only difference is the client was changed to bot
thats utterly wrong
^
delete the entire code
the code shown in the dbl example should be placed in your main file, the same file where you declare you bot
where is client.login?
this?
i mean, you can
where do you call the bot.login(token)?
but its easier if you put it in the same file where you declare your bot
in a config file
wait
.json
if you have let bot = new Discord.Client() then your dbl should be new DBL(token,bot)
yes i have it
what is in it?
you would put it there
yes, you can put it right under your bot
@grim solstice #development
(i change the token, relax)
what i need to do ?
i change client to bot?
delete the duplicated client and discord
finished
port being the port on the webpage for the VPS
no...
why do you keep duplicating code
you already have DBL
dont duplicate it
add the webhook options on your first DBL
yes, now add the webhook options
im adding the webnock options
now change 5000 to the port you were shown on the webpage for the vps
i put it
and changing password is optional but suggested
changed webhook Port
did you put the bot back in?
and there?
yes
ah yes
alright
in pass what i put?
whatever you want
now when you start your bot, you should see "webhook running at xxxx"
ok
now go to your top.gg page
and in the URL
put YOUR.VPS.IP.ADDRESS:50004/dblwebhook
and password is what your password was set to
and in Authorization, you put your password
oh its Authorization
yes
i put the pass
saved
you should see a vote in your bot's console
if your bot is running it should console log
dont say nothing
you restarted correct?
yes
yes
ok






