#topgg-api
1 messages · Page 68 of 1
You would do something like
dbl.webhook.on('vote', vote => {
webhookname.send(`User with ID ${vote.user} just voted!`);
});
Sorry took me so long to type it.
but you dont get what i mean i want to use this
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});
and i want this to work but webhook is not define
That is what the const is for
if you say webhook rn, it has no idea what webhook to send to.
webhook is not even recognized.
Welp; I dunno then
oh
const webhookname = new Discord.WebhookClient('webhookID', 'webhookToken'); dbl.webhook.on('vote', vote => { webhookname.send(`User with ID ${vote.user} just voted!`); }); if I put thin in my main bot file so if someone vote the bot then it will send messages in the server
!bal
Hello
Hi, I don't want this to be undefined. http://prntscr.com/puvjty
post your stats - read docs
i need help on #development
doesnt have anything to do with this channel, read the topic
can someone tell me how to get this code to work
dbl.webhook.on('vote', vote => {
clinet.channels.get(`623592233861513256`).send(`<@${vote.user}> ${vote.user} just voted on ModBot!`);
});
@rotund dune you spelt client wrong
oh
where do you get the url
where i get the webhookID and webhookTOKEN
@rose elk Closer attention to webhook_x args in DBLClient
Only webhook_port is required for the webhook to run but customized auth is strongly encouraged
You got it right
The npm module is posting server count of the current and not total server count like it used to
Have a bot on top.gg first
then it's in https://top.gg/api/docs#mybots
uhmmm, does it have to already be approved?
Yes
Is the vote webhook link good: http://<ip>:<port>/dblwebhook ?
Because I can not run the webhook for votes.
wrong channel
it is the right one lol
The message was deleted
what
The original message isn't there anymore
what are you on about
I'm replying to your initial message stating that "this is the right channel"
The npm module is posting server count of the current shard and not total server count like it used to*
Hi. I want to make Webhook in my discord server but how i can get Authorization code? (sorry for my english but I'm from Poland 😛 )
You set it yourself
is it possible to use ROBLOX web api in bots
yes
oh cool
and take this to #development
follow in
ik
Then why tf did you ask
How to make vote webhook with IFTTT?
i dont think there is support for ifttt/dbl
Ok
Can you write an API call to dynamically update your server's "Photo" to include the active number of voice users
#development for that stuff, api for dbl is in this channel @vivid dagger
ah woops
i do that sometimes too
Read the docs
Thanks, I guess I’d just use len() but that might become a problem in the future if my bot becomes popular
I want to make discord notifications when someone voted for a bot, but I don't know how to do it :/
(Is there any tutorial for this?
)
the docs i guess
speaking of votes:
i sent an email, but haven't gotten a response in 4 days.
i wanted to add voting rewards to my bot, so i figured i'd start with the example on the api page. i copied and pasted exactly what it said on the website (save the example token slot) but it still won't work
(d.js btw)
showing your code would be helpful

Im having trouble trying to install the dblapi.js npm module, could someone help?
when i try to do npm install dblapi.js it deletes a ton of other modules
nvm, i think i got it working

@uneven hawk you were probably using a different PM
ie yarn
I've had that issue before as well
How to connect discord webhook with bot on top.gg?
I want information about when someone votes for a bot
Is the retry-after header (for rate limiting) done in seconds or milliseconds?
Yes, but it's not specific enough. 
DBL expecting devs to be competent
An dusually everything internet runs on milliseconds
One way to figure out :p
Not that way 
It is in milliseconds
What the DBL API returns in retry-after field on 429
Right
I'm just sending the raw request with no library atm
You could just get the field and wait exactly that amount of time
Yes, I'm allowing requests until this.isRatelimited is true. Then using setTimeout to eventually set it as false. If it ends up being milliseconds and I don't convert it, it'll be sending a useless request.
It's not even super important I catch it as I'll probably never hit it, but it's to just be safe
Looks like it's float containing minutes and seconds
const DBL = require("dblapi.js");
const dbl = new DBL(process.env.DBL_KEY, {
webhookPort: 5000,webhookAuth: process.env.DBL_WEBHOOK_AUTH}, bot);
dbl.on('posted', () => {
//bot.channels.get(botlogchannel).send('Server count posted!');
})
dbl.on('error', e => {
bot.channels.get(boterrorchannel).send(`Oops! dbl error: ${e}`);
})
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
if (vote.type == "test") {
console.log("Test successful!")
} else {
if (vote.type == "upvote") {
bot.channels.get(botdblvotechannel).send(`${vote.user} just upvoted <@${vote.bot}>!`)
}
}
});```
I want to put this in my utils folder
but then, I am not sure how to connect anything here....
I am using a localhost:27017 ( mongoose )
floating minutes and seconds, example? 
huh
I am completely new to this
my goal is to make a vote command and a command that lists up the votes
but I am not sure how to start off. D;
ah, thanks for the help
I am completely new to this
my goal is to make a vote command and a command that lists up the votes
but I am not sure how to start off. D;
what do I require
start off
;-;
should I use the first example webhook ( small one ) or the newer one ( node ) ? in pins?
The first one
The latest pinned message is for times when you want to manually handle the webhook setup
Regarding what I asked yesterday:
https://discordapp.com/channels/264445053596991498/412006692125933568/644325451543609365
const DBL = require('dblapi.js');
const dbl = new DBL('my token here', { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('vote', vote => {
console.log(\`User with ID ${vote.user} just voted!`);
});
it's literally what it said on the docs
yes i have the api installed
there are no error messages
(ping me if you respond please)
@dusty roost host this in a vps or open the port 5000 in your box
😊
And modify your bot page
Url webhook: your_ip:5000
And je other case = password
thanks! how do i do that? (sorry for asking so many questions)
it seems like an easy enough solution, so yes
what do you mean?
my what
Wait
You wouldn't need to open up a port it should work
In linux yeah
oh a mod how lucky
"lucky"
Anyway Danny do you get any sort of output when you receive a vote?
Oh oops
Looked at the wrong name
Anyway do you get any sort of output when you receive a vote? @dusty roost
@dusty roost
dbl.webhook.on('ready', hook => { console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`); });```
I think you forgot this @dusty roost
o
I mean it's a means of seeing if the thing is actually listening to any requests on port 5000
If that doesn't do anything then the webhook isn't working
Also what are you using to host the bot @dusty roost
glitch
Wait
i feel like that's a common enough answer
I think the fact that when you send a request to glitch it needs to "wake" the application
The vote might just be timing out before it can even wake the application
the app is 24/7
Yes with uptime robot
^
And again glitch is a bit weird with things at times
If he's legit copying the code it should work
Yes
If it's not working it's either he messed up the code or glitch just doesn't work with webhook votes
Then it's his code
Yes
Either way I can't help much more
where do i get the webhookurl from @restive otter ?
Go to settings of the vote channel
And create a webhook
Copy the url
@dusty roost
Well, I'm switching to my phone.
no response from the test
Np
What is authorization on webhook?
A text that will be sent in request headers for you to verify that the request comes from DBL
Example?
You set it to anything
You could set it to I love cookies LOL and then see if Authorization field value is exactly that
What is the link to "Post Bot's Stats"?
Cyber28 Yes i know but what is this link supposed to be? https://top.gg/api/bots/639917890669117450/stats?server_count ?
Like that?
How to api request the votes?
And if a player has voted for today
So i can do votes with rewards
Ty
I just voted for my bot to test the api but it still shows it as False?
dblVote = await dblclient.get_user_vote(author.id)
print(dblVote) # False
possibility that it may just be delayed in updating the fact that you voted, or maybe that's probs why its best to use the api that @kind harness mentioned as i believe its more accurate (unless there is a limit to using it then maybe not a good idea)
how would I manage the response from https://top.gg/api/bots/464601463440801792/check?userId=
its a json response so just parse that
or seeings there is no other numbers in there just have it check if the response contains a 0 or 1
dblVote = await requests.get(dblVoteEndpoint + author.id)["voted"] TypeError: 'Response' object is not subscriptable
ur coding in python yh
yh? and yes
dont think you would have to use await to execute a get request right?
also after sending the get request you can just do:
if '0' in dblVote:
// user hasnt voted
welcome
actually
What kinda difference does using another library make
I'm getting a 401 error
rip
response = requests.get(dblVoteEndpoint + author.id) # https://top.gg/api/bots/464601463440801792/check?userId=115269304705875969```
Are you using requests in your discord.py code
yeah
Have you ever heard about blocking
Well, I've heard about it
What made you think switching to another library would fix something that is an issue on the API's side
10/10
It's best to use webhooks to work with upvotes in real-time instead of sending requests all the time and most likely getting ratelimited
whats my problem tho? @sullen nymph
https://discordapp.com/channels/264445053596991498/412006692125933568/645473755191050240 in here, you are getting False because the API doesn't process the upvotes that fast
how fast is it?
so i should use a webhook instead of doing this
Yes
There's no set time when the vote will be processed
It can take up to 5 or more minutes from what I've heard
dblpy provides one
huuh
All you have to do is specify webhook_port and preferably webhook_auth in DBLClient kwargs
rtfd for more information™️
is it possible to explain how i work this whole webhook thing and how i could use it for this
if not its ok
Have a webserver run somewhere, get its public IP, make sure you use an open port, put it all in an URL like http://ip:port/. You probably also want to use a separate endpoint for DBL (something like /dblwebhook)
@latent ocean aye fam, should be good
hmmmmmm
oh btw do you know how long it usually takes to update the amount of servers my bot is in after executing this
I believe close to instant, lemme see
Yep
https://top.gg/api/bots/614436954368376904/stats doesnt look like it to me
yup

shouldnt it goes {shard_count: 1, server_count: 1} in the updateStats?
for the webhook url, can I send it directly to a /folder/file.php?
@sullen nymph
Ehh
If your webhook will be ok with that and will process everything properly... sure?
You'll need to have DBL send the request to an endpoint
On a request to that endpoint, if you have Authorization field set, headers.get('Authorization') and make sure it's DBL, then proceed to do whatever you want with the data
is there anything else in the header?
no just the token you set
A bot (fdci-bot#1462) just dm'd me a server invite. Can a mod kick it please?
ss pls
Already been deleted
But why this channel out of all
Don't know the correct place to put it
How can i check if a user voted for the bot or not using node js
using node js
i no have description pls helpp
what pls dm me
How would I get the data from the webhook in php?
anyone to help me with aihttp
Look if i wanna to get votes in discord.py
await aioclient.get(url, headers=headers)
Is that the one?
I have javascript client.on('ready', () => { setInterval(function() { dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total); }, 1800000); }); and I get the error [dblapi.js autopost] Failed to post stats: undefined. What am I doing wrong here?
client.shards.totalShards
message.channel.send('hello everyone!
');
-api @restive otter
@restive otter
THIS CHANNEL IS ONLY FOR SUGGESTIONS/HELP/BUGS TO DO WITH OFFICIAL API LIBRARIES AND API DOCS FOUND AT
https://top.gg/api/docs
How would I get the data passed in the webhook in php?
how bot broke
-api @vital stirrup @desert tinsel
@vital stirrup @desert tinsel
THIS CHANNEL IS ONLY FOR SUGGESTIONS/HELP/BUGS TO DO WITH OFFICIAL API LIBRARIES AND API DOCS FOUND AT
https://top.gg/api/docs
Anything related to development but not the top.gg API, move to #development and ask your questions there
<@&264889767072628742> <@&304313580025544704> MY server wont show up under ym profile after i have added the discord server list bot
-atmods
Please do not mention (ping) more than one or two moderators for help, unless there is an emergency.
Here are some examples of emergencies:
- Raids / Multiple members mass spamming.
- Severe disruption of Discord's ToS (NSFW content, etc)
- Anything that requires more than 2 moderators to handle.
-atmods @amber prism
@amber prism
Please do not mention (ping) more than one or two moderators for help, unless there is an emergency.
Here are some examples of emergencies:
- Raids / Multiple members mass spamming.
- Severe disruption of Discord's ToS (NSFW content, etc)
- Anything that requires more than 2 moderators to handle.
my bad
sigh
Also going for both roles
sorry guys
-atmods @amber prism
@amber prism
Please do not mention (ping) more than one or two moderators for help, unless there is an emergency.
Here are some examples of emergencies:
- Raids / Multiple members mass spamming.
- Severe disruption of Discord's ToS (NSFW content, etc)
- Anything that requires more than 2 moderators to handle.
@near sparrow for good measure
lmao
wait twist resigned?
anyways i'm gonna go to bed
and haha 😛
same
nOt the ChaNnEl gUys

Honestly as a punishment tag me for every @ mod 🤣
@amber prism Your bot will be only displayed once it's approved.
ok
Bots added to the site are ordered by a queue based on the time they submitted their bot. Website Moderators check bots according to the queue and cannot check your bot just because you requested it. In addition, queue length is confidential and we cannot tell you your position in queue, either.
As the FAQ: How long is Approval? states, your bot may take up to a week or more until it is checked. There is no set time how long bot approval will take; there is a queue and you're not the first nor are you the last.
Please be patient.
@left egret discord server list
How i made a clear command 😅

what do you mean @restive otter
I want to code an clear command
to clear what 
ah

what language do you use
yes
-checkmybot
Only mods can use these commands
-bot
-checkmybot
Only mods can use these commands xz
X2*
And please #commands or #265156322012561408 for use commands
hey
people
dbl.webheek.on is causing error
the .on cause error
`dbl.webhook.on('vote', vote => {
^
TypeError: Cannot read property 'on' of undefined`
Make sure to supply valid webhook options so that it’ll generate the webhook property
hi i can't use the invitation link of my bot, can you help me
I don’t believe this is API related. Correct me if I’m wrong.
If you’re talking about like adding a new bot ask in #general
Will any of you read this channel's topic
no
its gotten to the point where I don't even care what channels people use as long as they arent breaking any rules
tell em to bring me my money
Why when i use my bot it the clien.run() returs future.resume() and an error
Dm me for help
as THIS server notifs are broken
-bots
I swear to fucking God
Merge #development with #topgg-api
please
i do
How to resquest votes in python using aiohttp
Cause the docs doesnt speak about that
Now i understand why noone ask questions about API
You can make just an http request to the api
Explain more than just “exceptions”
What’re you putting as the url
The request
That’s not-
What is the actual url
Ehh
/api
/[botid]/check?[userid]
I forgot url but i made it correct
cause if i didnt it will raise uncorrect url
or error 404
Uh
Ok well look at the docs
Under the Resources section is where you’ll find things regarding http requests
.
Ah yes .
Docs has only return types
🙂
👍
ye

hit it?
I have one question about API: When I check bot vote page, there is 12h cooldown, but in:
Individual User Id Voting Check for the past 24 hours.
Is this 24h? How to get information about last 12h?
ok, thanks
It's been like that for a year btw
> knows issue
> doesn't fix
> now the mods need to answer redundant questions
{ webhookPort: 5000, webhookAuth: 'password' }); what does this mean by password,? What password?
You have To choose a strong password
Yea i already did it all
And edit your bot page
On Authorization i put the same password, right?
Bruh
Idk
Yup
Hey can any body tell me how to start a Html
Someone know a NSFW API who works good ? (Tag me if you know)
@limpid heath DiscordBotList(top.gg) doesn't support this, sorry i can't help you
And this channel le only for top.gg api
@noble lagoon #development
can anybody tell me how to set my server count, please define in detail
Which library
Other
Your actual library that you use for your bot
DBM
because I'm friends with tons of bot creators who have their bots on top.gg / made on dbm
yes
you can figure out how to integrate our library with dbm
but we cant help you here
Hey i dont understand this whit the webhook to vote. Where i become the url. Its not the Channel webhook
@restive otter your bot is in verification, you can't get this for now
@oak shuttle wrong channel.
also you need to have an approved bot
4
Hey guys
I;m using python and I keep getting error "Module 'dbl' has no attribute 'Client'
any ideas?
dbl.DBLClient
Thanks so much! @sullen nymph
why isn't it like that on the official website?
documentation for the libs haven't been updated in a year or so 
For dblpy I suggest you refer to the official dblpy docs on https://dblpy.readthedocs.io/en/latest/api.html
is the server count accurate?
Usually DBL libraries depend on <Client>.guilds so unless your caching system is drunk, it should be ok
oh, then how do i undrunk my caching system, idk if i have one
u can't
its says 43 servers, but i doubt its that many
it depends on the library
yea
i havent really touched client.guilds
i just copy pasted the provided cog with minor changes to it
the bot in question does not do many poweruser commands to have me include client.guilds
Try fetching your guilds with https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.fetch_guilds and if that still returns 43, that should be your actual server count
so this will update on its own if its put in activity or in every bot launch is set as a list and thats it
will i have to make a loop for this ? or is it on its own?
Your client.guilds should be okay, so just use the example code
yeah but if i want to pass it to activity, should i make a second loop?
var dbl = new DBL("my token",{ webhookPort: 5000, webhookAuth: "my password" });
/* DBL */
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!`);
});
it logs (http://0.0.0.0:5000/dblwebhook) but when i try to test it it wont give me anything
how do i make this work?
i honestly dont know

oh well rip me 
hmmm
Simple af
as if thats the only way
A suggestion 😉 I mean if you like you could use any language whatever suits or even librarys like kola I think feathers
And some others
my only guess is that the auths dont match
are you trying to test this locally? if so, you need to have a port forwarded iirc
does having symoles like ? + or = effect it
i test it on my server
with the port open
it shouldnt
it shouldn't?
do i close the port?
ah nvm im stupid
hmm what can it be then
will none us letters matter?
like Ø
Im confused as to how to set up the webhook for votes
What are you confused about, the lib does all of it for you
I know it's not allowed to send server count to DBL if it's fake. What if I'm testing it? Is it allowed to display a lower number?
If you test it with a low number and then you start using the real server number and it's a lot, moderators might think the real number is fake
-api @elder lantern @tiny glade @spark dawn @obtuse owl @late crater @wheat geode
@wheat geode @elder lantern @tiny glade @spark dawn @late crater @obtuse owl
THIS CHANNEL IS ONLY FOR SUGGESTIONS/HELP/BUGS TO DO WITH OFFICIAL API LIBRARIES AND API DOCS FOUND AT
https://top.gg/api/docs
Reset token
ineed help
ask away
When trying to post server count I get this:
Error: Forbidden (status code: 403)
I resetted dbl token and it still does not work
Using: discord.py
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en-US"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en-US"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]-->
<head>
<title>Attention Required! | Cloudflare</title>```
this is the first few lines of the response so it might have to do something with cloudflare blocking bot traffic or something, idk.
what does it say under the title
it seems to work now, and I no longer have access to the response.
Why is the api not working
async postStats(serverCount, shardId, shardCount) {
^^^^^^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/storage/emulated/0/bot/zeusbot/node_modules/dblapi.js/index.js👍80)
2019-11-29 21:50:27 : pid 13651 exited
with code : 1 / signal : 0
you want to await postStats
async is for creating an async function, await is for using an async function
?
wait nvm it seems you are making an async function?
ooh it's from the module I see
what is your node version
you need to update your node
. _.
How idk how i install specific node version
how did you install your current node version
I use totime an android app d/node.js
I can install termux
Its an terminal emulator
you're coding on android?
but it seems whatever you are using has a really outdated node so you should look at something else
Np i install termux
There i can install every node version
How i install specific node version?
just install the latest
how do i post how many servers my bot is in while sharding? when i do postStats(180) it literally posts 180 servers as the count instead of automatically updating
maybe because you're posting as 180
.postStats(serverCount, [shardId], [shardCount])
hmm thats weird. someone told me a while back i could do postStats(180) and it would give the accurate server count, and it did for the longest time until i began sharding lol
thanks tho!
Not sure why they said that 
Lmao I still can’t get it to work right so my server count says 1k as of now
I have no idea how postStats(180) ever gave you accurate stats, but what library are you using?
Why this wont work? js const dbl = require('dblapi.js'); dbl.getVotes().then(votes => { if (votes.find(vote => vote.id == message.author.id)) message.channel.send('You have been voten!'); else message.channel.send('What? You have not voted me today, pleas evote here: https://top.gg/bot/.'); });error: TypeError: dbl.getVotes is not a function
it is
on the dbl source the function is this js async getVotes() { const response = await this._request('get', 'bots/votes', undefined, true); return response.body; }
yes? and on that function its async getVotes (btw its js not py)
im looking at the docs for js and your right, for me it looks like a lower case :/
k
someone?????
Have you looked at the dblapi.js example
didnt notice it, thanks!
tonkku im using djs
@craggy grove stable or master
stable
`const DBL = require("dblapi.js");
const dbl = new DBL(DBL_TOKEN, { webhookPort: myPort, webhookAuth: myWebhookAuth }, bot);
dbl.postStats(180);`
you've included your bot in the new DBL part so the library automatically posts stats
so whats been happening is that whenever you start you bot the server count is set to 180, but after some time the library has posted the correct stats for you
ahh ok
makes sense
im doing the same thing now where i include my bot, but it doesnt automatically post stats. do i have to do something different because im sharding?
im not doing poststats 180 lol
are there any errors
no errors are being thrown, ill post my code in a sec
actually is this against the rules
to post my link
to my bot's page
just want to show how the server count only displays the count of a single shard
you're not doing it to advertise so its fine
it is in 2k+ servers, ill post code in a sec
_ _
`const bot = new DiscordJS.Client({
token: TOKEN,
autorun: true
});
const manager = new DiscordJS.ShardingManager('./dio.js', { token: TOKEN });
manager.spawn(2, 0).then(complete => {
const DBL = require("dblapi.js");
const dbl = new DBL(DBL_TOKEN, { webhookPort: myPort, webhookAuth: myWebhookAuth }, bot);`
do i need to do bot.login() for it to automatically post stats?
so you're creating that client there just for dblapi.js?
yes, should i be doing something else?
you should supply the client of the actual shards
or you can remove it and calculate the stats manually and use postStats
yea i was originally calculating it manually with a bcEval and grabbed server count, except the code in the .then(complete => { }) runs after one shard as spawned
which makes me wonder if there is a way to detect when all shards have spawned, like an event or smomething
I believe the bot you have in there right now is just not doing anything because it never starts
unless d.js starts up the first shard which will then get posted
top.gg will add the Server Count togheter for you when you post with shardId
this is also how you get
I need a dbl_apikey
@sudden depot can I just send 999999999 instead of my guild count
@restive otter that's faking server count and can cause your bot to be deleted
So that's a no
just say what you need help with
I am a bit confused about the webhook.
As I've never used webhooks in the past, I don't know what I am supposed to use in order to set up the webhook.
So, what am I supposed to get? And where am I supposed to get it?
There's libraries that help you with creating a webhook
I've just been reading those. I didn't get it. It said "password" though, I don't know what it means by that.
A webhook is just a server running in background waiting for requests
Password? You mean the auth/authorization part?
Pretty much, yeah.
On DBL you choose the password
Where? I searched all around the site, I couldn't find it.
Are you using any DBL library?
Did you see the webhookAuth thing in DBL constructor
If you mean this, then yes.
Yeah, that's the thing you get to choose for yourself. It just has to match the text on your bot's Edit page (Webhook section at the very bottom)
Oh... I actually didn't scroll that far somehow. My scroll wheel stopped at submit and preview. I have no idea why, though it made me think there was nothing there. And then after you said it, and I went to check, it finally worked for some reason. I don't know what's wrong with my mouse, but uh, thank you for the help.
you're welcome
How can I test the webhook for votes, without voting for the bot?
why not vote for the bot to test it?
vote for your own bot, and take the vote away and then retest as needed
iirc theres no test system
Wait, I can take away votes from my bot?
yes i think so?
or am i getting confuzzled.
wait, no you cant.
but you can do this:
put code in your bot to capture the entire POST and dump it to a file
vote once, capture the vote
then replay that POST with a simple script
you can replay that post using curl or such
Well, that sounds a bit too much of work for what I am trying to do. I am pretty sure it should work, though I have 3 different outputs on the votes. One for each scenario where the bot finds the user. And I would like to get all of them tested without cheating(in a way) the vote system.
im sure its acceptable to register discord users for such purposes
i mean without a proper test system, how else can you do it 😛
It's going to send a thanks message in development server, where if the user is in the server, it will mention them, if not in the server, it will show the tag, and then when the user is not in any server with the bot, it will send the ID.
Ok so, another thing.
I just got this error popping up, saying I was rate limited
(node:2496) UnhandledPromiseRejectionWarning: Error: 429 Too Many Requests
at IncomingMessage.res.on (/rbd/pnpm-volume/5e67cf9e-ab38-4576-ac99-0726c5933577/node_modules/.registry.npmjs.org/dblapi.js/2.3.0/node_modules/dblapi.js/src/index.js:118:25)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:139:11)
at process._tickCallback (internal/process/next_tick.js:181:9)
(node:2496) 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(). (rejection id: 32)
Could that be because I have this inside inside of a message event?
dbl.isWeekend().then(weekend => {
if (dbl.hasVoted(message.author.id) && !weekend) giveXP = giveXP * 1.15;
else if (dbl.hasVoted(message.author.id) && weekend) giveXP = giveXP * 1.30;
});
possibly
but also
dbl.hasVoted also returns a promise and you're not waiting for it to resolve
so everyone is going to get the xp
Oh,
Ok so, my first attempt to set up the voting messages failed. It didn't even give an error.
Though, I do get this log Webhook running! http://0.0.0.0:5000/dblwebhook from
const DBL = require('dblapi.js');
const dbl = new DBL(process.env.TOPGGAPI, { webhookPort: 5000, webhookAuth: process.env.VOTEAUTH }, client);
dbl.webhook.on('ready', hook => {
console.log(`Webhook running! http://${hook.hostname}:${hook.port}${hook.path}`);
});
As I've said earlier, I haven't worked with webhooks before, so I don't exactly know what to do.
The hook hostname needs to be the address of your bot
I can't give you more info, I also never worked with it
Uh, I am unsure of how to make it that, and I am unsure if that means, the host or some other server.
Any idea how I can get that from Glitch?
Or actually, I think I have an idea
Uh, nevermind, they're not showing me the IP in the logs.
uhh I don't really remember how it goes but iirc it was projectname.glitch.me/.com
You can just send a test request
But like, I need to test to vote for a account that is in the development server.
Well nothing prevents you from voting with multiple accounts
Well, I am wondering if it's allowed, and stuff.
I just think it's more convenient to fake a vote through testing instead of voting every 12 hours with different accounts
meh I haven't seen punishment being handed out for that
Alright.
Neither is it honestly stated anywhere
I changed the url to the project url, still just 0.0.0.0
Edit the actual URL
The console.log part will always output 0.0.0.0
see it as a placeholder
Oh, so then, do I put that in as a option?
The zeros should be replaced with your actual IP/Glitch domain I sent earlier
and with that you get your actual server URL you'll need
Wait, I am confused, how do I replace the zeros again? Like, in the code.
You don't replace them in youd code
You replace them when entering the webhook URL on top.gg
Uh, I did put in the project there.
Save and try it
Oh wait, I just realized I forgot keepalive... Let's see if it works now I guess.
Nope, still zeros
Is yoour webhookPath set to 'keepalive'
No, it's set to dblapi
wait no
dblwebhook
Great, now I just got the rate limit again.
I have this to give people a little boost for 24 hours when they've voted
let voted = dbl.hasVoted(AuthorID);
let Voted = Promise.resolve(voted)
if (Voted) {
dbl.isWeekend().then(weekend => {
if (!weekend) giveXP = Math.round(giveXP * 1.15);
else if (weekend) giveXP = Math.round(giveXP * 1.30);
});
It's inside a message event.
Uhhhhhhhh
That'd explain it
You sent too many requests because you send a request per message your bot gets
Yeah, but like, it's for the leveling system, so that way, if they've voted, they get slightly boosted xp for 24 hours.
Well uh, how can I make it still work, but not get rate limited?
I honestly suggest you remove that for now
Alright, I've commented it.
cant u just store if a user has voted and let it tick along like that
without having to ping the system every single time a message gets sent
The overall system would go like this:
User votes -> Their ID is saved in database for 12 hours (or store timestamps as well to compare against later) -> on bot startup, fetch database, add users to cache -> when their vote is expired, remove them from cache
Uh, perhaps what I could do, is to store the time it expire, and if it was during a weekend or not, and their id, and then I use check their id up to the database?
Wouldn't be too hard, would just need the vote event to work, and it should go smoothly.
Glitch only allows port 3000 btw
Oh
Error
Webhook running! http://0.0.0.0:3000/dblwebhook
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::3000
at Server.setupListenHandle [as _listen2] (net.js:1360:14)
at listenInCluster (net.js:1401:12)
at Server.listen (net.js:1485:7)
at Function.listen (/rbd/pnpm-volume/5e67cf9e-ab38-4576-ac99-0726c5933577/node_modules/.registry.npmjs.org/express/4.17.1/node_modules/express/lib/application.js:618:24)
at exports (/rbd/pnpm-volume/5e67cf9e-ab38-4576-ac99-0726c5933577/node_modules/.registry.npmjs.org/node-keepalive/0.0.1/node_modules/node-keepalive/main.js:20:26)
at Object.<anonymous> (/app/main.js:7:1)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
Oh look something is using the port already
egh
what happens when you use glitch 🤷♂️
Once I changed it to 3000, I got that, and then I put it back to 5000, and the errors went away.
Webhooks are just so confusing to me.
I don't think Glitch has any port other than 3000 open
So really only viable option I see here is free your port 3000

But then, what am I gonna do with uptimerobot and the uptime?
get a vps = problem soved
That's a problem I never had and don't know s solution to
Does uptimerobot require an open port that desperately
i mean u could do a rather complicated requests handler to redirect multiple requests on the same port
Uhm, apparently, uptimerobot is down right now.

Uhm
Neither of them are working.
Ok so, I've fixed so that it doesn't give errors on port 3000, but the uptimerobot is messed up, and they are still just zeros
Which part of your code outputs zeros
dbl.webhook.on('ready', hook => {
console.log(`Webhook running! http://${hook.hostname}:${hook.port}${hook.path}`);
});
Webhook running! http://0.0.0.0:3000/dblwebhook
It'll always be like that
And now the errors are back
Oh wait nevermind
Old logs
Ok, finally the vote event works.
But now I have that issue with uptimerobot
I'm not familiar with it so I can't really help
It just pings a http to prevent it from going offline.
Yo
Docs need to be updated
Or website
Website python example still says dbl.Client and docs say dbl.DBLclient
Refer to dblpy.rtfd.io
The docs have been out of date for over a year now, and it's known you'd think they'd fucking updated it so this doesn't happen
3 characters too.
(And timings of votes)
@commands.Cog.listener()
async def on_dbl_vote(self, data):
print("PERSON VOTED PERSON VOTED PERSON VOTED ==============")
userID = data["user"]
global inventories
if str(userID) not in inventories:
inventories[str(userID)] = 0
inventories[str(userID)] = inventories[str(userID)] + 32
"""channel = self.bot.get_channel(642446655022432267)
channel.send("UPDOOT RECIEVED!!!!!")"""
user = self.bot.get_user(userID)
if user.dm_channel == None:
await user.create_dm()
await user.dm_channel.send(embed=discord.Embed(color=discord.Color.green(), description=choice(["You have been awarded 32 emeralds for voting for Villager Bot!"]))
So my bot isn’t detecting votes on dblpy
I have tried: resetting api key, restarting bot, restarting bot host (an rpi).
Sorry for weird indentation, it messed up when I copied it via vnc
If I knew python
F
I could probably figure it out by messing around with it like I usually do but I can because one can only vote every 12 hrs and I’m pretty sure making alts to vote, regardless of purpose, is against the tos
Use test
You can send test votes
It's in your edit when you set the webhook info
Heyo, webhook auth's aren't being send with the webhook.
What
Speak to me in idiot
Do I have to specify the webhook info when I make a new dblpy client?
What?
Were you talking to me?
What is API?
lol
...
application programming interface
np
@late crater I don't really use the dblpy lib for that.
@arctic arch when trying to add a authorization to the webhook it doesn't add the auth in the json POST. 😦
It should.
Whait?
The post info is just the user stuff

ty Steven
Ye
How does one send a test vote?
I looked through the docs (maybe I am blind) but there was no function to send a test vote, I also looked in the dev portal and on top.gg/api/docs
I'm using webhooks, I don't think you can send a test vote any other way.
K thanks
Unless they changed it
Whats the max char count for the auth?
idk
Alright, so I think I have webhooks set up properly, but I’m still not getting anything
I set the port to 5000, and port forwarded it
And I typed in my ip (not 192.168.1.x, I’m not that dumb) along with the correct path and port
Like http://69.69.69.69/dblwebhook:5000
Pretty sure I’m messing up the url
But idk the correct way
ip:port/dblwebhook
hey im getting a server count of 128 from the api but the fetch_guilds() gives me 100, is my cache broken?
i tried inv it into a server but only the api refreshes properly
Hey
When I use the package, it doesn't do a fetchClientValues() so the server count sent is the one of the current shard
how can I do it?
what
here are the stats displayed on top.gg
My shard #3 has 129 servers
but it doesn't post the global server count
I use dblapi.js
Nvm, found.
hey guys, what do i put here to use webhooks?
If you're using discord.py, put your global ip in along with the specified path and port
well i'm using d.js
ok
probably should have mentioned it but i didn't know it was relavant
You can read some about it here https://top.gg/api/docs#jslib
https://github.com/DiscordBotList/dblapi.js this will also be helpful!
An official module for interacting with the discordbots.org API - DiscordBotList/dblapi.js
Are you using Glitch
The link will be http://projectname.glitch.me/<webhookPath>
projectname being your Glitch project's name and <webhookPath, well...
well...?
Reading the docs will tell ye what your webhookPath will be :^)
/dblwebhook?
By default, yup
alright cool
thanks a lot
much appreciated 👍
now to see if it will actually work
how do i utilise the "test" feature?
oh nevermind
thanks shivaco for the help
also glitcj only has 1 port
Can i join our group pleaseeee 😦
@dense compass ^^

@plucky hedge I'm not entirely sure what you mean but if you're asking for people to join some kind of group this isn't the place for it. Please take a look at #rules-and-info. (Also non api related talk goes in #memes-and-media or #general )
Hello
pls beg
@craggy sentinel ^
Is there much need to ping mods for that
no ^
@willow spindle There is no "group" and stop pinging mods, please
they werent talking about that
Hey im getting this error, can someone explain to me what happened?```bash
RuntimeWarning: coroutine 'DBLClient.post_guild_count' was never awaited
status = discord.Activity(type=discord.ActivityType.watching, name=f'for &help | Rolling for {dblpy.post_guild_count()} servers')
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f891821d790>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x7f891b7b1600>, 13772.246144971)]']
connector: <aiohttp.connector.TCPConnector object at 0x7f891821d990>```
@tasks.loop(seconds=1800)
async def change_presence():
dbtoken = 'token' # set this to your DBL token
dblpy = dbl.DBLClient(client, dbtoken)
await dblpy.post_guild_count()
status = discord.Activity(type=discord.ActivityType.watching, name=f'for &help | Rolling for {dblpy.post_guild_count()} servers')
await client.change_presence(activity=status)```
this is the code
Read the error!
okay first of all
since change_presence runs on a loop, dont redeclare dbtoken and dblpy
second
you dont await it when youre setting the status, and you shouldnt either
as in
dont post your server count after you posted it and yeet its response into the status
instead fetch how many servers your bot is in
and put that in the status
get_guilds gives me a out of date number
thats why im trying to use dbl
get_guilds is stuck at 100 for some reason
and i have confirmed that is does not work properly, i asked the discord.py discord server , they told me "meh idk"
so yeah, is it not possible like so?
or im stuck with get_guilds?
len(<Client>.guilds) maybe?
That’s what I do







