#topgg-api

1 messages · Page 56 of 1

normal slate
#
const DBL = require('dblapi.js');
const dbl = new DBL(`my api key owo`, { 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 => {
    let mainguild = client.guilds.get('561972898554970113')
    let role = mainguild.roles.get('567302962888572958')
    mainguild.vote.addRole(role)
    vote.send(`Thanks for your upvote!`)
  console.log(vote);
});
``` 🤔
#

what's wrong there

#

it doesn't work anyways lol

shrewd delta
#

the server name for that service is literally the exact same

plain timber
#

yes it is

#

@normal slate did you set up the webhook in your bot's edit page?

normal slate
#

oh sh1t

#

where it is

plain timber
#

at the bottom

normal slate
#

URL?

#

i need to host it yes? ;-;

plain timber
#

yes

normal slate
#

@plain timber

#

good?

sullen nymph
#

/dblwebhook if you didn't change anything

normal slate
#

but in code there is webhook/url

restive otter
#

Nope

#

Get dblwebhook

normal slate
#
// catches a post request with the specified URL
app.post('/webhook/url', (req, res) => {
#

so i need change it?

sullen nymph
#

if you didn't change anything

#

Just keep it like that

normal slate
#

i only changed token to mine

#

request token

shrewd delta
#

the test webhook button doesn't actually seem to do anything

#

set up a quick ngrok and tried sending a request there and it didn't pick up anything

restive otter
#

Then your webhook isnt set up correctly

#

Or it wont access the target because of any firewalls

shrewd delta
#

I can send POST requests to the URL just fine using postman on another device connected to a different router

restive otter
#

Well its either the webhook, the port on your device or any firewalls blocking the connection

shrewd delta
#

well there isn't actually a webhook involved in this at all, the port is fine and there's no firewalls because other devices can send the same request through just fine

polar mirage
#

Did you save before using test !!

shrewd delta
#

whef

#

saving worked

#

the idea was to test the link I put in before saving it to my bot blobsweat

shrewd delta
#

alright awesome, I can see the request coming in from the test and I can view the request and response objects. I can see the headers in the request object, but I'm not sure where to find the user object it sends?

plain timber
#

@shrewd delta vote.user is the user id

shrewd delta
#

alright and what if I'm not using the dblapi module?

plain timber
#

The object is the same

#

Just use body-parser or something and use req.body

calm zealot
#

So i would like to use this with my bot, that is running on my local pc.
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});
});

Am i correct that all i would have to do is open port from router and firewall to my pc? am i missing something?

tired elm
#

can someone explain to me how to use the webhooks for discord rewrite if you don't mind?

quartz pumice
#

@tired elm even I want a tutorial or explanation on it

#

But from the information I've digged up by now

#

Ig we need to create a webserver with flask/django and recieve the post req

plain timber
#

@calm zealot well yes but the url and auth also needs to be set in your bot's edit page

sullen nymph
#

@tired elm @quartz pumice

#

Kind of

quartz pumice
#

Thanks for the example @sullen nymph

sullen nymph
#

You can check my Flask script out instead if you want

quartz pumice
#

yea checking it out rn

tired elm
#

Oh shit yeah that was really helpful thank you

restive otter
#

Is there a way of posting server count in the website with python async version? Im totally unfamiliar to the example version they gave.

restive otter
#

hi

restive otter
#

@runic grove it is sharded I said that- discord.js had an update its .totalShards now, ids are seperated so the docs don't add up rn

runic grove
#

huh, i wasnt aware of that

quiet ridge
#

if i want to create a bot to test my code with the dbl library should i make another listing on the site or is there a way to test it without it

polar mirage
#

What are you testing

#

If you want to test voting, you can use the test vote on the edit bot page.

#

The votes have a type parameter which will be "test" when using the test vote, so you can make your code only reply to that.

gloomy cypress
#

how i can get the Authorization r this is use my DBL token? @arctic arch

plain timber
#

@gloomy cypress

  1. dont mention admins for stuff like that
  2. its not your token
  3. it can be anything, it just has to be the same in your code
rigid lichen
#

Hum...

#

I've a problem

#

Here is my code :

#

// Gets vote webhook
const express = require('express');
const app = express();

var server = require('http').createServer(app);
server.listen(client.config.votes.port, () => console.log(`Atlanta listening on port ${client.config.votes.port}!`));

app.post('/votes', (req, res) => {
    console.log('[VOTES] Receiving a request...')
    if (req.headers.authorization !== client.config.votes.auth) {
        console.log('[VOTES] Rejected Post Request, Details Below\n', req.headers)
        res.status(401).send('Unauthorized');
    } else {
        console.log(`[VOTES] New vote post, user_id: ${req.body.user}, isWeekend: ${req.body.isWeekend}.`)
        client.functions.vote({user:req.body.user, isWeekend:req.body.isWeekend}, client);
        res.send('Sucess');
    }
});```
#

When I use Postman, it works

#

But when I test with DBL it doesn't work...

arctic arch
#

is your server accessible from the outside internet

rigid lichen
#

Yes it's not in local

#

Do you want the url ?

#

If you want I can send them (in dm)

#

@arctic arch Could it be due to a temporary dbl failure?

arctic arch
#

dbl's side is working fine

ocean pike
#

Why am I getting an error Error: 503 Backend fetch failed from dblapi.js module?

dusk lynx
#

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

limpid sorrel
#

@ocean pike that website is down if you get that error

ocean pike
#

@limpid sorrel what website..... lol

limpid sorrel
#

it's an API library, it interacts with the website

#

if the website is down, the API library also will not work

ocean pike
#

Oki

restive otter
#

How to check if the user has voted or not voted?

*Python

limpid sorrel
restive otter
#

" tell them that we use the days argument and it changes nothing (setting it to 1 or 31 does the same thing while it shouldn't) "

limpid sorrel
#

?

restive otter
#

That's my brother's question

limpid sorrel
#

i need more context

sullen nymph
#

@restive otter That's intended

#

Checking votes through API call checks if the user has voted for the past 24 hours, as shown on the screenshot justin sent

arctic arch
#

@restive otter days argument was removed from the api, the library is out of date

#

at the same time, any reputable python programmers here willing to become the maintainer for the dbl python library?

sullen nymph
#

If you need some really simple library that would work fine, count me in

normal slate
#
        setInterval(() => {
            dbl.postStats(client.guilds.size);

        }, 60000);```
#

it doesn't update my bot stats :v

#

api token is correct

runic grove
#

any errors?

normal slate
#

nothing, but i now forgot that i don't installed dblapi.js on vps

runic grove
#

nevermind

#

its just your browser cache

#

actually nevermind

normal slate
#

xD

runic grove
#

is it just not updating but not showing N/A?

normal slate
#

yesterday i used dblapi.js

#

and it updated to 8 servers

spiral steeple
#

I don't think you're allowed to post every minute, but that shouldn't be why it doesnt work

#

Wait I didn't read everything mmLol

#

Typical

rigid lichen
#
// Gets vote webhook
const express = require('express');
const app = express();

var server = require('http').createServer(app);
server.listen(client.config.votes.port, () => console.log(`Atlanta listening on port ${client.config.votes.port}!`));

app.post('/votes', (req, res) => {
    console.log('[VOTES] Receiving a request...')
    if (req.headers.authorization !== client.config.votes.auth) {
        console.log('[VOTES] Rejected Post Request, Details Below\n', req.headers)
        res.status(401).send('Unauthorized');
    } else {
        console.log(req);
        console.log(`[VOTES] New vote post, user_id: ${req.body.user}, isWeekend: ${req.body.isWeekend}.`)
        client.functions.vote({user:req.body.user, isWeekend:req.body.isWeekend}, client);
        res.send('Sucess');
    }
});```
#

I've that code

#

But the req.body is not defined (I got this error : )

hearty lintel
#

Ok so I rely on dblapi for the server count on my website for the bot.
Should I do like, every like 30 minutes it pulls from dbl and then sets a local variable or do in the request to my endpoint so it's fetched from dbl every time?

arctic arch
#

@sullen nymph see the current lib, and send a pr with your changes to bring it up to date and everything and we'll see

sullen nymph
rigid lichen
#

@arctic arch Do you know why "req.body" is undefined ?

arctic arch
#

you're missing the body parser

rigid lichen
#

Oh okay that's true thanks

arctic arch
#

also don't ping people for help

restive otter
#

Hey Tonkku can I ask you something?

arctic arch
#

just ask

restive otter
#

So my bot was declined but my bot you need to be in our server to see what is does it was declined because it wasn’t developed. Although it is I was wondering if I could show you in my server what it does.

arctic arch
#

this is not a question about the api, move to #general and ask the mod who declined your bot

plain timber
#

why are you even using dbl for that

spiral steeple
#

Could post your server count to an api of your own

hearty lintel
#

i mean i also retrieve the votes

#

so i may aswell grab server count as well

#

@spiral steeple @plain timber

plain timber
#

hi

#

k

hearty lintel
#

so which should i do :p

restive otter
#

I never used an API before.. How do i do it..

spiral steeple
#

read the docs and get back to me

restive otter
#

Docs are very confusing for someone that never used API's before...

spiral steeple
#

What lang do you use?

opal trench
#

For me personally, I just read the docs and use trial and error till I figure it out

spiral steeple
drifting citrus
#

I copied the webhook example on the api and tested my webhook and it received it, when on ready it is supposed to show the "Webhook running at http://${hook.hostname}:${hook.port}${hook.path}" part, but it doesn't and it also doesn't recognize votes.

hearty lintel
#

You have your endpoint open n everything?

sullen nymph
#

Does api/bots/{bot_id}/check still check if a specified user has voted for 24 hours?

plain timber
#

12 hours but yeah

sullen nymph
#

Wait what

#

They updated it?

plain timber
#

Months ago

sullen nymph
#

Docs out-of-date smh /s

plain timber
#

Actually last july

#

Yeah the docs are outdated

sullen nymph
#

Thanks for letting me know

plain timber
#

Yw

craggy gazelle
#

anyone who uses discord.py for their discord bot, because I have no clue how to implement the trigger_typing() method and how to disable the help command, so help would be appreciated, btw i tried reading the docs but i am hopelessly lost

warm cairn
#

I do not understand, I completed my password and my url with this format http://mypublicip:5000/dblwebhook by following what could be sent above. And my program follows this example : js 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!`); }); But the logs are coming out http://0.0.0.0:5000/dblwebhook despite that. And I do not have an answer when I test. Sadness

plain timber
#

@warm cairn the log should say 0.0.0.0

#

you need to change that to the public ip when you put it in your bot page

#

and also u need to save before testing

warm cairn
#

I have informed my public ip

#

and save

plain timber
#

weird

#

and the Authorization is the same as webhookAuth right

warm cairn
#

yes

plain timber
#

hm

#

can you try making the request with postman

#
warm cairn
#

sure

#

Can you explain to me what I should do on the software please? PleaseStop

plain timber
#

make a POST request to the url with the data that DBL would send

#

but DBL is down now so you can't see the docs

warm cairn
#

yes ;-;

plain timber
#

oh its back up

warm cairn
#

I enter the data where in the software?

plain timber
#

make a request

#

aand dbl is down again ugh

warm cairn
#

thx

#

It does not work, the software tells me that it had a connection error Thonk

#

I missed a step?

plain timber
#

that's probably why it isn't working in dbl

#

its an issue with your server

warm cairn
#

My bot is on cloud.google.com, I have to do some manipulation to allow the connection?

#

Ah

#

C'est bon

#

euh

#

I think I found

#

yes !

#

@plain timber Thanks youThumbsUp

plain timber
warm cairn
#

x)

