#topgg-api

1 messages · Page 60 of 1

sudden rampart
#

that's your DNS/internet

worn quail
#

e.e

buoyant sandal
#

does the test button like send you data? doesnt work....

#
@app.route('/dbl', methods=['POST'])
def dbl():
  user = request.form['user']
  print(user)```
#

is this bad?

#

im trying to receive data with python flask

sudden rampart
#

the data is sent as json, not form data

worn quail
#

so request.json()?

#

I believe

sullen nymph
sly ledge
#

ok who in here can help me with the python library

sullen nymph
#

I can

#

@sly ledge

sly ledge
sullen nymph
#

Correct

sly ledge
#

ok and when its online it says online on the page for ur bot

#

rihgt

sullen nymph
#

Yep

sly ledge
#

well mine just had ??? and ive spent a hell of a long time trying to get it to say the right status

#

and i cant

sullen nymph
#

Ah, it's not related to any of DBL libraries. It's either your bot is still awaiting approval wasn't invited when approved or kicked

sly ledge
#

oh it has to be in this server?

sullen nymph
#

For status yeah

sly ledge
#

oml ok, for some reason i took it out of this server

#

now i just need to get it back into here...

sullen nymph
#

I can invite it back if you give me its ID

sly ledge
#

lol thank u one sec

#

470652352492470282

#

that id right

sullen nymph
#

Yep

sly ledge
#

thanks you my dude

#

is there something i need to do to accept it

sullen nymph
#

Nah

worn quail
#

Know what ima just try Shiv's api reee

little mason
#

Hello, for the moment i don't have 100 votes. BUt is it better to star developing the vote command with the webhooks or not?

plain timber
#

@little mason webhooks let u run code when the user votes

#

also /check can take a while to update

little mason
#

@plain timber Okey thanks I will use web hooks

little mason
#

Hello, for creating a wekhook I ned to provide an URL, where can I find this URL ? Do I need to create a webhook in my server ?

plain timber
#

what language?

#

you need to code it

little mason
#

Python

#

How ?

#

Is there any doc for coding a webhook ?

#

@plain timber

plain timber
#

uh

#

on python you'll need to set up a webserver

#

and accept the post request from dbl

little mason
#

@plain timber Okey, but where I will look a tit

plain timber
#

what

little mason
#

@plain timber I will setup my web server. But where do I create a webhook ? I need to create it first, on my server discord ?

plain timber
#

no

#

its not related to discord webhooks

little mason
#

Ho, I see. I just need to create web server. And allow DBL to do request. But do I ned to setup a php page or something ?

plain timber
#

uh

#

no?

#

you dont need to use php

little mason
#

Okey, I just need to install apache2 and it's done?

plain timber
#

no you dont need apache

#

you need to code something to accept the post request

#

you can do it in python

little mason
#

I see, but from wich ip or hostname do I need to accept the request

plain timber
#

huh

#

dbl will send a post request to the url you provide

#

you can run code when you get the post request

little mason
#

Do I need to store the data from DBL send to my IP ?

plain timber
#

dbl will send the vote data

#

did you see the link i sent

little mason
#

Okey so I just need to accept post request

plain timber
#

yes

little mason
#

DBL ---> My Server ---> My bot

sullen nymph
little mason
#

@sullen nymph I'm keeping get this error: "error while attempting to bind on address ('0.0.0.0', 5000): address already in use")

runic grove
#

@little mason use another port

little mason
#

@runic grove I already tryed with 25565, same error

#

I done a nmap scan. The port 5000 is not used by another service

#

It's working now, idk why

little mason
runic grove
#

i dont use it. i can read the documentation just as well as you can

little mason
#

But it doesn't explain hwo to use it.

#

how to get vote etc...

runic grove
#

its just for webhooks

little mason
#

But if I want to get who voted for my bot with web hook because upvote has a limit of 1000

#

Do I need to create a webhook in my discord channel and provide it?

runic grove
#

discord webhooks and dbl webhooks are different. shivacos code allows you to run a dbl webhook and optionally hook it up to a discord webhook as well

little mason
#

I want to use the DBL webhook. When the connection is up, in myc ogs discordbotsorgapi what I need to do to get back the player who voted ?

#

Can anyone help me to setup webhook for the vote ? Please i'm here for like 2 hours omggg

#

I'm using python and @sullen nymph script

teal plaza
#

riks, have ur tried looking at the docs?

#

because

#

usually they're pretty helpful

little mason
#

Nothing explain how to use it

#

i want to use webhook

#

dbl webhook for the vote ^^

teal plaza
little mason
#

Same

teal plaza
#

Tht literally explains everything

little mason
#

No, not how to connect webhooks

#

from shivaco script

teal plaza
#

nothing against shiv, but why not just use the original?

lime gust
teal plaza
#
@bot.event
async def on_dbl_vote(data):
    print(data)

# Will output the following:
# {
# 'type': "upvote",
# 'user': "247741991310327810",
# 'bot': "264811613708746752",
# 'isWeekend': False
# }
lime gust
#

it's just http now

teal plaza
#

pretty simple

little mason
#

no, no that's bit hard for python

teal plaza
#

how is that hard for python

#

they're giving u a literal example of how to do it

little mason
#

I think I got it, but I'm looking a way to test it

lime gust
#

postman

little mason
#

I press the test button

#

I add the event on_dbl_test

lime gust
#

ok or do that

little mason
#

Put it print nothing

lime gust
#

try postman then, see if its a problem with ur code

little mason
#

postman ?

#

how

lime gust
#

postman is a http testing app

little mason
#

thanks lol

#

In shivaco code, it doesn't appear somewhere you can get back the info, like who voted etc..

lime gust
#

user is the snowflake id of the user that voted

little mason
lime gust
#

well have you configured the site to have an open port

little mason
#

yes the connection is good

lime gust
#

and have u set the the ip / url on dbl?

little mason
#

I put the same port

#

And the auth

#

In discord bot webhook

lime gust
#

yeah but is it port forwarded

little mason
#

How can I try?

#

do I nedd to use the default port?

#

5000

lime gust
#

that port needs to be open for the whole internet

#

right now its just open on your machine (or local network)

little mason
#

by default all port are open

hearty lintel
#

As in port forwarded?

little mason
#

I just done a nmap scan

#

The port is open

lime gust
#

from your machine go ahead and send a test request to it

#

And see what you get

little mason
#

How ?

hearty lintel
#

^^ open like a /test, and go to it via your IP address not your local host

lime gust
#

postman like i said

little mason
#

The reuqest URL test was not found in this server

#

wait

#

Not

#

It works

#

So it is working!

#

@lime gust

lime gust
#

Through your local IP?

little mason
#

Yes

lime gust
#

Or from the port forwarded up?

little mason
#

myvpsip:theport/test

#

on my chrome

lime gust
#

Ok

little mason
#

it say ""it work"

#

In the code I saw

#

that if I connect with /test it will say to me it work

#

so that's working

#

Why this is not working with vote?

hearty lintel
#

What lib are u using? Or are you doing routing yourself

little mason
#

shivaco

hearty lintel
#

Py?

little mason
#

y

#

e

hearty lintel
#

Oh ok

little mason
#

Nothing happend

#

But the server count still update

#

but it doesn't print something when someone wvote

lime gust
#

sorry i’m really not quite sure what is wrong. might be worth asking a mod

vagrant patrol
#

How can I get notifications if some one upvote my bot (JS)

lime gust
#

Webhooks

runic grove
#

webhooks, definitely

#

dblapi.js has webhook support by default iirc

plain timber
#

well you need to code it

#

and set it in the edit page

sullen nymph
#

@little mason How are you using it

little mason
#

@sullen nymph I found the solution after 4 hours. You make a misstake, you forgot a TAB. I send you where in a sec

sullen nymph
#

We're getting off-topic, let's move to DMs

tropic hill
#

This isn't related to the API, but rather the website. Could you please keep the bots previously submitted and add an option to resubmit?

teal plaza
#

@tropic hill throw it in another channel then 😃 will prolly get seen more if you either email them with a suggestion or post it in a channel not surrounding the APO

runic grove
#

theres the issues repo which only gets looked at to add labels

worn quail
#

Nothing really gets fixed there imo

runic grove
#

yeah

#

there are assigned issues that are well over a year old

#

offtopic anyways mmLol

restive otter
#

The website says I dont have any bots when I do, what do I do?

calm zodiac
#

you must wait for the bot to be accepted for it to show up publicly

restive otter
#

nvm

#

Im just stupid

#

thx anyway

hoary blade
runic grove
#

prolly is short for probably and apo is a typo

#

still off-topic lul

hoary blade
#

@runic grove yeah lol

little mason
#

Hello, anyone here who made a python bot and use a vote system ?

buoyant sandal
#

what is your question

#

Are you trying to check if a user voted for your bot, or run a script upon someone voting?

little mason
#

Yes @buoyant sandal

#

But it doesnt work fine

#

I need someone who already do a vote system un python who can explain to me

buoyant sandal
#

what does not work fine @little mason?

#

I can help you if you specify what you want to do.

little mason
#

@buoyant sandal I’m actually prety tired. I will look at it tomorow

#

I @ you tomorrow is it ok ?

buoyant sandal
#

sure

little mason
#

Thanks !

teal plaza
#

@hoary blade never ping me again plz

hoary blade
#

@teal plaza sorry 🙃

worn quail
#

@little mason something I do is make a aiohttp call (ima do this in a dm so the jerk named cry would shut up) to DBL and check if the userId is in the voting json

#

(Json, txt, whatever)

little mason
#

@worn quail Shivaco made a script in python who made those connections. I think that’s working good, be I need to review my code to see what’s wrong

worn quail
#

Mk

#

I just haven't figured out how to get a webhook working

#

Since my pi died

#

I'm needing to order another

little mason
#

Hi okey

worn quail
#

So in the meantime that's my only way of checking if a user has voted

little mason
#

I will see I’m home in 20 mins

worn quail
#

Oke

restive otter
worn quail
#

Pong the tonk

little mason
#

@sullen nymph ? Could you help me please. When someone vote it says new upvote! But id oesn't go into my code in the cogs discordbotsorgapi.

sullen nymph
#

Elaborate please?

little mason
#

One sec I show you my code

#

in the event on_dbl_vote

#

@sullen nymph

sullen nymph
#

Are you using dblpy autopost or the webhook I sent before

little mason
#

@sullen nymph The webhook you sent to me before

#

The github link

worn quail
#

tbh you could just make checks for the api and save the file as a json, pull from it when changes happen.

#

like if

#

current (web) != saved (file)

sullen nymph
#

Ehh, use dblpy autopost

little mason
#

@sullen nymph What's the difference with autopost ? Can I still get the user vote back ?

sullen nymph
#

webhook - no events used
autopost - emits on_user_vote when someone votes for your bot

little mason
#

@sullen nymph But with autopost is there a restriction when you hit 1000 vote ?

worn quail
#

My idea would work for that I think

#

If that restriction aplies

little mason
#

@worn quail What are you using ?

worn quail
#

Or if it gets too large you can store it as a variable

#

Asyncio GET http

little mason
#

@worn quail And is it working fine ?

worn quail
#
     async def user_voted(author_id=message.author.id):
         
         voteurl="https://discordbots.org/api/bots/543966796944769044/votes"
         async with aiohttp.ClientSession(headers=dblheaders).get(voteurl) as r:
                 
            
         
             json=await r.text()
         if author_id in str(json):
             return True
         else:
             return False```
