#topgg-api

1 messages · Page 42 of 1

restive otter
#

I think it's >=300

#

@humble bison this is why I hated fetch on the client side.

#

I had to manually check whether or not the response was correct

humble bison
#

ow

coarse seal
#

How do I use Discord Webhooks to see if someone voted?

humble bison
#

setup a web server that accepts POST requests

coarse seal
#

oh ok

#

can i use the last example on the jslib docs?

coarse seal
#

How do i get the guild of a vote user?

#

vote.user.guild

#

doesnt work

#

as user doesnt have .guild

humble bison
#

votes aren't tied to guilds

coarse seal
#

ik

plain timber
#

@coarse seal since votes aren't associated with guilds naturally you can't get the guild of a vote

coarse seal
#

i got

#

i iterated through every guild the bot is in, iterated through the members in them, compared the id to vote.user.id and then gave rewards

#

smart huh

plain timber
#

Users can be in multiple guilds though

#

So no not smart

coarse seal
#

it'll give it to the first guild it finds it in

#

after all economy isn't global

#

its per-server on my bot

plain timber
#

What's the perk

#

There's probably a better way

coarse seal
#

yep

#

but it'll work for now

plain timber
#

What do you give for voting

#

You could provide a link to the vote page with the server id as a query parameter

#

It sends query params in the post request

coarse seal
#

the votes come from api

restive otter
#

don't you need like multipart (or whatever enctype webhooks use) middleware

coarse seal
#

i dont think so

#

ken is it necessary to do something is res.body

azure pollen
#

well the webhook sends the user id who voted and what not in res.body

#

1 sec and ill make a quick app and test it

coarse seal
#

o.0

#

but how would we store the req?

#

in an object var?

restive otter
#

however you want to store it :D

azure pollen
#

sec

coarse seal
#

@azure pollen ya here?

azure pollen
#

working on it

#

1 sec

restive otter
azure pollen
#

im commenting the code and making it legible

#

calm ur tiddies

restive otter
#

ew

#

organized code

#

what kind of person does that, i just put all my 3k lines of code in 1 file with bad indenting and no commenting

azure pollen
#

congrats

#

you're a great coder

#

👏

coarse seal
#

lol

restive otter
#

thanks

#

my self-confidence levels are soaring

coarse seal
#

yeah if my code isn't documented i would die

restive otter
#

the most organization i have is grouping commands by perms

#

so like the code for administrator commands are all in the same spot

coarse seal
#

i have organized my package-json alphabeticaly and my cmd groups aso

#

also*

azure pollen
#

A manually coded webhook example. (NODE.JS)

const express = require('express');

// creates a new express app
const app = express();

// does the dirty work for us and parses the request body
const bodyParser = require("body-parser");

// the port the express app will run on
const port = 3333;

// the super secret authorization token so nobody can cheat the system
const token = "here is some super secret token!!!!";

// just sets the bodyParser stuff, nothing to worry about
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));


// these are just examples of the content you may receive!
const EXAMPLE_MESSAGE = {
    bot: '00021412412414',
    user: '00021412412414',
    type: 'test',
    query: '?test=data&notRandomNumber=8',
    isWeekend: false
};
const EXAMPLE_HEADER = {
    'user-agent': 'DBL',
    authorization: 'some lit auth token here',
    host: 'this.should.be.your.IP:andPORT',
    accept: 'application/json',
    'content-type': 'application/json',
    'content-length': '???',
    connection: 'close'
};


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

    // put the request body in a variable for use after we respond
    const message = req.body;
    const headers = req.headers;

    // check if the headers exist (good practice) and check if the authorization in the headers match the token we have saved as "token"
    if (headers && headers.authorization === token) {
        // tells the sender that the webhook sent successfully
        res.status(200).send(); 

        // do whatever you want with "message" here

    } else {
        // tells the sender they are forbidden because their authorization token is incorrect!
        res.status(403).send();
        // do nothing
    }

});


// this starts the express app and begins listening to the port we asked it to
app.listen(port, () => {
    console.log("Webhook server is listening on port: " + port);
});
#

that blur should have something like
324.242.242.242:3333 (the IP and PORT to your webhook catcher)

coarse seal
#

umm

#

dont roast me

#

but i run it on GLITCH omg

azure pollen
coarse seal
#

🤷

azure pollen
#

well it's not gonna work for you then

#

sorry

#

lmao

#

get good <3

coarse seal
#

i can specify the url

restive otter
#

i dont see what wont work about glitch

azure pollen
restive otter
#

its just a subdomain

coarse seal
restive otter
#

yeah

#

that should work

coarse seal
#

might work?

#

LEEMMME ***** TEST IT

#

omg

restive otter
#

i mean i'm a certified by website administrator great coder so i know what im talking about

coarse seal
#

so it'll work?

#

k lemme test it

azure pollen
#

my message is JUST BELOW 2000 chars

#

would ya believe it

restive otter
#

nice

azure pollen
#

it is tested and works

#

so yes

restive otter
#

glitch is great for small test apps

azure pollen
#

i'd just hire a server for a couple hours if i was doing a test app

restive otter
#

and ok for free "hosting" (aka shit)

azure pollen
#

it only cost like a couple cents

#

literally

restive otter
#

yeah

#

there was this study done

#

where people analyzed how people react to free vs a couple cents

#

who could have guessed, its a strong difference to the human mind

#

so a lot of people aren't prepared to pay 4 cents for a server

azure pollen
#

lmao

coarse seal
#

ken

azure pollen
#

yo

restive otter
#

also a lot of people might not even have means to pay because they're like 13

coarse seal
#

it wont work

#

the code wont

restive otter
#

yeah we need more info

coarse seal
#

as the express server ISNT HTTP

#

lol

azure pollen
coarse seal
#

rip

restive otter
#

express is an http server...

coarse seal
#

i tried lmao

azure pollen
#

tried googling

coarse seal
#

throws an error

#

you needa to http.server(app)

azure pollen
#

it's probably because there's specific ports you're allowed to use and not allowed to use

coarse seal
#

or smthing

restive otter
#

make another express application

#

if you want different ports

#

and if you mean for glitch, then idk just uh like... don't use glitch or something

azure pollen
#

from what i've heard

#

i'd bite the bullet and pull together a couple dollars a month

coarse seal
#

if (server && !(server instanceof Server)) throw Error('The server is not an instance of http.Server');

#

dblapi.js

#

meh

restive otter
#