tribal trout
#

Where can I see the documentation for the python lib for dbl

#

cuz the link on the site doesn't work

#

found it

#

bit silly that the wrong link is on the official site

restive otter
#

is it possible to get the vote count of a bot? if so, how?

tribal trout
#

The example on the github page for the python lib contains (at least) 2 errors

#
logger.info('Posted server count ({})'.format(self.dblpy.guild_count())```
has 1 `)` too little
#

and in```py
while not bot.is_closed():

bot is unresolved. Should be self.bot
tribal trout
#

there you go, that one ACTUALLY works

#

and i did an oof, forgot to take the token out xD

#

there

class DiscordBotsOrgAPI(commands.Cog):
    """Handles interactions with the discordbots.org API"""

    def __init__(self, bot):
        self.bot = bot

        self.token = 'token'
        self.dblpy = dbl.Client(self.bot, self.token, loop=bot.loop)


    @commands.Cog.listener()
    async def on_ready(self):
        self.bot.loop.create_task(self.update_stats())


    async def update_stats(self):
        """This function runs every 30 minutes to automatically update your server count"""
        while not self.bot.is_closed():
            logger.info('Attempting to post server count')
            try:
                await self.dblpy.post_server_count()
                logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
            except Exception as e:
                logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
            await asyncio.sleep(1800)```
plush garden
#

Hey,
I heard it is better to use webhooks if you want to know if user x has voted. Can someone explain to me how I can do that in Java? I have literally no experience regarding webhooks. Thanks!

arctic arch
#

set up a http server that listens for post requests with a json body

plush garden
#

Uhm, okay. Are there any libraries you can recommend?

arctic arch
#

I don't use java so I wouldn't know what to recommend

plush garden
#

Okay, thank you anyways!

arctic arch
#

you'll probably find something good on google

plush garden
#

Yeah, I'll look around

wicked storm
#

Is ok if I set the dlb.postStats interval to 300 seconds? or I should keep the default value of 1800?

gloomy sentinel
#

Hey guys, i think i need to authenticate my bot to use the api, but i am not experienced with http stuff. Can someone explain or link me how to do this? I have no idea how to use an authorization http header.

arctic arch
#

google how to add a header for your language / library

#

@wicked storm why would you do 300 seconds?

wicked storm
#

Just asking mate

tribal trout
#

Have the issues in the python example been corrected yet?

gloomy sentinel
#

hmm im using the python library as well, I just realised that its doing everything already. Im still getting "Unauthorized (status code: 401): {"error":"Unauthorized"}" though. I am sure that my token is correct. What else could it be?

steep wave
#

are you use library

gloomy sentinel
#

yeah im using the newest version of discord.py and the dblpy one to access the discordbots api

sullen nymph
#

How are you passing the DBL token in dbl.Client?

gloomy sentinel
#

self.dblpy = dbl.Client(self.bot, self.token, loop=self.bot.loop)

#

self.token being the string of the token

lapis plank
#

Of

#

Oof

gloomy sentinel
#

just like in the code example for dblpy

sullen nymph
#
            if not self.token:
                raise UnauthorizedDetected('Unauthorized (status code: 401): No TOKEN provided')

Yeah, dblpy somehow can't see the token

gloomy sentinel
#

i saw that one too, i am getting a different error though:
"Unauthorized (status code: 401): {"error":"Unauthorized"}"

sullen nymph
#

Oh, oops

#

So, token is passed but not sent in request Thonkang

gloomy sentinel
#

hmm i tried regenerating the token for a 4th time and now it works haha

#

sorry for wasting your time

sullen nymph
#

dblpy is some kind of magic

#

dw

tribal trout
#

i was getting the same error, thats what i was talking about when i was going on about the errors in the example

#

so i rewrote the example

#

now it works

fleet cloud
runic grove
#

iirc dblpy is broken, youre probably better off just making the http requests

fleet cloud
#

ow ok

sullen nymph
#

Huh

#

Oh

#

For now yeah, use aiohttp

#

Cool, I get 401 when using former token for requests

tribal trout
#

don't use the example and you'll be fine

#

dbl for python works fine

#

but you'll have to use the docs

sullen nymph
#

Can anyone explain why DBL sends 401 error code when the token is wrong?

mystic wing
#

Because it is the error code for unauthorized :think:

sullen nymph
#

Isn't it suppsoed to be 403

mystic wing
#

That's forbidden, different thing

sullen nymph
#

I think I'm confusing myself at this point

tribal trout
#

did someone already tell that the link on the api site for python is non-functional

#

and is a link to version 0.1.4

sullen nymph
#

(It's actually 0.1.3 but eh... since neither work, doesn't matter)

tribal trout
sudden depot
#

@tribal trout i think Therese a issue tracker somewhere

tribal trout
#

meh, it works now for me. I know where to find what I need so I don't really care about the rest

restive otter
#

x

plain timber
#

Use webhooks and store votes

sullen nymph
#

0 - no
1 - yes

sullen nymph
#

@tribal trout What does your on_ready in that code do

restive otter
#

o_0

mighty shuttle
tribal trout
#

What they tried to do with awaiting a bool

restive otter
restive otter
#
async function postToDBL() {
    request.post({
        url: `https://discordbots.org/api/bots/482855531220959242/stats`,
        form: {
            server_count: client.shard.fetchClientValues('guilds.size')
        },
        json: true,
        headers: {
            Authorization: dbltoken
        }
    })
    client.logger.info(`Anlık bilgiler başarıyla discordbots.org'a gönderildi.`)
}
#

