#topgg-api

1 messages · Page 24 of 1

arctic arch
#

what needs changing

spiral crypt
#

"Scroll Up"

#

xD

golden wind
#

the "readme"

arctic arch
#

is it an old version of the readme or Oliy's own bullshit

golden wind
#

ie literally all of the installation and example

#

just copy paste it

arctic arch
#

I can't just copypaste a markdown file lmao

golden wind
#

what format do you need it in?

arctic arch
#

a .oily file

golden wind
#

kk i'll update it tonight 😉

arctic arch
#

tbh I need to rewrite the documentation for the JS lib myself

#

it's missing details

sacred horizon
#

Does the api have an event for on vote? Like am i able to trigger code right when somebody votes?

elfin solstice
#

webhook

#

the api does provide a webhook you can configure when someone votes/unvote

sacred horizon
#

Oh ok thanks

elfin solstice
restive otter
#
var dbapi = require("./discordbots.js/index.js");
 
var db = new dbapi("secret token")
 
db.getStats("388025818720501760").then((botData) => { console.log(botData) })
#

ow

junior goblet
#

that's not how you require it

restive otter
#
0|disc     | You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
0|disc     | Error: 400 Bad Request
0|disc     |     at _response.transport.finalizeRequest.call.then (/Users/whirl/Desktop/disc/node_modules/snekfetch/src/index.js:195:23)
0|disc     |     at <anonymous>
0|disc     |     at process._tickCallback (internal/process/next_tick.js:160:7)

Why?

junior goblet
#

@restive otter you need to use require("dblapi.js")

#

@restive otter you aren't sending the stats correctly, can you show your code?

restive otter
#

Sure

#

i want to show the name of the bot

#

do not show your token

#

@junior goblet Did you see it?

#
const DBL = require("dblapi.js");
  const dbl = new DBL("token");    
  setInterval(() => {
        dbl.postStats(bot.guilds.size);
        console.log("Posted on DBL " + bot.guilds.size + " guilds")  
  }, 1800000);
#

try this

junior goblet
#

see what

restive otter
#

put in your ready event

#

at me is works

junior goblet
#

oh did you share your token

restive otter
#

const DBL = require('dblapi.js');

const dbl = new DBL('token I will add later', client);

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

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
  client.user.setActivity('>help');
  client.user.setStatus('online');
});```
#

@brittle swallow

#

Here it is

#

@junior goblet

junior goblet
#

yep

#

hang on

restive otter
#

@restive otter

#

?

#

put in your ready event

#

Um, wdym?

#

Consts?

#

to run when your bot is ready

#

You mean the consts?

vast junco
#

do I use my bot's client ID or ID from DBL

junior goblet
#

why does your new DBL() include your client @restive otter

restive otter
#
const DBL = require("dblapi.js");
  const dbl = new DBL("token");    
  setInterval(() => {
        dbl.postStats(bot.guilds.size);
        console.log("Posted on DBL " + bot.guilds.size + " guilds")  
  }, 1800000);
``` I use this and is working, put in ready event
junior goblet
#

you just need the token

restive otter
#

yes

#

Thanks

#

😄

vast junco
restive otter
#

I like how people are helpful here.

junior goblet
#

@vast junco use your client id

vast junco
#

oh

#

ok

junior goblet
#

are you using the lib?

restive otter
#

@restive otter 🕹

#

Thx

#

😄

#

@junior goblet It is not working

#

Not showing

#

the server count

junior goblet
#

are you getting any errors

restive otter
#

NO

#

@junior goblet Just no showing

#

and a eslint error I had

#

global-require

junior goblet
#

can you show your code again

#

use ```js ``` when showing me

restive otter
#

k

#
client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
  client.user.setActivity('>help');
  client.user.setStatus('online');
  const DBL = require('dblapi.js');
  const dbl = new DBL('');
  setInterval(() => {
    dbl.postStats(client.guilds.size);
    console.log('Posted on DBL ' + client.guilds.size + ' guilds');
  }, 1800000);
});
```]
#

@junior goblet

junior goblet
#

ok

restive otter
#

I did npm also

vast junco
#

where do I get my token from

restive otter
#

Tried three times

junior goblet
#

the api page

vast junco
#

I think it was at the bottom on the old documentation

junior goblet
#

if you click your bot app thing

#

avatar

restive otter
#

@vast junco Edit your bot and scroll down

junior goblet
#

you'll see it

vast junco
#

o

junior goblet
restive otter
#

Hm

#

@junior goblet Solution to my prob?

#

😦

#
const { DiscordBotsList } = require("dblapi.js")
const DiscordBots = new DiscordBotsList('token');
 
const id = '415099419592228864'; // Replace '' with a id.
 
DiscordBots.getBot(id).then((res) => {
    console.log(`Bot: ${res.body.name}`);
});
``` Why?
#

don't work

junior goblet
#

one sec

restive otter
#

ok

#

K

#

What about me?

junior goblet
#

@restive otter if im not wrong the way setInterval works is it wont fire the first time you run it

#

so you just gotta wait

#

your code works

restive otter
#

k

junior goblet
#

but you need to wait for the setInterval

restive otter
#

Yes yes yes, at me is the same

#

i waited

#

and is work the serer count

#

Unexpected require(). (global-require)'

#

There is eslint error

#

@junior goblet

junior goblet
#

?? idk

#

just ignore it

#

i guess

#

i dont use eslint

restive otter
#

k

#

I closed the problem

junior goblet
#

try it with a number

restive otter
#

What?

junior goblet
#

actually tbh it shouldn't matter

#

uhh

restive otter
#

K, I am waiting

#

then

junior goblet
#

what are you waiting for

#

you're fine

restive otter
#

after you wait

#

No, it doesn't work

junior goblet
#

oh

restive otter
#

verify is the servercount is working

#

wait more

#

do not restart the bot

