#topgg-api
1 messages Β· Page 86 of 1
See
so?
Nvm Bye
ahhh
dbl.webhook.on('vote', vote => {
console.log(`Test`)
})``` :/ Not Working When I Vote
*My Bot Has Been Approved
Help Me
second
only primary owner can edit webhook
I have edited from that account
what did you write on webhook settings
remove :5000 and try
2020-05-08T08:14:49.006305+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=POST path="/dblwebhook" host=universal-discord.herokuapp.com request_id=c2babc8c-27f0-473a-b9b4-b14840141b65 fwd="209.97.134.24" dyno= connect= service= status=503 bytes= protocol=https```
Got this when i test
NMW03 are u here?
Umm help
umm
at=error code=H14 desc="No web processes running" method=GET path="/dblwebhook" host=titonbot-beta.herokuapp.com request_id=b3c3c3ec-c519-428c-aa41-37bd446752fb fwd="5.173.185.106" dyno= connect= service= status=503 bytes= protocol=https
@willow spindle Sorry For Ping But Why Im Getting This When I Test?
U didnt replied thats y i pinged π
503 error code π€
-botinfo 684805224573042688
hmm
-botinfo 695991708680323174
bruv
Is this meant to be on it's own shard?
no
Why does the 2nd argument say "The ID of this shard" π€
and it starts with client.
Help pls
at=error code=H14 desc="No web processes running" method=GET path="/dblwebhook" host=titonbot-beta.herokuapp.com request_id=b3c3c3ec-c519-428c-aa41-37bd446752fb fwd="5.173.185.106" dyno= connect= service= status=503 bytes= protocol=https
its optional
Oh I think i see, it's if the bot doesn't have shards i'd assume
i havent seen it anywhere on the site
all bot has at least one shard
a more useful stat is the shard count
Alright cheers, was a little confused
you can post a server count for all shards, or you can post server counts individually from each shard
const DBL = require('dblapi.js');
const dbl = new DBL('Token', { webhookPort: 5000, webhookAuth: 'secret-pass' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
dbl.on('posted', () => {
console.log('Server count posted!');
})
Why it doesn't post servers?
no, your client instance/object
whatever = new Client()
whatever.login()
DBL(token,{options},whatever)
Hey Tim, would you mind helping me with the vote function?
I am suck with this.
@worn rivet your options are fine, dont change them
just add your client instance
at the end
ok
you created a client, right? you used either new Discord.Client() or new Client()
which name did you give it?
const dbl = new DBL('Token', { webhookPort: 5000, webhookAuth: 'secret-pass' });
I have there client
no, i mean your discord client
Ouh, i have two repositories, and 2 hostings
One with this code, and two with bot code
so you dont have a bot on the DBL hosting?
no
then where are you gonna get the server count from? to post
@tepid patrol just post your question
Umm xDDDD
Alright, sure thing.
So firstly, I'm currently struggling with how this webhook stuff works.
Do I need to set anything in this field? I host my bot on a VPS which has a dedicated IP; would it be this? https://vps-ip
yes, your vps's ip address, the port that you set up your webhook with, and the path you set your webhook with
if you didnt set a path, the default is /dblwebhook
alright so it'd just be https://ip:port
without the slash in the middle idk why it put that
so the full url would be http://YOUR.IP.ADDRESS:WEBHOOKPORT/dblwebhook
I'd assume the port would be the port I set here?
yes
Alright let me try that.
I've must've gone wrong somewhere π€
I assume everything here is correct?
no
You must/dblwebhook on the end
And authorization in not dbl token
Authorization is this password:
My main question is why does it say 0.0.0.0 as my ip when i run that code
^
o/ Lumap
uhm ok
That's correct tho isn't it?
It's correct
We will see π
Yeah but it doesn't π
π
But I dont see where I went wrong
But is there any error like this:
code=H14 desc="No web processes running" method=GET path="/dblwebhook" host=titonbot-beta.herokuapp.com request_id=ee4030f4-229a-4a1b-95ba-116e72837e3e fwd="165.22.130.154" dyno= connect= service= status=503 bytes= protocol=https
?
no because im not using heroku
So idk
It just doesnt print anything
@worn rivet why would they do such a thing?
it's the same
do you know what a variable is?
due to the way you said that I'm starting to doubt
For the c# wrapper is there a reason I randomly get null ref's from GetMeAsync ?
Ah im guessing because of the connection issues
How do I show the number of members' votes?
God this is so irritating, can anyone see where i've gone wrong? It doesn't print anything which means nothing is being sent.
I believe the issue is on the website where the "Webhook URL" is as I can use postStats from the bot to the website and it updates.
is your endpoint actually SSL
if not
dont have https
http and https make a big diffrence
I'll try all 3
ohw ait wtf
I asked that and then looked back at my console and it says this
Although when i press the Test button it doesn't work ?
Not sure, it's not working at all anymore and the only thing i changed was the authorization key
from the test button?
I'm pretty sure mines correct though as it printed that just voted message, although now nothing is printed. I might get a friend to vote and see if anything gets sent
It could be the test button or just the api itself but I have no idea; first time using this
π im gonna try and figure it out although i've pretty much tried everything
but i'm still confused how that printed
https
got a friend to vote and nothing came through
5000
what are you using?
i mean yeah it should
like it literally just worked somehow, and the only thing changed since then was the authorization key lmao
so is webhook a valid discord.js command
@tepid patrol dont use https, use http because you dont have SSL in your webserver
you can test your configuration using services such as reqbin
@trail garnet discord.js includes methods for Discord Webhooks. Top.gg webhooks are not discord webhooks
so it'd just be like this @vapid cape ?
yes
@vapid cape Im talking about discord webhooks, I can figure out the command
cool thanks
I think voting is delayed by a bit right now
so your voting event will take some time to fire
@vapid cape Thank you so much, it works now. Just takes around 2-3 minutes until i receive the response.
rip, thank god none of my bots use votes lmao
Tbh i'm only testing it out if i were to ever use votes
It's kinda good to know, I have no idea what to use votes for lmao
well normally they are not that slow, its usually quite instant
but the website has been having issues lately
It's kinda good to know, I have no idea what to use votes for lmao
@tepid patrol rewards for stuff in your bot, or access to features through votes
Yeah I guess
const dbl = new DBL(process.env.DBLTOKEN, {
webhookPort: 5000,
webhookServer: server
});
client.on("ready", () => {
setInterval(() => {
dbl.postStats(client.guilds.cache.size);
}, 1800000);
});
dbl.on("posted", () => {
console.log("Server count posted!");
});
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 am try to make if user vote send in console user just voted but he not working
did you set the Auth,and URL in edit page?
Then set and try again
@restive otter what i will put in Auth
glitch?
yes
oke
don't do https instead http
yes i know
okey.
Does anyone have a tutorial on how to create a webhook? I haven't played around with it, and i can't find anything i would want on google
I want to do it for the on_dbl_vote event
I have opened port 5000 on my router, but what is the webhook path used for? Can someone guide me?
https://prnt.sc/sdff88 what are the factors that can cause this error?
light hacks
maybe crashes
over heating the host of the bot
maybe too much usage of text or action of the bot
Why is botblock blocked from using the api?
(Third time asking)
Any ideas? https://discordapp.com/channels/264445053596991498/412006692125933568/708193716514455565 Please ping π
4th*
How long after starting up a DBLClient with autopost should I expect to see it post? (using the Python library)
and when it does post, does it make sure that the bot matches the Top.GG token? Because I have a test bot I'm trying to use to test it
help_
What should I put in my package.json? " dblapi ":" ^ 2.4.0 "?
Can we make program like if someone vote the bot then it'll send message on the server ?
are you on python?
does anyone know why this doesn't work :
dbl.getVotes().then(votes => {
if (votes.find(vote => vote.id == message.auhor.id)) {
//command script
}
});```
it runs anyway
even if the author hasn't voted
i took it from the docs (https://discordbots.org/api/docs#jslib)
pls ping me
@uncut hinge look at carefully your code, not "auhor", its "author"
so?
nope
Yes its a problem.
You can do directly if (voted){
dbl.hasVoted("95579865788456960").then(voted => {
if (voted) console.log("Tonkku has voted!!!")
});
yep
i tried it too
dbl.hasVoted(message.author.id).then(voted => {
if (voted) {}
});```
so, its not worked?
did you tried }else{?
Yes
yes
you can also directly put it into the if statement
if(await dbl.hasVoted(id)) {
// has voted
} else {
// hasnt voted
}
it will dont work.
10/10 grammar and yes it will
i tried it
sorry for my bad engliΕ
see
i see
it returns me this
(node:28100) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized
at IncomingMessage.<anonymous> (/home/discord/imaginarium-bot/node_modules/dblapi.js/src/index.js:118:25)
at IncomingMessage.emit (events.js:333:22)
at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:28100) 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: 308)```
did you provide an api key
yep
Is it valid
just regenerate
ok
Can someone help me
yes?
Regards I want to show in dbl how servers my bot had reached
How can I do
dbl.postStats
Where
main file or what you want
Okay
I see
Ok thanks
np
hi
How do i get a webhook working for python, discord.py? This is what i got, i have port forwarded, but i guess i need to setup more than that since it isn't working.
Why is botblock blocked from using the api?
-api @warped quiver
@warped quiver
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
http://<ip>:<port><webhook_path>
its should be just dblwebhook @lusty flare
ok where do i implement your api into my bot thats the problem here i had made my bot so long ago and have been out of full on programing for a while i do some tinkering here and there with my bot but where do i add the javascript libary command to?
not basic coding i just dont know what file i need to implement it into
basic coding
had some help with more advanced coding of the bot
do i add this into my discord.js file?
well see the issue is i have the bot set up funny thats the problem
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
}, 1800000);
});
this command cant go here
ofc not
bot id?
what should I do
gimme sec
put db.postStats into a setInterval
or this
dbl.on("posted") gets fired after the stat has been posted
const Discord = require('discord.js');
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
setInterval(() => {
dbl.postStats(client.guilds.size);
}, 60000) // One minute change to something like an hour
});
client.on('message', msg => {
if (msg.content === 'ping') {
msg.reply('Pong!');
}
});
client.login('token');```
something like that
still the same
show code
is english your second language?
turkish
do you have a ready event listener?
sorry my mistake
np
this is a glitch project right?
yes
ok I can join that if you like
dude
don't put it in the message event+ΒΏ
or else you'll spam the api
and you'll get IP banned
I suggest you learn the lang you're trying to use first
@balmy hamlet it's been solved.
Β―\_(γ)_/Β―
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 took it from docs and I filled everything but it is not showing when someone upvotes
What's the best strategy for dealing with webhooks and sharding?
Sharding my bot now, I have all my dbl and webhook logic inside of the bot instance itself, won't the webhooks step on eachother?
Express is not running if i add dbl webhook thing
did you really just asked the same question
yes
Express is not running if i add dbl webhook thing
Even it saying 404 in all my page
when i add that webhook the Webhook is only working
my website is not working
and also it listing the app automatically
like i do app.listen(process.env.PORT)
const DBL = require('dblapi.js');
const dbl = new DBL(process.env.TOP_GG, { webhookPort: process.env.PORT, webhookAuth: 'Tqbb72c7beyu2qQDUwue' });
dbl.webhook.on('posted', () => {
console.log("posted");
})
const express = require('express')
const app = express()
app.get("/", (req, res) => {
res.send("Hi!")
})
When i gone to / its not working
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 took it from docs and I filled everything but it is not showing when someone upvotes
Filled const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' }); in correctly?
Yes of course
And my project on the glitch
So I need to make changes on dbl edit page? @open garden
@open garden wdym
its made correct
its my second bot
Why i dont understand (cuz i dont have 1k+ votes ??)
@barren egret you need to make your own webhook encoder thats why
Invalid page @restive otter
@restive otter without /check
but why
without /check
ok
no i typed top.gg/bots/{bot.id}/check
@restive otter how to do that?
i wanted to see who voted
@barren egret well you can use glitch.me there is pre-made encoder model that you can use
and it works
I am using glitch
@restive otter https://top.gg/api/widgets/botid.svg
but . . .
change boti to yours
ok
nvm
botid
ok
i know it
Your bot doesn't have the correct permissions.
ok but how can i add this correct permissions
so how i can get vote vote count ?
like display how many vote i have
with command
@restive otter https://top.gg/api/widget/upvotes/botid.svg
@restive otter can you please provide me link for pre-made encoder model?
change botid to yours
@barren egret sure
but with javascirpt (i dont want to get that picture)
or i cant
??
you can make bot to send this link https://top.gg/api/widget/upvotes/botid.svg @restive otter
ok
another way ? not using link ?
maybe not
idk
kk
@restive otter thanks
Mention me here when you send link
is that way to get channel.size bot.guilds.channels.size ??
or bot.guild.channels.size
@barren egret https://glitch.com/edit/#!/dbl-webhook-example
just remix this,
edit .env
and put
the url
in this format
on page
Thanks!
@barren egret put this on website
change yourpagename to the name
you got
enjoy
^^
also auth must correspond on website and glitch too
can be anything
and you need to put on index.js too
Alright I'll try!
const dbl = new DBL('APITOKEN', { webhookPort: 3000, webhookAuth: 'PASSWORD' })```
change apitoken to yours
and password to the auth word you put on glitch
and your bot page
@barren egret
and for the main code you have it
Ah, when I try to open dbl webhook project then it says error to load
const dbl = new DBL('APITOKEN', { webhookPort: 3000, webhookAuth: 'PASSWORD' })```
@restive otter
I'll use it
this is just to define dbl
on header
after you did if you did right you should get this
@barren egret make sure you have a webhook on the desire channel
if not, its not goanna work ^^
Alright!
@restive otter i sended the picture
but when i upvote it doesnt reload
reload the picture ??
@restive otter its a delay due top.gg just wait ^^
also you can make a code with that url to show image from that
no i went to the link and i saw that it channegd
but the bot dosent change
@restive otter because you downloaded that as image
the image needs to remain
on host
no
dont download it
i used superagent
i havent
is it good module for getting pciture ??
.env: line 11: mywebhookurl : No such file or directory , I have set everything but only this error @restive otter
Auth=
dbl=``` , I put everything correct
that's what I put
if you dont have webhook knowledge i cant help u
I created webhook and copied url and pasted there
webhook are ezay
Webhook= https://discordapp.com/api/webhooks/....... That is what I pasted
@true talon Is it correct way?
app.post('dblhook', async (req, res) => {
let auth = req.headers['auth'];
if(!auth) return res.json({status: "Failed", message: `You didn't provide a 'Authorization' header!`});
if(auth !== process.env.Auth) return res.json({status: "Failed", message: `You didn't provide the correct authorization key!`});
if(!req.body) return res.json({status: "Failed", message: `You didn't provide any data!`});
if(!process.env.dbl) {
console.log(`You didn't add your dbl api key in the .env file.. smh`)
return res.status(401).json({status: false, message: `Unauthorized`})
}
let bot = req.body.bot;
let {body: user} = await get(`https://top.gg/api/users/${req.body.user}`).set("Authorization", process.env.dbl);
post(process.env.Webhook)
.send({embeds: [{
title: `Vote Here`,
color: 0xbc00ff,
url: `https://top.gg/bot/${bot}/vote`,
timestamp: new Date(),
author: {
name: `New Vote by: ${user.username}#${user.discriminator}`,
icon_url: `https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}${user.avatar.toString().startsWith("a_") ? ".gif" : ".png"}`
},
footer: {
text: `Discord Bot List`,
icon_url: `https://i.imgur.com/78Hl85r.gif`
}
}]}).catch(console.error)
});
app.listen(4000, () => console.log(`Website is up and running`));```
hooly
you dont use dblapi.js webhook system?
I use it only for posting server count on the website
I'm not understanding how to use it for votes , so some guy gave me this glitch link
oh sorry
TOP.GG API ONLY!!! ANY OFF-TOPIC CONVERSATION WILL BE DELETED AND MUTED - This channel is only for SUGGESTIONS/HELP/BUGS to do with OFFICIAL API LIBRARIES and API DOCS found at https://top.gg/api/docs
@barren egret read the dblapi.js docs
you dont need a glitch link or whatever
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!`);
});```
Will it work?
ok thanks , let me try
http://0.0.0.0:5000/dblwebhook
In terminal it posted it ^ correct? @true talon
where?
at webhook url?
I have https:/myglitchproject.glitch.me/dblwebhook there @true talon
https://
yes
.glitch.me:5000/dblwebhook
oh
https?:d?
so all things has been set up , now it should work
And it worked ! @true talon thanks!
regen your token
how i can stop else
already got a new API key but still getting 400 Errors
Code:
bot.on('ready', () => {
setInterval(() => {
dbl.postStats(bot.guilds.cache.size, bot.shards.id, bot.shards.total);
}, 1800000);
});
Error:
dbl.postStats(bot.guilds.cache.size, bot.shards.id, bot.shards.total);
TypeError: Cannot read property 'id' of undefined
I am using v12
bot.shards is undefined 
If you're not sharding, remove anything related to shards
It is sharded
But I used bot.shardID
Is it bot.shard.id
bot.on('ready', () => {
setInterval(() => {
dbl.postStats(bot.guilds.cache.size, bot.shard.id, bot.shard.count);
}, 1800000);
});
``` - I changed it to this let me see
english?
How does the dbl system message come?
server system notification
I would use ufw
then sudo ufw allow port you can make it more specific if you want to specify an ip
idk dbl's ip tho
or if it changes
that's what I was wondering
What data does dbl pull out from our bots exactly and why?
nothing but its status
you send it server data
and that's it
that I recall anyways
Server data?
number of servers
But it isn't required and you have to send it yourself
You can also send some shard data
but dbl doesnt "pull" anything besides status (which doesn't even work if it isn't here)
Why does it get(or why do we send) the server count?
Why is it used for
Is it used for something other than displaying how many servers the bot is in?
what else would it be used for?
it's a number
it's quite meaningless to dbl, just another data point in a database to take up space
I mean with the api other people can access it
Idk
I how take my bot api?
What?
I how find my bot api
Is there like a client.on('invite'...)?
o oki
oh sorry i thought i wa there
On the page, how long does it take to activate the counter for my bot's servers, once the code has been placed?
usually less than a minute
How strange, it doesn't activate me
then perhaps you did something wrong
this is my code;
const DBL = require("dblapi.js");
const dbl = new DBL('key api')
dbl.postStats(client.guilds.size);
and
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.cache.size, client.shards.id, client.shards.total);
}, 1800000);
});
what is missing?
dbl.postStats(client.guilds.size);
should also be inside the ready event
as it doesnt work if the client is not ready yet, and the setInterval only starts firing after the interval
also, if you're using v12, it should be client.guilds.cache.size
also in v12, its client.shard.ids[0] and client.shard.count
Hello. So I recently added this server count code to my bot. Can someone check if I can use it this way? For me it does not count the servers. Do I have to run a command or something else to show the count?
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
async def on_guild_post(self):
print("Server count posted successfully.")
async def sendStats_topgg(self, guilds, shards):
token_topgg = '**.**.**'
topgg = f'https://top.gg/api/bots/{self.bot.user.id}/stats' # https://top.gg/
headers = {'Authorization': token_topgg, 'content-type': 'application/json'}
shards_array = []
for shard_id, shard in self.bot.shards.items():
shards_array.append(self.shard_guilds(shard_id)) # [1000, 998, ...]
print(shards_array)
data = {"server_count": guilds, "shards": shards_array, "shard_count": shards}
async with aiohttp.ClientSession() as session:
response = await self.request(session, 'POST', topgg, headers=headers, json=data)
return response
async def send_stats(self):
guilds = len(self.bot.guilds)
shards = self.bot.shard_count
with suppress(Exception):
await self.sendStats_topgg(guilds, shards)
async def request(self, session, method, url, **kwargs):
async with session.request(method, url, **kwargs) as response:
print(response)
assert response.status == 200
return await response.json()
@staticmethod
def guild_shard(guild: discord.Guild):
return guild.shard_id + 1
def shard_guilds(self, shard_id: int):
count = 0
for guild in self.bot.guilds:
if guild.shard_id != shard_id:
continue
count += 1
return count
def setup(bot):
bot.add_cog(TopGG(bot))
@restive otter You can build in checks so they can't run the command but this would include a whole group
dont you need a loop/interval?
libraries like dblpy post it every 30 minutes
im not a python user but i dont see any timer that fires that code every 30 mins
Yeah, you are right. I need to check if I can build that in somehwere.
For "dblpy" it is self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)
#development please and also:
If you want people to be able to assist you, please provide more information, such as what library and language you're using, the code in question and what you are trying to do and/or what is causing the error.
Specifically the error section.
Im bored
This channel is for the Top.GG api only so for other development questions, which this is, please go to #development . Thank you! π
Hello, I'm having some trouble with updating my server count. I have copied the example with automatic server count posting.
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.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")
But my server count is never updated, what am I doing wrong?
I'm using discord.py
- add a
@commands.Cog.listener()to that on_guild_post
cuz shiv keeps forgetting to add that ree
- are you sure you're loading it as a cog?
how i can get "Authorization"?
I'm not sure I'm loading it as a cog, how do I do that?
are you using the commands.Bot() or discord.Client()
webhook doesnt working
why?
URL is not correct
yeah
0w0
you dont use discord webhooks
its normally somthing like
http://you.ip.goes.here/dblwebhook
are you using the
commands.Bot()ordiscord.Client()
I'm usingcommands.Bot()
then you can use bot.load_extension('some.path.to.file')
you will need a setup(bot) function
no response 0w0
I'm very confused with trying to display my server count on my bot and have 0 idea if im doing any of it correctly
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL(`mytoken`, client);
client.on('ready', () => {
setInterval(() => {
dbl.postStats(client.guilds.size);
}, 1800000);
});
dbl.on('posted', () => {
console.log('Server count posted!');
})
you dont need the interval if you put client in your new DBL
adding client there enables the autoposter
is this in your main bot file?
How can i enable the guild count of my bot?
the easiest way is using one of the official libraries
it is in my main file, yes
then just remove the setInterval, it should work just like that
@restive otter
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL(`token`, client);
client.on('ready', () => {
dbl.postStats(client.guilds.size);
});
dbl.on('posted', () => {
console.log('Server count posted!');
})
It still randomly isn't working, just want to double check that's correct
Im not good at APIs at all lmao
wdym randomly isnt working? what part of it is random?
you dont need to postStats at all
remove that too
Is there any problem with dbl api? Because it is not sending any message when somene upvotes
It was wroking well today but It is not working now
@barren egret I haven't received any error with my auto stats poster
Auto stats is working , but it is not sending any message to the terminal and discord channel and it was working today
I use webhooks and haven't experienced any errors today
i don't use webhook , i use bot to notify when someone upvotes . I tested it on dbl edit page too by using test button but not sending anything to discord as well as in the terminal @golden adder
Webhooks are better imo because they're obligatory once you get beyond 1,000 servers
Sooner you get used to them the better
But the test button wasn't working yesterday
For a while
It's a DBL problem. Only worked with real votes.
If you have a way to test with a real vote, do that @barren egret. If that doesn't work then it might be something else π€·ββοΈ
how to throw the voter as a message to a channel? There is 1k vote right now. :)
actually bot user mentioned me that issue and i looked into it
example text?
@golden adder what do you think about it?
Did you test with a real vote?
The test button wasn't working yesterday. The api worked with real votes though
hello
@golden adder Testing button was working for me today and I tried with real vote but not working
Hmm
Hey all β quick question cause I couldnβt find anything online or in pins β with sharding, our vote detection has stopped working. Is there any way to detect votes across all shards?
still get 400 errors any idea why?
@teal plaza are you using webhooks?
@dense shale where do you get that error? show the full error
when the bot starts i get a 400 Error
show full error
[DBL ERROR] Error: 400 Bad Request
const dbl = new DBL(process.env.API_TOKEN, { webhookPort: 5000, webhookAuth: 'NOTHING'},bot);is used for posting
console.log('[DBL Notice] Server count posted!');
})
dbl.on('error', e => {
console.log(`[DBL ERROR] ${e}`);
})
there is then the webhook stuff but this doesnt cause errors and still work
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
```
what is your dblapi.js version?
"dblapi.js": "^2.3.1", "discord.js": "^12.2.0",
thx
@vapid cape no we donβt have 1000+ votes β should we switch regardless?
webhooks are the only reliable way of receiving votes, but you need to store them yourself
ie: receive webhook -> store in database along with a timestamp -> check database and timestamp when people use commands
all other api methods are usually slow and often unreliable, according to people's complaints on here
why does this happen
(node:4302) ExperimentalWarning: The fs.promises API is experimental```
when i start my bot
Hey guys, someone know what is glitch port ?
@devout iris process.env.PORT
@devout iris
process.env.PORT
@vapid cape thank you!
-api @regal flower
@regal flower
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
Hi
const app = express();
const server = http.createServer(app);
const dbl = new DBL("token here", { webhookAuth: 'pass here', webhookServer: server})```
if i click on test it doesnt post anything
in the webhookServer do i need to put anything?
for js client.on('ready', () => { setInterval(() => { dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total); }, 1800000); });
I see they are pushing client.guilds.size, so do I run this for every shard and push them all individually? or do I push all stats through 1 shard using broadcastEval
How to get number for vote ?
Don't ask to ask.
Just ask your question, it wastes time if you say "i need help" or "can someone help me?" instead of just saying what the problem is. Save your time and other people's time and just ask the question.
Please read https://dontasktoask.com/ for an explanation on why this is an issue.
in the webhookServer do i need to put anything?
@restive otter token, pass here, server.. did you fix the variables?
@restive otter just ask
i cant understand what to put in the server's place @little robin others i have done
the url to your webserver
but idk if that method is correct
normally I set the api's webhook server in the bot page's config
Yea i did that @knotty garnet
In the config page
Do I need to make a edit in this
if you've set up in the config page all you need to do is make a webserver then
how do I get the bot to say "Thanks for voting for me" in user DM?
Go to the api documentation u will get there @silk echo
ok
how do I show the online status of the bot?
is application bot offline rn?
and does it automatically become online on its own
-wrongserver
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 :(
-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
why'd I be here if I got my answer at the docs XD
discord.js why he returns false?
its broken
stop dotposting
Can someone help me with the webhooks?
I put the webhook URL into the input and I pressed test and nothing happened
which url did you put?
Hello, i'm trying to use the endpoint https://top.gg/api/bots/{bot.id}/votes , I'm using GET method, I'm correctly passing the AUTHORIZATION header but I get {"error":"Forbidden"}
Any ideas why ?
I'm also sure that the authorization token is correct, I've verified twice
wrong channel
t!pp @signal juniper
thx bro
hi, does anyone know how i get webhookAuth?
can i put what i want then? I'm trying everything and does not notify that someone voted ..
@lapis pond the auth is what will be sent in the Authentication header in the http request
If you're not validating requests it'll be of no use for you
Have you set up an api server?
nope
is there any downside to having your bot react with 4 different reactions every 7 seconds for thousands of users? Is there a bottleneck somewhere with this situation? Unfortunately I don't think discord.js lets your bot perform 4 different reactions with just 1 request to the api...?
Wrong channel. This is for the top.gg api. However that sounds like api abuse to me.
yeah I'll go to the right channel. It's not automated though, I was talking about user-actions and how they'll scale with growth.
@limpid vector most rate limits are per server/dm channel, I'd assume that only things like changing your presence are global.
how to get existing express from dbl api.js?
look at the bottom of the documentation on the website
@spiral steeple that comment refers to things such as rainbow roles
Adding reactions to a message is fine pretty sure
-api
Hi
how i can do a command like if the user vote my bot int he last 12 hours, it can use it, if not, it send a message?
Just keep track of the time between command yourself, there's not really a way to check when the user last voted I think
javascript? @restive otter
yeah, that is it
ok
and it just returns true or false, so pretty simple
ok
@restive otter tbh i find that it is better if you just keep track of this yourself based on receiving webhook notifications because the .hasVoted(id) can take a couple minutes to update
Oh there's an actual function for that?
um
ok
@restive otter tbh i find that it is better if you just keep track of this yourself based on receiving webhook notifications because the
.hasVoted(id)can take a couple minutes to update
@trail sigil and how to that?
do you use a database?
i use mongodb
ok cool. let's move to #development
ok
Using: https://www.npmjs.com/package/botlist
const botID = '673994042450903089'
const listclient = new BotList.Client(botID, {
tokens: {
'top.gg': process.env.TOPGG_TOKEN,
'A LOT OF OTHER BOT LISTS': TOKENS
},
interval: 300000,
verbose: true
})
listclient.on('beforePost', () => {
const serverCount = client.guilds.cache.size;
console.log('Posting')
listclient.update(serverCount);
});
listclient.on('afterPost', (successful, failed) => {
console.log('Just finished posting to all bot lists, ' + successful + ' were successful, ' + failed + ' failed to post');
});
listclient.on('error', (error) => {
console.warn('Something happened', error);
});
listclient.start()
could you try test posting with a test program?
Using: https://www.npmjs.com/package/botlist
const botID = '673994042450903089' const listclient = new BotList.Client(botID, { tokens: { 'top.gg': process.env.TOPGG_TOKEN, 'A LOT OF OTHER BOT LISTS': TOKENS }, interval: 300000, verbose: true }) listclient.on('beforePost', () => { const serverCount = client.guilds.cache.size; console.log('Posting') listclient.update(serverCount); }); listclient.on('afterPost', (successful, failed) => { console.log('Just finished posting to all bot lists, ' + successful + ' were successful, ' + failed + ' failed to post'); }); listclient.on('error', (error) => { console.warn('Something happened', error); }); listclient.start()
@strong fiber but with this is to send server count to all discord bot list
and i want to if a person vote in the last 12 hours, it execute the command, if not, it dont execute the command
@restive otter What do you mean?
What???
They werenβt providing that code for you
Thats not what we are talking about
@strong fiber We only help with our npm package or a direct request to our API. Not with other unofficial npm packages
it is nothing with the package, it litterally sends the request directly to the api. It worked with the exact same token using reqbin
Still no support here if that's not the official topgg package
The best I can suggest is you to regen your topgg token
When it worked with the token i used?
Itβs the best I can suggest besides getting support from that packages support
And what if i get a 403 error when using the official npm package?
Will u then try to help me with the issue and why i am getting a 403
just ask in their support, they made that package, so they should provide you support
nonono now ima try with ur package
@strong fiber If you get a 403 using our package yes we can help you
Done
got a 403 error
const dbl = new DBL(process.env.TOPGG_TOKEN, client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})```
Error: ```Oops! Error: 403 Forbidden
Please, someone speak portuguese ? I need help.
print out the process.env.TOPGG_TOKEN in your logs and see if thats the correct one
Wouldnt it be a 401 error if it wasnt the right token
Fully incorrect
@restive otter
What's wrong?
It is the right token @restive otter
Regenerate the token and try it again
This goes back to my console:
Running at: http://0.0.0.0:5000/dblwebhook
const dbl = new DBL(
dblToken,
{ webhookPort: 5000, webhookAuth: dblPass },
client
);
dbl.webhook.on("ready", hook => {
console.log(
`π | Running at: http://${hook.hostname}:${hook.port}${hook.path}`
);
/* Ignore it => */webhook.send(`π | Running em: http://${hook.hostname}:${hook.port}${hook.path}`)
});```
And when I press the test button, it doesn't work
@gloomy fractal ^
@vapid cape ΛΛ
?
This goes back to my console:
Running at: http://0.0.0.0:5000/dblwebhookconst dbl = new DBL( dblToken, { webhookPort: 5000, webhookAuth: dblPass }, client ); dbl.webhook.on("ready", hook => { console.log( `π | Running at: http://${hook.hostname}:${hook.port}${hook.path}` ); /* Ignore it => */webhook.send(`π | Running em: http://${hook.hostname}:${hook.port}${hook.path}`) });``` And when I press the test button, it doesn't work
@devout iris
why ping me lol
that doesnt mean you can just ping me whenever you need help lol, i have other things to do
this is incorrect
top.gg webhooks are not discord webhooks
I was reading the documentation and had seen it.
Do I need to use what the console log, such as webhook?
no
webhooks is like a webserver, it depends on where its hosted
it can be the server ip address, domain name, website, etc...
in your case, glitch does it for you automatically
yourprojectname.glitch.me/dblwebhook
okay.
and glitch uses process.env.PORT
which is port 3000, but better use the process because they might change it
so webhookPort: process.env.PORT
ok
@vapid cape
It is? Because if it is, it still isn't working. :(
It continues logging 0.0.0.0 and does not log that the vote was taken.
what did you put in webhookAuth?
what did you put in webhookAuth?
@vapid cape The DBL autorization... why, is wrong ?
Does anyone know why it still doesnt work for me? https://canary.discordapp.com/channels/264445053596991498/412006692125933568/710159320607621134
403 error while using the official npm package, works when i do a direct request via reqbin with the same token
I am already doing that and it shows the right token
On error is this ``` console.log(Oops! ${e} ${process.env.TOPGG_TOKEN});
and it worked with the unofficial npm package until a couple days ago
But doesnt it throw a 401 when the auth is wrong and a 403 when something else is forbidden
whats your dblapi.js version?
2.4.0
is this in our main file?
@devout iris show your code
@vapid cape
what is dblPort?
what is dblPort?
@vapid cape 3000
@strong fiber try console.log(e) in your error event
so it shows the full stack trace
@vapid cape 3000
@devout iris its process.env.PORT. but return 3000
@devout iris you have a webserver running?
@devout iris you have a webserver running?
@vapid cape noup
then why do you have an http request?
Done, what part of it do you want me to send?
all of it
at IncomingMessage.<anonymous> (/rbd/pnpm-volume/4f8ad52e-ba22-41fd-9dd1-b43452d34f9e/node_modules/.registry.npmjs.org/dblapi.js/2.4.0/node_modules/dblapi.js/src/index.js:118:25)
at IncomingMessage.emit (events.js:201:15)
at endReadableNT (_stream_readable.js:1130:12)
at processTicksAndRejections (internal/process/task_queues.js:83:17) {
raw: 'error code: 1006',
body: 'error code: 1006',
status: 403,
headers: {
date: 'Wed, 13 May 2020 17:15:46 GMT',
'content-type': 'text/plain; charset=UTF-8',
'content-length': '16',
connection: 'close',
'cache-control': 'max-age=15',
expires: 'Wed, 13 May 2020 17:16:01 GMT',
'set-cookie': [
'__cfduid=db7bb5dc346cb1593d2a4775f0a731c601589390146; ' +
'expires=Fri, 12-Jun-20 17:15:46 GMT; path=/; ' +
'domain=.top.gg; HttpOnly; SameSite=Lax; Secure'
],
'expect-ct': 'max-age=604800, ' +
'report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
'strict-transport-security': 'max-age=15552000; includeSubDomains; preload',
'x-content-type-options': 'nosniff',
server: 'cloudflare',
'cf-ray': '592e05fd7c87ea8a-IAD',
'cf-request-id': '02b0a2126a0000ea8a6d3f5200000001'
},
ok: false,
statusText: 'Forbidden'
}```
its hosted on glitch with paid plan btw
if that is any help
then why do you have an http request?
@vapid cape ok, i removed
r i p

