#topgg-api

1 messages Β· Page 54 of 1

restive otter
#

cause they should just update it like why even have it if it just doesnt work

sullen nymph
#

It works but... yeah

#

It's bad

#

You could try and find them but idk if that's better than just giving users more practice with aiohttp RenShrugGif

restive otter
#

i have no practice with it

sullen nymph
#

Just copy the source code and modify it kek

restive otter
#

I really just need the post_server_count right?

#

if thats all im going to do

sullen nymph
#

If dblpy didn't make it all to complicated on the backend, yep

restive otter
#

just looking at the source code even it is kind of a mess

#

@sullen nymph any clue what self.BASE is?

sullen nymph
#

Iirc, the formatted link to DBL endpoint

restive otter
#

ah i just found it

arctic arch
#

eww no IPv4 didnt make it

plain timber
#

lol

#

if he made it, it wouldn't suck

arctic arch
#

it would've been deleted by now

timber fulcrum
#

@plain timber thought that too but because I generated it in the docs page It didn't work. i generated a new one on the edit page of the bot and now it works , wierdd , thanks for your help

#

Thonkku could you please check if my server's ip has been banned? On windows I don't get any 403 errors but on my server yes

arctic arch
#

it's not

timber fulcrum
#

why does it then spit 403 error on my linux server

#

I am using the example from doc

#

to be exact :

import dbl
import discord
from discord.ext import commands

import aiohttp
import asyncio
import logging


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

    def __init__(self, bot):
        self.bot = bot
        self.token = 'xxx'  #  set this to your DBL token
        self.dblpy = dbl.Client(self.bot, self.token)
        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 True:
            logger.info('attempting to post server count')
            try:
                await self.dblpy.post_server_count()
                logger.info('posted server count ({})'.format(len(self.bot.guilds)))
            except Exception as e:
                logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
            await asyncio.sleep(1800)


def setup(bot):
    global logger
    logger = logging.getLogger('bot')
    bot.add_cog(DiscordBotsOrgAPI(bot))
restive otter
plain timber
#

@restive otter u didnt blur it in the command part

restive otter
#

i realize that

#

lol

#

deletd it

#

he removed his server ip so

#

not gunna repost it

#

but his sql server is wide open

#

and his apache install has some vulnerabilities

timber fulcrum
#

for now I am using it only for private purposes uber

#

so I am not worring about that

#

will deal with them at some point

restive otter
#

you might want to close your sql port if your only using it locally

#

on your firewall

#

and update apache

timber fulcrum
#

it's not locally only

restive otter
#

oh

#

right on

timber fulcrum
#

does someone know why I get the 403 on linux?

#
Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}
Traceback (most recent call last):
  File "/home/discord/alcapone/cogs/dbl.py", line 25, in update_stats
    await self.dblpy.post_server_count()
  File "/usr/local/lib/python3.6/dist-packages/dbl/client.py", line 100, in post_server_count
    await self.http.post_server_count(self.bot_id, self.guild_count(), shard_count, shard_no)
  File "/usr/local/lib/python3.6/dist-packages/dbl/http.py", line 189, in post_server_count
    await self.request('POST', '{}/bots/{}/stats'.format(self.BASE, bot_id), json=payload)
  File "/usr/local/lib/python3.6/dist-packages/dbl/http.py", line 160, in request
    raise Forbidden(resp, data)
#

I am using the dblpy version installed with pip

plain timber
#

Might just be because dblpy is broken

timber fulcrum
#

and there isn't another library right ?

plain timber
#

Just use aiohttp

timber fulcrum
#

ok thanks

fair sigil
#

Well

lapis dagger
#

something new about my problem?

worn quail
#

xd

restive otter
#

haiii
can i catch some help here with the website server count for python 3.6? ._.

sullen nymph
#

Posting or getting?

restive otter
#

getting

worn quail
#

I have the code

restive otter
#

oh cool

devout dragon
#

in discord.js how would i make it so that if there is a ratelimit of some kind it would send the details about it in a channel, for example #ratelimits pm me if possible

dawn fjord
devout dragon
#

Sorry

restive otter
#

When you post a server count does it normally take a few minutes?

#

Because if it does then maybe my code worked if it didnt then my code lied to me and it didnt actually work

spiral steeple
#

No, it's normally as soon as you recieve a response

worn quail
#

Yeh it's normally instant

restive otter
#

Anyone know how to do the webhook stuff in js with dblapi.js? For me when i try webhook it just errors about the on thing

dbl.webhook.on('ready', hook => {
// stuff
});
restive otter
#

Send The error @restive otter

#

well it just says it can't 'on' of undefined or somethin

#

Send it

#

dbl.webhook.on('vote', vote => { console.log(`User with ID ${vote.user} just voted!`); });

#

yeah i did that yos

#

You are hosting

#

Where?

#

@restive otter

#

ima get it

#

hmm

#

nvm now it works somehow πŸ€” didn't work with exact same code before smhh

#

πŸ˜‚