Shard doesn't send them all

restive otter
#

ty

sudden depot
#

Anyone got the WEbhook Vote to work with heroku

sudden depot
#

@restive otter you need to await the fetchValues

short girder
#
dbl.webhook.on('ready', hook => {
    console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
})
dbl.webhook.on('vote', vote => {
    client.vote.inc(vote.user, 'votes')
    const voteChannel = client.guilds.get('554742955898961930').channels.find(channel => channel.name === 'votes' && c.type === 'text')
    console.log(`${client.users.get(vote.user)} has voted for Aliquid!`);
    voteChannel.send(`${cient.users.get(vote.user)} has voted for Aliquid!\nThis user has a total of ${client.vote.get(vote.user, 'votes')}`)
});```This does nothing when a user votes. Reason why?
#

@ me with answer

plain timber
#

@short girder did you set the webhook settings in the boy edit page?

short girder
#

wdym by that?

#

Oh I see. ty

#

What is the purpose of the veritification?

polar mirage
#

If you mean the authorization

#

Because if someone knows where your webhook is running they could send requests impersonating votes

#

And farm vote rewards on your bot I guess

short girder
#

ah

#

So not required?

polar mirage
#

Think it is required

#

You should use it

sudden depot
#

Its not required but as Wesley said, if somebody knows the Webhook he can get unlimited fake Votes

short girder
#

ah

unreal kestrel
#

How do we setup this “vote webhook”

#

In my bot

plain timber
#

What language

unreal kestrel
#

JavaScript

plain timber
warm cypress
#

How do you make bots?

plain timber
#

by coding

warm cypress
#

Thanks!

empty jackal
#

'''

shut sun
#

some said me that python wrapper for your api is broken. Is is true?

sullen nymph
#

Until someone merges my PR, it is true

restive otter
#

I can"t find a clear doc of JDA, someone have it ?

tribal trout
#

it isn't broken, but the example is

sullen nymph
#

Kinda both

restive otter
#

Why does it doesn't do anything when I vote 😢

#
const DBL = require('dblapi.js')
const dbl = new DBL('My Token', { webhookPort: 5000, webhookAuth: 'My 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!`);

  Money.findOne(
    {
      userID: vote.user,
    },
    (err, money) => {
      if (err) console.log(err);
      let CoinsToAdd = 120;
        if (!money) {
          const newMoney = new Money({
            userID: vote.user,
            money: CoinsToAdd
          });

          newMoney.save().catch(err => console.log(err));
        } else {
          money.money = money.money + CoinsToAdd;
          money.save().catch(err => console.log(err));
        }
      
    }
  );

});
sudden depot
#

did you set the webhook url in the bots page

restive otter
#

oops

#

maybe not

#

I don't know which url I have to post

#

:/

sudden depot
#

Why does

const DBL = require('dblapi.js');
const dbl = new DBL(process.env.DBL_TOKEN, client);
dbl.getVotes()

return 1000 Random Users

#

My Bot has 6 Votes

plain timber
#

um what

neat bolt
#

That’s all the bots that have upvotes I think

#

You needs to do dbl.getVotes(“id”)

#

@sudden depot

dreamy grove
#

pls

worn quail
#

@dreamy grove ?

restive otter
#

How do I post my total server count to DBL? (across shards)

arctic arch
#

you can either post shard specific counts and we'll add them up, or you can sum them up yourself and post that

restive otter
#

ah alright

restive otter
#

@arctic arch sorry to ping, but it worked and then all of a sudden it stopped counting them up and posts at just 1 shard

arctic arch
#

what are you posting

restive otter
#

The server count for each shard

#

Sorry for late reply

#

Same as before, but now it isnt counting them together

arctic arch
#

what's the format

#

make sure you have a shard id and shard count

restive otter
#

oh it just posts as soon as the shard starts

#

then the next shard starts, posts again

#

worked before

tawdry spindle
#

why don't you just use guildCreate and guildDelete events for that if u don't get 60 servers in a minute

arctic arch
#

no

mighty shuttle
#

Cause that could easily abuse the api

tawdry spindle
#

well i used to send it like that with a 50k bot and never get warned about it so

#

having 26 shards and using intervals r ew

restive otter
#

Just posted the stats, got 400 error code but it posted the full amount. Did it with client.shard.id instead of shards.Id

restive otter
#

@arctic arch apology for the ping, but I've tried asking a mod and been waiting for a bit;
When I launch the vote reward part of the bot (with 2 shards), it launches bot.js through index.js before the shards load, so the webhook already loads,
but then it tries to re-run the webhook and it says port already in use

#

So it just goes into an "exited before its client became ready" loop

spiral steeple
#

Read the error

restive otter
#

I did

#

The address is "in use" but I have no idea how to make it connect when all shards finish loading

spiral steeple
#

Only run it one one shard or run it in a seprate file that doesnt get sharded

arctic arch
#

load the webhook in one shard or a master process

restive otter
#

I'm loading shards in index.js, then starting bot.js

#

But it does it reversed

mighty shuttle
#

You're connecting twice, load the webhook on the final shard

#

Cause you're trying to run the webhook for each shard

restive otter
#

its doing anything ```const DBL = require('dblapi.js');
const express = require('express');
const http = require('http');

const app = express();
const httpserver = http.createServer(app);
const dbl = new DBL('token', { webhookAuth: 'password', webhookServer: httpserver });

dbl.webhook.on('ready', hook => {
console.log(Webhook running with path ${hook.path});
});
dbl.webhook.on('vote', vote => {
bot.channels.get('569500292815519756').send(User with ID ${vote.user} just voted!);
});

app.get('/', (req, res) => {
// ...
});

httpserver.listen(5000, () => {
console.log('Listening');
});```

#

How do I load it on the final shard?

arctic arch
#

just load it once in index?

restive otter
#

tonkku you know why its doing anything ? ^

empty jackal
#

lemaaa

restive otter
#

yes

empty jackal
#

nbr

restive otter
#

?

empty jackal
#

nasın

#

türçe

restive otter
#

stop speak chinese

empty jackal
#

bb

arctic arch
#

@restive otter you mean it's not doing anything?

#

do you get the listening message?