ok just run require("http").createServer iirc

coarse seal
#

i did

#

and it worked

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

why this not firing?

restive otter
#

because the webhook isn't ready

coarse seal
#

yeah but why isn't it?

#
const dbots = new DBL(process.env.DBL, { webhookAuth: process.env.authToken, webhookServer: server }, client);
#

is there

#

should i remove webhookAuth?

#

as it does check it in app?

azure pollen
#

you either use the dbl api example

#

or you use the manually coded example

#

you don't use both

coarse seal
#

THATS WHY IT WAS FUCKED up

azure pollen
coarse seal
#

stilll fucked up

#

lmao

#

it doesnt take 5 mins for such a small express app to initilize

#

well

#

the server initializes but

#

the webhook doesnt

#

fucc

azure pollen
#

huh

coarse seal
#

atleast now i know the ip of uptime robot lmao

#

@restive otter

#

in the url thingy on dbl

#

i would out:

#

does test use your own ip to POST the bot?

plain timber
#

@coarse seal no it sends it from dbls server

coarse seal
#

test button

coarse seal
#
const message = req.body;
    const headers = req.headers;
        console.log(message + '\n\n' + headers)
#

for the request from DBL

#

Output:

#

meh, why is it empty?

elfin solstice
#

Cause its an object, inspect it

sand hazel
#

Kek

twilit quiver
humble bison
winged star
#

@arctic arch

#

IncomingMessage.res.on (/rbd/pnpm-volume/c841a381-532c-47ce-b09f-dd3a3ad13c6d/node_modules/.registry.npmjs.org/dblapi.js/2.2.0/node_modules/dblapi.js/src/index.js:115:25)

#

...?

#

dblapi.js/src/index.js

arctic arch
#

that doesnt tell anything

winged star
#

Error: 403 Forbidden

#
(node:8736) UnhandledPromiseRejectionWarning: Error: 403 Forbidden

at IncomingMessage.res.on (/rbd/pnpm-volume/c841a381-532c-47ce-b09f-dd3a3ad13c6d/node_modules/.registry.npmjs.org/dblapi.js/2.2.0/node_modules/dblapi.js/src/index.js:115:25)

    at emitNone (events.js:111:20)

    at IncomingMessage.emit (events.js:208:7)

    at endReadableNT (_stream_readable.js:1064:12)

    at _combinedTickCallback (internal/process/next_tick.js:139:11)

    at process._tickCallback (internal/process/next_tick.js:181:9)


(node:8736) 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: 1)

(node:8736) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
arctic arch
#

so your token is wrong

winged star
#

hmm

#

regen

#

Same

arctic arch
#

what function are you calling

restive otter
#

So I have this

const DBL = require("dblapi.js");
const dbl = new DBL('token', {webhookPort: 5000, webhookAuth: 'password'}, bot); // "bot" is just the Discord.js 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(`Vote registered - User: ${bot.users.get(vote.user).tag}`)
});

And I have no idea what to put in these two boxes, or what to put where 'password' is, I've tried a few things and read the entirety of the API section on the website and the "vote" event never seems to trigger.

#

url prints in console tickYes password in the code tickYes still has no clue what the url or authorization areon the page tickYes classic dbl tickYes

#

ok thats it for today folks im off to bed

#

Thanks...?

plain timber
#

@restive otter the url is the IP or domain with the port and path, dblapi.js should log it to the console but if it says 0.0.0.0 you need to change that to the domain/IP
And the authorization is whatever you set as webhookAuth in the code

restive otter
#

That's what I thought - Thanks for the help

restive otter
#

Damn..

#

the webhook api worked fine

#

till a few weeks ago..

#

no requests are coming in from the site either

#

even test fails

#

Help?

#

I havent changed anything either..

shut ibex
#

Webhooks work for me

restive otter
#

Appearently my router gave itself a new ip ._.

#

yeah that doesn't just happen.

topaz wyvern
#

^

shut ibex
#

the router can assign u a different one

restive otter
#

Wait, you have to replace 0.0.0.0 to your IP?

#

I wish I knew that earlier

#

0.0.0.0 is a special IP address signifying all open network interfaces or some shit like that

#

so yeah don't use that in your webhooks

loud gulch
#

0.0.0.0 is localhost?

topaz wyvern
#

no

#

127.0.0.1 is iirc

restive otter
#

yeah

#

or just localhost

sudden rampart
#

0.0.0.0 is used to bind to all local interfaces

#

eg you have x.y.z.1 and z.y.z.2 ips

#

0.0.0.0 would bind to both

sand hazel
#

@arctic arch Hey, how is the ratelimit on the DBL API implemented? It says 60/m, but is it 1/s, or like it's total in a minute

sudden rampart
#

60/minute

#

you could do 60 in one second

#

then wait 59 seconds

sand hazel
#

Alright, thanks

glass wyvern
restive otter
#

@glass wyvern you need to be certified

glass wyvern
#

oohh, okey, What do you need to get certified? @restive otter

restive otter
#

@glass wyvern certification apps are closed right now

#

so you can't

glass wyvern
#

ahh, all right, thanks papaoS2 @restive otter

restive otter
#

np

indigo trout
#

Im using dblapi.js, and cant get any requests to come through to my code at all (all that fires is the ready function). I tried many things, even like above changing the hostname to my Ip but still cant get the vote function to fire. Any Ideas?

#
const DBL = require('dblapi.js');
const dbl = new DBL(dbltoken, { webhookPort: 5000, webhookAuth: 'passpass', webhookPath: '/test' });
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`--- VOTE ---`);
});
dbl.webhook.on('test', test => {
    console.log(`--- TEST ---`);
});
sudden rampart
#

with that port + path

#

it'd be http://your.ip:5000/test or https://your.ip:5000/test if you have SSL configured

indigo trout
#

yea thas what I have, and nothing happens when I vote, or test

restive otter
#

Hmm..I just thought of an idea:
dblapi.js should be in the form of an express middleware

#

it would integrate so much better with express-based http frameworks

#

you literally do