cyan wyvern
#
dbl.errors.Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}```
#

Anyone know why I might be getting this error

sullen nymph
#

Token invalid

plucky dagger
#

My bots showing as offline.
I did a quick search for online in:api (as I assumed it was an API thing like server count) and it appears the bot needs to be invited to this server for the status to show online.
How long after approval does that happen or do I have to request it somewhere?

spiral steeple
#

Improper channel, but you get the bot dev role as soon as it's accepted and thry are added as soon as their accepted so whenever luca dms you

#

It may have been kicked

cyan wyvern
#

@sullen nymph but what if my token is not invalid?

runic grove
#

you get forbidden if you are banned from the api or the token is wrong

spiral steeple
#

Unauthorized != Forbidden

#

Are you posting to the right id?

sullen nymph
#

I'd recommend posting server count manually

#

with aiohttp

cyan wyvern
#

@spiral steeple no...

#

Why do you have to do that

#

thats dumb

spiral steeple
#

Coding it yourself makes you dumb?

#

Makes sense

cyan wyvern
#

No why do you have to use the right id with the right token

#

Cuz then I cant test it without fucking up my bot

spiral steeple
#

Because you post stats with the id and token

#

/bots/id/stats

#

You cant post to a bot that isnt yours or doesnt exist

cyan wyvern
#

But you should be able to.............................................

#

For testing purposes

spiral steeple
#

That makes no sense

#

but ok

#

post stats to something that doesnt exist

cyan wyvern
#

So you can test and not mess up the things that matter

spiral steeple
#

just console.log the servers

cyan wyvern
#

Ok it still doesnt work

#

I still get a forbidden error even when I use the right ID

#
import dbl
import discord
from discord.ext import commands
import asyncio


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

    def __init__(self, bot):
        self.bot = bot
        if 'DBLToken' not in self.bot.config:
            self.bot.logger.error("Please disable modules.Discord Bots List API.DiscordBotsOrgAPI in bot.py")
            exit(3)
        self.token = self.bot.config['DBLToken']  # set this to your DBL token
        self.dblpy = dbl.Client(self.bot, self.token)
        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 True:
            self.bot.logger.info('Attempting to post server count')
            try:
                await self.dblpy.post_server_count()
                self.bot.logger.info('Posted server count ({})'.format(len(self.bot.guilds)))
            except Exception as e:
                self.bot.logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
            await asyncio.sleep(1800)


def setup(bot):
    bot.add_cog(DiscordBotsOrgAPI(bot))
#

This is my code

runic grove
#

isnt dblpy known to be broken?

cyan wyvern
#

I just learned this

runic grove
#

yeah youre better off making a regular POST request to the api or seomrhitn

cyan wyvern
#

IDK how to do that lol

#

I dont have a website to host it to

runic grove
#

you only need a webserver if you want to use the webhooks

#

if you just want to post server count you dont need a webserver

cyan wyvern
#

How do I make it then

#

Can you please help me with that

runic grove
#

i dont really use python. just google "python http POST request" and read the dbl api docs

cyan wyvern
#

what website do I make the post request to

#

is it just this site?

runic grove
#

read the docs

#

the documentation of the api is amazing

#

scroll down on this page

cyan wyvern
#

so its /api/bots/id/stats

runic grove
#

idk, i didnt read it xd

past finch
#

nvm

restive otter
#

hey is there like a starboard leaderboard?

plain timber
#

Nope

#

You can just Ctrl f tho bloblul

grand pebble
#

Hi

sullen nymph
#

@cyan wyvern use aiohttp

thorn violet
#

Anyone using the npm package for webhooks that also hosts using NGINX have issues with the webhook receiving votes?

prisma grotto
#

hi guys
help
pip install dblpy
Traceback (most recent call last):
File "/usr/bin/pip", line 11, in <module>
sys.exit(main())
File "/usr/lib/python2.7/dist-packages/pip/init.py", line 215, in main
locale.setlocale(locale.LC_ALL, '')
File "/usr/lib/python2.7/locale.py", line 581, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
when installed libs such error

worn quail
#

reinstall pip? idk

plain timber
#

Use aiohttp

#

dblpy is pretty broken

sullen nymph
#

That's

#

Python 2

#

You need Python 3

jovial pine
#

he reposted here at the same time he asked there

shrewd sapphire
#

@here

spiral steeple
#

no

narrow zenith
#

not even close

shrewd sapphire
#

@everyone

spiral steeple
#

you know it doesnt work right?

#

can you go home?

shrewd sapphire
#

Is it disable

spiral steeple
shrewd sapphire
#

Lol ok

#

πŸ‘

worn quail
#

...

arctic arch
#

this is off topic for this channel

worn quail
#

very

restive otter
#

i need fun api

worn quail
#

...

#

do you code a discord bot? or are you just trolling...

slender void
#

Why does it say that my bot is offline?

#

On the site? I just enabled the API and now it says its offline.

worn quail
#

i dunno

slender void
#

Nevermind its online now

#

Im just impaitent

plain timber
#

@slender void the API isn't related to online/offline status on the site

#

It gets that through discord

slender void
#

Oh

#

Ok

#

I was wondering that

#

Guess it just takes a few minutes to register

#

I do like the API though

#

Its really easy to use

sterile harbor
#

for the api, are the only stats you can post server_count?

restive otter
#

You can look at the docs

vivid surge
#

@prisma grotto dblpy probably doesn't support python2.7

#

try it with python3

runic grove
#

Dblpy is broken, dont use it

restive otter
#

πŸ€”

#

2.7?????

#

Omg thats old

dusty marsh
#

Does the current dblpy wersion work with the latest discord.py@rewrite version? Any experiences with it?

spiral steeple
#

Afaik the api libs dont depend on the bots lib

#

Idk how it is with py tho

dusty marsh
#

It does depend on the bot lib.

sullen nymph
#

Not really

#

It works

#

But not quite well

#

Just make a HTTP request yourself

#

With aiohttp

dusty marsh
#

ok, or I could make another api lib

sullen nymph
#

If you want to

dusty marsh
#

although it ofc won't be complete.

#

which is the most complete client library?

sullen nymph
#

Client lib wat

dusty marsh
#

client for dbl api, language doesn't matter

sullen nymph
#

Probably dbljs

dusty marsh
#

Ok then I can look at it for reference how the API works, thank you!

sullen nymph
#

Better to actually use dblpy source code for that tbh

dusty marsh
#

But it is incomplete

sullen nymph
#

It has working stuff

worn quail
#

xd

vivid surge
#

it literally takes like 3 lines to make the request with aiohttp

fading kraken
#

I'm getting duplicate votes for some users? one guy got 2 votes, another got 6

vivid surge
#
import aiohttp

auth={'Authorization': dbl_token}

async def post_count(n):
  data = {'server_count': n}

  session = aiohttp.ClientSession()
  await session.post(url, data=data, headers=auth)
  await session.close()```
#

or python with aiohttp.ClientSession() as session: session.post(url, data=data, headers=auth) to make it two lines

#

@dusty marsh

worn quail
#

xd

ebon mist
#

FIX THE FUCCIN WEBHOOKS LIKE BRUH THEY STOP WORKIn

spiral steeple
#

I mean mine works, but ok

sullen nymph
#

@vivid surge spoonfeed

#

You also forgot Content-Type header

#

Also, it's async with for aiohttp

vivid surge
#

yeah I was just trying to prove a point so I didn't worry about edditing also I didn't see anything about needing content type in the docs I must've missed it

sullen nymph
#

Most of APIs require that RenShrugGif

plain timber
#

Pretty much every request system defaults to json tbh

steep plaza
#

;rocar

#

;tocar

worn quail
tidal burrow
#

this reminded me of someone from other bot list, a guy answered someone's development question which already got the answer over 4 months ago

worn quail
#

xd

clever inlet
#

mood

restive otter
#

how do i figure out the gateway thing

plain timber
#

@restive otter this channel is for the DBL api, as the channel topic says

bronze arch
#

anyone know why my dbl.webhook doesn't work with 'posted' event on 2.3 (node/discord.js)

#

voting works, but reposting server count doesn't. Do I have to wait for all the shards to finish or something else?

plain timber
#

Uh posted isn't related to webhook πŸ€”

ornate abyss
#

can someone help me

#

if i do this:

#
async with aiohttp.ClientSession() as ss:
    async with ss.get(f"https://discordbots.org/api/bots/440176226338865167") as r:
        bot = await r.json()
await ctx.send(bot)
#

it gives back {'error': 'Unauthorized'}

spiral steeple
#

That normally means invalid token

#

You need an Authorization header

#

With your dbl token

#

Your bots*

