#topgg-api

1 messages · Page 112 of 1

restive otter
#

I got an error: Error: 429 Too Many Requests. How do I fix this?

patent lintel
#

Im using py to post my server count ```py
import requests

data = {'server_count': 71}
headers = {'Authorization': 'the CORRECT api key'}

r = requests.post('https://top.gg/api/bot/748670819156099073/stats', data=data, headers=headers)

print(r.json())``` but for some reason, it still returns {error: 'Not Found'}

rain heart
#

I got an error: Error: 429 Too Many Requests. How do I fix this?
@restive otter Wait about 1-2 hours, you seem to be ratelimited

restive otter
#

ah ok

sullen nymph
#

/api/bots

restive otter
#

@patent lintel

patent lintel
#

oh oops\

#

lol

#

/api/bots
@sullen nymph ty but that returns this: {}

#

like no json data

restive otter
#

no it should work :/

sullen nymph
#

Then it worked, Audit

patent lintel
#

oh ok

#

nice

#

Then it worked, Audit
@sullen nymph ok but this is my main code (i am posting to 3 websites, top.gg is one of them) py webs = ['discord.boats', 'top.gg', 'discordbotlist.com'] data = "" for web in webs: if web == 'discord.boats' or web == 'top.gg': param_name = 'server_count' if web == 'discord.boats': auth = 'Discord Boats Api key' url = 'https://discord.boats/api/bot/748670819156099073' elif web == 'top.gg': auth = 'Top.gg Api key' url = 'https://top.gg/api/bots/748670819156099073/stats/' elif web == 'discordbotlist.com': param_name = 'guilds' auth = 'discordbotlist Api key' url = 'https://discordbotlist.com/api/v1/bots/748670819156099073/stats' body = {param_name: len(client.guilds)} headers = {'Authorization': auth} r = requests.post(url, data=body, headers=headers) await ctx.send(f'Posted server count!') but for some reason, it just returns {'server_count': 66, 'shards': []} and it doesnt update to 71 (the actual server count, 66 was the old one)

#

i put the whole code, because it might be a small syntax error or something

sullen nymph
#

P.S. use aiohttp with your bot

#

print length of client.guilds yourself

patent lintel
#

P.S. use aiohttp with your bot
print length of client.guilds yourself
@sullen nymph wuts that

restive otter
#

its basically like node-fetch for python @patent lintel

patent lintel
#

ok

restive otter
#

it makes http requests a lot easier

patent lintel
#

ok but how does that fix my problem...

restive otter
#

well idk how to fix your problem, but you were asking what aiohttp was so I answered it. You can ask someone else to fix your problem ig.

sullen nymph
#

I'm not sure why it's sending 66

#

Unless that's your actual server count

patent lintel
#

no my actual server count is 71

#

and when i put my other code in another file to manually update it, then it worked

#

is there a differance?

floral orchid
#

const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
Where can I get the password?

rapid kettle
#

Webhook auth is set by you on the webhook page @floral orchid

floral orchid
#

from where exactly?
I could not find the place @rapid kettle

rapid kettle
#

Webhook section of edit page

#

iirc

floral orchid
#

still can't find @rapid kettle

rapid kettle
#

wdym

floral orchid
#

I did not understand ?

#

Am I setting it from the developer page?

rapid kettle
summer tinsel
#

how do I post bot guild number using dbl.postStats without shard id/total because I dont shard it yet

floral orchid
#

@rapid kettleAfter entering the top.gg page, I enter the api section, I click the webhook, but the screen does not appear as you did.

tacit phoenix
#

@rapid kettleAfter entering the top.gg page, I enter the api section, I click the webhook, but the screen does not appear as you did.
@floral orchid its in bot settings

lunar helm
#

dbl.getBot("mybot'sid").then(bot => {
console.log(bot.montlyPoints) //
});
@restive otter i've this problem:

(node:4) UnhandledPromiseRejectionWarning: Error: 404 Not Found
restive otter
#

wdym, did you enter your bot's id?

lunar helm
#

Yes

restive otter
#

hmm

lunar helm
#

I send you the screen

restive otter
#

is your bot approved on topgg?

lunar helm
#

is your bot approved on topgg?
@restive otter nope

restive otter
#

ah then it wont work

#

wait for it to get approved

lunar helm
#

👍

#

@restive otter

restive otter
#

yeah its fine but your bot has to get approved

#

before

lunar helm
#

Ok

#

Nice

restive otter
restive otter
#

@fickle lantern for discord?

#

So ofc discord

#

Or topgg

#

Oh demolaugh

jaunty plank
#

Do you have ssl setup?

#

If not dont use https but http

#

A reverse proxy, or other means of ssl

#

If you dont know, you probably didn't do it.

#

Yes

strange wraith
#

When I try to post the server count I get this error "Error: 429 Too Many Requests", I have tried every way listed in the documentation, but I still get this error

jaunty plank
#

You are being ratelimited for too many api requests.

strange wraith
#

Why have I had this for the last month?

#

And how do I fix this?

jaunty plank
#

Stop posting your server count until your unratelimited.

Send less than 60 api requests total per minute.

strange wraith
#

console.log("Server count posted!");

});

#

I was using this for the posting

jaunty plank
#

Thats just an event

strange wraith
#

I have no post event

jaunty plank
#

That is a post event

strange wraith
#

you should know what I meant

#

I meant api request

jaunty plank
#

Whats your statsInterval set to?
Or any .postStats methods used?

strange wraith
#

WHich means the auto poster limited me

#

Because that is how I have been recieving the error

jaunty plank
#

The auto poster would be the one getting the ratelimit yes

strange wraith
#

why would the auto poster be fast enough to limit itself, isn't that really crappy design

jaunty plank
#

Any api request goes to the ratelimit

#

The autoposter is set to 30 minutes

#

By default

strange wraith
#

Is there a list of api requests?

jaunty plank
#

No.

#

Not that I know of

#

Its the external ip

#

Internal can only be used for internal requests

#

http://ip:5000/dblwebhook correct?

#

Any firewalls?

#

Firewalls block connections through specific ports.

#

There wouldn't be a button. Youd have to use a command.

#

Depends on the firewall lol

#

I've never had the issue of not knowing what firewall i had or if I had one. So I am not sure how to help with it.

#

I would just allow the specific port you require.

#

Firewalls are a good idea to have enabled.

weak oyster
#

hi

silent sky
#

Does anyone know how we can make it so it post if your bot is online or offline? Because when my bot was offline it still said it was online

viscid hinge
#

hey, bots not giving voter role to people who voted
is this a known issue, or only for my server
ive tried resubmitting my server/updating it, the bots role is above the role it needs to give out
and it has admin perms

lucid owl
#

how do i authorize myself? didnt understand properly

hidden wave
#

Ok so I changed my dbl api code hosting to heroku and when I tried changing the webhook URL it doesn't work

#

Ping me if you have the answer

thorn zinc
#

Ok

odd carbon
#

Hello

#

How to listen to bot vote?

#

JDA

#

I mean java

#

So if player votes

#

He gets a reward

restive otter
willow spindle
#