const dl = require('dblapi.js');
const dbl = new dl(token);
const app = require('express')():
app.use(dbl())```
#

and boom, your route is configured

crude dock
#

so uhm... hey everyone! I've been wrapping my head around this for a few minutes now. My test button does absolutely nothing, I can successfully make http posts to my webserver, but putting the url and hitting test just doesn't do anything. I even created a url on https://webhook.site to see if the test button sends anything, but didn't work. Any one can shed some light? I'm using flask and python to catch the http posts

indigo trout
#

When placing the IP into the URL for the webhook, is it public Ip, or local Ip?

humble bison
#

public

indigo trout
#

It does not seem to respond to anything but the ready event. Is there anything I'm missing?

const DBL = require('dblapi.js');
const dbl = new DBL(dbltoken, { webhookPort: 5000, webhookAuth: 'passpass', webhookPath: '/test' });
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://(my public ip):5000/test`);
});
dbl.webhook.on('vote', vote => {
  console.log(`--- VOTE ---`);
  console.log(vote)
});
dbl.webhook.on('test', test => {
    console.log(`--- TEST ---`);
    console.log(test)
});
humble bison
#

@indigo trout have you tried the test thing

restive otter
#

@shut ibex the router ITSELF assigned a new ip

#

not the device where my webhooks are coming in

#

Cuz that ones static

#

but ig router isnt

restive otter
#

how can you even get a token

restive otter
#

on ur bot's edit page at the webhook section @restive otter

#

Yeah i got it

#

Thank you

#

np

indigo trout
#

@humble bison yea I have voted on it, pressed the test, no response

#

Also sorry, I was sleeping

restive otter
#

Wat

indigo trout
#

Wut, I didn’t mention you

restive otter
#

@indigo trout U did

and wym no response?

indigo trout
#

So I hit test, nothin, I hit vote on my own, nothing responds in the codes end. The webhook only responds to the ready event and that’s all

restive otter
#

Lol

#

@indigo trout Where do u host ur bot (where the webhook is supposed to send to) on?

#

pc? vps?

#

You need to get the router's IP
so like 0.0.0.0:FORWARDED PORT/dblwebhook for it to work if its hosted inside ur house

#

on a vps idk

marble urchin
#

I regenerated the token several time

#

and copy pasted the code of the documentation

#

I set the asyncio.sleep at 10sec for testing purposes

indigo trout
#

@restive otter I’ll try that. Thanks for the help!

restive otter
#

np

#

It worked for me so.. xD

sullen nymph
#

@marble urchin Does that happen when the bot is starting?

marble urchin
#

Yes

#

But also every time the function runs

sullen nymph
#

Wrong DBL token, it seems

marble urchin
#

no

#

not possible

#

I regenerated it several time

#

copy pasted it

#

several time

sudden rampart
#

is the token for the same bot

marble urchin
#

Yeah

#

Well here is the situation

#

I have 2 bots

#

and the one i'm having issues with

#

is destined to replace the old one

#

I stopped using DBL with the old bot

#

so it should work

#

since I removed the code part for DBL

marble urchin
#

on the old bot

#

Yeah ok

#

But then

#

why do I have this

#

(sorry for paint mouse skills tho)

sudden rampart
#

/shrug

#

can you try manually doing the request?

#

with eg postman

marble urchin
#

how do I do this ?

#

teach me senpai

#

and still having the error

marble urchin
#

@sudden rampart

long spade
#

Why do people use dblpy at all? Using aiohttp manually is better 🤔

sullen nymph
#

L a z i n e s s

marble urchin
#

at this point I think i'm going to do it the old way

#

coding a python package is nice. It's better if it's working

#

And now It works

#

thanks for the help

indigo trout
#

For webhooks, do you need a custom router forwarded port, or can you use like port 80?

restive otter
#

Can you have two bots use the same IP and port for their individual votes?

#

@indigo trout I'm pretty sure as long as the port is forwarded in your router, you can use any port you like. However 80 is a common port used for things like Http so unless you're really not using it setting it to port 80 might be a bad idea

distant dove
#

What can you do with the API except updating your bot's guilds count ?

tidal burrow
#

take a look at the docs and see for yourself

restive otter
#

@distant dove updating shard count, if the bot uses shards, and seeing who's voted for your bot - but as Deivedux said, you should check out the API page: https://discordbots.org/api/docs

dawn kernel
#

did webhooks break again or did something change?

#

altough it might be me switching from apache to nginx

#

idk

dawn kernel
#

yhe I forgot I was using apache_request_headers

opal hollow
#

What are shards?

humble bison
opal hollow
#

ok

coarse seal
#

Umm...

#

This doesn't respond to both ready and vote events.

#

Although, When I use the TEST button.

last cedar
#

for some reason i cant press the Test button

#

like i pressed it but nothing happened

plain timber
#

Did you try reloading

last cedar
#

yes i have

#

still doesnt work ;/

#

am i doing something wrong?

#

i can press the save button

#

but not the test

#

@azure pollen can u help me?

azure pollen
#

have you looked at the pinnged messages and made sure it's coded right

last cedar
#

yes i have

azure pollen
#

most likely a problem with your code and not with the test button itself

last cedar
#

do i have to put exactly as EXAMPLE_HEADERS?

azure pollen
#

no 😩

#

that's just an example

last cedar
#

oops srry

#

im still confused on y its not working

#

what happens if ur hosting on glitch? what do i need to put for host? @azure pollen

azure pollen
#

¯_(ツ)_/¯

#

i don't glitch

last cedar
#

AHH

arctic arch
last cedar
#

ok?

#

for both discordbots url section and glitch host?

arctic arch
#

glitch host?

last cedar
#

const header = {
host: link
}```
#

thats what i meant for glitch host ^

#

nvm

arctic arch
last cedar
#

i got
Cannot GET /

arctic arch
#

mmhm

last cedar
#

🤔

arctic arch
#

because there is no get routes

last cedar
#

which means?

arctic arch
#

you need to do a post request to the correct path

last cedar
#

;o

#

hmm

coarse seal
#

@azure pollen help me

#

@arctic arch

restive otter
#

are u out of ur fuckin mind?

sand hazel
coarse seal
#

@restive otter ummm....
No, my mind is in body.

quick rain
#

How to get an API token ?

copper vapor
#

You go to the api section and request token I think

#

On the website

turbid wave
#

Why am I getting this error?

plain timber
#

@coarse seal don't mention admins

mystic wing
#

@turbid wave make sure the values are correct

#

Ie token: value

turbid wave
#

how do I run it @mystic wing With like node index.js

mystic wing
#

it will startup when you run the file

turbid wave
#

Ok so I run it with node index.js

#

@mystic wing

latent sparrow
#
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});``` ok so I have this running but every time someone votes nothing pops up
topaz wyvern
#