#

Your bots dbl token*

#

Lmao I can type clear messages

ornate abyss
#

ah

#

where do i add that?

spiral steeple
#

As a header

#

Idk python

#

But it looks like you have no headers

ornate abyss
#

idk other apis like yt uses &key=

#

lemme just search it

spiral steeple
#

Thats query params

#

And insecure

ornate abyss
#

oof

spiral steeple
#

Iirc dbl only allows the auth header

sullen nymph
#

@ornate abyss blah.get(url, headers=your_dict)
your_dict will be a dict where key is Authorization and its value is your bot's DBL token

ornate abyss
#

ohh

#

worked, thanks! :D

sullen nymph
ornate abyss
#

this worked for me :) (posting it for other people on discord.py@rewrite 🀷 )

token= 'TOKEN HERE'
headers = {"Authorization": token}
async with aiohttp.ClientSession() as session:
    async with session.get(f'https://discordbots.org/api/bots/{botid}', headers=headers) as r:
        data = await r.json()
sullen nymph
#

It should be something like data instead of bot tbh

ornate abyss
#

oh yea

ornate abyss
#

how can i let my bot send a message when someone votes on my bot?

queen mason
#

@ornate abyss O your here as wel

ornate abyss
#

πŸ€”

sullen nymph
#

And that's not very helpful

ornate abyss
#

hmm

rare wyvern
#

get_upvote_info right?

sullen nymph
#

So you basically need a webhook running and upon getting a POST request, you would need to send a request to Discord

#

I actually have the webhook but it's not set up for posting in a channel

ornate abyss
#

so like how it posts the server count?

sullen nymph
#

Not really

#

Posting the server count is just a HTTP request

#

Whereas webhook is a server awaiting requests to be sent to it

ornate abyss
#

hmmm

queen mason
#

You and with the webhook you can set a message on some event link vote

#

that triggers when someone votes on your bot

#

But your using python right

ornate abyss
#

ye

queen mason
#

I don't know how it works in python

sullen nymph
#

I should add that into my to-do list for the webhook

queen mason
sullen nymph
#

I should mention that that library doesn't have any support for webhooks

queen mason
#

you but you can get upvote info some maybe you can do something with that?

ornate abyss
#

yea

queen mason
#

As I said I don't now how this library works

#

I'm using the node.js one

ornate abyss
#

ik how to get info etc

queen mason
#

πŸ‘

ornate abyss
#

but not how to let it send a message when it updates

#

Β―_(ツ)_/Β―

sullen nymph
#

I'll send you the code for webhook later (most likely tomorrow)

spiral steeple
sullen nymph
#

It's rather a separate script running in the background than a code for their bot

spiral steeple
#

Spoonfeeding is just straight up giving code

sullen nymph
#

Doesn't dbljs spoonfeed the users with its webhook support at this point?

spiral steeple
#

idk I made my own

sullen nymph
#

Setting up will be the users' problem, mine is to code it and make it work as well as possible

plain timber
#

Dblpy is broken and doesn't work well

sullen nymph
#

Exactly

plain timber
#

Just use http requests

sullen nymph
#

They want webhooks

plain timber
#

For webhooks, run a webserver

ornate abyss
#

hi

#

how can i make a dbl info command so it get all the info from the id but what if the bot doesnt have the servercount thing setup?

#

it gives this KeyError: 'server_count'

sullen nymph
#

Instead of doing ['server_count'], you can do .get('server_count') and check if that returns None or handle that error in try-except

ornate abyss
#

hmm asking it because it gets it from the api

#

Β―_(ツ)_/Β―

sullen nymph
#

Ah yeah

ornate abyss
#

oh so checking if its None?

sullen nymph
#

If you use .get on the dict returned, yep

#

Else, use a try-except

ornate abyss
#

oh ye try-except is a option

#

ye that works

#

thx

slate merlin
#

Sooooo anyone else having votes process multiple times?

sullen nymph
#

Either a bug or weekend votes multiplied

ornate abyss
#

my bot has not been restarted

sterile cipher
#

I'd check the logs

ornate abyss
#

well

#

currently im self hosting it

plain timber
#

And?

#

How is that related to anything

sterile cipher
#

Perhaps you had it set on an interval to post the count?

restive otter
#

Or an API lag

hearty lintel
#

for .js is there a way to .catch if the login failed? or is it just <DBL>|events#error ?

ornate abyss
#

With that I mean

#

It can’t restart for no reason only if I do it manually

#

Which I don’t

#

I have it set as if the bot is ready

#

I think

tawny cargo
#

webhook not working?

tawny cargo
#

just receive it, 30 mins delay wow

runic wasp
#

Im not really sure what to do with the api webhooks, am I supposed to give the link of an existing webhook or is there something else that needs to be setup?

#

Nvm

mystic brook
#

url

trail magnet
#

hello i need help

ornate abyss
#

β€œIf you’re lost read more about our (link)”

restive otter
#

events.js:183

      throw er; // Unhandled 'error' event

      ^


Error: listen EADDRINUSE :::5000

    at Server.setupListenHandle [as _listen2] (net.js:1360:14)```
spiral steeple
#

The port is in use

hearty lintel
#

I just put dbl.webhook.on('vote', console.log)
i put the same auth as the api options and put the url of the ported location into the api options and i pressed test it's just not doin a thing. any idea?

spiral steeple
#

Last time I used console.log it was a function mmLol

hearty lintel
#

thats the point?

spiral steeple
#

You need the parentheses

hearty lintel
#

it'll run console.log(theParamPassedThroughListener)

spiral steeple
#

console.log(vote)

hearty lintel
#

no then itll set the returned value of console.log to the event lol

#

you know the second param is a function that's ran on call?

spiral steeple
#

When it emits vote

#

It has a call back

hearty lintel
#

do u need me to prove u rn?

spiral steeple
#

No

light crag
#

The callback is a function. It will work

spiral steeple
#

I need you to listen

#

on('vote', (vote) => { console.log(vote) })

#

Thats wrong

light crag
#

That is shorthand for a function

spiral steeple
#

Lmao

light crag
#

You are still passing a function

spiral steeple
#

He isnt

light crag
#

console.log is a function

spiral steeple
#

Then something else is wrong

hearty lintel
#

no shit but its not that part lol

#

im generally new to this so idek if the test button does the stuff?

spiral steeple
#

It would emit the vote

#

I use my own lib for this, but if you arent recieving it, the address may be wrong on the dbl side on the site

#

You have it as http://ip:port/path right?

hearty lintel
#

im using and nginx that passes it through 443 but yea ive tried like every different variation

spiral steeple
#

And your console tells you the server is running?

hearty lintel
#

yea

arctic arch
#

lmao steven learned something about programming today

spiral steeple
#

Yes

hearty lintel
#

:p

spiral steeple
#

I wont ever use it

#

But yes

arctic arch
#

you should

hearty lintel
#

much nicer

spiral steeple
#

I dont just log on my callbacks

hearty lintel
#
.on("something", console.log)

is much better then

.on("something", (thing) => {
    console.log(thing)
})```
#