restive otter
#
Listening```
#

i get this

arctic arch
#

ok and what are you doing after that

restive otter
#

uh nothing Thonk

arctic arch
#

so

#

fill in the details on the website

#

save and test

sullen nymph
#

Any ETA on that dblpy fix? Thonk

restive otter
#

@arctic arch what website ?

arctic arch
restive otter
#

I put http://'ipwebserver':5000/dblwebhook on the website and when i 'm going to this url its sending "OK" But when i'm clicking on test webhook button, nothing hapenned

polar mirage
#

Did you click save

restive otter
#

Yes

short girder
#

for the webhook on js. What would be a valid webhookServer?
this: http://domain.com:port?

restive otter
#

http://127.0.0.1:port

#

remplace ip by your web server ip, and if you are in localhost remplace ip by your ipv4

short girder
#

ok

#

so instead of domain just ip?

restive otter
#

yes

short girder
#

ok ty

restive otter
#

np

arctic arch
#

webhookServer is an existing http server you want to link the module to

restive otter
#

tonkku?

arctic arch
#

how did you try it yourself?

#

localhost?

restive otter
#

yeah

arctic arch
#

make sure you've got ports forwarded so the outside internet has access to send requests

restive otter
#

okay

wraith flax
#

i just copypasted the code needed to display the server into my .py lib

#

and inserted the token

#

and nothing happens

short girder
#

What happens when I use the test button? Does the dbl.webook.on('voted') function run?

arctic arch
#

yes, it sends a test vote

wraith flax
#

tonkku you boffin know your queue LUL

arctic arch
#

what

short girder
#

ok

wraith flax
#

i aquire assistance

arctic arch
#

require*

#

I dont know python that well so

wraith flax
#

sorry my tf2 listening skills sucks

#

anyone u'd refer to?

sullen nymph
#

What's up

short girder
#
const DBL = require("dblapi.js");
const express = require('express');
const http = require('http');

const app = express();
const server = http.createServer(app);
const dbl = new DBL(config.apiToken, { webhookAuth: 'password', webhookServer: 'http://IP:PORT' }, client);


dbl.webhook.on('ready', hook => {
    console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
})
dbl.webhook.on('vote', vote => {
    client.vote.inc(vote.user, 'votes')
    const voteChannel = client.guilds.get('554742955898961930').channels.find(channel => channel.name === 'votes' && c.type === 'text')
    console.log(`ID ${vote.user} has voted for Aliquid!\nTag ${client.users.get(vote.user).tag}`);
    voteChannel.send(`${cient.users.get(vote.user)} has voted for Aliquid!\nThis user has a total of ${client.vote.get(vote.user, 'votes')}`)
});

app.get('/', (req, res) => {
// ...
});

server.listen(4500, () => {
    console.log('Listening');
});```This does nothing on test. This is what's on the bot webhook edit page: `http://IP:PORT/dblwebooj`
Reason why not work?
#

@ me with answer

#

Never even sends listening msg.

wraith flax
#

hmm i also have my own side of errors, but its on the Python side :c

#

or more like

#

@arctic arch the website is broken?

sullen nymph
#

Ah, good ol' dblpy

#

Website is good, dblpy is not

wraith flax
#

so dblpy sucks?

sullen nymph
#

Sort of

wraith flax
#

should i just

#

skip it

#

like i cant solve this issue

sullen nymph
#

idk when my PR will be merged, but until then you are better off using aiohttp

wraith flax
#

alrighty, thanks for the info

sullen nymph
arctic arch
#

I remember seeing something like dont name your file dbl and that fixes it

#

very weird

sullen nymph
#

That's if they get module 'dbl' has no attribute 'Client'

arctic arch
#

oh alright

#

surely the lib works for some people tho, whats the cause

wraith flax
#

dw ill just skip the existance of dblpy and try with aiohttp

#

well its something with forbidden error

#

i cant fix that, it's a connectivity issue between user and server

sullen nymph
#

What's weird is that the lib is supposed to wait until bot user is ready to use, but it doesn't

#

So it sends a request to None instead of bot ID in the endpoint

quartz pumice
#

pass an additional argument containing the bot_id ?

sullen nymph
#

It doesn't accept that

arctic arch
#

the bot id is optional in the rest api now tho

sullen nymph
#

Could honestly just use self.dblpy.http.post_server_count at this point RenShrugGif

wraith flax
#

ye

#

and just stick bot.guilds.count on it

sullen nymph
#

At that point you are sure your bot_id is fine and you can just slap len(bot.guilds) in there

#

But that doesn't seem user-friendly

wraith flax
#

i've done worse

#

so i guess i could manage

sullen nymph
#

You know where to get the params or should I post them?

wraith flax
#

that would be useful

sullen nymph
#

Just one sec

#

bot_id, guild_count, shard_count, shard_no

#

Just make shard_count and shard_no None

wraith flax
#

alrighty, thanks for the info!

sullen nymph
short girder
#
const DBL = require("dblapi.js");
const express = require('express');
const http = require('http');

const app = express();
const server = http.createServer(app);
const dbl = new DBL(config.apiToken, { webhookAuth: 'password', webhookServer: 'http://IP:PORT' }, client);


dbl.webhook.on('ready', hook => {
    console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
})
dbl.webhook.on('vote', vote => {
    client.vote.inc(vote.user, 'votes')
    const voteChannel = client.guilds.get('554742955898961930').channels.find(channel => channel.name === 'votes' && c.type === 'text')
    console.log(`ID ${vote.user} has voted for Aliquid!\nTag ${client.users.get(vote.user).tag}`);
    voteChannel.send(`${cient.users.get(vote.user)} has voted for Aliquid!\nThis user has a total of ${client.vote.get(vote.user, 'votes')}`)
});

app.get('/', (req, res) => {
// ...
});

server.listen(4500, () => {
    console.log('Listening');
});```This does nothing on test. This is what's on the bot webhook edit page: `http://IP:PORT/dblwebook`
Reason why not work?
#

@ me with answer

#

Also never sends listening log

sullen nymph
#

@wraith flax may I ask you for your code when you were getting error 403?

#

I don't seem to get it now no matter what I do

arctic arch
#

@short girder the webhookServer is supposed to be the server you set up on the line above

short girder
#

?

restive otter
#

webhookServer: server

short girder
#

bruh why! so simple

arctic arch
#

is there a reason you're setting up a custom web server?

#

both of you are using the example code with nothing in the / route

#

the module is able to host its own server as shown in this example

short girder
#

I am going to be making a website.

#

@arctic arch, Is this correct? JS Webhook running at http://0.0.0.0:0/dblwebhook Listening

#

This is what I get in console on boot

sullen nymph
#

:0 port doesn't seem to be quite legit

short girder
#

and nothing happens on test

arctic arch
#

the port is 0 when you use server linking

sullen nymph
#

TIL

short girder
#

wdym?

arctic arch
#

didn't find a way to get the port from a http server object

#

anyway

#

as I told leemaa

#

make sure you've got ports forwarded so the outside internet has access to send requests

short girder
#

You mean my port open?

arctic arch
#

so in your case 4500

short girder
#

Yes

arctic arch
#

make sure the port is open in your router and/or firewall so requests can go through

short girder
#

it is open

#

one sec lemme check

#

What should be on the bot webhook page?

#

http://IP:PORT/dblwebhook

#

then the auth be the same as webhookAuth: password?

#

Also if I were to go to http://IP:PORT/dblwebook, should anything happen?

fluid plover
#

...

short girder
#

?

#

Anyone help?

arctic arch
#

no, it listens to POST requests

short girder
#

Ok.

#

Is this correct:

#
// Webhook URL
http://IP:PORT/dblwebhook
// Auth
password```
#

@arctic arch, Sorry for pinging you so much

arctic arch
#

yes

short girder
#

mmmm

#
// This is logging variable ${server}
Server {
  _events:
   [Object: null prototype] {
     connection: [Function: connectionListener],
     request: [Function: bound _handleRequest],
     listening: [Function: bound _emitListening] },
  _eventsCount: 3,
  _maxListeners: undefined,
  _connections: 0,
  _handle: null,
  _usingWorkers: false,
  _workers: [],
  _unref: false,
  allowHalfOpen: true,
  pauseOnConnect: false,
  httpAllowHalfOpen: false,
  timeout: 120000,
  keepAliveTimeout: 5000,
  _pendingResponseData: 0,
  maxHeadersCount: null,
  headersTimeout: 40000,
  [Symbol(IncomingMessage)]:
   { [Function: IncomingMessage]
     super_:
      { [Function: Readable]
        ReadableState: [Function: ReadableState],
        super_: [Function],
        _fromList: [Function: fromList] } },
  [Symbol(ServerResponse)]:
   { [Function: ServerResponse] super_: { [Function: OutgoingMessage] super_: [Function] } },
  [Symbol(asyncId)]: -1 }
// Ready messages
Webhook running at http://0.0.0.0:0/dblwebhook
// Listening on port 4500
Listening
```This is what I get.
#
const DBL = require("dblapi.js");
const express = require('express');
const http = require('http');

const app = express();
const server = http.createServer(app);
const dbl = new DBL(config.apiToken, { webhookAuth: 'password', webhookServer: server }, client);

console.log(server)
dbl.webhook.on('ready', hook => {
    console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
})
dbl.webhook.on('vote', vote => {
    client.vote.inc(vote.user, 'votes')
    const voteChannel = client.guilds.get('554742955898961930').channels.find(channel => channel.name === 'votes' && c.type === 'text')
    console.log(`ID ${vote.user} has voted for Aliquid!\nTag ${client.users.get(vote.user).tag}`);
    voteChannel.send(`${cient.users.get(vote.user)} has voted for Aliquid!\nThis user has a total of ${client.vote.get(vote.user, 'votes')}`)
});

app.get('./website/index.html', (req, res) => {
// ...
});

server.listen(4500, () => {
    console.log('Listening');
});```
#

@arctic arch, Sorry for pinging so much. Just say if your too busy rn. I hate having to ping ppl.

arctic arch
#

so what's the issue right now?

short girder
#

Whenever I go to test nothing happens

#

Like how long does it take for the test to actually take action?

#

@arctic arch......

sullen nymph
#

For me it worked in about 1 to 5 seconds

short girder
#

Mmmm

#

Well nothing happens

#

I have no firewalls

sullen nymph
#

Port open in your router?

short girder
#

Yup

#

IPs are correct

#

Idk what's wrong.

#

Ya know what I'm going to not have the voting inside the server

arctic arch
#

make sure you've saved before testing

#

and that webhookAuth and the auth on the website match and aren't just password

short girder
#

ok

#
const DBL = require("dblapi.js");
const express = require('express');
const http = require('http');

const app = express();
const server = http.createServer(app);
const dbl = new DBL(config.apiToken, { webhookAuth: 'aBotMaster', webhookServer: server }, client);

console.log(server)
dbl.webhook.on('ready', hook => {
    console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
})
dbl.webhook.on('vote', vote => {
    client.vote.inc(vote.user, 'votes')
    const voteChannel = client.guilds.get('554742955898961930').channels.find(channel => channel.name === 'votes' && c.type === 'text')
    console.log(`ID ${vote.user} has voted for Aliquid!\nTag ${client.users.get(vote.user).tag}`);
    voteChannel.send(`${cient.users.get(vote.user)} has voted for Aliquid!\nThis user has a total of ${client.vote.get(vote.user, 'votes')}`)
});

app.get('/', (req, res) => {
    res.redirect('./website/index.html')
});

server.listen(4500, () => {
    console.log('Listening');
});```Still nothing happens.
#

@arctic arch

arctic arch
#

did you just tell us your auth

#

DM me your IP and I'll try sending a request

short girder
#

Sure

arctic arch
#

if I'm not able to do it, you either have the wrong IP or the port isn't open

#

are you hosting this from a VPS?

short girder
#

Yes

arctic arch
#

did anything happen

short girder
#

No

#

@arctic arch

arctic arch
#

there

#

it seems to be crashing when the correct auth is provided

short girder
#

Let me check console

#

wdym?

#

So when I have the correct auth it will crash?

#

Maybe try incorrect one?

#

to see

arctic arch
#

incorrect auth gives me 403 as intended

short girder
#

Mmm ok

#

Would it be an issue inside dbl.webhook.on('vote') event

arctic arch
#

I only included the user in my request tho

short girder
#

wdym?

#
0|index    | Oops! Error: 401 Unauthorized```
#

This is in console

#

@arctic arch

arctic arch
#

irrelevant

short girder
#

wdym?

#

I think it worked one sec

#

Cause it finally gave an error for sending a msg in the vote event

arctic arch
#

yup it works now

short girder
#
0|index  | ID 95579865788456960 has voted for Aliquid!
0|index  | Tag Tonkku#0107```
#

Let me add the message sending real quick

#

then try it one sec

#

@arctic arch try

#

??

#

@arctic arch, Sorry for ping again..... Could you try it

arctic arch
#

you can use the test on the website now

short girder
#

Tried nothing happened

trim bluff
#

Does DBL.js automatically handle ratelimits?

#

(To set guilds on join)

#

?tag tias

#

No it doesn't.

steady aspen
#

does anyone have thee documentation for discord.py 16.12

#

i cant find it anywhere anymore

sullen nymph
steady aspen
#

god bless

lucid drift
#

i am getting a access forbidden error when i attempt post my bots server count, is this putting in the token wrong?

sullen nymph
#

Dblpy?

lucid drift
#

i got it nvm

tribal trout
#

if you're using dblpy, don't use the examples

lucid drift
#

sorry, i was trying to post without the bot loading first

sullen nymph
#

Docs and examples are outdated for now

spiral steeple
#

"For now"

#

Been like that for like 6 months

#

That I know of

#

Idk about before then

runic grove
#

iirc shivaco fixed it but PR not merged

sullen nymph
#

^

ornate bane
#

@restive otter

#

👀

restive otter
#

Yes ?

#

Ok then

ornate bane
#

spam

restive otter
#

👌

runic grove
#

@grand blade

#

Ezhammer

#

LMAO

grand blade
#

this man left so my ban button wouldn't show, now I gotta delete these all

runic grove
#

Have fun with deleting those

grand blade
#

thanks mobile

restive otter
#

Constantly
Constantly errors with the dblapi npm package

#

Backend fetch failed
Connection times out
Etc etc..

#

Anyone has a reason for it?

#

Or like why it even happends?

proud sphinx
#

@restive otter what is your host?

restive otter
#

One that doesnt disconnect from nowhere

proud sphinx
#

Is it a stable vps? Because it can be that

restive otter
#

Look, even when i use my own damn phone i sometimes get the same backend fetch on the site

#

So its not even just the vps

#

Ofc its a stable vps

proud sphinx
#

I haven't noticed any issues with the api

restive otter
#

Its Digital ocean for gods sakes

proud sphinx
#

I have no idea

#

Maybe there is another outage coming

restive otter
#

Dude even my own phone on multiple networks not just my home one, my 4g etc get this error like 1 time per month

proud sphinx
#

So yeah the api might be a little bugged

arctic arch
#

that happens sometimes

#

its normal

restive otter
#

"Sometimes"

arctic arch
#

and it'll go away

restive otter
#

Happends on multiple vpses more than 2 times per month

#

It crashes my bot

#

Constantly

#

How the fuck can i catch the error on my bot

arctic arch
#

sounds like you need to implement error handling

restive otter
#

My bot already listens to every error thing i know of

#

Unhandled rejection, error, the other rejection thing..

proud sphinx
#

Well it shouldn't crash

#

External errors should be tolerated

restive otter
#

Well idfk

fast comet
#

shoves try catches everywhere

restive otter
#

Nah not gonna be that stupid lol

rugged sierra
#