#

Mhm

#

Has a delay, due to dbl, but it works

little mason
#

But when you reach 1000 votes what happend?

worn quail
#

I'm not there yet

#

But its just a theory since it access the api directly

little mason
#

@worn quail Are you french?

worn quail
#

No

#

Only lang I speak rn is english

little mason
#

okeyy

worn quail
#

Ima brb for a bit srry

little mason
#

I think your method is good

#

But I will be fuc**d when you reach more than 1000 votes

worn quail
#

Possibly

#

We will have to see

little mason
#

For the moment I will use your method who is pretty good

#

But it send a request every time ?

sullen nymph
worn quail
#

Ye

sullen nymph
#

Wait, why am I mentioning autopost

little mason
#

@sullen nymph How I use it ? I remove your wholecode

worn quail
#

lul

little mason
#

yes

#

thats not good

#

@sullen nymph Just help me to ue your method who you code in git

#

The connection is perfect

#

But why when i call dv_lon_vote

#

It's doesnt work?

sullen nymph
#

Specify webhook_port in dblpy Client and it should work, though I also suggest using webhook_auth

little mason
#

But just those ? Not the path?

sullen nymph
#

webhook_path is by default /dblwebhook, you can use that or edit it

worn quail
#

Ima make a smol code for dbl api

#