its good for debug tho

#

anyways

arctic arch
#

whenever you would do this, you should use the trick u just learned
doesnt just apply to console.logs

spiral steeple
#

How is it much better if it does the same thing Thonk

arctic arch
#

so your webhooks arent coming through?

hearty lintel
#

u can also handle it with the same written function wherever and stuff

#

yea basically i guess

#

i tried posting manually but there's a cors error but idk if discordbots.org is allowed too or whatever the case is

arctic arch
#
  • cleaner
  • you dont need a to declare a new function
spiral steeple
#

But I dont just do one thing in my callbacks either

arctic arch
#
  • less memory lul
spiral steeple
#

If I cared about mem usage why would I use js

arctic arch
#

faster

#

too

spiral steeple
#

Besides this is my vote function .on('vote', (vote) => { try{ var test = bot.playerstorage.get(vote.user) if(!test) return console.log(`${vote.user} voted`) }catch(err){ console.error(err) } if(!vote.isWeekend){ bot.playerstorage.math(vote.user, "add", 1000, "balance") }else{ bot.playerstorage.math(vote.user, "add", 2000, "balance") } return console.log(`User with ID ${vote.user} just voted!`) })

arctic arch
#

but like what if you have the same callback for two different functions

spiral steeple
hearty lintel
#

wait woah it randomly decided to work now

#

and they're all coming through

#

oh wow

arctic arch
#

-bots @hearty lintel

abstract mothBOT
#
JPBBerry#0001
Bots

@candid blade
@lament vale
@thorny walrus
@blazing token

hearty lintel
#

i just like 5 of the same req

#

is broke?

arctic arch
#

oh

spiral steeple
#

It uses your id to test

arctic arch
#

the system is probably a bit clogged so there's delays

hearty lintel
#

wait now auth isnt working

#

sksk

#

ok it works when i have no auth at all

#

yall should really like console the request response when testing a webhook it'd make thing much easier to debug

spiral steeple
#

Add it yourself Thonk

#

/node_modules/dblapi.js

hearty lintel
#

no in the browser

spiral steeple
#

Oh

hearty lintel
#

when u press the test button

#

its supposed to console the error

#

but here's the thing

#

it doesnt

spiral steeple
#

You can log auth erros on your side

#

errors*

#

I think that's it tho

#

But maybe a server not found or no response etc would be nice to have

sullen nymph
#

Delays on point

spiral steeple
#

I'm still not having a delay mmLol dbl likes me

sullen nymph
#

It used to do that back when I first set my webhook up

#

Took me like 2 mins of spamming test button to get it working

spiral steeple
#

well spamming clogs it more

sullen nymph
#

It started working eventually anyway

arctic arch
#

either you didnt save the password

#

or you're getting old requests in the queue from testing with no auth

sullen nymph
#

Welp, I am sure I saved the password back then

#

Also, don't worry, no requests are coming

arctic arch
#

I was talking to jpb

sullen nymph
#

oops

hearty lintel
#

yea it seems all good now

#

how would i go about attaching the webhook to express or do i just have to write my own post handler? cuz i see option.webhookServer

arctic arch
#

the docs have an example at the bottom

hearty lintel
#

oh i have to listen using httpServer not app

#

alrighty thnx

elfin lynx
#

can somebody help me get my bot to have a WATCHING or PLAYING status? i tried multiple things but, it doesn't work.

arctic arch
short pendant
#

so I made my bot using visual studio code, when I invite it to the server, it appears to be offline how do i make it online>

worn quail
ornate abyss
#

uhmmm

#

did the api break?

#

hmm luca still works

#

nvm

arctic arch
#

/api/bots

ornate abyss
#

yep.. 🀦

worn quail
#

xd

#

lol

ornate abyss
#

hmmm now this,

#

KeyError: 'owners'

#

it cant find the owners

#

code:

owner=' '.join([str((x)) for x in bot['owners']])
em.add_field(name="Owner(s)",value=f"<@{owner}>")
worn quail
#

json file

#

k

ornate abyss
#

ye

  async with aiohttp.ClientSession() as ss
    async with ss.get(f'https://discordbots.org/api/bots/{botid}', headers=headers) as r:
               bot = await r.json()
worn quail
#

did you missspell owners

#

by chance

#

idk

#

but y here

ornate abyss
#

isnt this for the api?

#

i dont think i did lol

#

its like that on the site

#

well nvm

worn quail
#

O

#

I thought that was something else

#

Rip

ornate abyss
#

Lol apparently my token was revoked

sullen nymph
#

Can we send non-integer as server count to the API?

ornate abyss
#

I think you can send anything xd

sullen nymph
#

/shrug

fluid inlet
eager bronze
worn quail
#

Β―_(ツ)_/Β―

sullen nymph
#
{'error': 'Invalid value for server_count'}
#

Well, rip my dreams of putting weird stuff on it

worn quail
#

xD

sullen nymph
#

Here goes CSS, ig

jovial pine
#

@azure pollen ❀

restive otter
#

#credit

restive otter
#

@wraith jay

wraith jay
#

Remove P

restive otter
#

I fixed

#

Xd

#

So now i just wait

#

Why am i so daffed e.e

#

Ok

#

Let me check my web

#

Shall i send u the web link

#

ok

#

shall I type in console

#

pnpm nodebot.js

#

node bot

#

Ok

#

I cant type in console on phone

#

Wow

#

Yes

#

@rapid ledge

#

Ok

#

And

#

Ok

#

No

#

Its undefined still

#

Yes

#

Cant use rn

restive otter
#

Is there a way I can see the coolodown where I can vote again?

spiral steeple
#

it's 12 hours

restive otter
#

I know that duh

#

I am asking if I can see the cooldown somwhere

worn quail
#

Don't think so...

spiral steeple
#

only if you save it to a db when they vote and check times

jaunty tartan
#

Anyone know a good tutorial for the ping to keep ur bot online on glitch.com ?

fleet pebble
plain timber
#

yes

fleet pebble
#

how does one authorize their api token?

vivid surge
#

add it in your Authorization header

fleet pebble
#

where?

#

@vivid surge

vivid surge
#

what

#

like in the request

fleet pebble
#

@vivid surge what am i supposed to do

#

this is so that when someone votes for my bot on DBL it will send them a DM

vivid surge
#

What do you know about http requests and stuff like that?

#

nvm not that much obviously

fleet pebble
#

yah

vivid surge
#

ok so I'd reccomend learning about them a little bit

fleet pebble
#

ok, but how do i "confirm" that API token

#

authorize i mean

vivid surge
#