can anyone tell me how I can have that webhook (the dlpapi.js thingy) be behind a reverse proxy like nginx

runic grove
rugged sierra
#

oke

#

didnt know its the same for webhooks (dont know shit about webhooks)

#

should I have ssl or is it useless?

runic grove
#

Useless

rugged sierra
#

uhhh not sure, but I already have it like that, soooo can I just leave it as it is?

#

(its not for me, just somebody hosting on my server)

unreal kestrel
#

can someone help me set up the webhook thing

#

i don't know exactly what to do

#

nvm

#

actually

#

i do

rugged sierra
#

@runic grove how do setup the webhook then?

restive otter
#

!radio1

#

!stations

restive otter
runic grove
#

@rugged sierra change server_name to whatever, and the proxy_pass to have the correct port. You need to configure the domains DNS or whatever its called as well with either cloudflare or the domain provider, to have an A record with the correct subdomain set, pointing to the servers IP

simple leaf
#

hey, can someone help me with this? My bot page says that the bot's status is "???" (I supposed it's not able to define it), but my bot is online. I'm even regularly posting the stats with the npm library. What can I do to make it appear online on the website too?

sullen nymph
#

Your bot is not in this server

simple leaf
#

How do I add it?

sullen nymph
#

It was probably kicked, search #mod-logs for your bot and see why it was kicked, fix the issue and ask a mod to invite it back

simple leaf
#

thanks

sullen nymph
crude thunder
#

HOW THE STARBOARD WORK

tidal burrow
#

WHO KNOWS, ITS A MYSTERY

oak spoke
#

i just submitted my bot and it just redirected me to this

#

i have no clue what happened

compact plaza
#

seems to be working now

#

try again

#

same thing happened to me a second ago

oak spoke
#

nope

#

wtf is going on

runic grove
#

backend issues, as you can read the error message

#

the website is being very slow for me right now

#

yeah, trying to log in just errors

oak spoke
#

ok so when i tried this on my phone it gave me a 403 error

runic grove
#

im getting 500

#

@arctic arch internal server error when trying to log in

tiny swallow
#

is it not possible to retrieve a bot's status via dbl's api?

arctic arch
#

there is an undocumented endpoint /api/bots/id/status

tiny swallow
#

oh, cool. thanks

#

is it possible to return the status via just /bots or is /bots/id/status the only way?

arctic arch
#

the status endpoint is the only way

tiny swallow
#

damn, okay. could i suggest possibly adding it to /bots so i’m not flooding the api with requests?

#

or will i just have to work around it myself

arctic arch
#

status will likely stay as exlusive to that endpoint

tiny swallow
#

okay then. thanks for the help

golden wind
#

@sullen nymph you're maintaining dblpy now?

sullen nymph
#

Kind of

dawn fjord
sullen nymph
#

We are in DMs, all good and sorry

arctic arch
#

@dawn fjord lmao it was dbl api related

dawn fjord
#

oh yeh, sorry about that, thought you guys were talking about d.py, my bad

fast comet
#

anyone here can lend me a hand with the DBL api c#?

sudden depot
#

No, I could probably answer a Question abuat it but you are not asking one and i would like to keep both of my hands to myself

boreal bridge
#

wot

fast comet
#

what?

#

I'd ask my question if I knew someone could answer it

boreal bridge
#

how is someone supposed to answer a question if we dont know what the question is

scarlet cobalt
#

One message removed from a suspended account.

fast comet
#

I've not seen any c# around so I supposed no one would answer it just like when I posted it in #development

#

I'm greatly confused on why you all sound so triggered

sudden depot
#

Because we want to help people, but you dont want to be helped

fast comet
#

If you wanted to help why not simply mention you may help and ask for my question? why make such a big deal out of this?

boreal bridge
#

anyone here can lend me a hand with the DBL api c#?

#

just ask the question

rugged sierra
#

okay, so, what options do I have to pass if I want to have it running behind a reverse proxy?

#

for the webhook

restive otter
#

Hi @restive otter

sullen nymph
spice cypress
#

Gist on a vote webhook & auto-posting stats
<link deleted> dm me that

plain timber
#

Looks like that's for an unofficial lib? This channel is for official libs and direct usage, see the channel topic

short girder
#
0|index  | Oops! Error: 401 Unauthorized```My bot is on 21 guilds, but says 20 and gives this in logs.
#

Code coming

#
const DBL = require("dblapi.js");
const dbl = new DBL(config.apiToken, { webhookAuth: 'aBotMaster', webhookServer: server }, client);



// This is in client.on('ready', () => {
// event
    dbl.on('posted', () => {
      console.log('Server count posted!');
    })

    dbl.on('error', e => {
     console.log(`Oops! ${e}`);
    })
plain timber
#

@short girder are you on the latest version of dblapi.js?

#

and is config.apiToken set correctly

short girder
#

Ya

#

let me try

#

@plain timber, No change same err

#

After install

#

again

woven igloo
#

My api not updating

#
const DBL = require("dblapi.js");

 const dbl = new DBL('token', bot);

dbl.on('posted', () => {
  console.log('Server count posted!');
})

dbl.on('error', e => {
 console.log(`Oops! ${e}`);
})
  
  bot.on('ready', () => {
    setInterval(() => {
        dbl.postStats(bot.guilds.size, bot.shards.Id, bot.shards.total);
    }, 1800000);
});```
weary ember
woven igloo
#

i know...the token is in the docs
im dont sent it here... @weary ember

weary ember
#

did 1800000 ms past?

woven igloo
#

WDYM @weary ember

weary ember
#

you are posting every 1800000ms which means it will only post after that long

#