And use pip

little mason
#

@sullen nymph I will try rn

#

@sullen nymph Not working, I specified the port and the auth. But still nothing happend. The data is not printed

sullen nymph
#

Are you opening the specified port as well as forwarding it?

little mason
#

The port is open, because I saw in the console New upvote

#

That's in your code

sullen nymph
#

Use on_dbl_test if you press "Test" on the pot's page, on_dbl_vote for votes

little mason
#

When I press the test utto I saw Nes upvote in the console

#

YTou script work

#

But not the event on_dbl_test

sullen nymph
#

How are you using on_dbl_test

little mason
sullen nymph
#

And are you sure your Authorization field is the same as webhook_auth

little mason
#

yes same

sullen nymph
#

Huh

little mason
#

Your connection script is working, but I don’t know the connection to the cogs Discord bot api is not working

#

The cogs reload the guild count

#

But the cogs doesn’t work with event with connection

#

@sullen nymph If you find the solution you are a god. I’m looking for a solution since yesterday

sullen nymph
#

Try restarting your bot fully and test your webhook again

little mason
#

Okey I’m going do this in a mins

#

@sullen nymph When I try to start my bot with the webhook_auth and webhook_port it say to me that he can't bind the adress or something but when I start my bot without webhook_auth and port it work perfectly but the test features still not work

#

So I tryed to start the bot without the webhook and after reload the cogs with the webhook but still not working

sullen nymph
#

If you don't specify port, the webhook won't run

little mason
#

When I specify it, my bot won't launch

#

This is the error :

sullen nymph
#

Slap me the full traceback ty

little mason
sullen nymph
#

Do you have anything else running on port 5000

little mason
#

no

#

I already made nmap scan

#

And tryed to kill the port

#

Bu nothing

sullen nymph
little mason
#

Why

#

But when I reload the cogs it's working

#

I think becausethe cogs sever who start the web hasn't stared yet

#

I don't know, hel me lol xd

sullen nymph
#

shrug then, I'm out of ideas

little mason
#

@sullen nymph And the URL that I need to provide on the dbl is http://myvpsip:theport/dblwebhook ?

sullen nymph
#

http://ip:port/webhook_path

little mason
#

there is a /

sullen nymph
#

ffs

little mason
#

disord is adding aslash

#

by default the webhook path is dblwebhook

sullen nymph
#

Yep

little mason
#

But I don't know, It receive the data from you script, but I doesn't give me the data with event

#

It print new upvote

#

when I do a test

#

But it doesn't send me the data

#

with the event on_dbl_test

sullen nymph
#

Can you just send me in the DMs the file you are currently using

#

Using the server.py won't work with events, as I stated before, as it doesn't use discord.py's event system

little mason
#

@sullen nymph So can I use event with python ?

#

@sullen nymph Check ur dms

worn quail
#

I removed the second .votes part

#

but owo

#

Ima make it check in a specific interval (60s by default)

little mason
#

But it doesn't delte the entry so if the user say the command twice

#

It will still say he has voted

worn quail
#

?

little mason
#

nothing xd

#

@sullen nymph DUDE UDE

#

ITS WORKING

#

working

#

just the webhook

sullen nymph
#

So ig my job is done here?

#

:p

worn quail
#

perhaps

little mason
#

Yes

sullen nymph
#

Nice

worn quail
#

Know what ima have it def--

#

Ouch

alpine fox
#
const http = require('http');
const express = require('express');
const app = express();
var server = require('http').createServer(app);
const listener = server.listen(process.env.PORT, function() {
  console.log('Your app is listening on port ' + listener.address().port);
});
const DBL = require('dblapi.js');
const dbl = new DBL(process.env.DBLTOKEN, { webhookServer: listener, webhookAuth: "PASSWORD"}, 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("Tested")
  let a = bot.channels.get("594168469310668830");
  a.send(`User with ID ${vote.user} just voted!`)
});

bot.on('ready', () => {
    setInterval(() => {
        dbl.postStats(bot.guilds.size);
    }, 1800000);
});

NO error, no message(already set in dbl edit)

#

when i try test it

#

no message

#

but dbl.postStats working

restive otter
#

Maybe bad port

alpine fox
#

no

#

glitch port

#

3000

restive otter
#

We can know if anyone vote without weebhook?

alpine fox
#

No

buoyant sandal
#

nope

#

@restive otter do you want help setting your vote system up?

peak pecan
#

what do you guys think, should the benefits of voting for the bot expire after some amount of time if the user doesnt vote again?

runic grove
#

yes. encourage them to vote as often as possible

restive otter
#

@buoyant sandal Yes, i want to know how i can know if anyone have voted without using weebhook

peak pecan
#

@runic grove i was thinking of like a week or month for the perks

buoyant sandal
#

What library are you using? @restive otter

restive otter
#

discord.js

buoyant sandal
#

So DBL will send a POST data in the form of json to the webhook you provide

restive otter
#

"the webhook" is my problem

buoyant sandal
#

If you have a website, you can have a page receive the data or just open a port to receive data on your computer

restive otter
#

I don't computer, and i have a website

#

have

buoyant sandal
#