13

frozen whale
#

Hi
I did this but the function on_guild_post isn't called when I execute update_stats. The server number is well sent.
Thanks

north vault
#

wow so colourful

restive otter
#

you don't need to execute it you can use the code in docs it does it automatically

frozen whale
#

Yes, I think it's easier to understand with colors

#

you don't need to execute it you can use the code in docs it does it automatically
@restive otter I execute the function when my bot join/leave a server

restive otter
#

top.gg does it per 30 minutes already I mean

frozen whale
#

I prefer manually to update just when it's necessary

#

and if I do it automatically the function on_guild_post will not be called I think

restive otter
#
import dbl
import discord
from discord.ext import commands, tasks

import asyncio
import logging


class TopGG(commands.Cog):

    def __init__(self, bot):
        self.bot = bot
        self.token = 'dbl_token' # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)

    @commands.command()
    async def update_stats(self):
        logger.info('Attempting to post server count')
        try:
            await self.dblpy.post_guild_count()
            logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
        except Exception as e:
            logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))

        # if you are not using the tasks extension, put the line below

        await asyncio.sleep(1800)

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        logger.info('Received an upvote')
        print(data)

def setup(bot):
    global logger
    logger = logging.getLogger('bot')
    bot.add_cog(TopGG(bot))```
#

@frozen whale

#

command to update manually

#

but not a function to call

#

put this below the event listener member join

frozen whale
#

My update work well but the function isn't called (it update in top.gg)

hidden wave
#

Ok so I changed my dbl api code hosting to heroku and when I tried changing the webhook URL it doesn't work

frozen whale
#

@commands.Cog.listener() I need it ?

restive otter
#
async def update_stats(self):
        logger.info('Attempting to post server count')
        try:
            await self.dblpy.post_guild_count()
            logger.info('Posted server count ({})'.format(self.dblpy.guild_count()))
        except Exception as e:
            logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))

        # if you are not using the tasks extension, put the line below

        await asyncio.sleep(1800)``` put this below the @commands.Cog .listener() right under async def on_
guild_join()
frozen whale
#

The server number is well update but it don't call the function on_guild_post

restive otter
#

why you really need to call it? you are doing it manually you can just put the code you want to run below it

frozen whale
#

My target is to track when a member vote for the bot. The function on_dbl_vote isn't called when I vote and I must wait a few hours to vote again so I try event functions with the on_guild_post. Both functions on_dbl_vote and on_guild_post aren't called

restive otter
#

yeah on_dbl_vote doesn't really work I use my own server and webhooks for it

frozen whale
#

I don't have any server so I can't track member votes ?

restive otter
#

you can

#

I used it for 2 months now I have all on my own

frozen whale
#

Thanks I'm going to try it

sullen nymph
#

Hi
I did this but the function on_guild_post isn't called when I execute update_stats. The server number is well sent.
Thanks
@frozen whale It's not called manually, unfortunately

#

The guild post event is called automatically by the autoposter if you use it

frozen whale
#

I can call update_stats manually

sullen nymph
#

(You can use self.bot.dispatch("guild_post") yourself)

#

Yeah, but the event isn't called by any of the methods publicly available to you as a dev

#

aka post_guild_count doesn't dispatch on_guild_post

viscid hinge
#

hey, bots not giving voter role to people who voted
is this a known issue, or only for my server
ive tried resubmitting my server/updating it, the bots role is above the role it needs to give out
and it has admin perms

fickle jewel
#

how do i setup a webhook for the node.js dblapi

strong ibex
#

is there any reddit api for memes i can use. (Please ping me when your talking to me)

tacit drift
#

is it possible to get a webhook sent on a new review?

rain heart
#

not as of now, but definitely a good idea to suggest imo

rugged elk
#

Hey i dont understand how to do this with on_dbl_vote my Code:

# Import
import os
import json
import dbl


# From
from discord.ext.commands import Cog
from discord.ext import commands
from discord.ext import tasks

def create_json():
    if not os.path.isfile("json"):
        try:
            os.mkdir('json')
        except:
            pass

def get_prefix(bot, message):
    create_json()
    with open("json/prefixes.json", "r") as f:
        prefixes = json.load(f)
    return prefixes[str(message.guild.id)]

bot = commands.Bot(command_prefix=get_prefix, case_insensitive=True)

botcolor = 0xffffff

class topgg(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.token = '--------'
        self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dbl', webhook_auth="------",
                                   webhook_port=1234)
        self.update_stats.start()

    @Cog.listener()
    async def on_dbl_vote(self, data):
        """An event that is called whenever someone votes for the bot on top.gg."""
        print("Received an upvote:", "\n", data, sep="")

    @Cog.listener()
    async def on_dbl_test(self, data):
        print("gfvdc")
        print(data)

    @tasks.loop(hours=1)
    async def update_stats(self):
        await self.bot.wait_until_ready()
        try:
            server_count = len(self.bot.guilds)
            await self.dblpy.post_guild_count(server_count)
        except Exception as e:
            print('Failed to post server count\n{}: {}'.format(type(e).__name__, e))