You probably arn't running the webhook properly

latent sparrow
#
var sender = message.author.id;
  dbl.hasVoted(sender).then(voted => {
    if (voted) return message.channel.send("Thou has perks (coming soon near you)");
    else return message.channel.send("Thou is not worthy of such perks. Vote here to get perks: http://bit.ly/vote_botty");
  });
  
}```
#

I also have that

#

and it works perfectly

plain timber
#

@latent sparrow did you set the webhook info in ur bots edit page

latent sparrow
#

yes

#

its all setup correctly

plain timber
#

@solid owl this is for questions about the DBL API as it says in the channel topic, for bot development questions go to #development

solid owl
#

sry

last cedar
#

For some reason people say they voted but my bot didnt say anything about them voting

coarse seal
#

@last cedar same with me

restive otter
restive otter
#

cuz ur browser sucks?

restive otter
#

No but srsly it depends what browser u use lol

#

the code behind the button isn't supported on every browser

tiny nebula
#

yeah sure it's magic code

#

something that only runs on Chrome

brave pond
#

Funny enough I can't click either of those on chrome

plain timber
#

Works for me in chrome

urban pawn
#

anyway of finding out new bots that have been added?

#

(ping me)

brave pond
#

funny enough

#

after I complained it didn't work. it started working

plain timber
#

Lol

past reef
#

Okie dokie, so I have a thing set up in Nerdcore Radio, that checks for the vote of a message sender(JavaScript library on discord.js), and it returns a 401 Unauthorized error. I have regenerated the API token of the bot and saved it too, but it seems like I keep getting the same error. I'll share some of the code here.

const yt = require('ytdl-core');
const stripIndents = require('common-tags').stripIndents;
const DBL = require('dblapi.js');
const utils = require('../utils');

const dbl = new DBL(process.env.DBL_TOKEN);

dbl.hasVoted(message.author.id).then(voted => {
        if(voted === false) {
            message.channel.send({
                embed: utils.embed(`Error!`, `You didn't unlock this radio! Please [vote for the bot](URL) to unlock this radio!`, [], {
                    color: "#ff0000"
                })
            });
        } else {
        // Do Stuff
        }
}

Any idea how this is possible?

plain timber
#

401 means no token

#

403 means wrong token

past reef
#

Oh?

plain timber
#

try console.log(process.env.DBL_TOKEN)

past reef
#

Sure, hold on.

topaz wyvern
#

does dblapi.js take in client also?

plain timber
#

thats for autoposting

topaz wyvern
#

ah okay

plain timber
#

its optional

past reef
plain timber
#

interesting

#

idk why ur getting a 401 then

past reef
#

It also seems like the bot only does this in the command file itself, instead of everywhere, because server count and such are posted to the DBL without any trouble.

plain timber
#

are you using the latest version of dblapi.js?

past reef
#

Oof, I gotta check, hold on.

#

Yep, latest version is installed.

#

OH WAIT--

#

It works now!

plain timber
#

oof

restive otter
#

console.log doesnt have a return value

#

so ofc it will log to console but eval will return undefined

#

most likely wrong token

restive otter
#

Can somebody tell me how can I prevent users getting multiple perks after voting?

#

like doing to vote command multiple times and get multiple perks

light crag
#

That's your own problem.

last cedar
#

How to send a message on discord once u upvoted?

#

using the dbl.webhook.on thing

restive otter
#

boi

#

just get the channel u want a message to be sent to
and put that in the vote event

restive otter
#

Can someone tell me the .hasVoted thing test if the person has voted for the bot past 12 hours or 24 hours?

humble bison
#

read the docs

restive otter
#

It says 24 hours but can I know a way to make it 12 hours?

#

Is there a way*

humble bison
#

don't think so

#

just 24 hours

restive otter
#

ok then

plain timber
#

@restive otter iirc it's actually 12 hours and the docs are wrong

#

But an admin needs to confirm that

restive otter
#

Yea i guess the docs havent been updated yet

#

cuz since they announced the 12h voting it was changed in the hasVoted too

mighty glacier
#

How can I get on vote function that will post who voted for bot in Python?

solemn dust
#

Anyone know why my bot can't mention everyone? bot.channels.get("***INSERTCHANNELID****").send(" This is a test to see if I can announce @everyone ")
I'm using discord.js and I cant seem to find anything about this issue.. They say you just type @everyone for it to work

#

Also I've checked permissions on the server and they are all set properly 🤔

#

yup didn't see I had disableEveryone set to true on my client options 🤦

dawn kernel
#

you can just do <@guildId>

open garden
#

Post your server count to our API. How do you do that?

dawn kernel
#

read the api documentation

open garden
dawn kernel
#

get your desired library

open garden
#

Ah ok ty.

dawn kernel
#

np

terse nebula
chrome canyon
#

😡 😡 😡 😡 😡 😡

restive otter
#

How to get an API key ?

#

🔠

plain timber
#

@restive otter its in api docs and your bot's edit page

#

@terse nebula what's the issue

restive otter
#

Thanks

#

How long does .hasVoted take to update the fact that someone has voted

#

ping me if u have the answer n ill see when i get back

terse nebula
#

never mind

#

it was a json mismatch

plain timber
#

@restive otter probably instant but it only checks the last 12 hours

restive otter
#

in the api is there something that has a timestamp for every person?

digital linden
#

is there an npm for the discordbots?

#

is it dblapi.js?

arctic arch
#

yes

digital linden
#

ok

restive otter
#

fellas, is it just me or are vanity and legacy no longer returned in a /bots/id call?

sand hazel
#

Hm I'll validate

restive otter
#

i dont see it so im wondering

sand hazel
#

Yeah it's not there

#

fun

restive otter
#

dang i wish i were able to read that

#

but yeah ouch

sand hazel
#

yeah idk who's maintaining the api atm

restive otter
#

applies

#

api docs*?

topaz wyvern
#

api docs are really outdated rn

restive otter
#

ye

sand hazel
#

I added the two field

#

but I only found out when I did an actual request

restive otter
#

dang i wish i could read that

#

oh wait youre that reaction role guy

sand hazel
#

Yeah

plain timber
#

lol

sand hazel
#

who do people know me as the reaction role guy

restive otter
#

dang epic bot ok back to the nitty gritty does discriminator not show # anymore?

plain timber
#

cuz u are

restive otter
#

that code almost makes me wanna learn go

#

yeah go away amirite lmeo

sand hazel
#