#

if you restart the bot

#

you need to wait again

#

Yup

#

k

junior goblet
#

@restive otter so whats the issue exactly? is res undefined or something?

#

you don't need to do res.body

restive otter
#
TypeError: DiscordBotsList is not a constructor
#

const dbl = new DBL('dbltoken', client); blake should I use this

#
const { DiscordBotsList } = require("dblapi.js")
const DiscordBots = new DiscordBotsList(config.dbltoken);
 
const id = '415099419592228864'; // Replace '' with a id.
 
DiscordBots.getBot(id).then((res) => {
    console.log(`Bot: ${res.body.name}`);
});
#

@restive otter without client

junior goblet
#

^

restive otter
#

k

#

and

#

@junior goblet

junior goblet
#

yeah

restive otter
#

@restive otter Code pls

junior goblet
#

oh

restive otter
#

Not full though

#
exports.run = (bot, message, args, Discord, config) => {

const { DiscordBotsList } = require("dblapi.js")
const DiscordBots = new DiscordBotsList(config.dbltoken);
 
const id = '415099419592228864'; // Replace '' with a id.
 
DiscordBots.getBot(id).then((res) => {
    console.log(`Bot: ${res.body.name}`);
});

}
junior goblet
#

why are you requiring "DiscordBotList" from dblapi.js

restive otter
#

k

junior goblet
#

that's not a thing

#

remove the {}

restive otter
#

after

#

?

junior goblet
#

make const { DiscordBotsList } = require("dblapi.js") into const DiscordBotsList = require("dblapi.js")

restive otter
#

ok

#

There is N/A

#

still

#

another error

junior goblet
#

yeah you don't need res.body

#

it already returns that

restive otter
junior goblet
#

should just be res.name

restive otter
#

i do it

#

is udnefined

#

undefined*****

junior goblet
#

what does res return

#

im not sure

#

you'll need to check what the name is defined as

restive otter
#

Bot: [object Object]

junior goblet
#

GWchadThonkery just console.log(res) on its own

vast junco
#

what the frick

restive otter
#

@vast junco

vast junco
#

oh

restive otter
#

😦

#

i don't code in python

vast junco
#

nep

#

import you hoe

restive otter
#

@junior goblet is works!

vast junco
#

dblpy pls

junior goblet
#

alright good blobthumbsup

restive otter
#

Wut 'bout m?

junior goblet
#

what about you

#

your code is fine

#

either remove the setInterval or wait

vast junco
#

do I put the class that handles interactions with the dbl API in my on_ready event?

golden wind
restive otter
#

@junior goblet Didn't work

junior goblet
#

error?

restive otter
#

No

#

@junior goblet

#

No error

junior goblet
#

did you remove the setInterval

restive otter
#

No

#

@junior goblet Can ya gimme an example?

junior goblet
#

just remove the setInterval around it

#

then it will post on ready

restive otter
#

k

junior goblet
#

what

restive otter
#

There is a erro

junior goblet
#

dont

#

post your token

restive otter
#

Oops

#

I forgot

#

Omg

junior goblet
#

anyways

#

whats the error

restive otter
#

@junior goblet

junior goblet
#

yeah ok you dont need to ping me all the time as well im right here

#

why are you formatting with css

#

this is js

restive otter
#

k

junior goblet
restive otter
#

k

#
client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
  client.user.setActivity('>help');
  client.user.setStatus('online');
  const DBL = require('dblapi.js');
  const dbl = new DBL('');
    dbl.postStats(client.guilds.size);
    console.log('Posted on DBL ' + client.guilds.size + ' guilds');
  }, 1800000);
});
junior goblet
#

alright

#

remove that }, 180000); at the bottom there

restive otter
#

done

#

@junior goblet Worked

#

Thank u very much

junior goblet
#

all good blobthumbsup

restive otter
#

😄

calm torrent
#

uh @golden wind the example can be improved GWjustinEyesReverse

#

and it definitely doesn't work

golden wind
#

where?

#

the one i linked?

calm torrent
#

in the readme

golden wind
#

cause i tested that and it defo does work

#

but

#

i can improve it

calm torrent
#

self.session isn't even defined

golden wind
#

i see

#

whoops

calm torrent
#
.. code:: py

    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 = 'dbl_token'  #  set this to your DBL token
            self.dblpy = dbl.Client(self.bot, self.token, loop=bot.loop) 
            self.updating = bot.loop.create_task(self.update_stats())

        async def update_stats(self):
            """This function runs every 30 minutes to automatically update your server count"""
           await self.bot.wait_until_ready()
            while not bot.is_closed:
                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))
#

pretty sure that should be better

restive otter
#

Can someone gimme more examples of the api js

#

?

#

I have done the server count

#

How i can get the avatar using dblapi?

#

from res.

#
const DiscordBotsList = require("dblapi.js")
const DiscordBots = new DiscordBotsList(config.dbltoken);
 
const id = message.mentions.users.first().id // Replace '' with a id.
 
DiscordBots.getBot(id).then((res) => {.................................................}
uncut crystal
#

why are you using the dbl API for that

restive otter
#

why not?

uncut crystal
#

because avatars are a Discord thing

restive otter
#

res.avatar

uncut crystal
#

you don't want to do this through the dbl API

restive otter
#

how?

uncut crystal
restive otter
#

i know -_-

#

(user).avatarURL

uncut crystal
#

yeah

#

then do that

restive otter
#

owww

#

aham

calm torrent
#

@golden wind read my message up there

restive otter
#

Example of some more

#

api

golden wind
#

@calm torrent ye i updated it in my local copy

calm torrent
restive otter
#

XilmamDnoi£!"!9£÷$9£!÷$$!÷£÷!9£÷9€÷/9€&÷/&€9÷/÷/&8÷^8/4&7!/3&€93/&9€÷/€÷9/!£93/

inner venture
#

Nice

spark osprey
#

Is there any way to get a response code from dbl.hasVoted('id') on Node.js? The 502 errors are crashing my commands.

raven zinc
#

catch the promise

vast junco
#

does anyone know what i'm doing wrong?

library: discord.py
py version: 3.6.3
lib version: 1.0.0a

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

    def __init__(self, bot):
        self.bot = bot
        self.token = 'token'
        self.dblpy = dbl.Client(self.bot, self.token, loop=bot.loop) 
        self.updating = bot.loop.create_task(self.update_stats())

    async def update_stats(self):
        """This function runs every 30 minutes to automatically update your server count"""
        await self.bot.wait_until_ready()
        while not bot.is_closed:
            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))