No idea what you mean by that

#

you use that as your authorization header value

fleet pebble
#

where?

#

in my bot?

vivid surge
#

in the http request

fleet pebble
#

ok

spiral steeple
fleet pebble
#

i have

#

i just dont know how to use the api token

#

i get an error saying my api token is invalid

vivid surge
#

Are you using the one from that page?

fleet pebble
#

no

#

im using the one from the My Bots page

vivid surge
#

you're using djs right?

fleet pebble
#

correct

vivid surge
#

if you're getting an error then that means you're not using it right

#

Like you're not using the authorization header right

fleet pebble
#

ok

#

well thanks for helping, im really tired so im going to sleep and think about it and then get back to it tomorrow

kind walrus
#

how do i add the api to my bot

#

i want it to show the members and have vote support so that it sends a message on vote

queen mason
sullen nymph
noble iron
#

@sullen nymph im going to steal this i love this

sullen nymph
#

Nah Imma sue you for using my stuff with MIT license

supple latch
#

yo so i added the discord server list bot right and it didnt add my server to my profile, any ideas on how to fix this

spiral steeple
#

Other than being in the incorrect place, I believe the bot is offline rn

restive otter
#

can someone help me

restive otter
#

Hello guys, I got 500 votes in 15 days so I bet next month I will reach 1k votes. I wanna ask something.

#

How do I use webhooks

plain timber
restive otter
#

Thanks

plain timber
#

Yw

worn quail
#

delet?

knotty snow
#

yeah i got it

worn quail
#

ah

rough tartan
#

@sullen nymph you're a legend thanks for the flask thing

sullen nymph
restive otter
#

-bots 175680857569230848

abstract mothBOT
#

User not found

restive otter
#

bots @restive otter

#

whoops

#

-bots @restive otter noembed

abstract mothBOT
#

Blload#6680's bots:
@restive otter

dawn fjord
#

Uber please not in here

restive otter
#

o

#

ok

stoic nebula
#

@mighty shuttle can you help me?

#

ok thnx resolved!

fluid plover
limpid bane
#

tried this but it says Ops! Error:401 Unauthorized

restive otter
#

is webhook shut down?
my votes dont come

#

and webhook test

#

umm

#

does anyone have the invite 4 sfe?

amber dune
#

@restive otter we arent the server to ask for that.. sorry. If an invite is expired then we cant do anything..

restive otter
#

?

#

ok

#

?

#

what?

#

Show it

restive otter
#

what?

#

show what?

limpid bane
#

how do i add servers in my bot

#

something like this

tawdry spindle
#

the channel is pretty old but still useful sometimes

limpid bane
#

i did but when i try it says Ops! Error:401 Unauthorized @tawdry spindle

tawdry spindle
#

Can you DM me your code and I'll help you there

limpid bane
#

ok

restive otter
#

Since i set up a domain and HTTPS for my site on my vps, DBL webhooks no longer work.. How can i keep the site running but also the vote webhooks?

#

Use it through the domain?

restive otter
#

Please help..

#

People vote but dont get their rewards now

grand salmon
#

can anyone tell me what does 503 Backend fetch failed

#

means

jolly hornet
#

500 codes are HTTP server-side codes so I'd assume the same for discord, and if so, it's not your fault and is on their end

grand salmon
#

ok

plain timber
#

yeah, thats when DBL breaks

grand salmon
#

i get it almost everytime

#

my error channel for my bot is almost spammed with this error

plain timber
#

why is it spamming the dbl api then

grand salmon
#

what?

#

like im getting it almost every 3 day's

#

but my bot is getting no command errors etc

#

so

plain timber
#

ok?

grand salmon
#

oki

#

just wanted to know what does that error means

#

Bye then

restive otter
#

Webhook isnt working correctly. Its Woking 5 days ago but isnt working now

tacit siren
#

Hey <@&265158261945270273> I dont know if its you, but @hot pebble crash I guess ...

plain timber
#

@tacit siren DONT MENTION ADMINS for no reason

#

this isn't bot support

#

We can't help with Boxbot

#

Go to the boxbot server

tacit siren
#

Ok sorry about this !!

plain timber
#

This is discord bot list

tacit siren
#

Okok sorry :x

plain timber
tacit siren
#

Done ! Thank tou

#

you*

plain timber
#

Yw

restive otter
#

from,
uber

sullen nymph
#

You probably should use Review button mmLol

arctic arch
#

dear uber, you should probably post in the appropriate place instead of #topgg-api

from,
tonkku

restive otter
#

dear @arctic arch ,

where? I thought api had everything to deal with site and api

from yours dearly xoxo hugs and kisses,
uber

restive otter
#

Webhooks still wont work :/

#

dear moosegange,

maybe people want to use incremental development instead of trying to debug however dbl's janky code insertion fucks their shit

from,
cadence

#

Since i set up a domain and HTTPS for my site on my vps, DBL webhooks no longer work.. How can i keep the site running but also the vote webhooks?

Around 19 people voted but didnt get their rewards!

restive otter
#

Now its still not coming through :/

fading kraken
#

@restive otter check your webhook URL set onyour bot page

restive otter
#

Dude

#

Its fine

fading kraken
#

do you have an IP there?

restive otter
#

I just set up a website on my vps on port 443 and now the webhooks just wont arrive on port 5000 anymore

#

Yes because it worked since a year till now

#

That should say the vps's ip..

#

Or atleast used to

#

@fading kraken

#

:/

sullen nymph
#

0.0.0.0 will be your public IP (IPv4) in the link

#

If you're using Windows, the port might be closed and that could be the issue

restive otter
#

Nope

#

Its open

#

No firewalls

#

I only set up a site with HTTPS & a domain. Until i did that the dbl voting worked fine @sullen nymph

sullen nymph
restive otter
#

And my vps also says HTTP is disabled but HTTPS is enabled

#

So i tried using https on dbl

#

No response either

arctic arch
tidal burrow
#

tf is happening

restive otter
#

dear admins
pls fix the webhooks
from,
Potato man

amber dune
#

lots of salt is happening bloblul

restive otter
plain timber
#

@restive otter this channel is only for asking for help with using the api (and complaining when the api breaks)

dawn fjord
#

We don't need you mini-modding. We've already said what we need to say. @plain timber

late jay
#

Excuse me but, why doesn't this work?

async def post_server_count(bot):
    dbl_url = f'https://discordbots.org/api/bots/{bot.user.id}/stats'
    dbl_headers = {'Authorization' : config.dbl_token()}
    dbl_data = {'server_count' : len(bot.guilds)}
    requests.post(dbl_url, headers=dbl_headers, data=json.dumps(dbl_data))
sullen nymph
#

json=dbl_data

#

Probably

late jay
#

πŸ‘

#

I'll try that

#

But basically it should be the same

sullen nymph
#