I do clean code

restive otter
#

wait wtf that's vscode

#

no wonder my eyes want to die

plain timber
#

yes u just noticed

sand hazel
#

yeah I love this theme

restive otter
#

sorry its hard for me to notice cancer when i see it

sand hazel
restive otter
#

wait did you make dbl go?

plain timber
sand hazel
#

I made go-dbl

plain timber
#

its unofficial

restive otter
#

but there really out here being one already

sand hazel
#

I requested a replacement of dblgo, but I haven't gotten a response yet

plain timber
#

turtlegamingftw made the official dblgo

restive otter
#

i requested my beautiful library to be added and they responded to my initial email but not my 2nd one

plain timber
#

didn tthey not respond to ur first one

restive otter
#

to be fair it was 5:13 am when they responded

plain timber
#

then they responded to ur second one

#

but not ur third one

sand hazel
#

the official dbl go lib atm is unmaintained and exits fatally

restive otter
#

there's 2

plain timber
#

ooof

restive otter
#

how long was Go library existed?

plain timber
#

@shut ibex zoomeyes

shut ibex
#

what

sand hazel
#

Yeah I've talked to him

plain timber
#

yes how long was it existed

#
Fishy!Today at 7:12 PM
the official dbl go lib atm is unmaintained and exits fatally
sand hazel
#

3 months ago?

restive otter
#

thought that said exists

shut ibex
#

it existed for 4 months and was added 1 couple days ago

#

I stopped maintaining it because they never added it to the site

#

so

#

¯_(ツ)_/¯

plain timber
#

they did

#

oh

restive otter
#

shouldn't tools be renamed libraries

plain timber
#

oof

shut ibex
#

they did 4 months late

plain timber
#

r u gonna fix it?

sand hazel
#

and the actual API doc is outdated

restive otter
#

inb4 library merge

shut ibex
#

no im not

#

my repo will be deleted

plain timber
#

oof

shut ibex
#

and fishys will take over

plain timber
#

is that y u lost the pink role

shut ibex
#

me and fishy talked about this

plain timber
#

and cert

restive otter
#

rip cert

shut ibex
#

dont even get me started about cert

sand hazel
#

I doubt my will even be imported for another couple months

#

My lib was created in need of my bot

restive otter
restive otter
#

ok

urban pawn
#

is there anyway of finding out everyone who has voted for ur bot?

#

(ping me if you know)

restive otter
urban pawn
#

ok ty

#

im making a request to get the votes on my bot is the header like this Authorization:{api token}

restive otter
#

yes

urban pawn
#

ok

#

im getting sent info about me

restive otter
#

wdym

urban pawn
restive otter
#

because youre the only voter (i think)

chrome canyon
#

I can decipher that token

urban pawn
#

oooo

#

i get it now

#

lol ty

restive otter
#

Someone has an better example of Webhooks?

arctic arch
#

what example are you trying now

ocean shell
#

is there an alt to the dblgo lib? or is it still maintained

loud gulch
#

go-dbl

#

iirc

restive otter
loud gulch
#

^ that

ocean shell
#

thx, any reason why the official one is not being updated

loud gulch
#

its not official

#

anymore

restive otter
#

Yep, the dev waited 4 months and it never got marked as official until a few days ago, so he abandoned it, and fishy (rumblefrog) made his own, so they're working together to replace the old, dead one with that new one

ocean shell
#

sounds good, it's just that the official one randomly quits my bot

restive otter
#

yeah

#

it exits fatally

ocean shell
#

may I know who's in charge of maintaining the api libraries

restive otter
#

it's various people

ocean shell
#

it's scary that no issue exist on that repo regarding that problem and it's been approved as an official lib

restive otter
#

well as i said, it was fine 4 months ago when he applied for it to be official

sand hazel
#

I think it's mainly the percentage of the devs that uses golang at all, and I don't think any admin is familiar with it

#

I've talked to Tonkku about it, just matter of time now.

ocean shell
#

well i hope @arctic arch will fix this before another bot randomly quits, i thought it was my code's issue

#

i'll go fix my code now, thx guys

arctic arch
#

the old go library made your bot quit

#

you mean stop the code?

sand hazel
#

@arctic arch log.Fatal quits the process

shut ibex
#

^

sand hazel
#

it's similar to process.exit() in js

shut ibex
#

I was stupid when creating the lib

#

ok thanks

sand hazel
#

it's ok, you'll learn eventually

arctic arch
#

gg

plain timber
#

replace to go library

#

google home hub?

sand hazel
#

to go

#

looks like one of those office room reservation thingy

#

¯_(ツ)_/¯

arctic arch
#

my room is my office so

restive otter
#

yo how do I add so it shows how many servers the bot is on
like on the web

dawn fjord
#

What language are you using?

restive otter
#

JS

dawn fjord
restive otter
#

ty

restive otter
#

How can i send server count to api?

mighty shuttle
#

Please don't invisible ping me

sullen nymph
#

Use an official DBL library for your language if there's one, otherwise do manual HTTP requests

blazing umbra
#

Can I get help on using the api on upvote and then rewarding the upvoter after?

restive otter
#

How to post Server Count to API

#

I dunno understand

#

there's

#

examples

#

in

humble bison
#

stop

#

linking

#

to

#

that

#

channel

#

its out of date

restive otter
#

it's out of date

#

but some still work

clever rock
#
const fetch = require('node-fetch');
 fetch(`https://discordbots.org/api/bots/YourBotID/stats`, {
    method: 'POST',
    body: JSON.stringify({ 'server_count': guilds?, 'shard_count': shards? }),
    headers: { 'Content-Type': 'application/json', 'Authorization': urQtToken }
}).catch(console.error);
#

here is an example using nodefetch

arctic arch
#

I feel like I need to point out the obvious
that has to be in an async function

chrome canyon
#

or if you prefer superagent for readability

const req = require('superagent');
(async () => {
    await req
        .post(`https://discordbots.org/api/bots/YOUR_BOT_ID/stats`)
        .set('Authorization', 'YOUR_TOKEN')
        .send({ 'server_count': GUILDS, 'shard_count': SHARDS})
        .catch(e => console.error(e));
})()
clever rock
#

thought they would know that, but anyways, changed it™

modern notch
#

hello

restive otter
#

@chrome canyon Lol. is that even how you call an anonymous function

chrome canyon
#

idk but it says async

#

so it gotta work

#

😤

restive otter
#

yeah. its not