def setup(bot):
    bot.add_cog(topgg(bot))```
#

and it don't works

#

i don't know anymore how to do it else

rain heart
rugged elk
#

i don't understand the docs thats the problem :/

rain heart
#

what exactly do you not understand?

#

aka what doesn't work?

rugged elk
#

the things with tghe votes

#

on_dbl_test and on_dbl_vote

hidden wave
#

so I changed my dbl api code hosting to heroku and when I tried changing the webhook URL it doesn't work

viscid hinge
#

hey, bots not giving voter role to people who voted
is this a known issue, or only for my server
ive tried resubmitting my server/updating it, the bots role is above the role it needs to give out
and it has admin perms
asked this like almost 24 hours ago

rain heart
#

It isn't api related, that's why you're not getting a response

hidden wave
#

It isn't api related, that's why you're not getting a response
@rain heart oh so I need to change back then

viscid hinge
#

oh

#

where do i ask then

#

i asked in support

#

then they redirected me here

rain heart
#

I mean Apex, not you @hidden wave

#

Well i definitely think that the dsl role stuff doesn't belong in api, not minimodding though mmLol

forest shard
#

How do you make the website display how many members your bots holds?

#

nvm

#

I mean servers

restive otter
willow spindle
#

@restive otter it is not official package

rapid kettle
#

@fickle lantern that isn’t dbl webhook

soft salmon
#

May I ask why doesn't my servers update anymore on my bot page when I added the webhooks to it?

summer tinsel
#

is it possible to use the api to get server count on my website?

willow spindle
#

yes

plucky lance
#

Instead of requesting our API to see the users who have voted for your bot, we now have webhooks! Webhooks will send a post request to a URL of your choice when your bot has been voted for.

#

It’s your own choice throwing your index into a folder or not.

vocal robin
#

When I used the dbl token by trying with my beta bot, It is showing on the page 5 server, now because it worked I implented the code in my alpha, do i have to generate the token new?

#

is it possible to use the api to get server count on my website?
@summer tinsel use a webhook

rain heart
#

When I used the dbl token by trying with my beta bot, It is showing on the page 5 server, now because it worked I implented the code in my alpha, do i have to generate the token new?
@vocal robin I suggest not using your dbl token on your testbot if your bot doesn't really have users yet. But no you won't need to regenerate it

latent narwhal
#

Hi

hidden wave
#

Hi

restive otter
#

@latent narwhal can you send me your code

vocal robin
#

@rain heart how long will it take, till it will refresh?

rain heart
#

Refresh the token?

#

Or what do you mean?

plucky tide
#

no bots appear in my bots and I already added one

rain heart
#

logout and login

plucky tide
#

logout and login
@rain heart thx

latent narwhal
#

@latent narwhal can you send me your code
@restive otter
I fixed the issue thanks

restive otter
#

👍

dawn temple
#

Okay

restive otter
#

how can i do when someone vote to my vote it will show?

i using this

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

Hey, I have a question (I'm using the API for python) :
Does event on_dbl_vote necessarily require webhooks server ?
Thank you in advance for the answers

fickle jewel
#

wait what

restive otter
#

How to set vote log in own server

#

In python

#

Boys

#

How to use this API?

jaunty plank
restive otter
#

Hello , what an api key can do?

#

Im new so ye

jaunty plank
#

https://top.gg/api/docs
all the features are listed on the docs.
The main api feature is a webhook for when users vote.

restive otter
#

Okay

#

webhook?

#

When someone vote a webhook message on a server?

#

i mean vote a bot

#

Or something

jaunty plank
#

no, top.gg webhooks dont work with discord webhooks

restive otter
#

Oh

#

Sorry for begging noob

jaunty plank
#

npnp

#

they are for sending data to your code specifically, which means making(or using one of the libs with webhook support listed on the docs page) to receive those requests.

restive otter
#

ohh

#

Okay

#

thanks

visual brook
#

wait so to create a top.gg webhook do i have to buy a domain?

jaunty plank
#

no, you can use the public ip.

visual brook
#

ah ok

#

because im trying to create a bot that gives roles as u vote

#

wait so do i need a express server?

jaunty plank
#

if your making a receiver yourself yes.

visual brook
#

reciever?

jaunty plank
#

the webhook is just an http server that receives requests.

visual brook
#

ok

jaunty plank
#

any http lib should work.

visual brook
#

ah ok

#

wait where do i get said api key

jaunty plank
#

the offical top.gg lib uses the inbuilt http module

visual brook
#

ah ok

#

this works with servers too righ?

jaunty plank
#

servers being vps/dedi machines?

visual brook
#

discord servers*

jaunty plank
#

oh, not directly.

#

it doesnt work with discord webhooks.

#

the request has to go to a discord bot for it to interact with discord.

visual brook
#

yeim creating a discord bot for it

#

\but im not exactly sure how to recieve it for servers

#

i got it for bots but

jaunty plank
#

its exactly the same, just receive the request with the proper auth and handle it any way you want.

visual brook
#

ah ok

#

tats the docs ri

jaunty plank
#

yep

visual brook
#

it still says i need a token

#

im just reading a example

#
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});```
jaunty plank
#

you can just put an empty string there, it should work fine

visual brook
#

okie

restive otter
#

T!rank

jaunty plank
#

wrong channel

visual brook
#

wait so once im done with my code, i go to the server and put my webhook there?

#

but whats the url?

jaunty plank
#

http://ip:port/path

visual brook
#

but didn't u say the ip , i could use the public one?

jaunty plank
#

yes

visual brook
#

whats hte public one

#

is it taht?

jaunty plank
#

your vps's ip, or wherever the code is being run, the public ip of that

visual brook
#

oh ok

jaunty plank
#

0.0.0.0 is not your public ip

visual brook
#

ah ok

#
const dbl = new DBL("", { webhookPort: 6500, webhookAuth: 'A23192HASD' });
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!`);
});``` if i do this, it just consoles ``Webhook running at http://0.0.0.0:5000/dblwebhook``
jaunty plank
#

its hardcoded to say 0.0.0.0

visual brook
#

oohh ok

#

its a security?

jaunty plank
#

no 0.0.0.0 just means "any ip"

visual brook
#

so im on my comp rn so in top.gg , in my server webhook i type "myip":6500

#

?

jaunty plank
#

http://myip:6500/dblwebhook

visual brook
#

got it

#

and then with those events and a client i give roles with the bot

jaunty plank
#

your code says 6500 not 5500

visual brook
#

oh ye just a example

jaunty plank
#

then yes, with the correct info thats it the url.

#

yep

visual brook
#

ty

#

ye when i do test webhook it doesn;t do anything

jaunty plank
#

do you have a firewall blocking requests?
if on a home network did you port forward?

visual brook
#

how do i port forward

jaunty plank
visual brook
#

ok then?

#

I can't login to my router lol
got locked out for 60 secs

jaunty plank
#

f

visual brook
#

they should make the default username and password admin

#

for all routers lmao

jaunty plank
#

all routers should have their default control username and password changed.

#

terrible idea to leave it default :p

visual brook
#

true

#

does anyone know the default username and password for zte routers?

jaunty plank
#

if you follow the portforward site, they list the default username and password for most routers.

#

which is why i link it, most routers have a guide specific for that router.

visual brook
#

ah ok

coarse scarab
#

yo guys i have a problem. When posting stats i get the unauthorized error even when i have this header: Authorization and Authorization: KEY

#

nvm i got it

restive otter
#

Where can i find my API token?

#

nevermind.

restive otter
#

How to use an api key

#

😅

#

can i do like when someone vote the bot and the bot give him reward

#

So h e l p

#

Anyone

#

Help

plucky lance
#

You can indeed send requests to the DBL endpoint to receive informations about your bot or use webhooks for example.

restive otter
#

Ok

jaunty plank
plucky lance
#

And yeah you’re allowed to reward users for their votes.

#

Also written down in the docs.

restive otter
jaunty plank
#

the url will typically look something like this
http://ip:port/path
ip is the public ip of the system the code is running on
port and path are defined in your code.

restive otter
#

;_;

#

how to gey webhook

#

get

#

Sorry im so dumb

jaunty plank
#

its seriously just http://publicIP:port/path

#

just have to fill in the blanks with your info.

restive otter
#

Ok

#

I have to put my IP?

#

in ip

#

?

jaunty plank
#

yeah, the public ip of where the webhook receiver code is running.

restive otter
#

port and path?

jaunty plank
#

port and path will be defined in your code

restive otter
#

Ohhh cool ok so how can i see my ip ;_;

jaunty plank
#

hosting on your home network?

restive otter
#

Yes

#

My home wifi

jaunty plank
restive otter
#

Ok

jaunty plank
#

just a heads up, on home networks youll need to port forward aswell.

restive otter
#

Okay ty

jaunty plank
restive otter
#

Ty

#

cya it's mid night

#

;_;

jaunty plank
#

👋

robust whale
#

How can I put the number of votes in the statistics command

#

using discord.js

rain heart
robust whale
#

i couldn't

rain heart
#

why not?

robust whale
#

I can only get server and shard numbers