Yeah

late jay
#

Wait

#

I think I still have to use dumps

#

The json parameter probably expects a json string

sullen nymph
#

It will convert

late jay
#

ok

crisp sentinel
#

Ping me if you can answer me btw

restive otter
#

@late jay Are you using this in a d.py bot?

late jay
#

Yes @restive otter

restive otter
#

You should use aiohttp

#

requests is blocking.

late jay
#

It works with another site, which means I'm probably not building the request correctly

sullen nymph
#

Tbh use aiohttp, requests fsr doesn't want to work

formal citrus
#

hey I don’t know how to add a bot to my sever

#

I tried

#

It won’t like work

dapper helm
#

@distant flare @crisp sentinel Is asking if your dblposter module still works

#

uwu

distant flare
#

it should

#

I should really update it tho .w.

#

and make it simpler

formal citrus
#

can someone please help me?

distant flare
#

@crisp sentinel it should work! But if it doesnt, let me know

crisp sentinel
#

I mean

#

3 lines of code is pretty simple lol

distant flare
#

make sure to check the npm readme

crisp sentinel
#

I will, thanks πŸ˜„

restive otter
#

Guys

#

i need help

restive otter
#

@formal citrus @That12#2255 Just Tell The question?!

fleet pebble
#

How can one make it so that when a user votes for your bot on DBL, it sends them a DM.

Please make sure that you know what you are talking about since the last person completely wasted my time

jovial pine
#

The second part of your message is kinda rude, everyone in here is trying their best to help, but here's a simple (and hence not too descriptive) run through of how to do what you want:

Make a webhook handler (a webserver with a specific endpoint that you have control over)

Hook this handler to an event on your bot (either run it on the same program, or have your bot poll a database or something)

Have your bot dm the people who voted (in the bot event handler)

vivid surge
#

arik btw requests.post is blocking and it'll stop everything on your bot from running

#

oh wait that was at 3:50am

worn quail
#

Lol

vivid surge
#

So the docs say to not use the /votes endpoint if you have more than 1000 votes so like

#

Just curious if there's any way for a larger bot to get all of its votes, if it misses one of the webhook calls or loses its local count then is it out of luck?

#

oh you know what I didn't read 2 lines down at the next endpoint

#

/check

plain timber
#

you can get the amount of votes with the normal bot endpoint

#

/check is for checking individual users

vivid surge
#

wait no that's just the last 24 hours

#

yeah

clever rock
#

another thing you can do is make the voting server independent to your bot

waxen pine
#

hm

jolly hornet
#

Are you running it on your local machine or a vps?

#

And I'm assuming you set the webhook link on DBL?

#

?

#

As in, in a discord channel?

#

Well that's your problem if that is true

#

Add the on 'ready' and then put in the webhook link that shows up

long scroll
#

Does adding/editing a webhook require reapproval?

spiral steeple
#

No

long scroll
#

cool, thanks

sullen nymph
#

No

#

0.0.0.0 would be your public IP

#

aka IPv4

wraith pine
#

I keep getting backend fetched and other errors from the api, any way to check if the api is up before I try to use it?

bronze arch
#

ok so my server count isn't updating, and for some reason my webhook is firing off a few times on the vote event randomly for a user (maybe once every 6-8 hours?). Using dblapi.js here is my code.

const dbl = new DBL(config.discordBots, {webhookPort: config.dblWebhookPort, webhookAuth: config.dblWebhookPass, webhookPath: "/" }, bot);

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


            dbl.webhook.on('ready', hook => {
                console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);

            });

            dbl.on('error', err => {
                console.error(err);
            });

            //check if voted (give points)
            dbl.webhook.on('vote', async vote => {
                // sometimes triggers 5 times, or 10 times for a user.
              });

thinking I may have done something wrong somewhere πŸ€”

plain timber
#

@quartz heron change 0.0.0.0 to the IP of your vps

sullen nymph
#

I believe it changes that to IPv4 of VPS

#

Or am I wrong and dbljs doesn't do that?

#

Wait, I got it wrong ig

#

Fuck

dawn fjord
#

Use properly formatted code blocks please (add js after the ```, and then a new line)

plain timber
#

Yeah probably

#

It's not actually "password" right

sudden rampart
#

remove the s from https

#

unless you actually have a ssl certificate on the webhook

restive otter
#
const dbl = new DBL("api token", { webhookPort: 5000, webhookAuth: 'password'});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});```
is ok?
bronze arch
grand salmon
#

how to create webhook?

#

Like.. Normal webhook

#

Not Discord webhook

plain timber
#

@grand salmon what language?

grand salmon
#

what do you mean?

plain timber
#

what programming language

#

you need to code the webhook

grand salmon
#

Im asking how to create webhook

#

I don't know in what language i need to do it

#

thats why im asking

plain timber
#

what language is your bot in...

#

you can do it in any language

grand salmon
#

JavaScript

plain timber
#

use dblapi.js

#

theres example code in the docs

grand salmon
#

theres only linking and using webhooks there

#

;-;

#

i wanna Create Webhook

spiral steeple
#

that does create the webhook

#

if you want to create your own using your own code to do something else, set up a server

meager hatch
#

are webhooks working?

plain timber
#

@grand salmon that code does create the webhook...

grand salmon
#

um

#

ok

fleet pebble
#

What file do i put all the API stuff in?

plain timber
#

@fleet pebble what... every bot is different, and it depends on what you're doing with the api + your file structure

#

@fallow grotto what's your code?

bronze arch
#

tbh mine has been doing that too

#

must be a silly mistake

#

it's not updating, it remembers the past value (or a wrong value)

stray pendant
#

to add guild count to dbl i need to add a background task with dblpy?

sullen nymph
#

Once per x minutes, yes

#

Just once - no

jolly pond
#

Why are webhooks so slow? People aren't gonna bother voting if they get the reward a hour later
Please fix this

#

Okay I scrolled up and I guess I should have used the thing from the API and not a php page lol

#

The API thing works instantly

#

This should be more clear

bleak coyote
#

@jolly pond out of curiosity, what php page?

jolly pond
#

@bleak coyote just a php page I made on my host for the webhooks

arctic arch
#

there's a backlog of requests in the webhook

bleak coyote
#

Well that might be why @jolly pond

jolly pond
#

Anyways it's fine now.
My point is that it should be more clear I should use the dbl npm webhook thing. I didn't know that was a thing until I scrolled up here

plain timber
#

thats only for js?

bleak coyote
#

Tho a request is a request, shouldnt be slow even with php

plain timber
#

for php you should make it yourself

jolly pond
#

@bleak coyote Well it is

#

It gets it like a hour later sometimes

#

@plain timber Yes I did and it's slow

arctic arch
#

oh

#

so it was slow because of your php code?

jolly pond
#

No

arctic arch
#

big lul

jolly pond
#

When I test it it's instant

#

When I use the webhook test it it takes time

#

And for real votes too

bleak coyote
#

It's smth with your host or your code, php code doesnt take 1h to make a request lol

weary ember
#

^

jolly pond
#

Okay Idk what was happening. πŸ˜…

arctic arch
#

the npm module just creates a webserver to listen to the same webhook requests

plain timber
#

it should be the same whether u use ur own php or dblapi.js

proud sphinx
#

@arctic arch it's slow in general

#

I got my webhook response in 2-3 hours

stray pendant
#

why on bdl the guild count doesn't appear?

#

the bot is connected to the dbl api

bleak coyote
#

@stray pendant whats the api response?

stray pendant
#

aiohttp.client_exceptions.ClientOSError: [Errno 104] Connection reset by peer

#

dblpy *

tall epoch
#

so I got this in log when updating guild count

dbl.errors.HTTPException: Backend fetch failed (status code: 503): <!DOCTYPE html>
<html>
  <head>
    <title>503 Backend fetch failed</title>
  </head>
  <body>
    <h1>Error 503 Backend fetch failed</h1>
    <p>Backend fetch failed</p>
    <h3>Guru Meditation:</h3>
    <p>XID: 382402563</p>
    <hr>
    <p>Varnish cache server</p>
  </body>
</html>
#

should I worry?

spiral steeple
#

A 5xx error is server side

#

All you can do is wait

proud sphinx
#

@tall epoch it's not at your end

#

just hold on

timid osprey
#

I am getting a 403 forbidden error

#

Is there problems with API atm?

jovial pine
#

anything with a 4xx = your fault

#

anything with a 5xx = api fault

timid osprey
#

I tried to regenerate my API token but didn't help

jovial pine
#

What are you trying to do

timid osprey
#

Update server count on bot

jovial pine
#

Hopefully you realize that DBL api needs its own token, not your bot token

timid osprey
#

Yes

jovial pine
#

using a library? or

timid osprey
#

dblpy yeah

jovial pine
#

πŸ€”

#

you're using the example code?

timid osprey
#

yeah

#
   raise Forbidden(resp, data)
dbl.errors.Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}