#

if you're going to write an anonymous function like that, you have to wrap it in () and actually call it

chrome canyon
#

I mean it's not like I care

#

it's just to demonstrate you need async

#

¯_(ツ)_/¯

restive otter
#

People copy paste that and expect it to work. lol

chrome canyon
#

okay

#

ma'am

#

this should be better if I'm not mistaken

restive otter
#

Please, spoonfeed me more code

chrome canyon
#

lmao

#

yeah

#

opinion on fetch engines?

restive otter
#

fetch engines?

chrome canyon
#

node-fetch, snek, request

#

blabla

restive otter
#

You mean http clients? lol

chrome canyon
#

SHHHHHH

#

I DON'T KNOW MY TERMS

#

no need to show everyone

restive otter
#

axios all the way.

chrome canyon
#

oh, why?

restive otter
#

Easy to use api, good with promises.

#

works isomorphically.

chrome canyon
#

hmmm I decided for superagent because of speed

#

and because I like the api

#
http.request GET  request x 14,176 ops/sec ±7.08%  (64 runs sampled)
http.request POST request x 17,465 ops/sec ±9.97%  (68 runs sampled)
superagent   GET  request x  7,778 ops/sec ±11.02% (58 runs sampled)
superagent   POST request x  9,754 ops/sec ±8.94%  (72 runs sampled)
snekfetch    GET  request x  6,656 ops/sec ±10.64% (60 runs sampled)
snekfetch    POST request x  6,274 ops/sec ±7.05%  (63 runs sampled)
node-fetch   GET  request x  5,327 ops/sec ±13.20% (60 runs sampled)
node-fetch   POST request x  4,960 ops/sec ±11.07% (55 runs sampled)
axios        GET  request x  3,307 ops/sec ±12.19% (65 runs sampled)
axios        POST request x  3,483 ops/sec ±11.82% (64 runs sampled)
Request      GET  request x  2,784 ops/sec ±7.77%  (58 runs sampled)
Request      POST request x  4,103 ops/sec ±16.06% (67 runs sampled)
got          GET  request x  2,223 ops/sec ±4.62%  (70 runs sampled)
got          POST request x  2,509 ops/sec ±3.51%  (74 runs sampled)
#

this my last bench

#

and well

#

yeah.

restive otter
#

Hmm, these numbers are good and all, but I can't say that they make enough of a difference for me to care much

#

if I really cared about speed, I'd use http.request

chrome canyon
#

you wouldn't

#

that's a pain in the ass

#

but thing is

#

axios and superagent have a similar api

#

but it's a third of the delay

restive otter
#

does superagent reject on non-200 error codes?

chrome canyon
#

who knows

#

yes it does

#

afaik

#

owo

jade pebble
#

does the api supports voting?

shut ibex
#

why wouldnt it

jade pebble
#

idk 'cause I never used it.

tidal burrow
#

support voting?

jade pebble
#

this I mean, like I want to put a command for my bot so that any user can just vote inside discord.

topaz wyvern
#

That's not possible afaik

humble bison
#

impossible

jade pebble
#

oh thanks for letting me know.

topaz wyvern
#

Np

jade pebble
#

does the api supports typescript?

humble bison
#

but if you set it up then yes

jade pebble
#

I think its fine. here

loud gulch
#

@jade pebble you can use an api in any language if there is a way to make a http request

jade pebble
#

no I've already made it.

jade pebble
#

or I can use discord's webhook?

loud gulch
#

you have to make your own webhook server

jade pebble
#

damn.

shut ibex
#

You can make ur own webhook server and trigger the discord webhook your self

jade pebble
#

how? I'm lazy right now.

restive otter
#

Set up an http server, with a route that accepts POST requests

#

handle the response as you wish

jade pebble
#

lol, that's it?

restive otter
#

yes

restive otter
#

It's simple really

silk tree
#

What is the "bot" passed into the _init_ meant to be? Is it a user object of the bot?

sand hazel
silk tree
#

So a discord.Client object will do?

sand hazel
#

should

#

try it

silk tree
#

Alright, thanks

restive otter
#

okay so I recently added so that it shows servers on the website

#

but it only shows if I click view.

#

does it take time to show outside of that or?

shut ibex
#

wdym

restive otter
#

Nvm I got it

last cedar
#

How do I know which user voted?

#

without the id?

plain timber
#

@last cedar can you explain?

last cedar
#

like if someone upvoted

#

u get their username

#

not the id

#

also u dont ping him using @

restive otter
#

U get their id lmao

#

not username

#

But if u want to get their username then just call client.users.get('the id') then get their username

sick egret
#

guys, I need help with webhooks

#

I have this code

