#topgg-api
1 messages Β· Page 75 of 1
no wait, if someone voted through the proper vote link on top.gg it will show their user id
what is glitch, some kinda cheapo vps?
im amused that you can just edit files directly on their site π
yeah is a small pseudo-vps
i will use soon repl.it
its not really a vps, its like a managed project
ive been using digital ocean so far without issue. few people here recommend contabo too
like google's app engine
yeah
@restive otter is gay
#savage
${vote.user} gives id
get it from the client
client.users.get(vote.user).username
yes
ty
so im seeing this unhandled rejection error i hadnt previously
i suspect its from guilds kicking my bot then him trying to send a spawn to the server (that hes no longer in)
missing access - thats for sure my bot been kicked right?
can be invisible/deleted channel
how exactly does one do that?
do?
do what?
Make the handler for invisible channels
catch
I'm putting the code on a Pastbin.
https://pastebin.com/rdE6jsY8The problem is with the api
the goal is just to count the number of servers the bot is on But it doesn't work. (ping me)
What do I have to do? @true talon
No, was talking about https://discordapp.com/channels/264445053596991498/412006692125933568/683326073018384403
And idk, I don't know d.py
np
i'm stuppid
I have to wait 30 minutes for the server count to update, is that right?
the script ?
In the code yeah
is that a separate extension you're loading in main file
yes
I thought you had to add the cogs inside a setup method
Try to use the on_guild_post event in the class
const dblTwo = new DBL("dbl token", { webhookPort: 5000, webhookAuth: 'password' });
dblTwo.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dblTwo.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
this isnt logging anything
wth is hastebin? π
just an online text editor?
so its not actually like pastebin then? π
your bots in more servers than mine π
but mines is 1 higher on the trending bots section of homepage β€οΈ
@sullen fox in the top.gg edit page, the URL and Authorization field, under webhooks
what did you put there?
Website URL? nothing
oh the webhook URL? yeah there's nothign there
same with Authorization
hm yes, sending requests into the abyss
const dblTwo = new DBL(my token, { webhookPort: 5000, webhookAuth: 'password' });
you need to fill those out to point to the location of your bot
is 'password' supposed to be whatever i put in authorization?
which will mean your bot need to be hosted somewhere with a public facing ip
i host it on aws
is 'password' supposed to be whatever i put in authorization?
@sullen fox yes
and yea password is whatever you want for authorization
what do i put in URL?
i googled for random authorrization token generator and just made a random alphanumerical string
do you havea url for you bot?
if not, get one
wdym
well, in order for your bot to recieve a webhook notification, your going to need to have your bot setup on some host thats always online, with a means of contacting it
else how would top gg know where to send the hook notification to
aws
ip:port should be fine
so like, 192.168.0.1:80
or w.e ~ as long as it matches where your bot is running
yea your ipv4 is fine
ok lets say im running my bot locally because im coding a new command or something and dont want 2 instances running
what would i change the ip to
why would you want to send a webhook to your local machine?
you would need to configure port forwarding for you router
and supply your own public facing ipv4:port
but tbh, you shouldnt be processing web hooks in dev mode
ok i filled out the URL and Authorization
i just do a simple check for a configuration variable that defines dev mode
url has my ipv4 f my host
and authorization has the password
and check your aws logs to see if its processed
problem: i have to wait until i can vote for it
test: avoids waiting
i voted 102 times earlier within around an hour of testing π
none of them count as actual votes ofc
how?
thanks
np. wasnt sure my arrow was big or red enough π
dblTwo.webhook.on('vote', vote => {
console.log('Someone voted.')
const logGuild = client.guilds.get(`id`);
const errorLog = logGuild.channels.get('id')
const voteLogs = logGuild.channels.get('id')
voteLogs.send(`${vote.user} just voted!`)
});
``` both the console and voteLogs.send arent working
Umm don't you need to provide an actual ID?
I mean I could be wrong but π€·π»ββοΈ
Placeholders
Oh true lol π€¦π»ββοΈ
if it doesnt work either your url/authorization is wrong, or your server is not accessible (ie: firewall/closed ports)
yea, ^ that
and my domain simply forwards to an ip address via a dns
like all urls do π
do you have a reverse proxy running?
if not, it should be xx.xx.xx.xx:3000/dblwebhook
did you put the port in the url?
either ip is wrong, or authentication is wrong, or contabo requires ports to be opened in their admin panel
guys is this where u get the code
Still can't get the voting to work
can I get a notification from the API whenever votes reset?
is there a webhook.on() event for that?
They reset on the first of every month at 12 AM UTC
It'd probably hurt the server to mass send requests to every running webhook at once to add a notification for them
@night veldt what code?
Has anyone got any idea why im getthign this error
Exception in thread "main" java.lang.NullPointerException```
Im using this code
```java
DiscordBotListAPI api = new DiscordBotListAPI.Builder()
.token("MyToken")
.botId("MyBOTID")
.build();
api.setStats(jda.getGuilds().size());```
I do the following in my code to get when the bot is voted, do I need to set the webhook url also in the bot's page on DBL?
bot.dbl_client = dbl.DBLClient(bot, bot.dbl_token, webhook_port=5000)
@bot.event
async def on_dbl_vote(data):
uid = data["user"]
print("Vote received")
await increment_ticket(bot, uid)
Yes
@night veldt what code?
https://little-files.glitch.me/data?file=291P22ZD.png has anyone a idea how to fix this because on my bot it is working and here not
@fallen basin can u send a clearer pic
https://little-files.glitch.me/data?file=33TX77DS.png this is the Code
Output body
https://little-files.glitch.me/data?file=41TG41MR.png and this is the Error
Output
body
@sullen nymph ?
console.log the body
So req.body.user can't be used
but the Funny is on @restive otter it is working
and what else do i need instead of req.body?
Make sure your brackets, parentheses etc are in correct places
Yes
@sullen nymph then what url do I put on my discord bot's DBL page?
http://<ip>:<port>/<webhookPath>
Since you are not overwriting the default value for webhook_path, it's /dblwebhook, so http://your_ip>:5000/dblwebhook
@fallen basin are you using express?
if so, you need to use the body-parser addon/middleware
okay thx i'll try it
@vapid cape
read the link i sent
@restive otter install what
use*
body parser
How to use that
Tim has a status which looks like a furry text
he Finshed it
I have set this up in my JDA main class
DiscordBotListAPI api = new DiscordBotListAPI.Builder()
.token("token")
.botId("botId")
.build();``` with my token and bot ID but it still says NA for the amount of servers
what's with the API and being like 1 minute late after a vote?
hasVoted() returns false until like a minute after a user has voted
How do I get the votes for my bot and then send it to a channel
use dbl webhook
I upraded to djs v12, but my server count isnt posted (here is my code : https://prnt.sc/ra0trw, https://prnt.sc/ra0tv6)
nothing in the console
dont tell me dbl.on things are useless
and that I have to do .then in the setInterval
https://prnt.sc/ra0v4i still nothing
did you try placing postStats outside of the interval?
They reset on the first of every month at 12 AM UTC
@spiral steeple
Thanks. What would be the best way to code this in if I wanted to automate resetting the vote counter? Time calculations are always messy
Am familiar with momentjs
checking for if the date is 12am UTC every second would be pretty intensive...
I would use a cronjob
setTimeout
but I would have to specify the time each month for the cron job?
and re setTimeout, calculating the timeout is the messy part
taking into account leap days like for last month, how many days in a month to times 86000 by, etc
You can set a cron job to run every month on the first at 12 am
Gotcha
That is https://crontab.guru/
An easy to use editor for crontab schedules.
Don't think so?
I've never messed around with webhooks before so I'm not entirely the correct person to talk to about them
my 3rd time asking here, how long does it usually take for votes to update for the api?
Anyway to test the api before your bot is approved
like an in-place java spoof library?
I donβt see it in the docs
So I doubt it
Unless Iβm blind. Iβm barely awake.
What's this?
@elfin maple my thing you code is broken re code
is there support for discord.js?
no
oh nice
There is @tawny heron
for v12?
Look at the js docs
which was published yesterday?
Pretty sure people who were using V12 before it was released have been using the Api
Tias
yeah like me
but im getting errors
that i asked about earlier and was told that v12/old master is not supported
at IncomingMessage.<anonymous> (/root/Musix/node_modules/dblapi.js/src/index.js:118:25)
at IncomingMessage.emit (events.js:323:22)
at endReadableNT (_stream_readable.js:1204:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:26284) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 84)
I misunderstood you @tawny heron
tonk didnt update yet?
im gonna do a PR for tonk then lol
@arctic arch one question tho, does the api support combining internal sharding with external? like sending {shards:[345,235],shard_count:4} from one process and {shards:[324,345],shard_count:4} from another
or you can only do it one-by-one or all-at-once
hmm not sure if I implemented it so you can have null for shards that you don't want to update
ah interesting
also, are you gonna update dblapi.js anytime soon, or should i send you a PR?
still thinking I'll wait and see how it goes
I see a lot of devs arent happy about the change
well, not hard to make it compatible with both v11 and v12
obviously I have to support both
you think there's a chance they'll rollback the .cache thing even in v12?
@restive otter wtf
not sure if they'll revert but some big breaking changes around managers could still be happening
personally i dont like the .cache thing
well, i dont think it will happen, considering they officially released v12
yesterday
oh lul, yeah they released it yesterday
so quick
hence why the pressure to update dblapi
it really came as a surprise for me too
shoulda just pinged me with "v12 is stable"
well, true, didnt think of pinging you lmao
so, this is for the new version?
oh, alright then
the guilds from all shards exist in client.guilds
yeah true
so the server count is the total server count
client.shard.id is undefined
client.shard.count includes shard count
so you get a request with total shard count and total guild count
dblapi works on discord.js v12?
not yet, but should be released soon
f
I don't have the time to test that rn, feel free to review the pr
you mean dblapi.js?
yes
its not updated for v12 yet
probably today or tomorrow
you mean v12?
yes
i've been using it for like 6 months already
oh nice
I have a question about the api. I need to get webhooks to get a notification when someone votes for the bot. How can I get the Webhook port and Auth?
just invent the data
wut?
invent the port and password?
you host a webserver essentially
the port of the server where the bot is hosted?
π€·ββοΈ
I don't understand
what ever you are running a webserver on
to recieve the webhook
you would have the IP and port be for that server
the port you set
the IP is your public IP normally
unless it's being routed through a domain
http://theinnkeeper.online:12345/dblwebhook -> what a example url would look like
http://123.456.78.90:12345/dblwebhook -> Example of an IP url
You have to run a webserver, dbl has a set of libs already made for it
ok
@arctic arch so internal sharding is treated as a single shard. but when using the shard manager, shard.id is undefined, so lets say you use the manager to launch 2 shards, and run dblapi on each shard. The bot would make two api requests both containing a server_count:123, shard_id:undefined and shard_total:2, does the api automatically increment a shard id by the order in which the requests come in, and then reset it when shard_total is reached?
or would it assume both requests are for shard 0 and overwrite one with the other?
it would assume the server_count is the total
the old sharding is still a thing with v12?
Some things changed, but most of the things are the same
that would make things tricky
I guess every changes can be found here https://discordjs.guide/additional-info/changes-in-v12.html
would assuming a shard ids array having only one id as being from the manager work
yes, when using the manager, most likely shard.ids will always have only 1 value
but if you want to venture beyond that, you could do something like dividing total by ids.length and then checking the ids of the shards
that's what you think but servers don't evenly distribute between shards
hii, i've just a problem, i don't know what to put in "webhook url" on the website because of i'm using glitch and not a vps
your project url/dblwebhook
that what i put
nvm my method only works if all processes have an equal amount of shards
yo do not need that

need what ?
I pushed a commit with my possible solution
create a server with https (?)
i was thinking about something like this
I had the same problem a few months ago
shard_id = client.shards.ids[0] / client.shards.ids.length
to support internal sharding combined with process sharding
const otherApp = express()
const server = http.createServer(otherApp)
const dbl = new DBL("dbl token",{ webhookPath:"/dbl",webhookPort:4387,webhookAuth:"psw" })
dbl.webhook.on('ready', hook => {
console.log("Webhook running with path " + hook.path);
});
dbl.webhook.on('vote', vote => {
console.log("User with ID " + vote.user + " just voted !");
});
otherApp.get('/', (req, res) => {
});
server.listen(5000, () => {
console.log('Listening');
});
here my code to get vote
but it only works if all processes have an equal amount of internal shards
it doesn't work
"Cannot GET /dblwebhook"
@worn kiln this is normal because webhook is not GET, the webhook is POST
mmh yes but when I click test on the website, it's doesn't tell me everytihng
check console
@worn kiln if you have an existing server, you dont use a port
specially in glitch, that only gives you one port
you should do this instead
let listener = server.listen(process.env.PORT, ...)
let dbl = new DBL(token,{webhookServer:listener,webhookAuth:"password"},client) // optional client if you want to enable the auto poster
in glitch you should use process.env.PORT as your port
oke i try
oh my god
it work
i just take the listener of basic glitch
thx u so much π β€οΈ
Why does the website still say my servers are N/A
I done exacly what it shows on the guthub for java
I done exacly what it shows on the guthub for java
@floral phoenix are you sending a get request to to right endpoint?
Also, there's an official DBL library for java
It's on their website
@knotty garnet
https://github.com/DiscordBotList/DBL-Java-Library
An API wrapper for https://discordbots.org/api/docs that works in Java - DiscordBotList/DBL-Java-Library
And im using Maven
Hm, weird
I use that exact library
Could you show us a snapshot of the part where you call the method?
Yay, another intellij user
Ah, I see the issue
Just a sec, gonna take a print
Waitaminute
It's correct
Is that method being called?
Also, are there errors in your log?
There is no errors no thats why im so confused
i dont know java, but does that code wait for a ready event? or only initializes stuff?
Not at all
But you might want to run it on debug mode to see why it's not updating
because you cant get the guilds before discord sends them to you
aka, you have to wait for the ready event before posting
Ah, that could be it
Since I call that only during cronjobs i haven't thought about JDA not having enough time to cache the info
does jda have a ready event?
Jda has it
onReadyEvent
However
JDA locks the thread until it finishes loading
So that a bit weird
It was supposed to work
So should i make a onReadyEvent and put that in there ?
well, try it
You could also try to put it inside a command
See if it works
Ah, and btw, you shouldn't create a DBL object each time
Ye not working
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>```
That thing
Yep
If you used it, I'd say to set it to debug level to get every event that happens on your code
@floral phoenix api.setStats(serverCount) returns a CompletionStage that needs to be executed
This is how I do it
api.setStats(serverCount).whenComplete((empty, error) -> {
// log success or error
});
Maybe you could do it another way if you don't want to execute anything after the server count is send
You don't need to continue it
The next step is called once it's complete
You could add a System.out there to see if it's completing tho
ok, I treated it kinda like a Mono/Flux reactor
Cannot indent it properly on discord lol
Here's the way I've done it
It's basically what you've done
But on a cronjob
^
i cant post the stats help me https://platinbae.is-inside.me/a4aqStmW.png
whats your code look like?
Im about to leave for work so i cant help much but thatll pry be needed for others to help π
sad
Wait some days til tonkku has published the new version of dblapi.js
@restive otter
i have the same problem
and i have solved it
i have change the version number
from 12.0.1 to 11.6.1 and it's working properly fine
just waiting for dbl to update
i know
Yes it is
JS:
Does this triggeres at every vote or only at a vote for my Bot?
dbl.webhook.on('vote', vote => {
only a vote for your bot
Ok thx
@arctic arch
when you are updating the api
?
i am waiting for it
the discord.js is stable now
He is aware
hmmm
How can I do something like this but for discord bot list in Python
I took a look at that but that seems to only do server count and not that message above
Webhook
So I need a web hook?
look at the example and read the docs
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 = 'dbl_token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)
# The decorator below will work only on discord.py 1.1.0+
# In case your discord.py version is below that, you can use self.bot.loop.create_task(self.update_stats())
@tasks.loop(minutes=30.0)
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count"""
logger.info('Attempting to post server count')
try:
await self.dblpy.post_guild_count()
logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
except Exception as e:
logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
# if you are not using the tasks extension, put the line below
await asyncio.sleep(1800)
@commands.Cog.listener() <-- This
async def on_dbl_vote(self, data):
logger.info('Received an upvote')
print(data)
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))```
imma steal this ty
lol
And stealing it and not knowing what it does still won't help you.
i know that. its not hard to see how it works
I gotta find an alternative to pagekite for forwarding for webhooks
multi threading serenity is hell
how can i make if user vote for my bot send to room
user ${message.author.username} vot for me
Webhook
and ?
U can read docs
okey
There is examples of how to do it
okey thanks
const dbl = new DBL(yourDBLTokenHere, { webhookAuth: 'password', webhookServer: server });
what's password ?
First, setup the webhook
Second, use the webhook password
I can't rly help, idk how webhooks works
okey np
You need a webhook set up to get the vote events
You then need a system for sending discord webhooks if you want it to display a message
okey
Hello
I wanted to know in which format does the top.gg webhook send data
I tried to recive the posted data using multiple ways
I am using express for this purpose
I tried:
express.json()
express.text()
express.urlencoded()
But none of them seem to work for me
Sorry I got it.
It works on express.json();
I was not saving my file!
it's always json, really few sites actually use xml for responses, and even those offer a json version of it
Not always. A site I wrote an api handler for a site that only uses xml
urlencoded is widely used as well
I wouldnt call it a popular site, but it still is updated regularly.
also multi-part data for file uploads
Hey, the API mentions a "test" vote Button, where can I find it ?
Make sure to save before you test
Hello there! I was thinking about using DBL's webhook vote feature but for some reason, when I test it from the website, it doesn't send anything in the console.
https://discourse-cloud-file-uploads.s3.dualstack.us-west-2.amazonaws.com/business6/uploads/glitch/original/2X/9/9bbdd0211784ec33c74dde7c67d3d30e28763491.png
const DBL = require("dblapi.js")
const http = require("http")
const express = require("express");
const app = express();
const server = require('http').createServer(app);
const listener = server.listen(process.env.PORT, function() {
console.log('Deployed successfully!');
});
setInterval(() => {
http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`);
}, 280000);
const dbl = new DBL(process.env.DBL, { webhookServer: listener, webhookAuth: process.env.PASS }, bot);
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 ID ${vote.user} has voted!`)
});
console says: Webhook running at http://0.0.0.0:0/dblwebhook
Also, here's a demo version that I made, that it doesn't include the tokens for security reasons. (for the users who use Glitch.com)
Project: https://glitch.com/edit/#!/dbl-testing
Thanks in advance,
TehPig_YT
Everything on the bot's DBL page is set up properly.
Notice: Problem has been solved
you should listen to the server not listener
what is ur djs version@blissful lake
u dont have to be like that he or she just ask a simple question even if the problem is solved
k
How do I fix 400 Bad Request errors?
this is my code
dbl.postStats(client.guilds.cache.size, client.shard.id, client.shard.count);
Discordjs Version?
also note client.shard.id in v12 is now client.shard.ids, an array of ids
but is your bot even sharded
I have it's just not released lul
you can npm i DiscordBotList/dblapi.js#djs-v12
to test it out
yes my bot is sharded with 2 shards
Well try to update dblapi.js
alr
an update is not needed if you don't add the client in the constructor
but if you have added the client in the constructor, why are you posting stats manually?
wait you can add the client into the constructor?
i think i have to blame myself for not reading the docs
you can but the version in npm does not support d.js v12 yet
so it automatically post it if the client is added?
yes
alr then i guess i just have to wait for the new api to be released to npm
or you can load up the github version with the command above and test it now
because npm i DiscordBotList/dblapi.js#djs-v12 βsave returns an error
just dont forget to install the npm release when that's out or you'll get errors later lol
ok thx
ok
dblapi.js v2.4.0 released with discord.js v12 support
finally
I think you can put in in #discord-news so anyone can see it
one of the twos
no
make sure to save before trying to test it
Hey how do I create an on vote event with shards (discord.js)? I've looked through a couple pages of messages in this channel but nothing has worked for me.
yes but you can't login to your dbl token on the same port multiple times
just place the webserver in the shardingManager
show code
const Discord = require('discord.js');
const client = new Discord.Client();
const Manager = new Discord.ShardingManager('./minecord.js');
Manager.spawn(2);
const DBL = require("dblapi.js");
const dbl = new DBL('token',
{ webhookPort: 5000, webhookAuth: 'pass' });
dbl.webhook.on('ready', hook => {
console.log(`${new Date()} Connected to DBL Webhook at http://${hook.hostname}:${hook.port}${hook.path}.`)
});
dbl.webhook.on("vote", vote => {
console.log(`User with ID ${vote.user} just voted!`);
client.channels.get(`683795130079379501`).send(`<@${vote.user}> just voted!`)
});
you cant use client in the shardingManager
i figured
you have to send it via broadcastEval
or however the shardingManager communicates with the shards
ie: Manager.broadcastEval("if(client.guilds.cache.has(CHANNELID)) { client.channels.cache.get(CHANNELID).send(DATA) }")
assuming discord.js v12
@dense compass ^
Can 2 servers have the same channel id?
It'd be really really low chances
but is that possible?
I want to say no simply because if it would somehow initiate at the same time, they'd simply go one after the other in terms of when they're processed, overall, maybe, but if it's handled correctly, it wouldn't
Though I wouldn't be concerned about it at all, it's next to impossible to do that
@spiral steeple no, channels are unique
Channels as a resource arent even guaranteed to be attached to a guild
you can tell this by the paths for interacting with them
This is creating a message within a guild channel
Because theres no reference of a guild, one can only conclude that they are globally unique
even across DM channels
@inner venture where is that screenshot from?
@ocean rain err, my computer
you guys could also use a webhook for getting whenever your bot receives a vote
no need for dbl authentication
just create an endpoint and pass it to the webhook field in the bot's configs
since almost everybody here is using d.js you should have no problem setting up a webserver
You think too high of the average skill here
@ocean rain if you want to know the program he's using, in the screenshot, it's Postman 
oh
We can't edit bots we're not owners of
http://ip:port/dblwebhookby default
mkay
Edit ip and port per your configuration
Ehm, what?
configuration? like i just make it like this
ig im putting localhost:port/dblwebhook
What is 401 Unauthorized?
means youre not allowed todo what ever your doing
Token was not valid or specified
^
lol
That isn't even a valid IP address
it only has 3 groups of numbers instead of 4 and 678>255
hasVoted !== getStats
hasVoted takes time
Depending on your eval command i think
no
yeah and one thing dbl has taught is that its shit with caching
That's why you use a webhook
Well did you await it
you didnt resolve the promise lol
I did lol
show code
no need for the weird async function
just do js pichu eval dbl.hasVoted('635383782576357407').then(voted => { message.channel.send(voted); })
and you'll see the true/false
I basocally have to... wait?
well I have to create a webhook
but idfk how they work
the dbl library does it for you
no. I mean webhooks in general
coz...heroku shit lmao (idk what to check https://prnt.sc/rd3x1x, https://prnt.sc/rd3yc5)
release?
wat
you dont need any other opptions
you just need a webdyno or whatever
heroku was made for webservers
webhooks have nothing to do with notifications?
idfk
@green mantle ?
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}`);
})
that?
did you set the webhook options?
webhook options
the webhook isn't defined so the webhook isn't running.
^
read the api docs.
oh and also set the webhook url and password on the site via editing your bot @shy socket
π¦
@fierce furnace this code main?
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}`);
})```
how to get top.gg token?
^
so if you vote for a bot and then the bot restarts the bot dont see that u have voted for him
interesting
If you only store your votes in memory, yeah
The bot might also miss a webhook call during the restart
I keep getting Error: 400 Bad Request request when trying to use postStats (discord.js)
Was ever since I updated to v12
You dont need to use postStats
But if you want to, make sure youre getting the correct server count, which in v12 is client.guilds.cache.size
If you add your client to the DBL constructor, it will do it for you automatically
Awesome
Bht make sure you have the lastest version of dblapi.js
Is there any way to check is user voted for bot and this return true only 1 time per vote, so user can't claim rewards multiple times?
webhooks
No API endpoint for this. Like during downtime?
const Discord = require('discord.js');
const client = new Discord.Client();
const express = require('express');
const fs = require('fs')
const http = require('http');
var app = express()
client.login('Discord Token');
const DBL = require("dblapi.js");
const server = http.createServer(app);
const dbl = new DBL('Top.gg Token ', { webhookAuth: 'SecureWebSocketPost', webhookServer: server});
app.get('/', (req, res) => {
res.send("Aktiv!")
});
app.listen(6573, () => {
console.log('Running on port 6573');
});
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size); },
1800000);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
Wont work
The Tokens are set. ..
And webhookAuth is set too
is there a ratelimit for guild update time?
-ping
I'm alive!!!
i created my bot and i created a script and it's not working someboody can help me?
this is something worng
wrong
thx
@lament crescent you leaked your token
Yeah i know i restart ham
What does: Error: 400 Bad Request mean when trying to connect
lol
is there an example of a daily system being implemented with DBL
Im pretty sure Top.gg bc its coming from dblapi.js
at IncomingMessage.<anonymous> (C:\Users\___\Desktop\Bot\node_modules\dblapi.js\src\index.js:118:25)
at IncomingMessage.emit (events.js:323:22)
at endReadableNT (_stream_readable.js:1204:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:1536) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1536) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
send the code
the one that's giving the error duh
uuh
I'll assume you're using your dbl token
first
did you just copy the code from the website
ik
I mean
idk why it's erroring
u sure that's where the error is coming from?
It means nothing
this is how I'm doing it
@stiff orbit kinda
dbl.on('posted', () => {
logger.info(`GuildCount Updated`)
});
dbl.on('error', e => {
logger.error(`DBL Had an error ${e.message}`)
})
I have the rest at the top of my file lmao
I don't think so
it's 11
pm
I got school tomorrow
yes
at the top of the file
I'm just showing that part
it doesn't matter lmao
How can u change the n/a on ur bot on the website?
@mellow plinth https://top.gg/api/docs
dblapi.js supports server count posting
yh but i need like a video so i know what im doing
examples
Well I didn't ask what those are 
was this not clear enough
@restive otter there are good text based examples, videos aren't needed
@arctic arch What do you mean by This channel is an archive of old examples? Kinda unclear.
Like how old are the examples?
I have a bot called @restive otter, and it carrys on giving multiple vote rewards whenever a user votes. It's down at the moment, but could someone check my code in a little bit please?
@sullen nymph would you be able to help please since you're one of the library developers?
I don't exactly remember how top.gg handles the weekend vote data
If you need help with it in discord.py though, I might be able to help
I don't mean weekend, I just mean it duplicates votes.
I'll send a screenshot
And the code
@commands.Cog.listener()
async def on_dbl_vote(self, data):
logger.info('Received an upvote')
voter = bot.get_user(int(data["user"]))
if data["isWeekend"]==False:
coinamount = random.randint(10,1250)
try:
await voter.send("Thanks for voting! As a reward, you've been given {} coins!".format(coinamount))
except:
pass
await bot.get_channel(671795061150842891).send(embed=makeEmbed("", "{0} has voted, and won {1} coins!\nVote [here](https://top.gg/bot/627859943889960961/vote)!".format(voter, coinamount)))
giveMoney(voter, coinamount)
else:
coinamount = random.randint(100,2100)
try:
await voter.send("Thanks for voting! As a reward, you've been given {} coins! Since it's the weekend, you get more coins than usual!".format(coinamount))
except:
pass
await bot.get_channel(671795061150842891).send(embed=makeEmbed("", "{0} has voted, and won {1} coins!\nVote [here](https://top.gg/bot/627859943889960961/vote)!".format(voter, coinamount)))
giveMoney(voter, coinamount)
#print(data)```
@sullen nymph
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='************', webhook_port=33, autopost=True)```
I have that too
Do you think there could be multiple instances running?
No, I've checked it all and I don't see why it would duplicate itself
I only ever run screen -S gembot python3 bo4.py once, so I'm not sure why Linux would duplicate it.
And it doesn't ever duplicate any commands
So I have no idea what's happened
@bot.event
async def on_ready():
print('----------------------------')
print('CONFIG')
dblsetup(bot)```
Could that be doing something?
What's dblsetup?
def dblsetup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(TopGG(bot))```
oh well there u go
?
on_ready fires multiple times
Oh does it?
on every reconnect
Ohhhhhh
every shard connect, every shard reconnect
So if I do this would it be ok?
dblsetup(bot)
print('Started top.gg webhook')
bot.run("************************")```
ig yh
Sounds reasonable
Thanks!
When I use ```js
dbl.getVotes().then(votes => {
votes.forEach(vote => {
`vote.id` is the ID of the user who has voted or the ID of the vote ?
user
I switched to a real vps (contabo). I took my bot files, replace some values with tokens and tried to run it, but I get this error :
lumap@vmi329048:~/PichuRewrite$ node index.js
/home/lumap/PichuRewrite/index.js:46
dbl.webhook.on('posted', () => {
^
TypeError: Cannot read property 'on' of undefined
at Object.<anonymous> (/home/lumap/PichuRewrite/index.js:46:13)
at Module._compile (internal/modules/cjs/loader.js:1147:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:996:32)
at Function.Module._load (internal/modules/cjs/loader.js:896:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47```
Was working fine with heroku
Literally the same code
Show the code
K
looks like you haven't configured your webhook
;-;
Nvm, fixed itself
How is the voting multiplier useful? Is there any advantage to supporting it?
(in the Java lib for dbl)
I'm not going to use it I don't think
well, at weekends your vote count as 2
it's nice to try to give people reasons to always vote at those days
Oh ok
That's cool
So I either double my prize or otherwise make it slightly better
Neato
Why does vote count as 2 on weekdays? Wouldn't it discourage users who work on weekdays?
Counts as 2 on weekends
1 on weekdays
Doubled I'm assuming because that's when most people are active on discord as a whole
Ok, makes sense

dbl.getVotes().then(votes => {
if (!votes.find(vote => vote.id == message.author.id)) {
message.reply(`You must vote for Helper to gain access to this command. To use this command vote for me [here](https://discordbots.org/bot/409538753997307915)`)
}return;
});```
is there something wrong with that
because i have voted
and it wont recognize that i voted
when i do npm install dblapi.js i get those and it wont show server count how can i fix this?
have you tried running your code?
you sure it's posted? can you show us the code and how you send it
so someone can help, igtg good luck
It doesnβt look like you actually posted it anywhere in that code
Yeah well I don't remember how long were DBL tokens but you just leaked a big part of it... Not a big deal but be careful about those next time.
Also yes, you did not send any data to DBL, you've just set up a webhook server which will not also work since I guess it requires Express to work BUT you don't have to worry about all that if you just want to send server count.
See postStats method here: https://top.gg/api/docs#jslib that's all you need, a single line code where you send the data.
Send it with an interval of at least 2 minutes, you can do it every hour or whatever you want but try to keep request limits in your mind.
@restive otter
@tawdry spindle i did all of that but its not showing servercount in consolelog
Uh? If you want to display your bot's server count why are you even looking up to DBL docs?
Well I'm pretty sure you tried console.log(dbl.postStats(... but that'll not return something I believe
nope
the code i show is what i put in the bot and install the other thing
someone was helping me with it works for them but wont work for me
The code in the screenshot?
And who's this "someone" since that screenshot is completely not relevant to your request
ok then if thats not the right way of doing it can u show me how to do
See
postStatsmethod here: https://top.gg/api/docs#jslib that's all you need, a single line code where you send the data.
Scroll down a bit
k ill check it out
@tawdry spindle it didnt work
it not updating count in page or not showing in ur console server count?
its not showing in console server count
thats what i have
ur logging a simple string with normal text...
ok so what do i need to add to get the server count to log?
console.log(`posted ${serverCount} Count.`)
you should make interval> check ratelimits in docs
i have that but still not console logging anything
its like my bot is not seeing the code
i even installed npm install dblapi.js
...
maybe u created other file and not requied it ...
i put the code in my events ready.js
then it would log
maybe did something wrong
does bot started and
logging anything in ready event?
you added anything to log when ready event started?
yea thats where my logs use to be
?
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});
dbl.getStats("651003099636301834").then(stats => {
console.log(stats).postStats(serverCount, [shardId], [shardCount])
console.log(`posted ${serverCount} Count.`)
});
}
thats what i have and my api key in there
what
Doing same thing everytime
in the new DBL line do you have your client
yes i have my client
okay so the module will handle posting for you
and the posted event will fire when it has done so
you don't need to set your own interval
what am i doing wrong in the code?
no, Sai
omg
is that your whole file