#
    await self.request('POST', '{}/bots/{}/stats'.format(self.BASE, bot_id), json=payload)

jovial pine
#

that's not

#

oh is that part of your stacktrace

#

you should be seeing Failed to post server count\n{}: {}

#

something along those lines

timid osprey
#
class DBots(commands.Cog):
    """Handles interactions with the discordbots.org API"""

    def __init__(self, bot):
        self.bot = bot
        self.token = 'tokenherebutremovedforcopypaste'
        self.dblpy = dbl.Client(self.bot, self.token)
        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 True:
            log.info('attempting to post server count')
            try:
                await self.dblpy.post_server_count()
                log.info('posted server count ({})'.format(len(self.bot.guilds)))
            except Exception as e:
                log.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
            await asyncio.sleep(1800)
#

Yeah I see that

#
dbl.errors.Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}
Failed to post server count

jovial pine
#

hmph

timid osprey
jovial pine
#

i cant think of any reason other than your token's wrong

timid osprey
#

I tried to regenerate it 3 times

jovial pine
#

you need to copy the whole thing, it's longer than the page

timid osprey
jovial pine
#

you should have a string that's quite long

timid osprey
#

yeah

jovial pine
#

has 3 segments, separated by .

timid osprey
#

Yeah I see the three .

jovial pine
#

πŸ€”

#

can you link to your bot?

#

Like, what bot

timid osprey
jovial pine
#

Yeah idk

#

maybe @craggy sentinel can help tehehe

#

(He's saying that he's getting 403 on vote api with a seemingly valid token using dblpy, his bot is posted there and i couldnt find anything wrong)

craggy sentinel
#

I've never used python myself

#

it suddenly stopped working?

timid osprey
#

It's been a while since I've used the API

#

As rewrite released which was the new d.py library and I haven't tried it out with this one

craggy sentinel
#

looks like you copied the example code which should work

jovial pine
#

The example code works with rewrite and async alike

timid osprey
#

I could check my old code

#

but it's pretty much the example one as well

#

Is there a way to check if my token is valid?

#

I guess I could try it without the bot

craggy sentinel
#

You could try sending other API requests with it

timid osprey
#

gonna try with postman

timid osprey
#

oh god I feel so dumb

#

I used a test bot to try it out with the wrong ID, so sorry πŸƒ

craggy sentinel
north stratus
#

I assume i get my api token when my bot is approved?

sullen nymph
#

Yep

restive otter
#

How do I send a message to the vote.user? Javascript

short glade
#

So this is API help channel?

spiral steeple
#

get user -> make sure they exist to your bot -> send message @restive otter

#

@short glade yes

short glade
#

@spiral steeple So everything related to the Discord API is supposed to be here?

spiral steeple
#

No

short glade
#

Well this is an API help channel πŸ˜‚

spiral steeple
#

This isnt the discord api channel

short glade
#

Then specify that somewhere

spiral steeple
#

It does

short glade
#

where?

spiral steeple
#

In the topic

short glade
#

lemme check

#

soz

restive otter
#

wait

short glade
#

riiiight..

#

so where does everything related to the discord api go?

restive otter
#

client.users.fetchUser(vote.user).send("thanks for voting!")

spiral steeple
#

You can go there

restive otter
#

this?

spiral steeple
#

That can work, but I think fetchUser is a promise iirc, you should also add a catch

restive otter
#

.catch(error) { console.log(error) }?

spiral steeple
#

I believe so

short glade
#

Why not just make a error event? πŸ˜‚

#

Then you don't need to catch error all the time

runic grove
#

nice token leak mmLol

short girder
#
    const dbl = new DBL(config.apiToken, client);
    
    // Optional events
    dbl.on('posted', () => {
      console.log('Server count posted!');
    })
    
    dbl.on('error', e => {
     console.log(`Oops! ${e}`);
    })```
This doesn't work? This is in my ready event, using `discord.js`.
https://discordbots.org/api/docs#jslib
#

@ me with answer

quartz stirrup
#

looks good

#

wdym it "doesnt work"

flint lava
#

Is there a way to make it so if someone clicks the vote button on the dbl website a message gets sent to a channel saying: (user) has just upvoted Cryptonox! My Bot is running on Discord.js

runic grove
#

set up a webhook

flint lava
#

Ok

candid spoke
#

How do i add a translation bot

#

To my server

narrow zenith
#

not the channel to ask that

short girder
#
            ^

TypeError: Cannot read property 'on' of undefined
    at Object.<anonymous> (D:\omnia-bot\omnia\bot.js:262:13)
    at Module._compile (internal/modules/cjs/loader.js:738:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10)
    at Module.load (internal/modules/cjs/loader.js:630:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
    at Function.Module._load (internal/modules/cjs/loader.js:562:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:801:12)
    at internal/main/run_main_module.js:21:11
(node:15720) UnhandledPromiseRejectionWarning: Error: Shard 0's process exited before its Client became ready.
    at Shard.once (D:\omnia-bot\omnia\node_modules\discord.js\src\sharding\Shard.js:88:39)
    at Object.onceWrapper (events.js:285:13)
    at Shard.emit (events.js:197:13)
    at Shard._handleExit (D:\omnia-bot\omnia\node_modules\discord.js\src\sharding\Shard.js:272:10)
    at ChildProcess.emit (events.js:197:13)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12)
(node:15720) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 12)```Code```dbl.webhook.on('vote', vote => {
    client.vote.inc(vote.user, 'votes')
    client.guilds.get('554742955898961930').channel.find(c => c.name === 'votes' && c.type === 'text')
    console.log(`User with ID ${vote.user} just voted!`);
  });```