#
const express = require('express');
const http = require('http');
const app = express();
const server = http.createServer(app);
const DBL = require('dblapi.js');
const dbl = new DBL(`Bot token here`, { webhookAuth: 'my password here' ,webhookServer: server});
dbl.webhook.on('ready', hook => {
  console.log(`Succes, webbhook running on http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
    console.log(`User with ID ${vote.user} just voted!`);
    });
app.get('/', (req, res) => {
  res.sendStatus(200);
});

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

I just don't know what to put in the webhook hurl in the dbl bot page

#

url*

restive otter
#

where do u host ur bot on

sick egret
#

on a vps in digitalocean

restive otter
#

then get that vps's IP, (make sure port 5000 is open)

sick egret
#

it is

#

and I have the ip, I just don't know what to put there

restive otter
#

then put that ip into the ip

#

so like 0.0.0.0:5000/dblwebhook

sudden rampart
#

http://

restive otter
#

0.0.0.0 would be the ip

#

Ye srry lol

#

with http://

sick egret
#

ah

#

I was doing without the dblwebhook

#

thx

#

I'll try

restive otter
#

ok np

sick egret
#

hmmm not working

#

maybe I'm missing something

#

is enough with that code and having the ip and port or I must do something more

#

ah wait

#

I have wrong token in config

restive otter
sick egret
#

well nope

#

still pointing to 0.0.0.0

light pollen
sick egret
#

nvm got it working

#

I wrote in the url dlb instead of dbl

azure pollen
#

look at the api docs

sick egret
#

Dw man, got it working, just a typo in the link

daring garnet
#

i get 403 forbidden when attempting to get/check votes https://discordbots.org/api/bots/510114241307607051/votes (this isnt my bot btw this is just a bot with less than 1000 votes to see what "simple user" means)

getting just the bot works fine tho

arctic arch
#

only the owner of the bot can get the votes

daring garnet
#

o.... how is that authorized?

#

or i should check

#

found it

#

thx mighty tonku, ur rust bindings be dun soon

restive otter
#

Thanks!

daring garnet
#

how come some of the api is snake case, like bot stats, while the rest is camelcase

mighty glacier
#

Any example on how to use webhooks in Python?

restive otter
#

if you're using discord.js

restive otter
#

i'm using JDa Java

topaz wyvern
sweet skiff
#

What is a discord bot server
Without a bot commands channel

mighty shuttle
sand hazel
#

what is u blind

sweet skiff
#

Hey don't blame me if I didn't see it

sand hazel
jade pebble
#

don't blame us if we blame you.

mighty shuttle
#

Okay thats enough

jade pebble
smoky trench
#

when it posts server count

mighty glacier
#

Any example on how to use webhooks in Python?

plain timber
#

@mighty glacier you'll need to set up a webserver to receive post requests

jade pebble
#

and you can make a web server using python. other options are php, nodejs, ruby on rails, etc.

restive otter
#

But python http servers suck

mighty glacier
#

Idk how, still new at coding 😕

smoky trench
#

and python web server tutorial would be fine

#

you just need to listen for a post request, nothing difficult

mighty glacier
#

It would be much easier if the Dbl could post through discord webhooks

#

I'm not gonna try to make web server

jovial idol
#

can i use dbl.webhook.emit("vote", message.author);
to make an fake vote event ?

arctic arch
#

well, yes

jovial idol
#

thanks

restive otter
#

@arctic arch why cant we use discord webhooks tbh?

#

All you'd have to do is send the correct payload to the discord webhook endpoint

arctic arch
#

thats not the purpose

restive otter
#

I'm not sure I understand

#

The webhooks are supposed to notify when a user has voted for the bot

#

Giving people the option to send to a discord channel may be just enough for most

azure pollen
#

just catch the webhook and send the user a DM
or better yet, send it to a channel yourself

#

it's so you can retrieve the data from the upvote and reward accordingly

sly pivot
#

🇹🇷

alpine fox
#

🇦🇿

sly pivot
#

🥚

alpine fox
#

Neii

azure pollen
#

@alpine fox @sly pivot those emotes do not belong here and do not contribute to the conversation, please refrain

sly pivot
#

Why

azure pollen
#

because those emotes do not belong here and do not contribute to the conversation

frail lance
#

Does the votes reset every month?

plain timber
#

Monthly votes reset but all-time votes don't, in the API points is all time and monthlyPoints is monthly

surreal barn
#

https://i.imgur.com/7DvUU6G.png

Shit code, I did it for testing ONLY, but can anyone explain why in the right mind it doesn't get user on webhook request? It's hitting the URL when the vote is done, but NO get or post is given by DiscordBots..

shut ibex
#

DBL webhook posts a url

surreal barn
#

Well yeah.. hence my code lol..

plain timber
#

@surreal barn what do you mean it's hitting the URL but there's no post 🤔

surreal barn
#

@plain timber as in I can see its calling my url as it inserts into the DB but all post data ie the user id is not coming in

shut ibex
#

maybe you should log the data

humble bison
#

@restive otter webhooks aren't specifically for telling you someone voted

restive otter
#

Yes I know that.

humble bison
#

they're designed to let you know so you can do that, as well as/or reward users and such

#

then supporting discord webhooks is dumb

#

personally

restive otter
#

this isn't anything new though

#

I see a lot of people here who don't even reward users, they just want to send a message to a channel

arctic arch
#

then they can do that via their bot

#

if I support discord webhooks, lots of newbies are likely to never figure out what the webhooks are really for

restive otter
#

newbies seem to be intimidated by HTTP servers 🤷

arctic arch
#

that's true but it's a learning opportunity

#

dblapi.js does most of the work for you, I hope other libs do something similar

restive otter
#

Oh, you're right

#

Then why do so many people complain Thonk

#

Its mainly the js guys

#

now it seems like laziness on their part

summer oracle
#

newbies seem to be intimidated by HTTP servers
rightly so
i bet 95% of users are setting their servers up insecurely

#

ew what

#

also

#

its doesnt really matter if your discord bot gets rekt by an insecure setup no harm is done and best case ppl will learn something

tepid garden
#

can someone give me a example of like a webhook where when you vote it sends a message

#

because im confused on how to do it

topaz wyvern
#

What lang

tepid garden
#

javscript

#

javascript*

#

node.js

#

no.

#

sorry ill look up a video on all of this

#

im %100 new to webhooks :b

tepid garden
#

never mind i dont know how to use webhooks its confusing

dawn fjord
plain timber
kindred ocean
#

can someone help with setting up reaction role

#

im constantly getting an error on the fetched message

plain timber
#

@kindred ocean go to the reaction role server

sand hazel
#

wrong message id or channel

#

And I have a support server

plain timber
#

Oh the owner is here lol

kindred ocean
#

where?

#

plz

sand hazel
kindred ocean
#

i been at this for hours

plain timber
#

Fishy u can send the link

kindred ocean
#

thank you

sand hazel
plain timber
#

Go there @kindred ocean ^

kindred ocean
#

i went and there are no channels even after reading the documents

#

can i @ fishy

plain timber
#

🤷🏾‍♂️

sand hazel
#

did you read #6 Thonkang

kindred ocean
#

yes but my funky computer

#

omg

solemn knot
#

funky fresh pc

harsh glen
tepid garden
#

to set up the console.log when someone votes do i set it up like this (it also has the post servers in it)```
const DBL = require("dblapi.js");
const dbl = new DBL('token', { webhookPort: 5000, webhookAuth: 'pass' }, bot);

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

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

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

tepid garden
#

?

arctic arch
#

looks correct

tepid garden
#

its not saying when someone votes or when i test it

arctic arch
#

have you configured your webhook correctly on the website
if you're running locally, are ports open

tepid garden
#

dont you go into the bot and set up the webhooks then gen a token

#

the post server count is working

#

just not the votes

arctic arch
#

server count:
You send a request to our server
Your bot -- HTTP Request --> DBL server
webhooks:
We send a request to a server your bot (dblapi.js) is hosting
Your bot <-- HTTP Request -- DBL server

If you haven't configured your webhooks correctly on the edit page, the webhook request arrow doesn't know where to go
Your bot? ?----|
Your bot? ?----| --- DBL server
Your bot? ?----|

If you don't have the required port open, the webhook request arrow gets cut off before it reaches your bot
Your bot |---- DBL server

tepid garden
#

how do i get it open

arctic arch
#

I assume you are self hosting it on your computer?

#

in that case you're gonna have to check your router's model and search google for how to do it

#

this step is mostly unnecessary if you're hosting on a VPS

humble bison
#

if i put a url param on the vote url, will the webhook provide it?

#

aka if i put ?ref=674 on /bot/:id/vote, will the webhook provide it to me or not

plain timber
#

@humble bison well there's a query key in the post body so I assume so

humble bison
#

alright, thanks

zenith marsh
#

My bot is now failing to post server count to DBL.

plain timber
#

Any error?

shut ibex
#

ok

restive otter
#

it would be nice if the dbl python module had a http vote thing

plain timber
#

Tonkku thought all the libs support webhooks but afaik only the js one does

sand hazel
#

I'll add one to the the go lib

azure pollen
#

i like that explanation

#

if you can't understand then you can't be helped wearies

plain timber
#

TBH we should have webhook examples form more languages

#

It would be best if support is added to the libs tho

arctic arch
#

@plain timber I said I hope other libs will add support smh

plain timber
#

That's not what it looks like

arctic arch
#

just... read it?

#

I hope other libs do

sand hazel
#

webhook is available in go-dbl now

plain timber
#

@arctic arch it sounded like "I hope other libs already do" instead of "I hope other libs will do"

daring garnet
#

how dare you tonku why does this matter

unkempt owl
#

<DBL>.getVotes() sometimes returns the votes for my other bots, other than the one who’s token is in the constructor. Is there any way to fix this server side? Or would receiving webhooks be the only way

arctic arch
#

ae you sure it's using the right token

unkempt owl
#

Yes, because it returns the correct bot’s data initially, then when I run the command again a few seconds later the data changes

arctic arch
#

are you hotswapping tokens

unkempt owl
#

I’m not sure what that is

#

You can see it here when it randomly switches from 5 votes to 11 votes found in the same interval loop

#

I’ve even tried changing the token but it still sends another bot’s data

shut ibex
#

You do know you don't need to do dbl = this.dbl right?

unkempt owl
#

I was just using it for the interval example

lyric coyote
#

Hi, I would like to add a bot, but I'm kinda new to this. Can someone please help me?

restive otter
lyric coyote
#

Okay, I will try that. Thanks

plain timber
#

@lyric coyote just to make sure, you made a bot and want to add it to the website?

#

or you want to add someone else's bot to your server

lyric coyote
#

I was looking to add a dice roll bot

plain timber
#

to your server?

lyric coyote
#

Yeah

restive otter
#

oh

plain timber
lyric coyote
#

Yeah, I am trying to set up an rp server

plain timber
lyric coyote
#

Thank you so much

plain timber
#

yw

zinc lintel
#

For the Python DBL API, is there a way to track if the user has voted.

#

If so can an example be provided xD

plain timber
#

Note that this may only show the last 1000 votes

restive otter
#

Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}
Traceback (most recent call last):
  File "/home/uniquebot/cogs/discordapi.py", line 25, in update_stats
    await self.dblpy.post_server_count()
  File "/usr/local/lib/python3.5/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.5/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.5/dist-packages/dbl/http.py", line 160, in request
    raise Forbidden(resp, data)
dbl.errors.Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}

#

what this

#

saying something about forbidden on
line 25 what is : await self.dblpy.post_server_count()

quaint venture
#

code? @restive otter

restive otter
#

import dbl
import discord
from discord.ext import commands

import aiohttp
import asyncio
import logging


class DiscordBotsOrgAPI:
    """Handles interactions with the discordbots.org API"""

    def __init__(self, bot):
        self.bot = bot
        self.token = 'token here'  #  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))

#

just updating to python 3.5.3

quaint venture
#

The error is here > "await self.dblpy.post_server_count()"

#

And it looks like it can't connect

#

Because the website responds with 403

restive otter
#

weird

#

weird

#

wait it shows that error but it works lol

tidal burrow
#

this is why I don't use libs

#
  1. they aren't always error-free
  2. they must always be up to date by their creator
sullen nymph
#

Aaaaaaaaaa

#

Your token is wrong

#

That's it

restive otter
#

nope

#

its right

sullen nymph
#

DBL thinks it is

#

Reset and try again

tidal burrow
#

do you lurk here or something

sullen nymph
restive otter
#

did nothing lol

#

but it works whats weird

timid parrot
#

hey can someone help me with the servers count in the page?

#

im trying since 1 day but nothing happens

#

no error no result

sullen nymph
#

Which lib

timid parrot
#

dsicord.js

sullen nymph
#

Oh welp, I'll pass

timid parrot
#

:/

#
  const client = new Discord.Client();
  const DBL = require("dblapi.js");
  const dbl = new DBL(`My token`
  , client);
  
  // Optional events
  dbl.on('posted', () => {
    console.log('Server count posted!');
  })
#

whats wrong? 🤔

sullen nymph
#

Either token being wrong

tidal burrow
#

are you even posting server count is the question, or are you just waiting until it will be magically posted

sullen nymph
#

or you putting a bot one instead of DBL one

#

If you pass Client into DBL params, it will autopost every 30 mins

tidal burrow
#

that's dbl lib?

timid parrot
#

discord js

#

so i need to change class for DBL?

#

im so lost xd

sullen nymph
#

Look at my first 2 messages

timid parrot
#

which ones

tidal burrow
#

nice

sullen nymph
#

Well

#

The ones after you said "whats wrong"

timid parrot
#

ah oke

#

yeh ik i changed token to post it here

restive otter
#


Failed to post server count
Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}
Traceback (most recent call last):
  File "/home/uniquebot/cogs/discordapi.py", line 25, in update_stats
    await self.dblpy.post_server_count()
  File "/usr/local/lib/python3.5/site-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.5/site-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.5/site-packages/dbl/http.py", line 160, in request
    raise Forbidden(resp, data)
dbl.errors.Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}

so i tested it and the error seems to still be there every time it updates the counter idk what it is but it works but the error is still there

#

i see it says 403 error but that ant on my end ive tried everything

arctic arch
#

403 would happen when the ID doesn't match with the token

restive otter
#

but what is weird tho i see that but it works just fine like it updates the server count but it gives that error what i would of thort it would not work but it does