So who should i contact
@strong fiber Just get a new IP
tonkk probably
@devout iris test using reqbin
if you dont know how to test, send me your glitch project name and i can test for you
can i talk to u in private ?
Am I allowed to test my DBL implementation on my dev bot (with inaccurate server count data) before pushing it to prod?
no.
true
sure
nevermind my sharding framework implodes when I try to run 2 shards apparently
I have a question. My api says it is in 11 servers, but I know that it is in more. Did I something wrong? Or is that normal, that it is not in synch?
it should refresh every so often
if you're using one of the official libraries, it should post every 30 minutes by default
I see, hmm, it didnt change. Does it matter where I have put the code? Atm it is in my main js. Or should I rather put it in my backend, where I set up my express server
you should put it in your bot's main file
ok, thanks
has anyone written typings for the bot object here https://top.gg/api/docs#bots
- how do you fetch the total guild count from this endpoint, it doesnt look like you can but i have seen bots display total guild count
really weird that it doesnt have a server count property lmao
this means nothing to me
lol
lol u have to query /stats for this info
why??
pointless
im not making 2 rest calls to fetch the info of a single bot
Β―_(γ)_/Β―
perhaps the server count is managed by a different process, and thus requires a separate endpoint
and they didnt bother to link it internally
making 2 rest calls for a single command is something i dont want to do