Do you have access to html editing?

restive otter
#

Yes

buoyant sandal
#

Try making a page with the extension .php and have it receive data with method POST.

restive otter
#

I didn't learned php

#

I just know html, css, js

buoyant sandal
#

Let's configure the webhook on DBL. Make a file with the extension .php and go to https://discordbots.org and edit your bot. Scroll down and find the API section and provide the url to the php file. And then we can set up the php file

sudden rampart
#

a php file won't just magically execute by existing

restive otter
#

yes

sudden rampart
#

if there's no php engine set up there's no way it'll run

buoyant sandal
#

I know, I'm trying to get the webhook set up on dbl and then program the file

#

We can use php input and use json_decode, I think🤔

#

{'type': "upvote", 'user': "247741991310327810", 'bot': "264811613708746752", 'isWeekend': False } DBL should send something like this

sullen nymph
#

"type": "test" for test :p

buoyant sandal
#

Yeah

patent dock
sullen nymph
worn quail
patent dock
#

in discord.js, how do I check if a user voted for my bot?

buoyant sandal
#

You use a webhook

restive otter
buoyant sandal
patent dock
#

yeah but not for a server bot for like

#

every user

restive otter
#

Its global

buoyant sandal
#

You configure a webhook to receive POST data which is in json

#

Scroll up

patent dock
#

uh

buoyant sandal
#

There is no other way without a webhook

patent dock
#

oh I thought webhooks were for a single server

buoyant sandal
#

On dbl vote, data is sent to a webhook to analyze and reward or whatever you want to do. This feature cannot be done with the dbl bot token because the client is the one requesting data. The point of on dbl vote is that the website sends a notification to the bot that someone voted with the userid and all the information.

#

By webhooks, you cannot use discord channel webhooks.

#

You need to have your own

patent dock
#

sounds

#

difficult

worn quail
#

Meh

#

I'm working on a way to auto-check for that

buoyant sandal
#

This process is actually pretty hard

#

Try updating your server count on dbl using the dbl token. If you can get that done, you can probably work out the on dbl vote feature.

elder tulip
#

How to see how many votes my bot has got

worn quail
#

your av disturbs me

elder tulip
#

Sorry

#

@worn quail can u tell me

worn quail
#

what lib

elder tulip
#

Others

worn quail
#

I cant help you if I dont know what you made your bot in

elder tulip
#

Golang

worn quail
#

I am not gonna be able to help

elder tulip
#

Y

sullen nymph
elder tulip
#

Can anyone tell me

worn quail
#

"Why" you expect me to know Golang?

#

dont assume

elder tulip
#

It's my lib

#

It is in others

#

On the site

worn quail
#

You need to know how to use the lang to supply help

#

I dont know the lang.

#

So I can't help.

#

End of story

elder tulip
#

What is the use of API key

restive otter
#

?

#

Wdym

elder tulip
#

What is the use of bots API key

worn quail
#

do you know what a api key even is

elder tulip
#

No

#

Tell what is it

spiral steeple
#

Ensures the people accessing the api aren't random

#

and allows dbl to identify bots that spam the api

plain timber
#

its like a password to use the api

buoyant sandal
#

It's in the Authorization part in the header. You can have your program check the password to make sure its from DBL, and not from someone who replicated the data to reward themselves, etc.

nimble fossil
#

Please do not use this channel for questions regarding your bots disappearance. @novel aspen

[Edit]: Issue resolved.

noble smelt
#

@elder tulip sexy lady ahh

teal plaza
#

@noble smelt plz don’t use this channel for stuff like this or randomly ping people with stuff like that

restive otter
#

I made a discordbotlist.js file and pasted the code and my DBL token to show the server count but it still saying N/A

sullen nymph
#

What code did you paste