rain heart
#

and then .size from that

robust whale
#

okay thanks

jaunty plank
#

with the dblapi.js lib you can just use getBot rather than getBots if your just getting one bots votes, the bots object that is returned has points with is the number of total votes, or monthlyPoints for the votes this month

dbl.getBot(client.id).then(bot => {
    console.log(bot.points) // 7000000
});
south yoke
#

can I have two bots log in to the same dbl client? like for testing and stuff

rain heart
#

If it's not at the same time and don't post stats (for example you wouldn't want your testbot that is in 1 server to post)

sinful knoll
#

I'm a total newbie to anything related to webhook APIs, but want to make voting rewards for my Discord.py bot. Is there a good article to get started with?

silent sky
#

ummm

#
Uncaught Promise Error:  Error: 404 Not Found
    at IncomingMessage.<anonymous> (/home/container/node_modules/dblapi.js/src/index.js:118:25)
    at IncomingMessage.emit (events.js:326:22)
    at endReadableNT (_stream_readable.js:1223:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  raw: '<!DOCTYPE html>\n' +
    '<html lang="en">\n' +
    '<head>\n' +
    '<meta charset="utf-8">\n' +
    '<title>Error</title>\n' +
    '</head>\n' +
    '<body>\n' +
    '<pre>Cannot POST /api/bots/stats</pre>\n' +
    '</body>\n' +
    '</html>\n',
  body: '<!DOCTYPE html>\n' +
    '<html lang="en">\n' +
    '<head>\n' +
    '<meta charset="utf-8">\n' +
    '<title>Error</title>\n' +
    '</head>\n' +
    '<body>\n' +
    '<pre>Cannot POST /api/bots/stats</pre>\n' +
    '</body>\n' +
    '</html>\n',
  status: 404,
  headers: {
    date: 'Mon, 16 Nov 2020 07:17:09 GMT',
    'content-type': 'text/html; charset=utf-8',
    'transfer-encoding': 'chunked',
    connection: 'close',
    'set-cookie': [
      '__cfduid=d8808f44654c53b72f01fec06cd0dd9b71605511029; expires=Wed, 16-Dec-20 07:17:09 GMT; path=/; domain=.top.gg; HttpOnly; SameSite=Lax; Secure',
      'country=US; Path=/'
    ],
    'x-powered-by': 'Express',
    'content-security-policy': "default-src 'none'",
    'x-content-type-options': 'nosniff',
    'cf-cache-status': 'DYNAMIC',
    'cf-request-id': '0671833ade0000371d6601c000000001',
    'expect-ct': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
    'strict-transport-security': 'max-age=15552000; includeSubDomains; preload',
    server: 'cloudflare',
    'cf-ray': '5f2f6e3e2a3d371d-MIA'
  },
  ok: false,
  statusText: 'Not Found'
}

restive otter
#

this is too much for my brain to process

silent sky
#

lol

fallen merlin
#
dbl.postStats(client.quilds.size)

TypeError: Cannot read property 'size' of undefined
#

how to fix it?

haughty rune
#

@fallen merlin you've put quilds

rain heart
#

You misspelled guilds

haughty rune
#

dbl.postStats(client.guilds.size)

fallen merlin
#

same code

haughty rune
#

no

#

you wrote quilds

fallen merlin
#

ahh lmao

haughty rune
#

its guilds

fallen merlin
#

lmao

#

sorry

haughty rune
#

no worries

gleaming zenith
#

How to invite bot??

rain heart
crystal flint
#

Asu

past crescent
#

how do you do a Server Count on a java bot tagg my

hidden wave
past crescent
#

thx

meager harness
#

top.gg has any api endpoint to check if a user has voted the bot today or not?

sullen nymph
#

/bots/{bot.id?}/check

visual brook
#
const dbl = new DBL("", { webhookPort: 5500, webhookAuth: 'idk-if-i-can-show-this' });
console.log(dbl)
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!`);
});```
even when i click test webhook nothing logs, can someone help?
eternal moth
#

@visual brook are you hosting free?

visual brook
plucky lance
#

Correct hostname and path?
Port 5500 opened?

eternal moth
#

cuz I couldn't do that with Heroku

visual brook
#

yep

eternal moth
#

I use Pipedream for all my POSTs

visual brook
#

im hosting it on my comp rn

#

not on heroku

rain heart
#

@eternal moth try makig a manual request through postman for example

#

Oh through your computer?

visual brook
#

Correct hostname and path?
Port 5500 opened?
@plucky lance yes

#

ye

rain heart
#

Yeah no wonder why that doesn't work, you need to portforward 5500 if you want to make it work

visual brook
#

it is portforwarded

plucky lance
#

Aye port forwarding in your router

rain heart
#

Are you sure? Try pesting the port

visual brook
rain heart
#

Oh

#

Try a postman request then

plucky lance
#

And create a rule for your firewall for incoming TCP connections on port 5500 for all apps

visual brook
#

how?

#

im not great at postman

#

i think thats already done

plucky lance
#

If you have no clue how just disable your firewall for a few seconds for the test

#

That’s faster than explain you how to create the rule

#

(on mobile)

visual brook
#

give me a sec

plucky lance
#

Btw that port test you run doesn’t say anything about the real status of it

visual brook
#

oh then what should i do?

plucky lance
#

Test the webhook now with a disabled firewall

#

If it still doesn’t work the port isn’t open

visual brook
#

no there's no other console

#

the thing is i personally called my isp and they told me its open

meager harness
#

/bots/{bot.id?}/check
@sullen nymph this has rate limit?

plucky lance
#

The ISP doesn’t block ports but your router does

sullen nymph
#

Only the global ratelimit that applies to all routes

#

60/60s

meager harness
#

Oh! Ok

visual brook
#

no the isp gave me the router and set it up

#

and they opened the port

plucky lance
#

Do you have set a rule in your router yet?

#

To your device (PC)?

visual brook
#

ah no

#

any documentation fort aht

plucky lance
#

Well google the routers name and/or type

#

It should usually not block incoming connections to your device but that’s the last barrier if your firewall is disabled

visual brook
#

okie imma try that

#

would u reccomend me onloading that onto a vps and testing it?

plucky lance
#

That’s easier since there’s nothing which blocks your connections by default if you haven’t set it up manually

visual brook
#

ye

plucky lance
#

huh? I don’t understand the question.

visual brook
#

ye nvm

plucky lance
#

The router of the hoster doesn’t block connections only your servers firewall does if set up

rain heart
#

Use something like ngrok for testing maybe

granite spire
knotty garnet
#

just do netstat smh

tiny heart
#

Where to do coding?

sullen nymph
#

waat

tiny heart
#

I am nt able to see server counts i can only see N/A

#

So where to do coding for that?

vocal ledge
#

in ur bots code/ main file

sullen nymph
tiny heart
#

Ok

#

Thanks 😄

#
const dbl = new DBL(process.env.TOKEN, client);```
#

Is this ok?

visual brook
#

the webhook isn't working for me

const dbl = new DBL("", { webhookPort: 5500, webhookAuth: 'aaaaaaa' });
console.log(dbl)
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!`);
});``` im running this on a vps but it still does not console anything when i click test webhook on top.gg
maiden dock
#

How top.gg/servers Webhook url works theres no Auth

visual brook
#

there is an auth?

maiden dock
#

Where

#

Im seeing no Auth

#

I mean Token*

#

This thing for top.gg/servers/ID/edit is not there

#

@visual brook ^

visual brook
#

its for servers

maiden dock
#

How will i do webhooks without the Token

visual brook
#

@plucky lance if ur online can u help me with this

restive otter
#

Can someone please help me with this problem?

#

I'm trying to install dblapi.js with npm

#

but this happens Could not install from "dblapi.js" as it does not contain a package.json file.

tiny heart
#

Please Help

    at IncomingMessage.<anonymous> (/home/runner/my-sr2-bot-1/node_modules/dblapi.js/src/index.js:118:25)
    at IncomingMessage.emit (events.js:327:22)
    at IncomingMessage.EventEmitter.emit (domain.js:483:12)
    at endReadableNT (_stream_readable.js:1220:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:351) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:351) [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.
rain heart
#

Wrong dbl token presumably

maiden dock
#

How will i do webhooks without the Token
@maiden dock

restive otter
#

Wrong dbl token presumably
@rain heart wut? i only wanna install dblapi

tiny heart
#

Wrong dbl token presumably
@rain heart me?

rain heart
#

I meant @tiny heart

#

@restive otter check the top.gg docs for the correct package

tiny heart
#

my code is

const dbl = new DBL(process.env.TOKEN, client);```