inner venture
#

does it error

vast junco
#

no

#

thinking

#

Not logging code errors

#

but there are some things that are underlined red in vscode

vast junco
calm torrent
#

what error?

restive otter
junior goblet
#

this isn't really related to the API, you'd best ask in #development or something

sacred horizon
#

Thats justome
Javascript

#

Custom*

daring burrow
#

lol

restive otter
#

Is The API going slow or something?

#

my bots taking time to respond to commands

sudden rampart
#

don't request from the api every time a command is executed

restive otter
#

?

inner venture
#

are you sending a request to the api everytime a command is executed

restive otter
#

idk

#

@buoyant jasper.command(pass_context=True)
async def purge(ctx, args1: int):

#

then i write some code like

#

bot.say

junior goblet
#

@restive otter if you're talking about the Discord API, this channel is only for the DBL api
if you think the Discord API is being slow, you can see https://status.discordapp.com

restive otter
#

well it was for 10 min

#

then it sped up again

#

no signs of it slowing on the satus tho

#

rip

vast junco
#

this is for help with the dbl api

restive otter
#
    req.post(`https://discordbots.org/api/bots/${client.user.id}/stats/`)
        .set('Authorization', 'A TOKEN')
        .send({
            "server_count": client.guilds.size
        })
    .catch(console.error)```
#

why no work?

#

req is snekfetch

tame kindle
#

use dblapi.js

restive otter
#

kk

sleek agate
silver dove
#

Do I need to use the official api lib? can't I send my own request?

golden wind
#

@sleek agate thats normal and has always been there

#

@silver dove you dont have to, but it is recommended

silver dove
#

nah i'd rather use raw snekfetch

sleek agate
#

@golden wind is that considered a dbl token

golden wind
#

what no

#

its an easter egg per se

#

why would that be considered a token?

silver dove
#

the thing is, in the docs, it only shows examples of dblapi.js, not raw requests >_<

golden wind
#

okay

#

i dont know js at all

#

but you could look at the source code?

#

or

silver dove
#

tried that

golden wind
#

ye

silver dove
#

thanks BlobSmile

golden wind
#

was gonna link that

#

👀

sleek agate
#

I was gonna plan a server count

#

but the api with no docs just redirects you to something

arctic arch
restive otter
#

I have one question
I tried the api
But it's doesn't detect my bot
Is this normal ?

arctic arch
#

you don't seem to have an approved bot

restive otter
#

Oh ok

#

So i will /* */ the code

sick temple
#

what do i put on Java API > API#getVoters(String)?

#

404 docs not found

#

nevermind.

#

why get the bot id as a string and not a long tho

#

its a long afterall

#

who the f wrote this

sudden rampart
#

nik

sick temple
#

its weird

#

and seems a little retarded

sudden rampart
#

use mine :^)

sick temple
#

if its actually working, yea

#

what the firetruck is this thing

#

it actually is retarded

sudden rampart
#

getVoters("Luca")

sick temple
#

by name????

sudden rampart
#

no

sick temple
#

i was to say

sudden rampart
#

that doesnt work but compiles

sick temple
#

it wont run, and it wont interrupt either

#

yes and thats the thing

#

the library is retarded

#

it should take a long

#

it takes a string

#

what is this

#

and why

#

its the library being unable to get

inner venture
#

@sick temple lmao

#

I can make it take a long too if you want shrug

#

I dunno why I went with during

#

String

sick temple
#

long would be more fitting, since afaik discord is handling IDs as longs

#

also

#

im a bit of a stupid firetruck

#

because guess what

#

...wrong token

#

im sorry blaming you @inner venture lol

#

well, ive learned a lot about requests in the process xd

cunning forum
#

🤦

sick temple
#

yup

inner venture
#

Lmfao

#

It's ok friend

#

I forgive you

sick temple
#

mo addreaction 1 ❤

#

:( no permission

sick temple
#

its not working again

#

and creating an infinite wait

#

it should work tho

little harbor
#

Are the API docs down? I get an error when I try to access them.

#

oh

#

nevermind I wasn't logged in

#

that's weird

#

I'm guessing that's a bug then? owoThinking

uncut crystal
#

what was the error

little harbor
#

"Oops, I think a bad happened, I'm trying again just hang in there"

#

so... not very descriptive

#

:P

uncut crystal
#

yeah that's a bug

#

one we're aware of

#

actually, maybe not for the docs

little harbor
#

ah

sweet delta
#

Now that we can upvote once every 24 hours, if we use the webhooks.
Does the API send a post request for every upvote a user do? or only for the first time?
Does the API send an "unvote" post request when the 24 hours are over and that the user can vote again?

sudden rampart
#

every upvote

#

and no

sweet delta
#

hm

#

ok

restive otter
#

HOW do i check my dbl api?

#

GUYSSSSS

azure pollen
#

ohhhh myyy goooodddddddddd

#

what do you mean

restive otter
#

how do i know if its working

azure pollen
#

you get a response from the API? SpinningLUL

restive otter
#

Where do i need to get response

azure pollen
#

from the code you used to call the API on

restive otter
#

Ok

#

how can i found it

#

i really want my server countt

azure pollen
restive otter
#

Dudeeee

#

Watch ma code in pm

arctic arch
#

go learn how to code first

#

or just use a lib smfh

azure pollen
#

no

restive otter
#

ok

azure pollen
#

u can ask Tonkku 4 help

#

kthx

arctic arch
#

ken pls

restive otter
#

ken?

azure pollen
#

@arctic arch can u help this person pls

#

ur the API guy

arctic arch
#

lang?

#

js?

azure pollen
#

thanks tonk, i gotta brb now

restive otter
#

yes

arctic arch
#

using what

restive otter
#

node

#

whe first part of my code

#

is it fine?

arctic arch
#

dont post your token

restive otter
#

il re gen him

arctic arch
#

you use discord.js?

restive otter
#

yes

#

const Discord = require('discord.js');

arctic arch
#

just use the autoposting

restive otter
#

?

#

that?

arctic arch
#

yes

restive otter
#

its in the code

#

how do i check its working

arctic arch
#

you check if you can see the server count on the site

restive otter
#

lmao

restive otter
#

how is it that i get this error when the time is up

#
C:\Users\Jake\Desktop\stats\node_modules\snekfetch\src\node\index.js:93
          options.connection.close();
                             ^

TypeError: options.connection.close is not a function
    at ClientHttp2Stream.stream.once (C:\Users\Jake\Desktop
uncut crystal
#

first of all, change your token, right now

restive otter
#

oh shit

#

my bad

uncut crystal
#

and second of all, it's not really related to the API, try #development

terse trellis
#

how GetVotersAsync is working?
voters from that day? or the total?

#

on C#

timid nexus
#

Hey guys

#

I was wondering if you could check for daily votes with dbl.hasVoted("129908908096487424")

tame kindle
#

@timid nexus

#

idk

restive otter
#

Does a POST in the API return anything?

obsidian isle
#

ah nvm

pseudo patrol
#

So I got dblpy installed but "No module named 'dblpy'" THINKCEPTION

steady sundial
#

@timid nexus no you cant

timid nexus
#

Another thing, if someone upvotes, then cancels the upvote and upvotes again

#

Does it post to the webhook again or does it cancel out

#

As in do I have to cancel it out on my end

sudden rampart
#

posts again

unkempt escarp
#

@pseudo patrol Yea same issue.

arctic arch
#

it posts for the cancelling too

full socket
#

Do the webhook urls have to be https?

arctic arch
#

no they don't

full socket
#

Alright, thanks

arctic arch
#

but I advice against plain http

#

but I can understand if you can't get a domain and stuff

full socket
#

Yeah, I can't right now unfortunately :/

snow fiber
#

You could get a tk domain or something from freenom and setup a reverse proxy

#

Does DBL take self signed certs into account, not that I have any but out of curiosity

arctic arch
#

I'm pretty sure self signed certs don't work

#

node's https module rejects bad certs including self-signed

cunning forum
#

wew

#

why not make it skip the error

#

isnt there any way to do so?

#

I have a couple selfsigned certs installed as root level certificates on my computer

#

and hmm

snow fiber
#

I actually agree with Tonkku, self signed certs are bad

cunning forum
#

no

#

when you test SSL

#

and cant be bothered with LE

#

or pay for a cert

#

selfsigning works great

arctic arch
#

I might've probably allowed bad certs

#

if LE didn't exist

cunning forum
#

its not a bad cert

#

its a one you dont trust

severe mist
#

okay, so what exactly changed?

#

I read the announcement, something about channels?

arctic arch
#

something about webhooks

golden wind
#

@pseudo patrol @unkempt escarp use import dbl , the docs on the dbl site are incorrect

pseudo patrol
#

I did that but got an error 🤔

golden wind
#

post the full error here and i'll fix it soon(ish)

pseudo patrol
#
Traceback (most recent call last):
  File "C:/Users/***/PycharmProjects/NekoBotRewrite/bot.py", line 9, in <module>
    dbl = dbl.Client(bot=config.botid, token=config.dbots.key)
  File "C:\Users\***\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dbl\client.py", line 59, in __init__
    self.loop = kwargs.get('loop') or bot.loop
AttributeError: 'int' object has no attribute 'loop'``` ![Thonk](https://cdn.discordapp.com/emojis/356771720863940608.webp?size=128 "Thonk")
unkempt escarp
golden wind
#

what are you using to initiate the client?

pseudo patrol
#

dbl = dbl.Client(bot=config.botid, token=config.dbots.key)

golden wind
#

dont pass the bot id, pass the actual bot object

pseudo patrol
#

ooo

golden wind
#

see this example

unkempt escarp
#

@golden wind Awesome thanks, got it to work! blobnomcookie

golden wind
#

😃

pseudo patrol
#

await self.dblpy.get_upvote_info(bot_id=config.botid) gives a NotFound: Not Found (status code: 404): {"error":"Not Found"}

calm torrent
#

dont provide the bot id and whats the resposne?

pseudo patrol
#

its the same

#

NotFound: Not Found (status code: 404): {"error":"Not Found"}

#

If I https://discordbots.org/bots/(botid)/votes + authorization header in postman I get a 404 too Thonk

    <h1>Sorry we tried very hard but something went wrong :(</h1>
    <h1>Not Found</h1>
    <h2>404</h2>```
#

or is it /api/bots/*** lol

#

xD

sudden rampart
#

/api

austere flower
#

When I use api.getVoterIds("String", int) what is the int for?

golden wind
#

@pseudo patrol what version of the api are you on?

pseudo patrol
#

latest

#

await self.dblpy.post_server_count(shard_count=self.bot.shard_count, shard_no=self.bot.shard_id) is working but not get_upvote_info() so I just used aiohttp

golden wind
#

🤔

jolly pier
#

i'm working on adding typescript on the dblapi.js module, its annoying to look up the website everytime...

arctic arch
#

alright

#

make sure to PR it 😃

jolly pier
#

what does postStats() return?

#

or it just doesn't return anything?

arctic arch
#

if it's unsuccessful, there's {"error": "Describing the error"} and if it is successful it's just an empty object

jolly pier
#

ok, also the way to call the api needs to change to aply the typescript, now instead of ```js
const dbl = new DBL('Your discordbots.org token', client);

#

its js const dbl = new DBL.DBLAPI('Your discordbots.org token', client);

arctic arch
#

I don't like that

jolly pier
#

me neither, but else i cant typescript the module zoomeyes

arctic arch
#

are you sure?

#

typescript sucks

cunning forum
#

yes it does

jolly pier
#

ikr, im gonna try to find a way to don't change how to call api

#

what about: ```js
const dbl = require('dblapi.js').DBLAPI("Discord Bots Token", client);

arctic arch
#

nope

#

try to avoid making a breaking change

jolly pier
#

ok

jolly pier
#

i founed the way of how to add ts without doing a breaking change, wait some mins, then i will PR

#

im pr rn

#

done

ivory wren
#

So I added the below code to my bot, and started getting To Many Request errors after a few minutes... did I do something wrong?

        const DBL = require("dblapi.js");
        const dbl =  new DBL('MyToken', client);
#

did I do something wrong? I got the code from the api example page

inner venture
#

How many requests are you sending...

ivory wren
#

From what I understood It said that it was automatically handled when I do it that way.

azure pollen
#

show code

#

or is that the only code?

#

ok u dont need to show ur token

#

but

#

how often are you restarting your bot, if you are?

ivory wren
#

not restarting

azure pollen
#

how often are you calling the module then

ivory wren
#

1 time

#

at load

azure pollen
#

@arctic arch WaitWhat

#

i'd say just skip it for now and i'll see what tonk says SpinningLUL

ivory wren
#

ani_fidget_spinner I shall wait lol

ivory wren
#

@azure pollen Do I need to let it send at an interval, or can I just update it 1 time at load and 1 time for each Guild_Create?

azure pollen
#

probably best to do a long interval

#

best ask tonk

#

he knows the api more than myself

ivory wren
#

kk for now I'm going to set a long interval, and I'll wait for his reply. Thanks 👍🏻

ivory wren
#

So is setting it at the intervals acting like a heart beat, and keeping the bot marked as "ONLINE" on the website?

inner venture
#

The status on the site is just taken from discord @ivory wren

ivory wren
#

Well mine just shows a grey ??? next to it

timid nexus
#

Heyo

#

I was wondering if anyone knew when the "You have already voted for this bot today" message disappears

#

as in the timezone

ivory wren
azure pollen
#

ok

junior goblet
#

@timid nexus its not based on timezone, it's 24 hours exactly from the time you vote

timid nexus
#

Oh good

#

So it's per user

junior goblet
#

yeah

arctic arch
#

maybe you restarted your bot so many times you hit the ratelimit at some point

restive otter
#

How to send a message to whoever have voted

#

Need example

sudden rampart
#

use a webhook

tough yoke
#

Whats that the news webhook ?channel_id=

#

didnt got it

inner venture
#

You can specify query params in the original vote link that you send to the user and then the webhook will post those same params back to you once they vote

restive otter
#

Hi

#

In the list it shows my bot is in 1 server and actually it is on 30 server!

#

servers*

vast junco
#

show code

restive otter
#

@vast junco Thanks, I have resolved it

vast junco
#

oh

restive otter
#

so, i post to the api and for some reason it says that its in 3k servers when its only 1.7k, I think its a sharding issue, idont know.

inner venture
#

@restive otter which one of your 300 bots are you having issues with

restive otter
#

@inner venture cough cough, not 300, anyways its @paper monolith

inner venture
#

you've set shards 0 and 1 both to

#

1748 servers

#

Im gonna guess that you have two shards and youre posting the full server count to each

restive otter
#

I tried to setup Webhooks with Discordbots, but somehow it's not working.
Steps I have done:

  1. Created a Webhook in Server Settings.
  2. Copied the link I got there and pasted it into webhook field at the edit panel of my bot (screenshot).
  3. Saved it and voted.

Well, nothing has happend.
No message in the channel.

What am I doing wrong? Did I somehow missunderstand Webhooks and how they work or is it something else?

inner venture
#

Webhooks are a generic concept

#

DBL's webhooks dont have anythign to do with Discord's

restive otter
#

So what should I do then?

inner venture
#

To receive the webhook, you need to setup a webserver and point the webhook to that webserver

#

and then your bot will receive that request

restive otter
#

thank you!

inner venture
#

no problem friend 😳

restive otter
#

The 😳 emoji somehow scares me thonkC

sudden rampart
remote bramble
#

cool

inner venture
#

AZUL AZUL

#

AI AI AI

tame kindle
potent plank
#

ok so

#

I've set up the webhook for my bot

#

but for some reason the post data is empty

#

what does that mean?

arctic arch
#

what's your setup

potent plank
#

uh I'm running a php script on an apache server if that's what you mean

#

switching to nginx wouldn't be a problem for me

pure mica
#

hi. i'm sans. sans the skeleton.

remote bramble
#

ok

potent plank
#

so uh

#

can anybody help me with my problem?

restive otter
#

How to send message to whoever votes!

light crag
#

You have to set up a webserver to accept webhooks which will give info on someone who voted when they vote

restive otter
#

I want the bot to send dm voter a message

#

@cobalt ruin How to send message (DM) to the voter whoever vote for the bot?

#

I see there is understandable explanation in the API

abstract mothBOT
#
Whirl#9077
Bots

@random oak

restive otter
#

spotify @oblique fractal

vagrant kayak
#

That looks like a selfbot 👀

restive otter
#

@vagrant kayak I was telling that I cannot use my bot commands in #topgg-api channel

tardy crater
#

bots dont respond in any channel outside the testing channels, unless its luca and tonkkubot.

#

well testing and bothell

vagrant kayak
#

ok makes sense, wording was weird

inner venture
#

Wrong channel

lofty pebble
#

okay ^^

potent plank
#

uh

#

I still need help with my problem

#

I switched to nginx but that didn't help either I still don't get any data

arctic arch
#

so you get no data?

short forge
#

it posts your server count to your bot's profile

restive otter
#

how to post server count DBL API? with python's reqeusts module

short forge
#

don't use requests, it could freeze up your bot if a request takes too much time

#

use aiohttp instead

restive otter
#

sorry......^_^;;

short forge
#

also maybe consider using dblpy library for server count post

restive otter
#

my bot prefix is "f."

short forge
#

it has functions for posting

#

so

restive otter
#

my nick = __FUNC__tion

short forge
#

@oblique plaza you aren't doing it correctly, i don't think

#

are you even calling postStats?
is your api token correct?
is there errors whenever trying to post?

#

uhh

#

still should change your token btw

#

wait

#

are you using the user token for the dbl api

#

you're required to use your bot's api key

#

for posting

#

probably

sullen nymph
short forge
#

python3.5 doesn't have f-strings

#

only python3.6 has em

sullen nymph
#

Oh.

#

👌

potent plank
#

@arctic arch yes my post is completely empty

arctic arch
#

how are you getting the body

potent plank
#

I use php's global variable

arctic arch
#

does php decode json Thonk

potent plank
#

oof I hope

#

if not I could just decode it manually

arctic arch
potent plank
#

ok I see

#

I'm trying that

potent plank
#

ok wow

#

I did that

#

but the data is still empty

#

both the array and the json string

primal lark
#

Why is this example still wrong? ```Python
import dblpy
from dblpy import Client
import asyncio
import aiohttp
import json

dbl = dblpy.Client()

botid = 264811613708746752 # your bots user id (client id on newer bots)
token = 'abcxyz' # DBL Bot Token. Obtainable from https://discordbots.org/api

class Example:
def init(bot):
bot = bot
session = aiohttp.ClientSession(loop=bot.loop)

async def poststats():
    await dblpy.post_server_count(botid, dbltoken, 65)

async def getstats():
    resp = await dblpy.get_server_count(botid)
    print(json.dumps(resp))``` https://discordbots.org/api/docs#pylib 😄
#

And this isn't working too ```Python
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 = 'dbl_token'  #  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 __unload(self):
    self.bot.loop.create_task(self.session.close())

def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(DiscordBotsOrgAPI(bot))``` https://github.com/DiscordBotList/DBL-Python-Library bloblul

#

@golden wind

dawn topaz
#

Im not sure if this is an api issue or what, but I was talking in a Discord.js discord channel and got directed here due to the output of some logs

#

Long story short

#

A whole lot of 400 Bad request issues since updating to d.js 11.3.1

golden wind
#

@primal lark because i cant update it on the site

primal lark
#

But on the github page its wrong too o.O

steady sundial
#

@dawn topaz show us your code

primal lark
#

its different wrong but still wrong 😄

steady sundial
#

That has nothing to do with the discord hersion

#

For me it works fine

golden wind
#

@primal lark shit ye i fixed 5hat last but didn't push

#

lemme find it

dawn topaz
golden wind
#

@primal lark what was the output when you ran it?

#

9h ye nvm

arctic arch
#
body:
0|bot      |    { error: 'Required parameter shard_count missing or invalid value' }
golden wind
#

remove the unload func @primal lark

dawn topaz
#

thats what i dont get. Why

#

that didnt happen before 11.3.1

arctic arch
#

are you sending a shard_id?

dawn topaz
#

nope

primal lark
#

I did not run it yet but this is wrong: await self.dblpy.post_server_count() The parameters are missing

dawn topaz
#

bot not in enuf servers to shard it 😛

golden wind
#

@primal lark what version is your dblpy module cause it should be working

#

i triple checked that

primal lark
#

Ok w8

arctic arch
#

show me the code you use to post stats

dawn topaz
#

talking to meh tonk?

primal lark
#

0.1.3

arctic arch
#

yes

golden wind
#

okay updoot it should work 👍

dawn topaz
#

dbl.postStats(bot.guilds.size); dbl is defined above this

#

and it worked flawlessly until today

arctic arch
#

hmm I dont see how d.js update would break that

dawn topaz
#

i dont see either but im saying its a bit of a coincidence mayb? 🤔

primal lark
#

@golden wind Nothing changed yet?! Or what did you update? o.O

golden wind
#

it should auto pull the server count from the discord.py bot instance passed in the __init__

primal lark
#

Oh ok

#

Thanks

#

I try

golden wind
#

i should probably add an update function into the api to notify of you're out of date

primal lark
#

Am I out of date? o.O

golden wind
#

0.1.5 is the latest

#

so a bit

primal lark
#

ok 👌

arctic arch
#

@dawn topaz what's your bot's ID

primal lark
#
    from .client import Client
  File "/usr/local/lib/python3.5/dist-packages/dbl/client.py", line 31, in <module>
    from .http import HTTPClient
  File "/usr/local/lib/python3.5/dist-packages/dbl/http.py", line 234
    await self.request('POST', f'{self.BASE}/bots/{bot_id}/stats', json=payload)
#

Im getting this error when I import the example @golden wind

golden wind
#

gimme the full error @primal lark

#

you're missing a line 😂

primal lark
#

Sorry 😄

#
  File "run.py", line 6, in <module>
    import statics, loops, utils, discordbotlist
  File "/home/discord/xenon/discordbotlist.py", line 1, in <module>
    import dbl
  File "/usr/local/lib/python3.5/dist-packages/dbl/__init__.py", line 19, in <module>
    from .client import Client
  File "/usr/local/lib/python3.5/dist-packages/dbl/client.py", line 31, in <module>
    from .http import HTTPClient
  File "/usr/local/lib/python3.5/dist-packages/dbl/http.py", line 234
    await self.request('POST', f'{self.BASE}/bots/{bot_id}/stats', json=payload)
                                                                ^
SyntaxError: invalid syntax
golden wind
#

what

#

you're running with python 3 (just checking)

primal lark
#

yes

#

3.6.3

golden wind
#

thonk

dawn topaz
#

oof sorry Tonk

arctic arch
#

@dawn topaz ok I see that you're sending 0 for shard id and count

dawn topaz
#

im not trying to send shard count or id in the first place

arctic arch
#

are you sure that's what you're calling

golden wind
#

@primal lark hmm idk I'll look when i get home

arctic arch
#

it doesn't make them send 0 with the code you sent

primal lark
#

Ok thanks 🙃

dawn topaz
#

okay well i still dont see why it would work for a while then just stop working today

#

@arctic arch would specifying shard id and count fix this issue? 🤔

arctic arch
#

well yea

#

weird tho

dawn topaz
#

yes very weird

arctic arch
#

have you passed client to the constructor?

dawn topaz
#

I'm having a brain fart in what that is again. been a long day

arctic arch
#

is it new DBL('token') or new DBL('token', bot)

dawn topaz
#

the second one

arctic arch
#

oh okay

#

so the autoposter is doing stuff

dawn topaz
#

yea

arctic arch
#

do you call postStats() manually

dawn topaz
#

Well i do this for actually posting it

#

dbl.postStats(bot.guilds.size, bot.shards.Id, bot.shards.total);

#

for atleast thats what i changed it to

arctic arch
#

do you start your bot using the sharding manager?

dawn topaz
#

my bot isnt sharded

arctic arch
#

do you spawn it with child process?

dawn topaz
#

my entire bot is started with pm2

#

triggering bot.js

arctic arch
#

ok that would explain why it picks up the sharding

robust olive
#

client.shards.Id should be client.shard.id hyperThonk

dawn topaz
#

🤔

#

docs errar?

#

@arctic arch this is definitely something to look into cause the error did not go away after putting in the post shard id and count

arctic arch
#

you put your client in

#

so it auto-posts

#

you dont even need to call postStats

dawn topaz
#

well i have it posted in some of my events

#

which may be a weird choice

#

to me it wasnt particularly

#

guildCreate and guildDelete, and ready all contain the dbl code to post stats when those events are called

arctic arch
#

this should fix it

#

npm install DiscordBotList/dblapi.js
tell me if it still continues to error

dawn topaz
#

now im getting a totally different error

#

which is in regard to posting that shard count

arctic arch
#

ok what is it

dawn topaz
#

unrelated

#

to the api

arctic arch
#

oh ok

#

anything to do with the module?

dawn topaz
#

nah

#

shards is undefined so im just gonna remove that since im not using the sharding manager atm

arctic arch
#

were you getting the error at startup before?

#

probably tbh

dawn topaz
#

the long hastebin that i posted

#

yea i was

#

okay

#

I dont 100% know as of yet

#

but it appears to have been resolved

arctic arch
#

okay

#

it better be because I released version 1.1.1 with the fix

dawn topaz
#

interesting very emergency hotfix there 🤔

arctic arch
#

yes

golden wind
#

@arctic arch perfect, except the __unload function isn't actually needed 😂

arctic arch
#

I copied it from your github

golden wind
#

maybe allow us lib devs to edit the page?

#

ye i haven't pushed my latest version

arctic arch
#

push it then

calm torrent
#

imo
while True: should be changed to while not self.bot.is_closed():

neat bolt
#

Webhook
Don't rustle your feathers for no reason, if you're lost you can read more about our webhooks here

Logan's Webhook Options

URL

For that part of API what do i do?

arctic arch
#

do you want to set up a webhook?

neat bolt
#

y e s

golden wind
#

@calm torrent while not self.bot.is_closed(): doesnt work on my end

#

@primal lark everything is working fine on my side?

#

can you double check it?

primal lark
#

@golden wind seems to work 👍

#

Thanks 😃

golden wind
#

(i didnt change anything lol)

primal lark
#

@golden wind Weird. Its working on windows but not on linux

golden wind
#

weird

#

its working on my debian machine

#

whats the output of python -V and python3 -V ?

primal lark
#

Oh I only have Python 3.5.3

#

On the linux

#

Does the api need 3.6?

golden wind
#

no

primal lark
#

@golden wind But thats the only difference between my windows and my linux machine o.O

golden wind
#

idk lol

neat bolt
#

i need help with webhooks....

inner venture
#

whats up tea cup

#

@neat bolt

neat bolt
#

im confused

#

i put in my webhook link but nofthing happened

inner venture
#

Did you setup a webserver to listne for the post request?

neat bolt
#

umm

inner venture
#

lemme guess

neat bolt
#

im new to Webhooks.

inner venture
#

you put in a discord webhook url?

neat bolt
#

yes

inner venture
#

well theres your problem

neat bolt
#

oh

inner venture
#

Webhooks are a generic concept

#

DBLs webhooks have nothing to do with discords

#

Basically, whenever someone votes on the bot, DBL will send a post request to the url of your choice with relevant info

#

So you need to setup a webserver to receive that request

neat bolt
#

so if i wanted it to send it a discord channel i have to?

inner venture
#

You cant just send it to a discord channel

neat bolt
#

oh

inner venture
#

You'd have to receive the request

#

parse it

#

and then send discord a message

neat bolt
#

o k

robust olive
#

what is a yin_yang Thonk

#

#

oh

sullen nymph
#

The token and ID are right. 🤔

calm torrent
#

send code

#

don't provide any parameters into post_server_count

sullen nymph
#

One sec.

#
def __init__(self, bot):
        self.bot = bot
        self.apitoken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjM0MTgzNTE3MTYwNTExODk3NiIsImJvdCI6dHJ1ZSwiaWF0IjoxNTIwMTQ5MTQ0fQ.V0rdI4NGPnB91u3VJTXB16adJaAMwHmCKxv2nJ7oLv8'
        self.dblpy = dbl.Client(self.bot, self.apitoken)
        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.servers)))
            except Exception as e:
                logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
            await asyncio.sleep(1800)
#

Will regenerate a token.

calm torrent
#

regen your token

sullen nymph
#

Yep.

calm torrent
#

did that code work?

sullen nymph
#

Nope.

#

I get error 403 on the startup. 🤔

calm torrent
#

the code in your error traceback is different

#

try saving and running the bot again

restive otter
#

How to send a message by bot to who ever has voted

sullen nymph
#

This one is where I get error 404.

#

And error code 403 on startup. 😄

calm torrent
#

@restive otter webhooks

restive otter
#

@calm torrent aki bot uses and sends using bot only

calm torrent
#

what?

restive otter
#

@calm torrent can you give an example

#

I have no idea how to use webhooks for this api

calm torrent
#

read the docs, create a webserver

restive otter
#

k

calm torrent
#

no.....

restive otter
#

So

calm torrent
#

have you read the api documentation?

restive otter
#

Yeah

#

I did

#

I can't seem to find any info there

calm torrent
#

you need to create a webserver to handle the request

restive otter
#

I got it

#

Oh

#

We need to edit bot

#

@calm torrent Where to get the webhook url?

calm torrent
#

you need to create a webserver to handle the request

#

can you read my messages? GWcfcThonk

restive otter
#

@calm torrent how to?

calm torrent
#

uh what lang are you using?

restive otter
#

Discord.js

sullen nymph
#

@calm torrent Alright, the code for updating stats on the website works, as turns out. 😂

#

That's what I needed the most, sorry for wasting your time. 😄

calm torrent
#

haha no problem, don't provide parameters unless you are using shards GWproximThumbsUp

sullen nymph
#

👌

restive otter
#

@calm torrent discord.js

calm torrent
#

@restive otter i don't know js personally but maybe you could try the express lib?

#

heard people using it

restive otter
#

@calm torrent I use express glitch

#

@calm torrent But how to get url

calm torrent
#

m8

#

create a webserver

#

idk what's glitch

restive otter
#

@calm torrent Create

#

THen

calm torrent
#

but stop pinging me since idk about javascript

restive otter
#

K

#

Hm

#

Well, they should mention more about webhooks

calm torrent
#

Well, you can google how to make a simple webserver to catch responses

restive otter
#

Example of WEBHOOK

#

Discord.js

#

I am stuck I have seen hundreds of articles and Docs too

vagrant kayak
#

Webhooks are as simple as a POST request from a user to your site containing info

restive otter
#

Never found anything

vagrant kayak
#

Except this case a bot

restive otter
#

URL?

#

How to get url?

vagrant kayak
#

You create it

restive otter
#

How?

vagrant kayak
#

Dear lord

restive otter
#

Lel

vagrant kayak
#

Do you know how to create a webserver with urls

restive otter
#

Host?

vagrant kayak
#

Huh

elfin solstice
#

Okay at this point Rule 7b applies, if you dont know how to make a webserver for receiving simple Post requests then use google there are plenty examples out there.

vagrant kayak
sullen nymph
#

I put no arguments in get_upvote_info(), right?

sullen nymph
inner venture
#

@sullen nymph you might wanna talk to @Francis

#

@golden wind

sullen nymph
#

Sure.

marsh pagoda
#

Gi

#

Hi

inner venture
#

hi?

golden wind
#

@sullen nymph on v0.1.4 and above, get_user() has been replaced by get_user_info()

steady sundial
#

Your api cooldown is broken

#

I do a request every 3 seconds and I get error 429

arctic arch
#

why are you doing a request every 3 seconds

#

can someone do the math im havinga headache

#

is that over the ratelimit

sudden rampart
#

20/minute

sudden rampart
#

@steady sundial are you sure you don't do any other requests in other places?

tidal burrow
sudden rampart
#

the recommended is posting on an interval

#

eg 30 mins

tidal burrow
#

I see

#

does it raise anything when trying to go over the limit?

sudden rampart
#

discord sometimes fucks up and spams guild joins

#

posting on an interval is safer

#

and can spam less the api

tidal burrow
#

yeah I just want to know if the API has an exception on if it goes over the limit

elfin solstice
#

yes

#

it will block you for a duration (i think it was a hours, not sure) from using the api

sudden rampart
#

1 hour

tidal burrow
#

time to create a background task

#

thanks though

pulsar lance
#

is any body else getting jda problems

#

like connection wise?

sudden rampart
#

no

inner venture
#

@pulsar lance wrong channel

sullen nymph
#

@golden wind I will try out later, thanks! 😄

tidal burrow
restive otter
#

no

shut ibex
#

how would i actually set up the webhook...

inner venture
#

@shut ibex wdym

shut ibex
#

like the url and stuff

inner venture
#

gonna need you to be clearer

shut ibex
#

idk what to put for the url

vagrant kayak
#

Your url for a webserver?

inner venture
#

You need to setup a webserver

#

and put in a url that points to that web server

shut ibex
#

so like set up nginx to work with the url?

fiery widget
#

Does this have any support for ruby?

shut ibex
#

to ask questions about coding

inner venture
#

I dont believe there is a ruby API lib for DBL atm

#

so youll have to implement the API yourself

shut ibex
#

wait up

#

i thought the webhook only sends the data once

inner venture
#

it does

shut ibex
#

Then how am I supposed to check if it gets triggered