try to do js bot.on('ready', () => { dbl.postStats(bot.guilds.size, bot.shards.Id, bot.shards.total); setInterval(() => { dbl.postStats(bot.guilds.size, bot.shards.Id, bot.shards.total); }, 1800000);

woven igloo
#

nope

glacial harbor
#
 const DBL = require("dblapi.js");
        let dbl = new DBL('ur token', bot);
        dbl.on('posted', () => {
            console.log('Server count posted!');
        })

        dbl.on('error', e => {
            console.log(`Oops! ${e}`);
        }) ```
restive otter
#

can share my own Application Programming Interface here (via link)
note: written from translation

runic grove
restive otter
#

thanks.

sudden depot
#

@restive otter thersE soemwhere an email to suggest it to be an offical lib

runic grove
#

yeah i highly doubt its for dbl

wicked storm
#

Can I connect to the dbl using the same token on two instances?

#

Trying to test smth

plain timber
#

yeah

wicked storm
#

good,

wicked storm
#

Can somebody help me with messaging the user on vote? (discord.js)

#

Tried the example

dbl.webhook.on('vote', vote => {
    console.log(`User with ID ${vote.user} just voted!`);
});```
but it come as `TypeError: Cannot read property 'on' of undefined`
spiral steeple
#

You have to actually set up the dbl webhook

wicked storm
#
const dbl = new DBL(config.bot.dblToken, bot, { webhookPort: 5000, webhookAuth: 'pass' });``` is this good?
spiral steeple
#

The client goes at the end

wicked storm
#

ah

spiral steeple
#

So your bot should be the last thing

wicked storm
#

Now for got sake, why does it error with smth that isn't even on bot.js ...

#
D:\path\test.js:22
            let msg = await message.channel.send(`⏱ | The command is in cooldown.`);
                      ^^^^^

SyntaxError: await is only valid in async function```
spiral steeple
#

Because await is only valid in an async function

wicked storm
#

it worked PERFECT a moment ago ..

spiral steeple
#

Just make whatever function that is in (something in test.js) async

wicked storm
#
} else if (cooldowns.has(message.author.id)) {
            let msg = await message.channel.send(`⏱ | The command is in cooldown.`);
            message.delete();
            msg.delete(10 * 1000);
            return;
    
        }```
#

As I said, it worked perfect

#

and it does for the other commands

spiral steeple
#

That doesnt tell me if the function is async

wicked storm
spiral steeple
#

Make the .then async

#

async (vote) => ...

wicked storm
#

Ok, that worked

#

Any reason what it just popped out now?

spiral steeple
#

?

wicked storm
#

I mean, it worked before, and after trying to setup the webhook part it broke

spiral steeple
#

Because it never got to loading the commands

#

It errored before it required the file with the error

wicked storm
#

oke then

#

Um @spiral steeple if you don't mind me, how do I proper setup a voting system?

#

I got http://0.0.0.0:5000/dblwebhook as webhook, sent a test but nothing happened.

worn quail
#

oohsothatshowyoudoit

plain timber
#

@wicked storm

  1. you need to paste that in to your bot's edit page as the webhook url
  2. change 0.0.0.0 to the public ip or domain of the server
  3. set the webhook authorization to the one set in your code
  4. save webhook
  5. test webhook
worn quail
#

k so if I was to set it as my PI's external IP would it work like that?

wicked storm
#

if i'm on pc for testing, I should use my IP?

worn quail
#

Google "what's my ip" and copy it

#

I think

wicked storm
#

is here a different way than using webhooks?

#

All I need, is to send a message to the user on vote.

plain timber
#

no, you need to use webhooks

#

but it isn't hard

#

and if you are using it on your computer, you will probably need to change your firewall/settings to make sure its exposed

wicked storm
#

ok, I will give it a try.

restive otter
#

Has the python library been updated yet?

sullen nymph
#

Yep

#

Both on Pypi and GitHub

restive otter
#

Woooo ima go have a look!

jolly leaf
#

Hmm, I'm having trouble since today with the Webhook 🤔

#

My website doesn't seem to read the http authorization sent by discordbots.org when someone votes

#

I try to read it with $header = $_SERVER['HTTP_AUTHORIZATION']; but it's always blank

restive otter
#

How do I make a discord bot?

narrow zenith
restive otter
#

Ok, @narrow zenith Sorry.

shut sun
#

why this page

#

is not working

sullen nymph
shut sun
#

thanks

sullen nymph
wicked storm
#

Guys, how can I get the total votes count of my bot? Tried

        dbl.getVotes().then(v => {
            console.log(v.length)
        });```
But it's pretty behind comparative to the website value.
balmy hamlet
#

idk

#

I've never tried a vote count

polar mirage
#

Isn't there a getPoints

#

Total all time votes

#

If that's what you're looking for

#

dbl.getBot(botid)*

#

Returns an object with a points property

wicked storm
#

Ty @polar mirage

waxen wind
#

.

worn quail
#

]]dotpost

#

oof

waxen wind
#

lol

violet crown
#

this is the link of my discord webhook

weary ember
#

it isn't meant for discord webhook. its meant to send post request to ur server

glad summit
#

Lmao

tidal burrow
#

even that can be misleading

#

"ur server" still doesn't mean a discord server

fleet cloud
#

Well I have a problem too with the webhook. I clicked the test button and it gave me that, but a lot of ppl upvoted but it actually doesn’t sends it in the chat from the webhook ...

arctic arch
#

is your webhook url a discord webhook

fleet cloud
#

Well yes ... and that doesnt works but would it be possible with the api then ? ... somehow want to let a webhook send the votes in a chat ...

arctic arch
#

you need a webserver that listens to the webhook requests and converts it to a discord webhook or send it via your bot

fleet cloud
#

Mmm ok ! Ty

cosmic apex
#

How I can ask api to give me an User HypeSquad house ? It’s possible to get it ?

#

(Ping for answer please)

arctic arch
#
  1. this is a question for #development
  2. No, it is not possible to get information about user profiles as a bot account
    However, I think it is now possible with oauth
cosmic apex
#

Thanks

jagged escarp
#

Hey all, using the .NET API, I have the following lines in my code for when my client is Ready. I am trying to update my guild count that displays on the DBL website. The issue I am encountering is the code can't get past IDblSelfBot me = await dblAPI.GetMeAsync();

Is this an operation that normally takes a very long time? If not, what might be going wrong?

Code:

var botID = ulong.TryParse(Config.bot.botUserID, out ulong ID);
            var mutualGuilds = _client.GetUser(ID).MutualGuilds;

            AuthDiscordBotListApi dblAPI = new AuthDiscordBotListApi(ID, Config.bot.token);
            var dblBot = dblAPI.GetBotAsync(ID); //Gets bot through DBL API.
            IDblSelfBot me = await dblAPI.GetMeAsync();
            await me.UpdateStatsAsync(mutualGuilds.Count());

Any help is appreciated, thanks.

worn quail
#