and error is
```(node:351) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized
    at IncomingMessage.<anonymous> (/home/runner/my-sr2-bot-1/node_modules/dblapi.js/src/index.js:118:25)
    at IncomingMessage.emit (events.js:327:22)
    at IncomingMessage.EventEmitter.emit (domain.js:483:12)
    at endReadableNT (_stream_readable.js:1220:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:351) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:351) [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.```
maiden dock
#

Nvm my prblm fixed

restive otter
#

mine isnt

#

@restive otter check the top.gg docs for the correct package
@rain heart I'm doing npm install dblapi.js but it isnt working

#

same error

#

Could not install from "dblapi.js" as it does not contain a package.json file.

tiny heart
#

where can i see my top.gg token?

sullen nymph
tiny heart
#

thanks 😄

restive otter
#

can someone please help me?

jovial kiln
#

Sure

restive otter
#

Can someone please help me with this problem?
I'm trying to install dblapi.js with npm
but this happens
Could not install from "dblapi.js" as it does not contain a package.json file.

#

@jovial kiln Any idea?

jovial kiln
#

Do you have a package.json

eternal moth
#

nice rank up @jovial kiln

plucky lance
#

@visual brook Yo I'm back. What's up?

rain heart
visual brook
#

@plucky lance the bot with the same code doesn't work on the vos too

swift elm
#

What's a 1006 error code mean?

jaunty plank
#

1006 with the api?

plucky tide
#

no bots appear in my bots and I already added one

rain heart
#

logout and back in

#

not related to api though

#

@plucky tide

plucky tide
rain heart
#

oh

jaunty plank
#

I dont remember if bots show in the api page until approved or not.

rain heart
#

yeah your bot has to be approved first

#

in order to use api features

jaunty plank
#

yeah, they dont show on that page until approved. you can see your bots on here.
https://top.gg/me

#

what where you saying about prefixes before i interrupted @pallid forge

visual brook
#

oh gg @jaunty plank

jaunty plank
#

oh wrong chat KEKW

plucky lance
#

@visual brook oh lol did u try the webhook for a non-approved bot?

visual brook
#

Non approved?

#

I didn't put any bot in it yet

#

Just calling the wbhook

plucky lance
#

Don’t think that will work without any bot.
The webhook will post requests to your endpoint only if an event got triggered for your bot.

#

For example a vote

visual brook
#

ye i do have a event @plucky lance

#

i have the vote eve

lyric bay
#

okay so what powers does the top.gg api hold?

jaunty plank
lyric bay
#

ty

drifting nebula
#

Is the dblapi.js still depreciated?

sour sequoia
#

how do i make that my bot will say how many servers he is in on the web

restive otter
#

U have to post your stats using the API

sour sequoia
#

me?

restive otter
#

ye

sour sequoia
#

okay ty

restive otter
#

If there are any problems ping me ;)

visual brook
#
const dbl = new DBL("", { webhookPort: 5500, webhookAuth: 'aaaaaaa' });
console.log(dbl)
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!`);
});``` im running this on my vps but when i click test webhook nada
sour sequoia
#

@restive otter
i downloaded that, now look,

#
ot.on('ready', () =>{
    console.log("this bot is online!");
    setInterval(() => {
      bot.user.setActivity(`a!help | ${bot.guilds.cache.size} Servers.`, {type: "PLAYING"});
  }, 60000);
  setInterval(() => {
    dbl.postStats(bot.guilds.size, bot.shards.total);
}, 1800000);  
  })
#

i added that to ready event

restive otter
#

Yes

sour sequoia
#

is it like that?

restive otter
#

Yes

#

but keep in mind

sour sequoia
#

?

restive otter
#

the first time it will post is in 180000 ms

sour sequoia
#

its 30m

restive otter
#

so u may should add one in the ready event and one in the interval

#

yes

sour sequoia
#

wdym?

#

i have to?

restive otter
#

No

sour sequoia
#

or it will do the same thing with that as well

restive otter
#

K

#

lemme say it bettrr

#

The first time it will post the stats is in 30 minutes

sour sequoia
#

okay

restive otter
#

so you may would like to set it in the ready event aswell, to let the stats instant posted

sour sequoia
#

okay.

#

o and

#

look

#

i always need to refresh it

#

so it will show that he is approved

restive otter
#

ye, its the cache

sour sequoia
#

will it fix it self in a couple of hours?

#

???

restive otter
#

yes

sour sequoia
#

and so do the votes?

restive otter
#

Idk, it seems to take a few hours on my bot

sour sequoia
#

and so do the votes?
@sour sequoia

#

?

restive otter
#

Aswell

sour sequoia
#

okay ty

#

lol and 1 last thing

restive otter
#

Yes

sour sequoia
#

and so do the N/A

#

?

restive otter
#

N/A will be the server count

sour sequoia
#

ik

#

so it will change in 30m right?

restive otter
#

But you gotta wait first 30 minutes

#

yes

sour sequoia
#

okay

#

wow you should get promoted lol

restive otter
#

and do you have shards?

sour sequoia
#

not yet

restive otter
#

Then you have to limit stats posting to only the serverd

sour sequoia
#

i did

restive otter
#

So bot.shards.total should be removed

#

k

sour sequoia
#

i already removed it

restive otter
#

then you only have to wait 30 minutes and it should work ;)

sour sequoia
#

wow you should get promoted lol
let me know if they did

restive otter
#

Lool

#

I gotta survive the trials first

sour sequoia
#

good luck

restive otter
#

But Im going for it

#

thanks

sour sequoia
#