restive otter
#
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL(token here', client);
exports.run = async (message, token, client, args) => {
// Optional events
dbl.on('posted', () => {
  console.log('Server count posted!');
})

dbl.on('error', e => {
 console.log(`Oops! ${e}`);
})
new DBL(token, [client])
client.on('ready', () => {
    setInterval(() => {
        dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
    }, 1800000);
});
}```
#

thats it

sullen nymph
#

new DBL(token, [client]) why is this there? thonkku

restive otter
#

uh

#

lemme remove it

#

still showing N/A

sullen nymph
#

client.shards.Id
If you are not sharding, why specify shards

restive otter
#

yikes i removed the shards

#

still confusedwhat

restive otter
#

Assuming this doens't work with JDA?

sullen nymph
restive otter
#

I'm suprised

#

Umm.. wat?

#

Also, what is a shard?

sullen nymph
#

Shard is basically a separate connection of your bot for certain amount of guilds your bot is in

restive otter
#

@sullen nymph

#

oh

#

Also, have you got any ideas on why the ... isn't working?

restive otter
#

@sullen nymph

#

does anybody else experience problems with updating bot's info via api?

worn quail
#

@restive otter put "" perhaps?

#

Idk about js or java strings uet

inner venture
#

@restive otter it's a placeholder

#

its meant to be substituted with you retrieving your bots server count

#

ie like

#

jda.getGuildCache().size()

rigid shuttle
#

Can I not use the webhook config on dblapi ? Because I only want to post stats (Nodejs) tanking

#

Aprrently yes

restive otter
#

I couldn't make it say servers size in DBL >.< anyone can help????

narrow geyser
#

Read examples

restive otter
#

@narrow geyser i did, didn't work that's why: >.<

narrow geyser
#

Code and error

worn quail
#

@restive otter what lib

restive otter
#

discord.js

worn quail
#

And are you trying to GET from the api or PUT your server to the api

#

Well then I'm of no help :p

restive otter
#

uh k xd

bold edge
#

It is possible to see who voted without using a webhook, not sure why you are being told that a webhook is needed.

worldly hollow
#

the only way to do it is through a webhook

#

sorry

#

i guess

spiral steeple
#

You cant get it as they vote tho

plain timber
#

you can see

#

yeah

#

you can check who has voted

#

but webhooks let you run code as soon as they vote

bold edge
#

Yeah, but the user was being told that you can only use a webhook in order to see who voted, which is incorrect.

plain timber
#

where?

#

webhooks are recommended because they work for all bots and dont have much delay, but the api works

blazing pumice
#

When I write f!yiff

#

The bot says "API Error. Invalid imgtype".

worldly hollow
#

oh no nsfw commands

#

i mean my bot has those too so i should probably shut up

blazing pumice
#

Lol.

polar mirage
#

You probably meant to join the support server for whatever bot you're experiencing that issue with

blazing pumice
#

Hm.

#

Okay.

#

Yes actually.

#

But that discord server popped up.

plain timber
#

this is the discord bot list server

blazing pumice
#

That's sad.

plain timber
#

what

restive otter
#

Hello?

#

Do you need help

restive otter
#
#

@ionic field

ionic field
#

im currently using the dbl.webhook.on('vote', vote => { console.log(`User with ID ${vote.user} just voted!`); }); method but voting can take anytime from instant to up to around 30 minutes. is tehre something that im doing wrong or is the api slow? (im quite new to dbl so idk how the api is like)

plain timber
#

@ionic field that should be instant but you cant really do anything about it

#

maybe its just slow some times

ionic field
#

ive seen bots where its always instant so i cant help but wonder if ive done something wrong with the api

plain timber
#

maybe ur just unlucky blobshrug

#

sometimes its instant, sometimes it lags

#

but that code looks fine and you cant really make it faster

ionic field
#

hmm

#

the way that i have it is on vote it stores it into a db with the timevoted and on each command it checks the db and then checks if the time is greater than a 12 hour period

#

should i be attempting someway else or is this method effective?

plain timber
#

that's the best way to do it

ionic field
#

hmm

restive otter
#

One day have passed and still couldn't make the server count even with examples.. If someone can help me in DMs it'll be appreciated, my lib is discord.js

plain timber
#

@restive otter code?

restive otter
#

yes @plain timber i tried making a file for it it didnt work then i pasted it in events/ready.js and still N/A

plain timber
#

any errors?

#

and i was asking you to send the code here

restive otter
#

@plain timber no there's no error, a min and i'll send the code

#
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('my dbl token here', 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);
    }, 1800000);
});```
runic grove
#

@restive otter do you know how setInterval even works

restive otter
#

Uh no i copy pasted this from the examples

runic grove
#

and that was your first and biggest mistake

plain timber
#

Don’t make a new client just for dbl

#

Use the same client you were already using

restive otter
#

@runic grove @plain timber I did it, thanks for the help.

restive otter
#

Uncaught Promise Error: { DiscordAPIError: Missing Permissions

#

help me

worldly hollow
#

your bot doesn't have permission

restive otter
#

how do we do it

#

it works fine and fast in my test bot

dark helm
#

@restive otter give the bot a role that has admin privileges

#

it just depends on the perms

jaunty steppe
sullen nymph
#

iirc latest

jaunty steppe
#

oo ok thanks

sullen nymph
#

You can compare points from the dict returned by get_bot_info

jaunty steppe
#

ok ty

#

z = await dbl.get_bot_upvotes() and x = await dbl.get_bot_info() return different numbers

#

_upvotes returns 3 while _info['points'] returns 6

sullen nymph
#

Yep, then get_bot_upvotes returns votes for the past 12 hours

#

points is overall and there's monthlyPoints just in case :^)

jaunty steppe
#

ohhhhh

#

ok thanks

#

website is down for me

#

@sullen nymph

rugged sierra
#

yeah it works again

jaunty steppe
#

yayyyyyyyyyy wonderful

carmine bone
#

Error :

runic grove
#

npm i dblapi.js

carmine bone
#

@runic grove
now this.

#
internal/modules/cjs/loader.js:584

    throw err;

    ^


Error: Cannot find module 'quick.db'
runic grove
#

npm i quick.db

candid mountain
#

hello guys, I have a problem with the api in my bot, it does not show how many servers my bot is on, neither in the profile of my bot or in the widget.

Excuse my English, I speak Spanish.

rugged sierra
#

stop crossposting

cold ledge
#

^

plush ore
#

It's ok, they posted it in the correct channel

#

It contains easy ways to upload your server count

candid mountain
rugged sierra
#

how long did you wait?

candid mountain
#

approximately 1 hour

rugged sierra
plush ore
#

any errors?

rugged sierra
#

why do I get unauthorized if I fetch the /bots endpoint?

#

ah nvm

#

didnt know you need the token for every endpoint

plush ore
#

It's incase we need to block troubling bots

candid mountain
buoyant sandal
#

does it return any errors?

candid mountain
#

nope

#

nothing

buoyant sandal
#

Then the script never ran

#

Try printing at intervals to see where the code stops

worn quail
#

@candid mountain make http request

#

That's something you can do

#

Though, I'm working on a very simple way of sending it. I'll put it here once its done

candid mountain
#

thanks dude waiting for this

worn quail
#

k

#

Lemme just make sure it works for both rewrite and async

#

I may have it by tomorrow, on pip

buoyant sandal
candid mountain
rugged sierra
#

The one in reference is an example wtf

#

No wonder it's not working

buoyant sandal
#

@candid mountain the dbl api token is separate from your bot token

rugged sierra
#

No I think he thinks the token in reference can be used

#

But it's a example

buoyant sandal
#

the one in reference is an example and invalid

arctic arch
sullen yoke
#

I've got a question about the webhook and I'm using the dblpy library. I've setup the config on discordbots.org and I've followed the example to setup the listeners for on_dbl_vote and on_dbl_test but nothing happens?
I can see the traffic being allowed through my firewall on my router and I can open a telnet connection on the port my bot uses for the webhook...
Sadly I get no output or exception and I'm not sure what else to try, does anyone have any suggestions?

plain timber
#

@sullen yoke you set the webhook settings in your bot edit page

sullen yoke
#

yes, I've done the config on discordsbots.org and I'm use the test funciton to test this

#

and I can see the traffic on the firewall logs

sullen nymph
#

Are you forwarding to the port you specified in dblpy Client?

sullen yoke
#

yes, if the traffic come in on port 5000 then it gets forwarded to the local ip of my bot

sullen nymph
plain timber
#

you saved before testing right?

sullen yoke
#

yes

#

I wouldn't see an output on my router logs if dbl didn't know my details

sullen nymph
sullen yoke
#

😢

#

Nevermind I fixed it 🎉

restive otter
#

Hi, i want make a Indonesian Bot, But are the staff in DBL know that language?

#

This is why google translate exist

#

So are I'm can make a Indonesian Bot than apply in here?

sullen nymph
#

Yes

restive otter
#

Thank you for the information

outer kettle
#

Hey

#

I am not getting approval since 1hr

#

I added my bot!

acoustic trench
#

Is there any way to get the API widget to show all owners or does it only just show the one?

worn quail
#

@outer kettle it takes up to two weeks

near sparrow
#

@outer kettle It takes some time, just relaxxxxx 😃

#

Also please don't use this channel for non-API related stuff

outer kettle
#

Please don't ping me!

#

I am watching you!

acoustic trench
#

On that note, I would like a ping if anyone knows about my question. Thanks in advance

rugged sierra
#

if it doesnt work then prob not

plush ore
#

@wet sequoia each shard will post their shard stats unless you lock it to only send stats of specific shards by id

wet sequoia
#

thx

past finch
#

Does the vote webhook actually send data? I'm logging everything sent and it doesn't seem to send anything?

rugged sierra
#

yop it does

past finch
#

How tho? I'm logging POST, GET and REQUEST data in PHP, and still nothing

rugged sierra
#

its post, dbl posts to your endpoint

#

I don't know shit about php so, just make sure you parse it right, its application/json

past finch
#

Hmmm okay, ta

buoyant sandal
#

You can set up a PHP page to receive POST data in the form of json

past finch
#

Lol, I know. I'm not a script kiddie. Think it's my rewrites

buoyant sandal
#

can you show us your code for the PHP file?

past finch
#
$data = [
    'POST' => $_POST,
    'REQUEST' => $_REQUEST,
    'GET' => $_GET
];

file_put_contents('/../api.log', json_encode($data) . "\n", FILE_APPEND);
buoyant sandal
#

take out the request and get line

#

and do you get errors?

past finch
#

Literally all it is atm, that was for debugging cos post was empty

#

lemme check

rugged sierra
#

the webhook worked for me

#

at least 5 mins ago

buoyant sandal
#

try voting for the bot and check what happens

past finch
#

No errors at all

#

Voted a while ago

buoyant sandal
#

the test feature may not work

past finch
#

it was empty

buoyant sandal
#

did you click save on the edit bot page?

past finch
#

Yeah, I'm getting the posts, just the data is empty

#
$ cat api.log
[]
[]
[]
[]
[]
[]
[]
{"POST":[],"REQUEST":[],"GET":[]}
buoyant sandal
#
'type': "upvote",
 'user': "247741991310327810",
'bot': "264811613708746752",
'isWeekend': False
}```
#

it should send something like this

#

take out the request and get

#

it only sends a POST data

past finch
#

They're not causing an issue, but yeah I'll remove. I'm gonna test it with curl and see if it's a me issue

#

So I posted with curl and the data came through

#

curl --data "param1=value1&param2=value2" mywebsite.com/api/vote.php

Logs:
{"POST":{"param1":"value1","param2":"value2"},"REQUEST":{"param1":"value1","param2":"value2"},"GET":[]}

#

Any help? Both the test voting and actual voting does not post any data

rugged sierra
#

probably not an api problem

past finch
#

I dont know what else it could be

rugged sierra
#

||php||

karmic hound
#

Iirc it's in the body not url parameters like your curl request

rugged sierra
#

he is curling his page

#

oh wait

#

yeah now you say it

past finch
#

I even do curl -X POST --data "param1=value1&param2=value2"

#

Wait wdym

rugged sierra
#

dbl has the data in the body, not the params

past finch
#

Ooooohhh

#

I think I get you

#

YESS LADS

#

file_put_contents('../api.log', json_encode(file_get_contents('php://input')) . "\n", FILE_APPEND);

#

file_get_contents('php://input') was the trick

karmic hound
rugged sierra
#

I learned basic php in school but this will never make sense to me

past finch
#

My entire bot is written in PHP 😂

#

It works very well tbh

karmic hound
#

So you're that one downloader a month GWvictoriaMeguFace

past finch
#

What do you mean lol

rugged sierra
#

not much people code Discord bots with php

past finch
#

Ahh yeah

#

Well I use PHP on a daily basis for work, so I know it more than any other language

karmic hound
#

Afik only 1 lib for php discord

And like no one uses php for discord

past finch
#

Actually there's 2-3

rugged sierra
#

yop just googled

karmic hound
#

Didn't think it was really meant to run websocket long term

past finch
#

Yasmin is what I use

karmic hound
#

MegaThonk back in my day we had one

past finch
rugged sierra
#

I'm happy I didnt get that job for php

#

Any Langauge: string.split
php: explode 💥

past finch
#

Yeah man, it's exciting

#

And when you wanna join it together again implode

karmic hound
#

C doing split GWshikizPersianDerp

sullen nymph
#

We're getting kinda off-topic 👀

past finch
#

Lol, anyway, thanks guys

ocean grove
#

x!help

hearty lintel
ocean grove
#

@hearty lintel Okay thanks

buoyant sandal
#

bots cannot text here. Please use bot commands in #commands, #265156322012561408, or your own server. We want to keep this channel purely for api.

restive otter
#

Any SourceCode For Dbl api

#

To show Upvotes AnD everything

#

Discord.js

narrow geyser
#

Read examples

faint walrus
#

someone can explain how vote system work?

steady wadi
#

Votes reset monthly

#

the more votes you have, the higher you are on the bot leaderboard

restive otter
cold ledge
#

does the npm package for the api update server count on its own?

#

as in i don't have to manually run it or put it in a timer

sullen nymph
#

dblapi.js?

cold ledge
#

yes

sudden rampart
#

if you pass your client, it should

cold ledge
#

okay

#

thx

jovial isle
#

hello ı want my api upload discordapp.com but this document say one probleam and "Invalid server format" I need help. Please help me.

worn quail
#

one, simple fix. Just dont put your server in there yet.
Two why here.

young copper
#

?

#

I am using Discord.js

#

And I wanna make an UpVote Counter

runic grove
#

read

#

the

#

docs

young copper
#

@runic grove ?

worn quail
#

bruh

severe crystal
#

How would I use the webhook part of the API? I don't understand it.

worn quail
#

The webhook is for dbl to send vote info to your bot

severe crystal
#

I know, but how would I use it?

worn quail
#

docs, Google, all those exist

severe crystal
#

I read the documentation. I don't understand it.

worn quail
#

Create a webserver using your router. You will likely have to request a static IP from the provider, unless it doesnt change.

#

Forward the webserver to DBL in the webhook area of the bot edit page

#

And then idk what else mmllu

severe crystal
#

okay

#

I'll see.

#

Thanks.

river musk
#

Hello, I'm hosting the BOT on Heroku, this code doesn't work.. Can someone help me please?

const http = require('http');
var port = process.env.PORT || 3000;

var static = require('node-static');
var file = new static.Server();
var options = {
  host: 'discordbots.org',
  Authorization: "secret"
};
var server = http.createServer(options, function(request, response) {
  request.addListener('end', function() {
    file.serve(request, response);
  }).resume();
}).listen(port);

const DBL = require('dblapi.js');
const dbl = new DBL("secret", { webhookServer: server });
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});```
#

I'm new to webhooks tho

young copper
#

@river musk Do you have a specific error ?

river musk
#

well, i dont have any error

#

but

young copper
#

Normal

#

You need to create a web server using your rooter

#

after forward the webserver to DBL in the webhook area of the bot edit page

#

@river musk

river musk
#

mhm, i still need to use my router even I host it on Heroku? Thonk

young copper
#

Try with your rooter

river musk
#

okay

young copper
#

0.0.0.0.0

#

Its not a rooter

river musk
#

oh, I don't have static ip tho - I need to ask my internet provider to change it

young copper
#

Okay

runic grove
#

what

#

@river musk what do you mean by "doesnt work"

river musk
#

when I test the webhook, it doesn't do anything

runic grove
#

what did you put on the website for the webhook url

river musk
#

uhh, what website? I'm sorry, but I'm pretty new to these things :D

runic grove
#

it cant magically figure out where your webhook is

river musk
#

nvm, i'm just an idiot and forgot something :D thx for help btw

runic grove
#

youre welcome(?)

plain timber
#

It always says 0.0.0.0, also do it on heroku/whatever you are hosting in, not your router

rugged sierra
#

why is the backed having so much server failures? its a bit annoying

hearty lintel
#

It’s likely due to the whole cloudflare issue but I’m not getting many failures? Check your end

rugged sierra
#

If I get 503 Errors its the prob the server failing, not me

#

Its not all the time, but every time look in the logs

sullen nymph
#

DBL restarting probably

rugged sierra
#

I see this in the logs since a few days thonkhappy

sullen nymph
#

DBL restarting probably

rugged sierra
#

long restart

rigid lichen
#
ypeError: Cannot read property 'on' of undefined
4|atlanta  |     at module.exports.run (/home/d/dbots/AtlantaBot/events/ready.js:26:25)```
#
let DBL = require("dblapi.js");
            let dbl = new DBL(client.config.apiKeys.dbl, { port: client.config.votes.port, webhookAuth: client.config.votes.password });
            dbl.webhook.on("vote", async (vote) => {
                let dUser = client.users.fetch(vote.user);```
#

What's the matter ?

hearty lintel
#

@rigid lichen it’s webhookPort not port

rigid lichen
#

🤦

#

Thanks

#

Does the test button on the bot edit page work with this wrapper?

hearty lintel
#

Yes ofc

polar mirage
#

Yes but don't forget to save

rigid lichen
#

okok

#

how can i use webhook and stats in the same time ?

#

I must create two variable ?

polar mirage
#

You can use the same dbl object

worn quail
#

^

#

I still need to request static ip

restive otter
#

salam ealaykum warahmat allah wabarakatuh

sullen nymph
restive otter
#

shabb 'abi swy bwt barubut khasin fyn

#

fih hamayuh wakalshi

plush ore
modest delta
#

ve aleykum esselam

narrow geyser
cursive kindle
#

does anyone know how to check if a user voted a bot

sullen nymph
#

What lib

cursive kindle
#

discord js

full socket
cursive kindle
#

ty 😃

full socket
#

There are two endpoints: one that returns the bot's votes but will fail if your bot has more than 1k votes, and the other checks if a user has voted for your bot or not

cursive kindle
#

owo

#

due to discord word imit oof 2k right?

runic grove
#

no

full socket
#

Use this lib for js. It has a .hasVoted(id) method

cursive kindle
#

ooo

#

tysm

full socket
#

Nope. It's because more than 1k results would be too much data to return

cursive kindle
#

ooo

full socket
#

But I recommend setting up webhooks to get realtime updates when a user votes

cursive kindle
#

oo

#

didnt work...

young copper
#

Can I use api on my phone ?

#

I can only install package

#

And create text file

#

Like json or js or md all I want

runic grove
#

wha..

restive otter
#

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!`); });

in "yourDBLTokenHere" do I need to paste my DBL token or do I need to put the token in parentheses?

#

I'm kind of new at this and I'm confused

runic grove
#

paste the dbl token as a string

restive otter
runic grove
#

anything you want

young copper
#

What is a DBL Token ?

buoyant sandal
restive otter
#

I put my token correctly and the password of my webhook, but when someone votes on my bot nothing appears ... I did the following thing:

#

but in the end nothing appears in my terminal. (note: token and password I configured correctly ... I think)

hearty lintel
#

did you actually set up the webserver

#

unless youre adding the webhookServer right in it doesnt fire a Webhook::vote iirc

restive otter
hearty lintel
#

Yea

#

And it should automatically make /dblwebhook

worn quail
plush ore
worn quail
#

wait how do you know that's from ig

plush ore
#

I dont

hearty lintel
#

Omg I’m so tired

#

Sorry I thought this was off topic

plush ore
#

Yes

restive otter
#

What do I put in "server"? I do not know how to use this API, so I'm confused of what to do

hearty lintel
#

From the code you send above you’re ok

#

That’s what it’s meant to be

calm zodiac
#

U can leave server blank iirc

restive otter
calm zodiac
#

That looks right

hearty lintel
#

Well you’ve gotten to listen with the server to port 5000 and also make sure the web server is open and then throw it in the edit board

calm zodiac
#

Oh yes @restive otter ^

plain timber
#

why are you using http.createServer and webhookServer

#

if you use webhookPort then you dont need any of that

#

you probably cant have both webhookPort and webhookServer

restive otter
#

okay

hearty lintel
#

@plain timber you can but webhookPort is pointless. adding the webhookServer actually enable the vote webhook cuz without it i believe atleast, that the vote event wont be fired without it youll just have to manage the post yourself

plain timber
#

@hearty lintel webhookPort sets up the webhook, you dont need webhookServer

hearty lintel
#

yes but then you need to set up the app.post()etc. yourself

plain timber
#

you should use webhookServer if you want to connect it to another server, or webhookPort if you want dbl to set up the server

hearty lintel
#

supplying webhookServer automatically creates the route

plain timber
#

no, you dont need any app.get

#

webhookPort creates the server and the route

hearty lintel
#

ooh

plain timber
#

you dont need to use http at all

hearty lintel
#

mk

worn quail
#

oh

#

ok

proper atlas
#

could i get some help setting up webhooks?

plain timber
#

@proper atlas always say what language + specifically what the issue is

bold edge
#

Is it possible to use webhook voting if your bot is hosted on heroku?

polar mirage
#

yes

pale sable
#

Hey, i got question, im voting for a bot but im not getting any points or rewards, one more thing, if i have 2 accounts voting is separate right?

calm zodiac
#

@pale sable not all bots have rewards/points for voting

clear kayak
#

How long does it take for a vote to get deleted from the api ?

spiral steeple
clear kayak
#

Doesn't seem to be after 12 hours

spiral steeple
#

votes are reset every month

#

oh you using that

#

uh I thought it was 24

pale sable
#

Minirem got points if you vote

clear kayak
#

Individual user votes

pale sable
#

Yup

spiral steeple
#

yeah 24

clear kayak
#

Thanks Fedora

proper atlas
#

Could I get help with webhooks? I’m using js and I have no clue how webhooks work but I wanna detect when someone votes

sullen nymph
#

@spiral steeple 12

#

Docs outdated

spiral steeple
#

Then someone should get on that, no?

sullen nymph
#

Yell at Tonkku probably

toxic niche
sullen nymph
#

Me

toxic niche
#

do you use the dbl lib

sullen nymph
#

Yep

toxic niche
#

How do you get the list of people who upvoted? I keep getting: <classname> has no attribute _ensure_bot_user()

sullen nymph
#

Did you name any of your classes dbl by accident

#

Or anything

#

files, folders, etc

toxic niche
#

no, One of a cogs is Moderation, which is a class.

sullen nymph
toxic niche
#

imcoming image

sullen nymph
#

Ah

toxic niche
#

i'll have to regen token later

sullen nymph
#

I see what you're doing there lol

#

use self.dblpy, not dbl.Client in your commands

toxic niche
#

wait do I need self in the function

sullen nymph
#

Don't pass self

#

Yeah you don't

worn quail
#

I see non-edited idle

#

Also ty for the token I guess

bold edge
#

@polar mirage How would one get votes working if bot is hosted on heroku, I have the code part fine it's just the URL and port that I'm having trouble with.

worn quail
#

Get a pi and make http requests to your heroku project

polar mirage
#

Why would you need a pi for that

#

lol

worn quail
#

Idk

polar mirage
#

@bold edge if you're on the heroku dashboard there's an "open app" button

#

That brings you the link you'll need

#

aka your project

#

idk the structure anymore, haven't used heroku for a long time

polar mirage
#

Language?

dim halo
#

d.js

polar mirage
#

are you using dblapi.js

dim halo
#

no

worn quail
#

Wait

#

That's reddit

#

I need github

polar mirage
#

Ok well

polar mirage
#

You could either post your server count yourself

worn quail
#

That

polar mirage
#

Or use dblapi.js

worn quail
#

^

polar mirage
#

Pass your client to it

#

And it'll post for you

worn quail
#

I just make raw api requests

polar mirage
#

dblapi.js doesn't rly support my way of sharding so I'll have to do that too mmLol

dim halo
#

installed, what's next?

polar mirage
#
const DBL = require("dblapi.js");
const dbl = new DBL('Your discordbots.org token', client);```
worn quail
#

^

polar mirage
#

And it should start posting

dim halo
#

a

#

oke

polar mirage
#

replace client with whatever client is called

#

You may have called it bot or something else

worn quail
#

^

#

And your discordbots token with your api token

dim halo
#

wair

#

wai

#

wait

#

XD

bold edge
#

@polar mirage Yeah I can get the link but no matter what port I try it does not work.

polar mirage
#

You shouldn't even have to put a port

#

It should automatically redirect

bold edge
#

Ahh so in the code I can remove the port part?, didn't know that

dim halo
polar mirage
#

Oh

#

Actually idk

#

You're using dblapi.js for it

bold edge
#

Yep

dim halo
#

help me

#

Xd

bold edge
#

e is not defined means you've not declared what e is

worn quail
#

^

polar mirage
#

I didn't use dblapi for it back when I was using heroku

#

So not sure