short girder
#

@ me with answer

restive otter
#

@short girder what's the .webhook for?

short girder
#

idk? I'm trying to add 1 in my db to that user every vote. So that when they do o!claim. I get the amount of votes with the amount I save in my db. But idk how to work this. First time with this api before.

restive otter
#

try it without the .webhook

short girder
#

sure

#

Oops! Error: 522 Origin Connection Time-out Gives this after a while and never posts the server and shard count. Plus the websitr is giving me a 503 error

restive otter
short girder
#

Oh ok

#

Ok now no errors web fixed. No errors now, so I don't need the webhook part right? @restive otter

restive otter
#

yea

short girder
#

Ok. So it should work each time someone votes?

restive otter
#

idk i guess so

#

Β―_(ツ)_/Β―

plain timber
#

@restive otter no that's wrong

restive otter
#

oh

#

ok

plain timber
#

@short girder you need dbl.webhook.on, the error is because you didn't include the webhook settings in the new dbl line

short girder
#

Ok let me look api

#

@plain timber, I see the api, but don't know how to implement it. How?

plain timber
#

Have you seen the docs

short girder
#

api from dbl web

#

ya

plain timber
#

It has a webhook example

short girder
#

Would I need to run that separate from my bot or no?

plain timber
#

In the new dbl line you didn't put the webhook settings

#

No

#

You just need to fix your code...

short girder
#

const dbl new DBL(config.apiToken, {webhookAuth: 'password', webhook: server }, client});

#

@plain timber

#

Like this?

#

Sorry I'm new to webhooks. Haven't used them yet.

plain timber
#

It's webhookPort and webhookAuth

#

No webhook

#

Just look at the example...

short girder
#

I did

plain timber
short girder
#
const dbl = new DBL(config.apiToken, { webhookPort: 5000, webhookAuth: 'password' }, client);

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

Like this?

#

@plain timber

#

Sorry for pinging

plain timber
#

Yeah

fleet pebble
#

How does one get their server count to display on their bots page on DBL?

dawn fjord
#

You have to post your server stats via our API @fleet pebble

fleet pebble
#

What code would i put into my bot file?

#

is there a template

#

?

fleet pebble
#

cool beans

spiral steeple
#

If only you viewed the channel topic

plain timber
#

^

#

Docs are good

latent pasture
#

Hello guys !
My bot is written in Python3.7, and i'm using webhook to get the voters ID and give them some rewards.
But sometimes, DBL sends something wrong to me and it's throwing me this error :

Expecting value: line 1 column 1 (char 0)
INFO:aiohttp.access:::1 [29/Mar/2019:19:30:47 +0000] "GET /dblwebhook HTTP/1.1" 200 160 "-" "-"

ERROR:aiohttp.server:Unhandled exception
Traceback (most recent call last):
  File "/usr/local/opt/python-3.7.0/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 447, in start
    await resp.prepare(request)
  File "/usr/local/opt/python-3.7.0/lib/python3.7/site-packages/aiohttp/web_response.py", line 353, in prepare
    return await self._start(request)
  File "/usr/local/opt/python-3.7.0/lib/python3.7/site-packages/aiohttp/web_response.py", line 667, in _start
    return await super()._start(request)
  File "/usr/local/opt/python-3.7.0/lib/python3.7/site-packages/aiohttp/web_response.py", line 410, in _start
    await writer.write_headers(status_line, headers)
  File "/usr/local/opt/python-3.7.0/lib/python3.7/site-packages/aiohttp/http_writer.py", line 112, in write_headers
    self._write(buf)
  File "/usr/local/opt/python-3.7.0/lib/python3.7/site-packages/aiohttp/http_writer.py", line 67, in _write
    raise ConnectionResetError('Cannot write to closing transport')
ConnectionResetError: Cannot write to closing transport```
#

As you can see i'm using aiohttp and this line is kinda strange :

INFO:aiohttp.access:::1 [29/Mar/2019:19:30:47 +0000] "GET /dblwebhook HTTP/1.1" 200 160 "-" "-"```
Usually the line above looks like this : `INFO:aiohttp.access:::1 [29/Mar/2019:19:30:47 +0000] "POST/dblwebhook HTTP/1.1" 200 160 "-" "DBL"`

And this exception makes my bot crash.

I'm listening for **POST** requests as this line shows up : 
```python
app = web.Application()
app.add_routes([web.get('/', hello), web.get('/dblwebhook', Get_Voter), web.post('/dblwebhook', Get_Voter)])```
Do you guys have an idea on what the problem is ?
Thank you.
jovial pine
#

uhhhhhh, afaik the dbl api never GET requests

#

maybe you have something else GETting?

#

if its a public ip address (on port 80) there can be chinese web scanners that want your data

#

(also if you noticed, the DBL POST request has "DBL", but the GET request doesn't)

latent pasture
#

Thank you for your answer, i've changed the routes to app.add_routes([web.get('/', hello), web.post('/dblwebhook', Get_Voter)]) (I removed the web.get('/dblwebhook', Get_Voter))
For the moment it seems to work

The port i've chosen is the number 8000, which port should i use to avoid intrusions ?

sullen nymph
#

1-1023 are a no-no

elfin haven
#

Me and a friend have a bot in discord.js, and we are trying to post our server count to the bot list. We are doing everything correctly and no errors are posting in console, but the server count isn't posting.

spiral steeple
#

Thanks for showing the code so we can see what's going wrong πŸ‘Œ

elfin haven
#
const Discord = require("discord.js");
const bot = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('config.dblkey', bot);

bot.on('ready', () => {
    setInterval(() => {
        dbl.postStats(bot.guilds.size);
    }, 300000);
});
spiral steeple
#

well, when you provide a client, it auto posts

#

but idk why it wouldnt be posting

#

and dbl.postStats takes a client

sudden rampart
#

it posts after 30 minutes iirc

spiral steeple
#

not a number