just... keep doing what you did with me

#

and you will be good

restive otter
#

I will ;)

agile moat
#

hello i have a question. How toes the top.gg api work? this is my code (Discord is also defined):


const DBL = require("dblapi.js");
const dbl = new
DBL(`my token here (its a correct token)
`, bot);

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

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

And i get this error:

``Oops! TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["authorization"]``
slender flower
#

change

DBL(`my token here (its a correct token)
`, bot);

to

DBL(`my token here (its a correct token)`, bot);

You shouldn't leave the trailing new line at the end as its an invalid header field value character

#

@agile moat ^

agile moat
#

k

tiny heart
#

what is webhook?

sour sequoia
#

its been 2h since i added the server count thing

#

and it still show N/A

tiny heart
#

its been 2h since i added the server count thing
@sour sequoia please show the code

sour sequoia
#
bot.on('ready', () =>{
    console.log("this bot is online!");
    setInterval(() => {
      bot.user.setActivity(`a!help | ${bot.guilds.cache.size} Servers.`, {type: "PLAYING"});
  }, 60000);
  setInterval(() => {
    dbl.postStats(bot.guilds.size);
}, 1800000);  
  })
#

@tiny heart

tiny heart
#
bot.on('ready', () =>{
    console.log("this bot is online!");
    setInterval(() => {
      bot.user.setActivity(`a!help | ${bot.guilds.cache.size} Servers.`, {type: "PLAYING"});
  }, 60000);
  setInterval(() => {
    dbl.postStats(bot.guilds.size);
}, 1800000);  
  })

@sour sequoia not this

#

give server count one

#

@sour sequoia

Add this

const dbl = new DBL('Your top.gg token', client);```
sour sequoia
#

i did

tiny heart
#

show that

sour sequoia
#
const DBL = require("dblapi.js");
const dbl = new DBL('jauhgahguahngmuajguagujuajguagj', bot);

fake token btw

#

just spammed buttons

tiny heart
#

any error?

sour sequoia
#

no

#

yes

tiny heart
#

how did you defined bot

sour sequoia
#

i found a erorr

tiny heart
#

i found a erorr
@sour sequoia show

sour sequoia
#

Error: 401 Unauthorized

tiny heart
#

your token is incorrect

#

did you used your top.gg bot token? or Discord Developer Portal one?

#

@sour sequoia

sour sequoia
#

Discord Developer Portal

restive otter
#

@sour sequoia Did you got an error?

sour sequoia
#

Error: 401 Unauthorized

#

did you used your top.gg bot token? or Discord Developer Portal one?
@tiny heart
Discord Developer Portal

tiny heart
#

Discord Developer Portal
@sour sequoia use top.gg one

sour sequoia
tiny heart
#

1 min

sour sequoia
#

k

restive otter
#

and then get your api token

tiny heart
restive otter
#

^

#

Yes

sour sequoia
#

hello world

tiny heart
#

???

sour sequoia
#

thats the web you sent me to

#

@tiny heart

tiny heart
#

@sour sequoia

sour sequoia
#

k got it

#

ty

tiny heart
#

np 😄

restive otter
#

Whats your code rn (Remove your token)

sour sequoia
#

wow thats a really long token

restive otter
#

Yes

#

it is

sour sequoia
#

can i do

#

const dbltoken = 'long a$$ token'

#

and then

#

const dbl = new DBL(dbltoken, bot);

restive otter
#

Yes

tiny heart
#

yes i think so

sour sequoia
#

okay

restive otter
#

Thats correct

tiny heart
#

i have done like

const dbl = new DBL(process.env.TOPGG, client);```

and still it works
restive otter
#

Yes

#

change client -> bot

#

if you defined client as bot

tiny heart
#

no

#

i have defined client only

sour sequoia
#

em

restive otter
#

k

sour sequoia
#

guys

tiny heart
#

not bot

restive otter
#

but im talking to broken tooth

tiny heart
#

guys
@sour sequoia any error?

sour sequoia
#
bot.on('ready', () =>{
    console.log("this bot is online!");
    setInterval(() => {
      bot.user.setActivity(`a!help | ${bot.guilds.cache.size} Servers.`, {type: "PLAYING"});
  }, 60000);
  setInterval(() => {
    dbl.postStats(bot.guilds.size);
}, 1000);  
  })```
#

i forgot what to put instead of the 1000

#

i changed it so it will send the error

#

forgot the number

tiny heart
#

1800000

#

@sour sequoia

sour sequoia
#

k ty

tiny heart
#

np

sour sequoia
#

what is the minimum i can put the number on?

#

with out the bot crashing

#

Y E S @tiny heart @restive otter

#

ty for the help

#

and omg @restive otter get promoted already

restive otter
#

@sour sequoia Lol, nice that it works!

agile moat
#

hello i have another API question

const waah = `token`
const DBL = require("dblapi.js");
const dbl = new DBL(waah, bot);


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

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

the console error is

Oops! Error: 401 Unauthorized

#

Discord is also defined

#

ok nvm the token was wrong lol

restive otter
#

nvm

#

u found it out

fiery owl
#

may someone help me to set up the vote webhook?

tacit lichen
plucky lance
#

Nope
It’s not supposed to send requests to Discord webhooks but to your own endpoint.

fiery owl
#

is something like this ok?

#

and if yes, where can i find an ip to use for free? is the one of my home wifi good? Since i cannot use heroku one...

buoyant geode
#

IP:5000/dblwebhook

#

is this right?

tiny ingot
obsidian delta
#

Hi, which library can i use for top.gg api in javascript?

plucky lance
#

Take a look at the docs pinned in here

obsidian delta
#

Yes, but dblapi.js package has been deprecated

versed storm
#

It's still working and has no alternative for now

placid peak
#

someone have to undeprecate it

#

aka fork and continue maintaining

restive otter
#

yep

buoyant geode
#

the events are not working

#

i connected to my webhook but it is not getting post

fair herald
#

Hm,

restive otter
#

@buoyant geode U replaced 0.0.0.0 with your IP?

buoyant geode
#

yes

#

i did

restive otter
#

Hm

#

Did u set the correct auth?

buoyant geode
#

look

fiery owl
#
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});```
buoyant geode
#
const dbl = new DBL(process.env.dbl, 
        { webhookPort: 5002, webhookAuth: 'haha no' });
        dbl.on('posted', () => {
            hook.send("DBL posted");
        })
        dbl.on('error', e => {
            return require('../../tools/error')(e, undefined);
        })
        dbl.webhook.on('ready', hook => {
            console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
        });
        dbl.webhook.on('vote', async vote => {
            const user = client.users.cache.fetch(vote.user);
            if(user){
                hook.send(`${user.username} just voted ${client.user.username}`);
            }
        });
#

look

fiery owl
#

so i have to set this on my index and then use the "has voted" on the vote command?

restive otter
#

wait it's not hook.send

#

i think

#

cuz hook is not defined in that event

#

i think

vagrant oyster
#

My console is getting spammed by this