As a webhook could I use a webpage I have (my bot's webpage)

jagged escarp
#

Never mind to the above I just noticed there's an api endpoint I can send the data to instead c:

short mesa
#
const dblw = new DBL(process.env.dtoken, {
    webhookPort: 5000,
    webhookAuth: process.env.wtoken
});

Webhook running at https://0.0.0.0:5000/dblwebhook

I feel like 0.0.0.0 is unhealthy... any thoughts on what the problem could be?

boreal bridge
#

@short mesa that simply means it is listening over ip rather than only at your home network

short mesa
#

Ok, but I'm hosting it, how would that work?

#

Or will I just have to host the webhook locally

#

And so now I'm doing a local host and not getting any results from the testing, let me guess, port forwarding.

boreal bridge
#

Well yes port 5000 needs to be open

plain timber
#

@short mesa its supposed to say 0.0.0.0

#

It always says that

grizzled agate
proud sphinx
#

Wrong token

grizzled agate
#

well @proud sphinx i have even regen the token also for it but since i have change the whole bot now i get this error 😦

sullen nymph
#

I hope you don't have any new lines, spaces etc

grizzled agate
#

basically @sullen nymph the whole bot have been change all commands are working its only the api key that i get the error from 😦

sullen nymph
#

Do you mind regenerating once again and showing me how your token looks in your code

grizzled agate
#

what i did was adding the token on the config.json file and in the main file grabing it like i would with the token stating DBL

#
"DBL": "TOKEN HERE"
``` @sullen nymph  thats in the config file and in the main file i have this
#
const DiscordBotListAPI = require('dbl-api');
const DBL = require("dblapi.js");
const dbl = new DBL('config.DBL',client);
sullen nymph
#

'config.DBL'

#

I'm sorry what

#

Why is it a string

grizzled agate
#

not sure xD the token was first in there but decided to move it to the config file 😦

#

so any other way that i can put that ?? please @sullen nymph

sullen nymph
#

I don't know js, but I would say you need to require your config.json file and then get DBL key from that

#

Google will be your friend on this one

grizzled agate
#

ok will have alook on the docs for it ty for the help @sullen nymph

young cliff
#

can someone direct me to customize my bot page? like edit the background and the buttons outside the html field of the bot description

severe crypt
#

You need to have your bot certified before you can do that.

young cliff
#

oh ok

plain timber
#

false

#

@severe crypt @young cliff you don't need to be certified

#

just use css

#
<style>
put css here
</style>
young cliff
#

Is there any documentation on this?

plain timber
#

css is a commonly used language, google it

proud sphinx
#

He means in dbl

#

No there isn't

young cliff
#

But where does it go

plain timber
#

for dbl just use the browser devtoold

#

in the long description

proud sphinx
#

Just use the chrome devtools

young cliff
#

Ok

plain timber
#

you can use any html including <style> in the long description

#

but not js, thats cert only

young cliff
#

I know that, I was talking about outside the long description like the full background behind the long description field.

#

Thank you

plain timber
#

yes you put the code in the long description section

severe crypt
#

@plain timber so I could use css on my bot's page.

plain timber
#

yes

#

anyone can

severe crypt
#

Thanks

jagged escarp
#

(C#/.NET)

I'm trying to get the api response that gives a 1 or 0 based on if the user has upvoted my bot within the last day. I'm using https://discordbots.org/api/bots/{Config.bot.dblapikey}/check?userId={Context.User.Id} but I'm getting a 401 Unauthorized response. Do I have the correct URI?

sudden rampart
#

bots/{Config.bot.dblapikey}/check is wrong

#

it's /bots/BOTID/check, or just /bots/check

jagged escarp
#

Thanks

#

So when I hardcode the values (bot ID and my ID) I get the normal {voted:1} response, but when I try to use

HttpClient client = new HttpClient();
...
var dblResponse = await client.GetStringAsync($"https://discordbots.org/api/bots/538910393918160916/check?userId=146092837723832320");

I get a 401

#

Like if I copy and paste that link into my browser, it works, but in the code, I get a 401

short girder
#

Hey so for dblapi, is it required to use the webhookPort: for the webhook? And if yes, any other way to do it?

#

@ me with answer

plain timber
#

@jagged escarp 401 means you didn't put the API key in the authorization header properly

#

@short girder if you want to use the webhooks, then yeah you do need webhookport unless you use webhookserver

short girder
#

Which I would still need a port either way.

#

My VPS Doesn't like too many ports open. Since I'm trying to have my website separate from my bot.

plain timber
#

Uh yeah

#

It needs to run a webserver

jagged escarp
#

@plain timber I get a 401 with both my api key and the bot ID on its own, according to Natan it's just the bot's ID that goes into the URI I believe

plain timber
#

The API key doesn't go in the url

#

You need to send it in the Authorization header

jagged escarp
#

oooh got you

restive otter
#

Is there any basic tutorial for the voting api?
The references on the docs aren't helping much....

plain timber
#

What language? And what are you trying to do?

#

The docs are more useful if you've used apis before

latent ocean
#

uhh seems like I can't install/use dblpy because if I use correct aiohttp version, it get incompatible for d.py and if I get the correct aiohttp version for d.py, it get incompatible for dblpy... help?

sullen nymph
#

(I would recommend updating to d.py 1.0.1)

latent ocean
#

Ohhh

sullen nymph
#

Now I am thinking whether should I completely drop support of async dpy or push an update tomorrow

alpine yew
#

I have a problem with dblapi.js!

dbl.webhook.on('ready', hook => {
            ^
TypeError: Cannot read property 'on' of undefined

at...
arctic arch
#

you haven't properly configured your webhook

alpine yew
#

Yes thanks you

boreal bridge
#

@sullen nymph just drop support

sullen nymph
#

Poor async fellas

boreal bridge
#

rewrite 10x better

#

you play a2oa?

#

dayz mod?

sudden rampart
sullen nymph
#

A2OA sure I do
Yeah, that goes to off topic

worn quail
#

I use async. And likely still will tbh

#

Might combine both async and rewrite.

sullen nymph
#

It's not rewrite, it's latest now. Also, I doubt that's possible but good luck

worn quail
#

No.

#

Using two different .py files

restive otter
#

@plain timber
What language? And what are you trying to do?
Python. Vote based Rewards basically

worn quail
#

K

#

New or async

#

Cause if its async that would be great

restive otter
#

New... async is dead

worn quail
#

awh

restive otter
#

oh wait, you were talking to other person XD

worn quail
#

Nah I was talking to you

restive otter
#

oh 😮

worn quail
#

I mainly use async cause I could never get rewrite to properly work

restive otter
#

Async is discontinued afaik

#

Cause, if you do pip install discord, it'll install rewrite

worn quail
#

pip install discord==0.16.12

#

Nah

#

You can still use it

restive otter
#

ye, you could do that but you'll be missing out a whole lot of stuff i guess

worn quail
#

True.

restive otter
#

Are webhooks only for 1K+ votes or can they be used for single votes too?

loud gulch
#

you use them above 1k

restive otter
#

like, take this use case into consideration:

  1. User used vote command which displayed the vote link.
  2. User didn't vote immediately but did so after like an hour.

Now, I don't think it's a good idea to keep polling the votes/check endpoint till a vote from that user is detected.

#

Or is it the only way?

sullen nymph
worn quail
#

thankyou

quartz pumice
#

Pin the repo or the post server count example >.<

sullen nymph
ebon dragon
#

How do i set up a webhook for receiving upvotes

plain timber
#

What language @ebon dragon

ebon dragon
#

Javascript

#

I almost said english lol

plain timber
#

Lol

ebon dragon
#

I mean, how do i set up a webhook, not how to use it

plain timber
#

Well the code "sets up" the webhook

#

It will log a URL to the console

#

Use that as the webhook URL in your bot page

#

If it says 0.0.0.0 change that to the public IP or domain of the server

#

And set webhook authorization to the webhookAuth in your code (it's like a password)

ebon dragon
#

Okay, thanks, you helped me a lot

plain timber
#

Yw

ebon dragon
#

Also, how do i get public ip 😄

#

From console

plain timber
#

curl it

ebon dragon
#

Thanks

sudden depot
#

do you need port forwarding too for a webhook

plain timber
#

Yeah

#

It's just running a webserver

wicked storm
#

On discord.js, what would be the best way for a check for a command that require the user to vote in order to use it?

#

Rn I use dbl.hasVoted(message.author.id).then(async (vote) => {} but it take a few minutes in order the user to be able to use itt.

plain timber
#

the only other way would be to use webhooks and store votes in a db

spiral steeple
#

I wouldnt use that anyway, that will get you ratelimited real quick, you should do what advaith said

stone nebula
#

Another option that I've experimented with is giving the user a role that allows them to use certain commands.

wicked storm
#

Ught, why does everything vote based has to use webhooks p.p

dawn fjord
#

What's the issue? It's not that difficult to setup a solution that allows you to receive web hooks

wicked storm
#

Well, does anybody have an example on how do to it on glitch.com?

wicked storm
#

Even tried https://glitch.com/edit/#!/plum-town and get Error: listen EADDRINUSE: address already in use :::3000

worn quail
#

dontuseglitch

wicked storm
#

For moment is ok.

plain timber
#

@wicked storm you already have a webserver running, you will need to connect to that using webhookServer

#

The existing one is probably created by express

#

Hmm that code should be right Thonking

#

Looks like you also have a express code somewhere else

#

So it's running twice

restive otter
#

s!serverinfo

wicked storm
#

@plain timber I think the express code is to make the bot stay online.

#

Also, when you guys say "save the votes to a database" you literally mean to save the vote to a mysel db or so? Like ID: 123456789012344

worn quail
#

That's what I would do.

#

Use user id

ebon dragon
#

I also want to make some commands for voters only, but how could i do that without using a db? Because my bot sometimes is offline.

worn quail
#

File creation

runic grove
plain timber
#

@wicked storm well you'll need to export the listener there and use that one in dblapi.js, you can only run one express server

ebon dragon
#

Can you send an example, please?

plain timber
#

@ebon dragon the only way without using a DB is by using .hasVoted which may update late and/or get ratelimited

#

The /check is the same thing as .hasVoted but directly using the http api

sour garden
#

when your bot receives a vote does the webhook fire immediately or is there a delay like the other voting endpoints?

spiral steeple
#

It's usually instant, when I test vote it's in the console before I can alt tab

sour garden
#

ok

#

so my code isn't working then.

#

which is a problem, because i just voted with my alt account to test, and now i can't vote again

spiral steeple
#

It has a test vote

#

Right in the options

#

When you're setting the webhook settings

sour garden
#

i know

#

but that doesn't allow me to test if voting unlocks the votelocked commands

#

basically, it was annoying me that it took like 2 minutes to unlock the command

#

so now, it uses webhook instead of /check

spiral steeple
#

Well vote.user for a test will get your id

#

You could add your alt as an owner

#

So you can test with it too

sour garden
#

eh it's fine