{ Error: 401 Unauthorized
    at IncomingMessage.res.on (/root/xx/node_modules/dblapi.js/src/index.js:118:25)
    at IncomingMessage.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
  raw: '{"error":"Unauthorized"}',
  body: { error: 'Unauthorized' },
  status: 401,
  headers:
   { date: 'Mon, 16 Nov 2020 15:14:07 GMT',
     'content-type': 'application/json; charset=utf-8',
     'content-length': '24',
     connection: 'close',
     'set-cookie':
      [ '__cfduid=d5da86113247a78exxb1c102db91605539647; expires=Wed, 16-Dec-20 15:14:07 GMT; path=/; domain=.top.gg; HttpOnly; SameSite=Lax; Secure',
        'country=GB; Path=/' ],
     'x-powered-by': 'Express',
     'access-control-allow-origin': '*',
     'access-control-allow-headers': 'Authorization',
     etag: 'W/"18-XPDxxMk4yY1/PADG4jYM4rSI"',
     'cf-cache-status': 'DYNAMIC',
     'cf-request-id': '067337e76e000xx1000000001',
     'expect-ct':
      'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
     'strict-transport-security': 'max-age=15552000; includeSubDomains; preload',
     'x-content-type-options': 'nosniff',
     server: 'cloudflare',
     'cf-ray': '5f322xx065a-LHR' },
  ok: false,
  statusText: 'Unauthorized' }
leaden obsidian
#

it might be a stupid question sweat_2 how can I make the bot to perform something when someone vote ?

restive otter
#

am currently trying to make it so when the user votes for the bot they receive a item

leaden obsidian
#

same here laugh

restive otter
#
dbl.webhook.on('vote', async (vote) => {
    const user = bot.users.cache.fetch(vote.user);
    if(user){
    hook.send(`${user.username} just voted ${bot.user.username}`);
            }
      const findItem = data.items.find(i => i.name.toLowerCase() == 'key');
      let userInv = data.items.filter(i => i.name.toLowerCase() !== 'key');
      if (findItem) {
      userInv.push({ name: 'key', amount: 1, description: 'Vote key.' });
            data.items = userInv;
            await data.save();
            }
})
#

not sure if it will work

leaden obsidian
#

oh I have to use the webhook

#

ty for the info ❤️

restive otter
#

fetch is not a function

#

make get instead of fetch

restive otter
#

Hey can anyone help me dbl api I'm getting error on heroku dbl not found

#

And i had installed dblpy

buoyant geode
#

cuz hook is not defined in that event
@restive otter hook is a Webhook from Discord

#

and if it is not defined, node.js will tell me

restive otter
#

Hey can anyone help me dbl api I'm getting error on heroku dbl not found?

twilit wigeon
restive otter
#

i don't know how to do

rain heart
restive otter
#

@rain heart hey can you help me with dblpy api

rain heart
#

the documentation explains everything

#

i don't have any advanced knowledge of python

restive otter
#

K

wispy peak
restive otter
#

I copied the msg of H so credits to him

#

🤣

rain heart
wispy peak
#

So where to put this!?

#

Pls help

jaunty plank
#

thats just a url to the widget

wispy peak
#

Yes so where should I put the url??

jaunty plank
#

wherever you want the widget to show.

rain heart
wispy peak
#

Umm like 😅

jaunty plank
#

this is what it looks like

leaden obsidian
#

anyone here that can kindly explain me how to setup the webhook sweat_2

wispy peak
#

Umm where is the place to insert it I'm new in topp.gg advertising bot

jaunty plank
#

insert what, insert the widget link?

leaden obsidian
#

i use python cry_2

wispy peak
#

Yes @jaunty plank

jaunty plank
#

you insert it where ever you want the widget to show

wispy peak
#

Means in the bot setup right??

jaunty plank
#

theres not any reason to put it there imo, since the stats the widget shows is already on your bots page.

#

the widget is pretty much just an image with your current bot info.

wispy peak
#

Why am I not able to edit it??

rain heart
#

Because you cant

wispy peak
jaunty plank
#

you dont.

#

you put that, where you want your widget to be shown

#

if you for example, have a website, you can put your widget there

#

if you want it to show in a command a user can do, you put it in the response there.

wispy peak
#

I don't have any website for bot

jaunty plank
#

the widget isnt mandatory, its just an optional visual thing.

restive otter
#

@restive otter hook is a Webhook from Discord
@buoyant geode k

jaunty plank
#

if you have no use for it, you dont need to do anything with it.

wispy peak
#

But I wanna remove that N/A

jaunty plank
#

widgets have nothing to do with posting server counts.

wispy peak
#

And put my server no. list there

#

Then how do I do

jaunty plank
#

under the tools section of the docs, you can view the various libraries which can post your server count for you, or you can use the api endpoints.

for the manual api endpoint https://top.gg/api/docs#bots

wispy peak
#

Where??

jaunty plank
#

thats not the docs.

wispy peak
#

Where?

rain heart
#

Read it

#

Read the title of that page

wispy peak
#

Ok

#

Now?

#

Where should I head??

#

Widgets??

rain heart
#

what is your goal? interacting with the api, correct?

jaunty plank
#

widgets do nothing for you posting server count

wispy peak
#

My goal is to remove N/A and put the no. of servers my bot is in..

rain heart
#

go to your corresponding Bot language under tools then

#

Read the documentation there

wispy peak
#

I actually didn't start coding in JavaScript cuz my pc is gone... So currently I'm doing it through bdfd

#

At winters I'll start with javascript

rain heart
#

Can't help you then

#

you wont be able to use dbl's api with bdfd

wispy peak
#

Kk tellme for javascript only..

visual brook
#

hi my ports are all open and this is my code

const dbl = new DBL("", { webhookPort: 5500, webhookAuth: 'A23192HASD' });
console.log(dbl)
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});

dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});``` but even when i input this on my top.gg server and click test webhook nothing logs can someone help
rain heart
#

Read the tool section for your corresponding programming language then

visual brook
#

am i supposed to add the discord bot of it rn??

rain heart
#

Did you follow the webhook tutorials on the apidocs correctly?

visual brook
#

yes

jaunty plank
visual brook
#

ywait its a server

#

not a bot

#

isn't it the same?

jaunty plank
#

its the same, didnt notice you where talking about a server!

#

mb

visual brook
#

and if its same for server too then yes

#

ye its a server 😅

jaunty plank
#

the url will look something like
http://ip:5500/dblwebhook

visual brook
#

yep

jaunty plank
#

ip not being 0.0.0.0

visual brook
#

yep

#

myvpsip:5500/dblwebhook

jaunty plank
#

sorry if this all seems basic to you, lots of people learning these things.

visual brook
#

ah ok np

#

im running it on my vps so all ports are forwared

#

i clarified that again with my provider

jaunty plank
#

I think it may be
const DBL = require('top.gg');
needing to be
const DBL = require('dblapi.js');

#

unless top.gg is a clone of dblapi.js

visual brook
#

ok let me try

#

it is a clone

jaunty plank
#

oh intresting, can you link to it?

visual brook
#

sure

#

its a fork

jaunty plank
#

as far as i can tell, it should work.

visual brook
#

ye this is just the sampel

#

its supposed to work haha

#

but for some rerason its not

jaunty plank
#

potentially might be beneficial to use something like postman to test it manually

visual brook
#

im not sure how to use postman

rain heart
#

anyone getting ```
long error code brr

@leaden obsidian try in #development if that's not api-related

leaden obsidian
#

i see thanks

visual brook
#

its really weird its not llo

jaunty plank
#

postman just makes http requests so you can test things.
for example heres a postman test to my webhook.

visual brook
#

ok just give me a sec

jaunty plank
#

yeah, going through top.gg you dont get the various errors you can get.

visual brook
#

im just making a account on there

#

ah ok

#

so its like a manuak checker

jaunty plank
#

yeah, just gives more control/info

visual brook
#

ye i hate my internet

#

isn['t allowing me to even login lmao

#

imma do it tommorow its really late here

jaunty plank
#

okay!

restive otter
#

postman just makes http requests so you can test things.
for example heres a postman test to my webhook.
@jaunty plank where is this page ?

rain heart
#

that's just the password you can use in order to authorize the requests

#

it has to match the one on your bot page

jaunty plank
rain heart
#

postman useful indeed

restive otter
#

but how can i get this password?

#

@restive otter you make it

#

on your bot page

#

then webhooks

#

on my bot's page it doesn't have this password, just a key api

#

@restive otter

#

thanks

#

👍

#

@jaunty plank how are you getting the port ?

jaunty plank
#

The port can be any available port.
You define it in your code.

restive otter
#
const dbl = new DBL(process.env.dbl, { webhookPort: 5002, webhookAuth: 'password' });
#

just have that atm

jaunty plank
#

Then the port is 5002

restive otter
#

well its just copyed

#

from a post

#

so i have no clue atm

jaunty plank
#

The webhookPort: 5002 is what sets the port.

restive otter
#

ye

jaunty plank
#

You fill in the url that points to your webhook receiver.

#

In most cases the structure is.
http://publicIP:port/path

restive otter
#

is that your ip ?

#

Can anyone help me with dblpy api?

#

@jaunty plank is there a video on the api on how to set the webhook up so am not taking up your time ?

#

I don't know how it works, what would the path be?

jaunty plank
#

Nope. The webhook is seriously just an http server which receives post requests on a single endpoint.

#

Most libs set the default path to dblwebhook

restive otter
#

Woo would you put public ip as my public ip ?

jaunty plank
#

Yeah where ever the code is running, the public ip of that.

grizzled gate
#
const bot = new Discord.Client();
const waah = `hiddentoken`
const DBL = require("dblapi.js");
const dbl = new DBL(waah, bot);


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

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

this not work, why? 🤔
little mason
#

Hello, any idea on why dblpy lib auto guild posting is not posting the shardcount too?

restive otter
#

this not work, why?
@grizzled gate uh i think its client, not bot

jaunty plank
#

it can be called bot, depending on the users definition.

restive otter
#

it can be called bot, depending on the users definition.
@jaunty plank isnt client the built-in topgg module?

jaunty plank
#

the client/bot needs to be your actual bot(logged in)

#

no, client is discordsjs or eris client

restive otter
#

ah ok

jaunty plank
#

it can be called whatever, it just needs to be the actual client for the autoposter

grizzled gate
#

this not work, why?
@grizzled gate uh i think its client, not bot
@restive otter thank you ❤️

restive otter
#

@restive otter thank you ❤️
@grizzled gate no read what @jaunty plank said above, I suggest taking the waah variable out and replacing it with your token directly, and seeing if it works.

fathom narwhal
#

is this correct? py self.dblpy = dbl.DBLClient(self.bot, self.token)?

#

its working on my pc but not on server?

violet wave
#

I would need help with one thing
How do I build my Webhook https address?

#

Forgot which parts belong where

#

https://ip:port?/dblwebhook

jaunty plank
#

http://ip:port/path

#

if youve not setup ssl, dont use https

violet wave
#

My entire ip address when I google it? (Hosting on device)

jaunty plank
#

yeah, public ip.

#

if its on a local network, youll need to port forward aswell.

rain heart
#

i still suggest using ngrok for testing it out

#

for production, use the servers ip

#

so you don't have to go through the hassle (and presumably security) of portforwarding

fiery owl
#

If i am using heroku to host the bot, the webhook url will be something like this right?https://git.heroku.com/RepoName.git/dblwebhook

rain heart
fiery owl
#

well it does not work

#

was looking for a suggestion

fair herald
#

What no

#

Thats not how heroku works

fiery owl
#

so i have to use an ip?

fair herald
#

Thats the git repo, not the application

#

No

#

You can use a domain

fiery owl
#

from heroku?

fair herald
#

Use

#

Have you ever used heroku before?

#

Send the heroku application name

fiery owl
#

no, my only experience is hosting my bot...

fair herald
#

Send the heroku application name
@fair herald

fiery owl
#

dogmahost

fair herald
#

@fiery owl what port have you set the thing to be

fiery owl
#

no one

#

i can set it to a casual one like 5000 ig?

fair herald
#

Yes

#

You are using discord.js right?

#

Or a javascript lib

fiery owl
#

discord.js

fair herald
fiery owl
#

https://dogmahost.herokuapp.com:5000/dblwebhook

fair herald
#

Yes

fiery owl
#

alright thanks a lot, let me try

fair herald
#

I think so atleast

#

Im going to be. So dont ping me

fiery owl
#

ah okay, i just tried the request from webhook but nothing from console

jaunty plank
#

Try without the port in the url.
Use the PORT environment variable in your code.

fiery owl
#

i dont know how to use this PORT environment variable

#

you mean to just remove the port thing from the code?

jaunty plank
#

Nope, using the port environment variable. The specific way to use it depends on the language.

fiery owl
#

i am using discord.js

jaunty plank
#

process.env.PORT rather than 5000

fiery owl
#

okay will try immediatly

#

Cannot read property 'on' of undefined

#

i am using this:

#
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});```
#

instead of 5000 i put : process.env.PORT

versed storm
#

probably returns undefined if you didn't specify a valid token.

fiery owl
#

i used the correct token tho, the one from the site

jaunty plank
#

The webhook doesn't require a token anyway.

versed storm
#

I mean that's literally the exact example from the docs

#

did you change it in any way?

fiery owl
#

yes yes ofc i changed the things, just dont wanted to share token ecc

#
const dbl = new DBL(`very long token`, { webhookPort: process.env.PORT, webhookAuth: 'blanknamepassword' });

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

looks like this

#

and the url is : https://dogmahost.herokuapp.com/dblwebhook

jaunty plank
#

Which you are doing.
Maybe heroku uses a diffrent env variable.

#

Well, it says its PORT
The port to bind to is assigned by Heroku as the PORT environment variable.

fiery owl
#

maybe i should specify the port in the url too?

jaunty plank
#

The error is specific to the code

fiery owl
#

yes it says : Cannot read property 'on' of undefined

jaunty plank
#

This code is running on heroku correct?

#

Your not testing locally right?

fiery owl
#

ah, i am testing it not on heroku