#topgg-api

1 messages · Page 73 of 1

frigid shore
#

@arctic arch how to make request

sullen nymph
#

Скинь свой полный URL и webhookAuth мне в лс

frigid shore
#

ну так это же секрет..

sullen nymph
#

Ты уверен, что webhookAuth и Authorization одинаковы?

#

Порт открыт полностью?

frigid shore
#

да, auth одинаковый точно

#

а что значит порт открыт полностью

sullen nymph
#

Брандмауэр не блочит, порт открыт в настройках роутера, т.д

frigid shore
#

а, ну это я не знаю)

#

я могу поместить на глитч

#

но

#

я не знаю айпи

little ice
#

hum

#

look like this is the error

sullen nymph
#

Что

frigid shore
#

ты айпи спалил

sullen nymph
#

Как ты не знаешь, открыт ли порт? nekohmm

arctic arch
#

is that the current IP of the webhook server

frigid shore
#

ну в общем

#

мой скрипт

little ice
#

yup

#

whenever i use the button test

#

sometimes it work

#

sometime it don't

#

and produce this

arctic arch
#

are all your ssl things in order

frigid shore
little ice
#

it should be

#

i changed it like 4 months ago

sullen nymph
#

Шо по айпи

#

Ты где айпи брал

little ice
#

'running test rn in case'

frigid shore
#
const dbl = new DBL('токен',{webhookPort:1024, webhookAuth:'пароль'})

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

это все

sullen nymph
#

Я бы попробовал порт выще 1024

frigid shore
#

может еще что-то надо

#

мне просто тонку сказал 1024

sullen nymph
#

Tonkku were you sure suggesting port 1024 was a good idea nekohmm

arctic arch
#

I said

#

but 1024 should work

little ice
#

looks good

#

no major error

sullen nymph
#

Я готов уйти в запой

arctic arch
#

it would error otherwise

frigid shore
#

стоп, его еще открывать надо?

sullen nymph
#

Офк

#

Они магически сети доступными не становятся pogey

frigid shore
sullen nymph
#

В настройках роутера nekohuh

frigid shore
#

о гспд

arctic arch
#

is this getting off topic

frigid shore
#

?

sullen nymph
#

A bit

arctic arch
#

are you talking about the api or not

frigid shore
#

about api

#

Не

#

походу не выйдет

#

у меня нет админского доступа к роутеру

sullen nymph
#

Рип

#

Можно тогда попробовать порт 80 ErynDerpyn

frigid shore
#

он открыт? Harold1

little ice
#

should i use other cipher ?

#

or any idea of why it does this ?

sullen nymph
#

По стандарту для хттп открыт

#

Нам стоит переместиться в #memes-and-media если мы будем говорить о портах

frigid shore
#

ну ок

vapid cape
#

@little ice are you using letsencrypt with nginx?

little ice
#

uh

#

euh

#

i don't know like that

#

any way to check this ?

vapid cape
#

is nginx your primary webserver?

little ice
#

yes

vapid cape
#

how did you configure SSL for it?

little ice
#

i mean it's from some times ago but by looking though tutorial and all and manipulating nginx.conf

#

i bought a certificate and configured it

vapid cape
#

ah you bought it

little ice
#

yeah

vapid cape
#

where did you buy it from?

little ice
#

my certificate is fine

#

i do have 2 "issues"

#

but there not errors

vapid cape
#

what are the issues?

restive otter
#

Who is Russian?

little ice
restive otter
#

@sullen nymph @frigid shore are you Russian +

frigid shore
restive otter
#

О ура

#

Го в ЛС

#

А кто ещё русский?

frigid shore
#

щас, я просто делаю

sullen nymph
#

Просто опиши свою проблему

restive otter
#

Не-не я просто так, пообщаться

#

Бота кодите?

sullen nymph
#

Я занят + советую прочитать тему этого канала

restive otter
#

Кто может помочь с Dashboard?

vapid cape
#

@little ice show your nginx ssl configuration

little ice
restive otter
#

@sullen nymph а какую ты библиотеку написал?

#

Просто у тебя роль Library Coder

frigid shore
#

ДАААААААААААААААААААААА

little ice
restive otter
#

А что за библиотека?

vapid cape
#

@little ice the only thing i see different from my config is that you dont have TLSv1.3

#

but that shouldnt matter, as most people still use TLSv1.2

little ice
#

yeah

#

surely

vapid cape
#

does your cypher list contain all of these?

#

ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384

little ice
#

ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES

#

i did try the test button 3 times waiting 5 minutes between in case

#

only one passed

#

other just vanished

#

nothing logged in error.log

#

and the same problem doesn't happen with service like zapier/twitch for example

vapid cape
#

very strange

#

do you have these in your ssllabs report?

little ice
#

first no because i still had Tlsv 1.1

#

but after removing it i do have the same error

#

but it shouldn't be a problem

#

this affect only old browser basically

vapid cape
#

check this

#

to use older TLS versions, you need to enable the older cyhpers as well: ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA;

#

another thing you could do is update your openssl and your nginx

#

and enable tls 1.3 while you're at it

little ice
#

i don't think i need to enable older cipher

#

could be a security breach somehow

vapid cape
#

well idk which cyphers the client sends

#

then set it up with their "intermediate" profile

#
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;```
little ice
#

ssl_prefer_server_ciphers off;

#

i do have this on

vapid cape
#

this basically lets the client chose their preferred cypher

#

instead of the server enforcing it

#

mozilla posted an article about it, saying that its better for the server to decide with old protocols, but better for the client to decide with newer ones

#

because newer ones are all secure enough that you can let the client decide based on performance instead of security

little ice
#

uh

vapid cape
#

yeah your nginx doesnt support 1.3

#

thats why update

#

or remove it and keep it on 1.2 only

little ice
#

will do that for now

#

test button are working for now

#

i will wait for an actual vote

#

thanks a lot for your patience and help

#

really appreciated

vapid cape
#

i hope it works lol

little ice
#

i hope too ..

arctic arch
#

so I'm now looking at the logs

#

seems like most requests work

#

but I did see a few status code 500 responses

#

and now there's a few 301 responses because it was http (webhook wont follow redirects)

#

and 3 requests that got no response because you mistyped https as htpps

#

but otherwise it's all successful around

restive otter
#

why?

#

n/a

vapid cape
#

you need to post server count yourself

restive otter
#

where

vapid cape
#

read the link

restive otter
#

im read

#

no found

vapid cape
#

you need to send a POST request to the top.gg API

#

you can do that manually with any HTTP library, or you can do that with one of top.gg's libraries

restive otter
#

your bot is accepted?

#

No

#

So that can't work

#

wait till someone accept your bot

#

Ok, then if it doesn't show that it is online, it's also because it hasn't been accepted yet?

#

that don't work because @abstract moth is watching top.gg

#

and your bot is in approval

#

at me was the same error

#

OK thanks for the information

green mantle
restive otter
dapper copper
#

@green mantle you know

#

lol

restive otter
#

pls meme

ionic flame
#

just checking user has voted or not

#

on command having cooldown of 10 seconds

restive otter
#

Someone can help me when someone vote the bot to send in a specific channel with webhooks?

green mantle
#

DBL webhooks iirc don't support that directly, you would have to use your own webhook system for sending to discord

ionic flame
#

just checking user has voted or not
... if anyone knows why?

green mantle
#

you shouldnt be flooding the API with requests to get votes

#

it would be better having a temp file or db for storing votes

vapid cape
#

@ionic flame are you the only one who uses it? or is it a public command?

#

if its public, are there multiple people using it at the same time?

ionic flame
#

@vapid cape it is public. But afaik 60 requests are allowed/min

#

And i don't think 60 ppl run cmd at sane time

vapid cape
#

are you checking if they have voted every single time they use a command?

#

regardless of rate limits, this is a very bad solution

#

you should at least use caching

#

or switch to webhooks

ionic flame
#

How can i use webhook to check whether they have voted?

green mantle
#

store it

ionic flame
#

Like DB?

#

And it's pretty strange, rate limits go after I restart the bot!

vapid cape
#

is this in seconds or miliseconds? @arctic arch

arctic arch
#

seconds

vapid cape
#

@ionic flame make sure you log every request so you can get a visual on how many requests your bot is actually making

#

but yes, the ideal solution would be to use a database, and store votes as you receive them via webhooks

#

and then check if a user has voted in your database

#

you can use a database that supports storing data with timeouts, so it automatically deletes them after 12 hours

ionic flame
#

Thanks for suggestions!

#

you can use a database that supports storing data with timeouts, so it automatically deletes them after 12 hours
@vapid cape do you know any?

vapid cape
#

there are many

#

depends if you prefer a sql, or a nosql one

#

a file based or a server based

ionic flame
#

I have tried both. Anything is fine

vapid cape
#

redis for example

#

or an sqlite wrapper

#

or something like keyv

restive otter
#
  caller.utils.createMessage(command.msg.channel.id, {
    embed: {
      color: caller.color.blue,
      description: lang.commands.vote.description.replace('@link', `https://top.gg/bot/668481980547072007/vote${command.guild ? `?guild=${command.guild.id}` : ''}`),
    },
  });
};

exports.Settings = {
  command: 'link',
  category: 3,
  show: true,
  permissions: [],
  dm: true,
};```
#

why no work

#

Not hape help command

#

have*

#

@restive otter

#
exports.Run = async function Run(caller, command, guild, lang) {
  caller.utils.createMessage(command.msg.channel.id, {
    embed: {
      color: caller.color.blue,
      description: lang.commands.vote.description.replace('@vote', `https://top.gg/bot/668481980547072007/vote${command.guild ? `?guild=${command.guild.id}` : ''}`),
    },
  });
};

module.exports.help = {
    name:"vote",
    aliases: ["v"]
  }
#

@restive otter don't work..

#

😤

#

mate

#

u miss put now settings

#

if u want lemme give u the command u edit it?

#

@restive otter please give me vote command )

#

u gonna edit it

#

are u from turkey ?

#

nah

#

romania

#

k

#

oh

#

deleted ?

#

wait

#

?

#

look dm

#

if u need it send me dm

unreal pilot
#

how can i get the Json from the api?
(Python)

sullen nymph
#

What

willow spindle
unreal pilot
#

i am talking about the top.gg api

#

how can i get it in my code?

green mantle
vapid cape
#

webhooks, read the links CF8 posted

restive otter
#

where can i get link?

vapid cape
restive otter
#

yeah i will read that

#

is correct?

willow spindle
#

no

#

url is a your server ip:port/dblwebhook

vapid cape
#

dbl sends webhooks to YOU, not to DISCORD

#

you have to put a url where YOU can receive them

#

your server, your vps, your bot's host

restive otter
#

how to get your server ip:port/dblwebhook

willow spindle
#

server ip is ip of your vds

vapid cape
#

where is your bot hosted?

willow spindle
#

how to get your server ip:port/dblwebhook
@restive otter if you are using glitch:
https://your-project-name.glitch.me/dblwebhook

restive otter
#
const DBL = require('dblapi.js');
const dbl = new DBL("mysecrettoken", { webhookPort: 5000, webhookAuth: 'mysecretpassword' });
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!`);
});
#

right?

#

or i am super idiot

vapid cape
#

depends

#

where is your bot hosted?

restive otter
#

glitch

#

why?

vapid cape
#

then the webhookPort should be process.env.PORT

#

the rest is correct

restive otter
#

ok so when somenone vote bot

#

in console will show

#

name of person voted

vapid cape
#

only id of the person

#

you can use the test button to see if it works

restive otter
#

ok but in env

#

i need to put something?

vapid cape
#

no

restive otter
vapid cape
#

now go to the bot edit page and press the test button

restive otter
#

ok i pressed

vapid cape
#

did it work?

restive otter
#

nothing

vapid cape
#

then you did something wrong

#

make sure the url is correct, and the authentication is correct

restive otter
#

i think url

vapid cape
#

also, your token should be your DBL/top.gg token, not your discord token

restive otter
#

wut?

vapid cape
#

the url is correct

#

because the webhook is not GET, the webhook is POST

#

its normal that GET doesnt work

restive otter
#

so that i want when somenone vote to show in a channel

#

i can show you my dbltoken and authorization?

vapid cape
#

ok

restive otter
#

dm or here

vapid cape
#

your authorization is not your token

#

your authorization is a password you create, and then put the same password in the Authorization in the edit page

#

it doesnt matter what it is as long as its the same in your code and in the website

restive otter
#

oh

#

ok

#

but

#

for webhooks

#

how can i get dbl token

vapid cape
#

its the same token you use for posting servers

#

the one you sent me looks correct

restive otter
#

from here no?

vapid cape
#

yes

restive otter
#

ok i rechecked

#

so now what i do?

vapid cape
#

save and test again

restive otter
vapid cape
#

send me what you put now, and what you put in the website

#

webhookPort

#

is not 5000

#

its process.env.PORT

#

webhookPort: process.env.PORT

#

and it should be dbl.webhook.on("vote")

#

not dbl.on("vote")

restive otter
#

ok

#

done

#

but at webhookport

#
  console.log(`Webhook running at http://${hook.hostname}:webhookPort: process.env.PORT:${hook.path}`);
#

sorry if i am super idiot

vapid cape
restive otter
#

oh

#

@vapid cape

spiral steeple
#

Your port is in use

#

are you on glitch?

restive otter
#

ye

spiral steeple
#

Use the same server as your uptime robot

restive otter
#

i don't host that

#

bot on uptimerobot

vapid cape
#

you have a webserver already running

#

likely using express

restive otter
#

ye

#
  const http = require("http");
  const express = require("express");
  const app = express();
  app.get("/", (request, response) => {
    response.sendStatus(200);
  });
  app.listen(process.env.PORT);
  setInterval(() => {
    http.get(`http://redwebhooks.glitch.me/`);
  }, 280000);
vapid cape
#

so the webhook cant create a server, because you cannot have 2 servers

#

so you need to put the server in the dbl config instead of webhookport

restive otter
#

where?

vapid cape
#

webhookServer:app

#

instead of webhookPort

#

if it doesnt work, then you need to put the server in its own variable: const server = app.listen(...) webhookServer: server

restive otter
#

wow i have a err in my brain

#

can i give you full main file??

vapid cape
#

sigh... fine

#

dont do this

#

use either one or another

restive otter
#

ok..

#

now i use

#

only

#

bot

vapid cape
#

ok

#

if app doesnt work

#

then do what i said

#

change app.listen() to const server = app.listen()

restive otter
#

ok i will change

#

now

vapid cape
#

and then put server instead of app in webhookServer

restive otter
vapid cape
#

... no...

#

@restive otter

restive otter
#

wow so that is so hard to make..

#

@vapid cape so

#

in app.listen() put webhooksServer:app

vapid cape
#

no

#

dont change anything in app.listen

#

put it the way it was before

#

the only thing is that instead of app.listen you do const server = app.listen

#

you just add const server in the front

#

then in the webhook options, where you put your top.gg token and the webhook password, you put server instead of app

restive otter
#

i delete

#

the whole

#

app

#

its to hard

#

and i don't understand

#

anything

#

@vapid cape sorry if i lose your time pepe_cry

willow spindle
green mantle
#

the port No

#

the ip

#

yes

willow spindle
#

which port should I use?

#

5000?

green mantle
#

dont rlly matter

#

but ports 0 - 80 are protected

#

so its not necessarily advised imo

spiral steeple
#

Yeah the 1024-49151 are good ones to use

willow spindle
#

Should the port on the site be the same as the port in the code?

spiral steeple
#

No, in fact you cant. You cant have 2 servers on the same port

vapid cape
#

if node is directly exposed, the port should be the same

#

if node is behind a reverse proxy or similar, then no

#

if you have an existing server, you can attach it to the dbl library

#
let srv = server.listen(...)
let dbl = new DBL({token:token,webhookServer:srv})```
willow spindle
spiral steeple
#

When a port is not provided, the library sets it to 0 so that's normal because you gave it a server

#

idk if you need it to start listening after you create it tho

#

@vapid cape might know

tame turtle
#

aaaa ateam

vapid cape
#

it just needs to be a valid http server object, doesnt matter when it starts listening

spiral steeple
#

Well I didnt know that, learned something new

willow spindle
#

i am confused

#

should I use http.createServer ? (i dont know anything about servers)

#

I just started using VDS
@ me if you can help

hexed pivot
#

@willow spindle

#

I was having same error but I got the solution

#

var server = app.listen(process.env.PORT)

#

That's it

#

or you can also do
var server = app.listen(4000, function() { console.log("listening to port 4000")});

willow spindle
#

@hexed pivot Should the port on the site be the same as the port in the code?

vapid cape
#

yes

#

if node is directly exposed

abstract mothBOT
#

@pale flint

Please do not mention (ping) more than one or two moderators for help, unless there is an emergency.

Here are some examples of emergencies:

  • Raids / Multiple members mass spamming.
  • Severe disruption of Discord's ToS (NSFW content, etc)
  • Anything that requires more than 2 moderators to handle.
left egret
#

Don't ping mods for useless/non emergency reasons

#

Read this embed

pale flint
#

Ok

green mantle
#

also this isnt the channel for that question

pale flint
#

Sorry

left egret
rotund dune
#

I need help i used this

const DBL = require('dblapi.js');
const dbl = new DBL("top.ggtokentoo", { webhookPort: 30009, webhookAuth: 'mypasswordhere' });
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!`);
});

i get reply Webhook running at http://0.0.0.0:30009/dblwebhook
and when i click test nothing happend

restive otter
#

same problem 😔

willow spindle
#

@rotund dune do you set webhook url and password?

rotund dune
#

@willow spindle i did password and webhook url on website

willow spindle
#

url is a your server ip:port/dblwebhook

rotund dune
#

oh

#

ip of server

restive otter
#

server's ip?

rotund dune
#

@willow spindle still nothing

restive otter
green mantle
#

you need to replace the 0.0.0.0 bit with your public ip

#

for the url itself

restive otter
#

im sorry but i dont really get what the "ip" is

#

ik ikkk

green mantle
restive otter
#

0:

#

and i have to put that in the "url" in the bot dbl page

vapid cape
#

where is your bot hosted?

restive otter
#

is heroku the answer youre looking for?

vapid cape
#

ye

#

or whatever heroku uses for the project url

restive otter
#

how do you know

green mantle
#

he just knows

#

tim is a knowledgeable man

vapid cape
#

all heroku projects have a public url

#

since they are meant to run small websites and web systems

rotund dune
#

@vapid cape i have some error and can't fix it

#

like all work but when i test nothing happend

vapid cape
#

dm me your code with the tokens and the top.gg settings

rotund dune
#

Done

vapid cape
#

how does your website run? an express server?

#

or apache/nginx

rotund dune
#

idk its my mate server

vapid cape
#

then you need to ask him

#

because you are opening that port in the same machine, but that doesnt mean the machine is exposing the port

#

if the website is behind a reverse proxy for example, that port will never be reached

rotund dune
#

we use apache

vapid cape
#

so you need to make an internal redirect or a reverse proxy

#

because yourwebsite.com will connect to apache, and apache doesnt know what to do with port 30009, its not configured for it

#

you need to tell apache to send that port to your node program

rotund dune
#

how can i do it lol

vapid cape
#

i dont know how your server is configured lol

#

the one who set it up should do it

rotund dune
#

he is offline rn

vapid cape
#

then wait i guess

#

or try using the machine's ip address instead of the website url

rotund dune
#

how do i find trhat on linux

#

@vapid cape i am trying to test it on my pc but still cant

#

its no reply

vapid cape
#

the hosting company should have that info

#

check the hosting company's control panel or something

restive otter
restive otter
#

UnhandledPromiseRejectionWarning: Error: 401 Unauthorized
is this a good sign?

willow spindle
#

your token is invalid

restive otter
#

oh did i missclick "regen token" Thonk

#

its been a while and i came nowhere

#

still getting an invaild link
http://0.0.0.0:16981/dblwebhook

and it wont respond with anything when clicking on test

spiral steeple
#

Why are you saying that's imvalid

#

0.0.0.0 is all ipson the machine

#

It's just different with heroku

#

Theres a special url you need to use that I dont know

restive otter
#

its different with heroku?

#

okay lets say that the link to check the application is
https://dashboard.heroku.com/apps/cowboish-bot

#

or to make it more clear
https://dashboard.heroku.com/apps/application-name

spiral steeple
#

and your port should be your process.env.PORT

restive otter
#

i dont think it is

spiral steeple
#

Yes because there's nothing running on it and if the dbl webhook was it's only listening for POST requests

restive otter
#

server.listen(process.env.PORT);
You mean this

#

what should it listen to then?

vapid cape
#

the url is as steven said

#

and dont forget the /dblwebhook part

#

the url will not work in the browser, only for POST requests. browsers make GET requests by default

restive otter
#

so the url is not reachable

vapid cape
#

not by a browser's default way of accessing websites

restive otter
#

mm

#

but im still stuck...

#

nothing happens when i click "test"

vapid cape
#

dm me your code including the tokens, and the top.gg settings page

restive otter
#

aight

vapid cape
#

you dont need two instances of DBL, make just one

vapid cape
#

what do the logs show?

restive otter
vapid cape
#

did you run heroku ps:scale web=1?

restive otter
#

whats this?

vapid cape
#

to enable web dynos

#

do you have web dyno enabled?

restive otter
#

nope

#

should i enable it?

vapid cape
#

yes

restive otter
#

done

#

okeeee

#

and a big err

vapid cape
#

show the error

vapid cape
#

remove the sendStatus part

#

in app.get

restive otter
#

wait

vapid cape
#

what is index.js line 41?

#

you didnt send me that part

restive otter
#

oh it was res.setStatus() smthn

#

oh now it says "Hello?"

vapid cape
#

good, that means your server is working

#

now try the test button

restive otter
#

nope

#

still nothing

#

oh shit

#

omg thank you so much Tim <3

#

and now because i had two dynos on the bot duplicated
but it fixes itself if i turn "worker" off and keep web on

#

:)

vapid cape
#

👍

true talon
#

Worker works almost h24, but web has more downtimes @restive otter

#

Be aware

restive otter
#

oof why is it so?

vapid cape
#

all free hosts have limitations

hearty valve
#

@elder sandal

green mantle
#

dont randomly @ admins

restive otter
#

Hi

edgy terrace
#

I'm having an issue about the website. Everytime I login, it logins my other, useless account

green mantle
restive otter
#

How to promote server quickly

#

Or how to get member quickly

#

Like disboard

sullen nymph
#

Did you read this channel's topic?

restive otter
#

Me ??

green mantle
#

yes

restive otter
#

No

#

Ok

#

It say's that i can ask ques but its have to be funny

green mantle
#

no

#

You will be muted if you continue

restive otter
#

Reason

jagged escarp
#

Will Top.GG webhooks post to an IP:Port URL instead of an actual web domain

green mantle
#

yes

#

see the docs

molten locust
#

hi, if i add my bot to top.gg, do i also have to include the gg api in my bot?

#

also: what would be the benefits in adding the api other than being able to give bot users vote rewards

clever rock
#

@jagged escarp clarification: no

#

not only ip port or domain

#

you can also put domains

jagged escarp
#

Thanks, I was able to get things working thankfully

#

It was working all along I just hadn't caught the issue yet so I blamed the webhook lol

molten locust
#

should the api be added to bot before or after it has been approved?

spiral steeple
#

That's not possible

#

you only get a key after approval

molten locust
#

yea, i figured it'd probly be after, but figured i should ask to be sure 😄

#

ty 🙂

languid thunder
#

!stop

restive otter
#

Just stuck with a minor thing, How to get the Author ID once someone vote? I am not really able to make it work. Any help would be appreciated.

molten locust
#

author id?

#

you mean the id of the voter?

restive otter
#

Yes

molten locust
#

webhooks 🙂

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

PY 😋

green mantle
molten locust
#

😛

plucky bough
#

.hasVoted isn't working

#

for some reason

#

Ill wait a few minutes cause maybe it needs to update

#

but it takes awhile

#

nvm it works

#

just takes a long time

spiral steeple
#

It's recommended to use webhooks

spare axle
#

Webhooks are significantly faster

#

Cause logics

zenith roost
#

Umm

#

Requiem PnW tells me I should receive a message shortly, but I never do

#

and then it's always on cooldown

#

for registering

vapid cape
#

wrong channel, and possibly wrong server

elfin maple
clever rock
#

thats not a bug

#

thats what you call cache

spare axle
#

F

marsh panther
#

Hi, I'm still having an issue with dblapi.js.
It's currently using 365MB of RAM and 10% CPU on a good server. And it is just listening to the vote event then send a message

restive otter
#

Just listening to the vote event? how many guilds, servers, channels, messages, emojis, roles and presences are cached?

arctic arch
#

I seriously doubt thats from the dblapi module

#

more likely it's your bot

restive otter
#

Ikr

#

Discord.js's PresenceStore eats most of the memory

marsh panther
#

I'm using Eris. The bot is in 100 guilds and has about 200k users

vapid cape
#

this guild by itself has almost 100k lol

worn quail
#

^

junior schooner
#

So... I don't really get the purpose of the whole API, and I don't think it's written anywhere. Why should I use it in the first place?

vapid cape
#

the api is not required, so use it if you want to

#

the goal of the api is to give bots access to top.gg's voting platform and create applications around it

#

as well as to post server counts to be displayed in the website

pallid python
#

What is API mean and do?

fierce stream
#

it can give u information

#

and u can use it in a bot or whatever u want

#

for more info go read what a rest/json api does

daring cove
vapid cape
#

its dbl.DBLClient(self.bot, self.token)

#

not dbl.Client(self.bot, self.token)

daring cove
#

Oh ok thanks

#

Did it change?

green mantle
#

nope

#

its been that for a while

balmy hamlet
#

That name is kinda redundant

sullen nymph
#

Traceback purposes be like

restive otter
#

#link

#

+link

#

#help

narrow zenith
restive otter
#

Hi, how i can do functions but for donators or see if the person vote the bot

#

I see that a lot of bots have that function

hollow sandal
#

which language are you using?

restive otter
#

Js

hollow sandal
#

have you tried using dblapi.js?

restive otter
#

I installed it, but im asking for how i can do that

hollow sandal
#

oh

restive otter
#

is ok, i already saw

#

dbl.hasVoted()

hollow sandal
#

I can't say on that, I am unfamiliar with js

restive otter
#

No problem

#

i already see how

prisma dawn
#

Does anyone know why this doesn't work (as in top.gg doesn't update my server count when I send this):

            dbltoken = "[REDACTED]"
            servers = {'server_count': util.get_server_count()}
            headers = {"Authorization": dbltoken, "Content-Type": "application/json"}
            async with aiohttp.ClientSession() as session:
                async with session.post(url="https://top.gg/api/bots/496480755728384002/stats", data=json.dumps(servers), headers=json.dumps(headers)):
                    await util.say(ctx.channel, "Done!")

This doesn't give me any error, so I have no clue what the problem is. This is written in Python 3.5.2, and dblpy requires 3.5.3+ to install so I can't use the library.

worn quail
#

cache problem is most likely

#

dbl caches the server counts (reason one to have it send like every 5 mins) and updates eventually.

prisma dawn
#

i've updated multiple times over multiple days

worn quail
#

also

#

you're trying to dump the server

#

do len(servers)

#

and you dont wanna json.dumps the headers

#

just use headers=dblheaders

prisma dawn
#

ah ok

#

so I shouldn't json.dumps anything?

worn quail
#

I do mine as a string, so encase it in '(headers)'

#

No

prisma dawn
#

oh ok

worn quail
#

Nevermind, I was wrong. But yeah you do len(servers) and keep the token the same

prisma dawn
#

oh

#

wrong about what

worn quail
#

The token, I thought I did it as a string

prisma dawn
#

ah ok

#

the bot class is defined in another file and I can't import it into the files with the commands, so I use util.get_server_count(), which is basically just
sum(len(client.servers) for client in shard_clients)

worn quail
#

you can get the bot class

#

from (where the bot class is) import (the bot class) as bot

prisma dawn
#

yeah the problem is importing the file causes a weird chain of errors

#

lemme try and find them

worn quail
#

ok

prisma dawn
#

ok this is a more normal error, but sometimes i get weirder errors:

    from . import run
ImportError: cannot import name 'run'
#

(it's trying to import run.py, which is where the bot class is)

worn quail
#

you would import run

#

The . Import is for modules

#

like things you install from pip

prisma dawn
#

oh

#

i don't believe so

worn quail
#

or from run import bot

#

yeah, lemme head over to the testing channel

#

unless you start your bot from a __init__ file

prisma dawn
#

i think you have it switched around, all the files in my bot are imported with from . import <>, and modules are imported like import time

worn quail
prisma dawn
#

i start it from a directory without an init

#

ok

sullen nymph
#

Why do you still have 3.5.2 python

#

What's your dpy version

prisma dawn
#

0.16.12

#

i made a rewrite to 1.3 but i haven't implemented it yet

#

i have 3.5.2 because that's what came installed on my vps

sullen nymph
#

But you could use 3.6 no problem

prisma dawn
#

no it gives me errors on 3.6

#

which is what the rewrite is designed to fix

sullen nymph
#

What kinda errors

prisma dawn
#

i don't remember anymore, the last time i tried was many months ago

sullen nymph
#

I remember using async with 3.6 just fine

prisma dawn
#

yeah but i use like 20 modules

#

it's not just async

sullen nymph
#

rip

green mantle
#

if it was a OS based error, that was an issue with python 3.6.0 and got patched with 3.6.1

#

i would advise upgrading D.py version and upgrading python to 3.7.x

restive otter
#

^

prisma dawn
#

i think it isn't an OS based error because it is able to send get, post, and patch to other websites

#

I had used python 3.6.9 I believe

#

@green mantle

#

I may also do a big bug fixing thing when Python 3.9 comes out

pallid python
#

What is api?

willow spindle
rose cargo
#

How would I get the number of votes my bot has in javascript

steady granite
#

Hello people. I have a Python discord bot hosted on Heroku. In the last 3 days, sometimes (low frequency) I get this KeyError: 'content-type' when sending embedded messages.
Why is this happening? And why does it happen only rarely?

Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.7/site-packages/discord/ext/commands/core.py", line 83, in wrapped
    ret = await coro(*args, **kwargs)
  File "Ve7s.py", line 227, in play
    await Play.go(ctx=ctx, args=args, client=client, partidas=playing, admin=ve7sadmin, vets=VeTs, db=ve7sdb)
  File "/app/Ve7sGame/Play.py", line 141, in go
    await game.task
  File "/app/Ve7sGame/Play.py", line 114, in match
    await gameloop(game, partidas, client)
  File "/app/Ve7sGame/Play.py", line 44, in gameloop
    await game.canal.send(file=File(data, f'hazzu.{ext}'), embed=embeder)
  File "/app/.heroku/python/lib/python3.7/site-packages/discord/abc.py", line 839, in send
    content=content, tts=tts, embed=embed, nonce=nonce)
  File "/app/.heroku/python/lib/python3.7/site-packages/discord/http.py", line 164, in request
    data = await json_or_text(r)
  File "/app/.heroku/python/lib/python3.7/site-packages/discord/http.py", line 43, in json_or_text
    if response.headers['content-type'] == 'application/json':
KeyError: 'content-type'```
rose cargo
#

How would I get the number of votes my bot has in javascript

restive otter
#

@steady granite happened to me when discord was having ssues yesterday

steady granite
#

Worse, there seems to be no improvement. I may have to ignore this exception and try to send the message again ...

green mantle
#

It was a cloudflare issue

fierce field
#

guys, is there an api that serves to show the number of servers where is my bot? (my english is bad)

Example image:

green mantle
#

look on the site

fierce field
#

where?

green mantle
#

c l i c k t h e l i n k

fierce field
#

...

#

i need a tutorial

#

xd

green mantle
#

read the docs

fierce field
#

I don't understand what to do

green mantle
#

read what it actually says

silent pilot
#

@steady granite is heroku free,

#

?

willow spindle
#

yes

steady granite
#

Yes. If you confirm your account with credit card, you get 1000 hours free / month. My bot stay 24/7 online with this

vapid cape
#

@fierce field what is your coding language and library?

fierce field
#

JavaScript

vapid cape
fierce field
#

I still do not understand... sadbrudda

balmy hamlet
#

@fierce field then learn

#

What kind of "developer" doesn't know how ro read the docs

vapid cape
#

it literally says how to install and how to use

balmy hamlet
#

Yes

vapid cape
fierce field
#

where to run the installation? I only ask

vapid cape
#

you never used npm?

#

how did you make your bot?

balmy hamlet
#

DiScOrD bOt mAkEr

willow spindle
#

@fierce field which lib do you use

fierce field
#

javascript?

willow spindle
#

javascript is not a lib

balmy hamlet
#

You should be a white name tbh

willow spindle
#

do you using a discord bot maker?

balmy hamlet
#

^

fierce field
#

yes

vapid cape
#

lol

willow spindle
#

@dense compass

balmy hamlet
#

Dbm is, sadly, allowed

willow spindle
#

allowed?

balmy hamlet
#

Yed

#

Lmao

#

Read noctaletz custom statua

willow spindle
#

🤦‍♂️

balmy hamlet
#

They removed it

vapid cape
#

@fierce field if you install DBM-MODS you can use the action send stats do dbl

#

otherwise you have to code it yourself as a custom script

#

ask in the discord bot maker server for help

fierce field
#

Okay

restive otter
#

@abstract moth

gray root
#

I am sending {"server_count": count, "shard_count": shard_count, "shard_no": shard_id}, from all my shards, however it's not updating on the bot page. How often does the server count updates on the page?

#

shard_count would be 6
server_count varies between shards
shard_no would be 0 to 5

sullen nymph
#

Are you getting any errors?

wind barn
#

Hey, I have a Problem. I used this code, but If someone votes for my Bot, nothing happend in the Console:

const Discord = require('discord.js')
const DBL = require('dblapi.js');
const client = new Discord.Client();
const http = require('http');
const dbl = new DBL('"mytoken"', { 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!`);
});```

Were ist the Problem?
#

Do I have to open the Port on my Router?

#

Or were do I get the Password?

sullen nymph
#

Port must be open, password is created by you

wind barn
#

Ok

#

Thx

vapid cape
#

did you configure the url and auth in your bot's edit page?

prisma dawn
#

The server count still fails to update when I send the post. I use this code, and it gives no error, but doesn't update even after waiting over an hour.

    payload = {'server_count': util.get_server_count()}
    dbltoken = "[REDACTED]"
    dblheaders = {"Authorization": dbltoken, "Content-Type": "application/json"}
    dblurl = "https://top.gg/api/bots/496480755728384002/stats"
    async with aiohttp.ClientSession() as session:
        async with session.post(url=dblurl, data=payload, headers=dblheaders):
            await util.say(ctx.channel, "Done!")
#

The main bot is in discord.py 0.16.12, but when I use the same code and correct token on a copy in discord.py 1.3.1, it still fails.

wind barn
#

@vapid cape Yes I did

#

@sullen nymph how can I create the password? Is it my PCs password or something like that?

green mantle
#

dont do that lmao

sullen nymph
#

Anything you come up with

green mantle
#

it can be anything

#

just dont use the same password for everything

#

tends to be a bad idea

wind barn
#

Ok

#

Because it is still not working lmao

#

Were can I set this password

#

Sorry If I'm asking silly things, but I'm new in javascript

sullen nymph
#

Authorization field on your bot's top,gg edit page

wind barn
#

Ah ok

sullen nymph
#

Yup

wind barn
#

Ok thank you

prisma dawn
#

does anyone have an answer to my question a bit farther up? (i can repost it if you want)

sullen nymph
#

What is util.get_server_count's type

prisma dawn
#

int

#

it failed as str also

sullen nymph
#

save the response for .post and see the response code

prisma dawn
#

ok

#

it was 200 last time i made it display

sullen nymph
#

What's your current server count

prisma dawn
#

uh

#

112 something

#

1123 last i checked

sullen nymph
#
5573 Servers```
![special_think](https://cdn.discordapp.com/emojis/387971496678653952.webp?size=128 "special_think")
prisma dawn
#

yeah that's why im updating it

wind barn
willow spindle
#

this is not api related

restive otter
#

oh sorry

restive otter
willow spindle
#

your dbl token is invalid

restive otter
#

oh

#

ty

willow spindle
#

oh no

restive otter
#

what?

willow spindle
#

"Required parameter server_count or shards missing"

restive otter
#

where i change it?

willow spindle
#

show your dbl code

#

without dbl token

restive otter
#

const dbl = new DBL(config.dblToken, client) dbl.on("posted", () => { console.log("Connected to DBL") })

willow spindle
#

is there .postStats code?

restive otter
#

no why?

willow spindle
#

i think @arctic arch can help you

restive otter
#

k

arctic arch
#

what's client

restive otter
#

i need to change that client to this.client ?

arctic arch
#

client needs to be your bot's client, however you obtain it

restive otter
#
    const dbl = new DBL(config.dblToken, this.client)
    dbl.on('posted', () => {
      console.log('Server count posted!');
    })

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

    setInterval(() => {
      dbl.postStats(this.client.guilds.size, this.client.shards.Id, this.client.shards.total);
    }, 1800000);
#

this is my new code

arctic arch
#

...

willow spindle
#

what is client

arctic arch
#

NMW asked if you had postStats code and you said no

#

but you clearly have some right there

restive otter
#

yes, and i added that

arctic arch
#

if you want to use the automatic poster, remove your manual interval
if you want to use your own code, remove the client from the DBL constructor

#

and those events only cover the automatic poster

restive otter
#
    const dbl = new DBL(config.dblToken, this.client)
    dbl.on('posted', () => {
      console.log('Server count posted!');
    })

    dbl.on('error', e => {
      console.log(`Oops! ${e}`);
    })
``` (sorry if i didn't do what do u say, my english is very bad)
willow spindle
#

const client = ....

#

show this code

restive otter
#

const client = new Bot({
fetchAllMembers: true
});

willow spindle
#

what is Bot?

#

discord.js?

restive otter
#

class Bot extends Client {

willow spindle
#

why are you using open source...

restive otter
#

why not?

#

nvm, i don't need more help

prisma dawn
#

ok I get this long error when trying to post server_count to top.gg with aiohttp (python), I took out the long number/letter sequences because idk if some of them need to be private:

<ClientResponse(https://top.gg/api/bots/496480755728384002/stats) [400 Bad Request]>
<CIMultiDictProxy('Date': 'Fri, 21 Feb 2020 18:37:20 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '52', 'Connection': 'keep-alive', 'Set-Cookie': '__cfduid=[REDACTED]; expires=Sun, 22-Mar-20 18:37:20 GMT; path=/; domain=.top.gg; HttpOnly; SameSite=Lax; Secure', 'X-Powered-By': 'Express', 'Etag': '[REDACTED]"', 'X-Cacheable': 'NO', 'X-Varnish': '449151971', 'Age': '0', 'Via': '1.1 varnish-v4', 'Cf-Cache-Status': 'DYNAMIC', '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': '[REDACTED]')>

#

no clue what the problem is, the json body conforms exactly to the specifications in the api docs

arctic arch
#

send the json body

#

also can you get the response body

#

it will have more info on whats wrong

prisma dawn
#

it's farther up

#
    payload = {'server_count': util.get_server_count()}
    dbltoken = "[REDACTED]"
    dblheaders = {"Authorization": dbltoken, "Content-Type": "application/json"}
    dblurl = "https://top.gg/api/bots/496480755728384002/stats"
    async with aiohttp.ClientSession() as session:
        async with session.post(url=dblurl, data=payload, headers=dblheaders):
            await util.say(ctx.channel, "Done!")
arctic arch
#

that's just the headers, not the body

prisma dawn
#

how do I get the response body then

arctic arch
#

idk about python

worn quail
#

@sullen nymph

prisma dawn
#

what does it look like then

worn quail
#

let's get shiv in here again

#

they made the DBL python lib

prisma dawn
#

ah ok

vapid cape
#

did you log util.get_server_count() to make sure its actually populating server_count with a valid value?

worn quail
#

^

prisma dawn
#

yes

#

1127

worn quail
#

400 bad request would mean that you didnt send the right data

prisma dawn
#

int

worn quail
#

sometimes

arctic arch
#

I've seen json=payload instead of data=payload before

prisma dawn
#

i've used both

#

both failed

worn quail
#

I use data=payload

#

it works fine

sullen nymph
#

json=payload is for requests

arctic arch
prisma dawn
#

ah ok i'll get that

worn quail
#

@arctic arch bRUH

#

ur bad

#

that's get not post

prisma dawn
#

oh that's true

arctic arch
#

if you're dumb enough to not modify the example from a documentation to your needs you shouldn't be a programmer

worn quail
#

^

#

fax

arctic arch
#

just add the as resp and print the response

prisma dawn
#

i am

worn quail
#

but... we're not trying to get stats? Or did I miss something

vapid cape
#

hes trying to post them lol

worn quail
#

^

arctic arch
#

we're trying to get the error response from topgg api to see what the error is

worn quail
#

but you arent gonna post anything with aiohttpclient.get

arctic arch
worn quail
#

ah

#

well

vapid cape
#

he just showed that to add the response line

#

and print it

worn quail
#

the context was something that was missing

#

sorry tonkku

#

you know I'm dumb

arctic arch
#

omg bruh why are you getting servercount from github api lol

prisma dawn
#

{'error': 'Unexpected token s in JSON at position 0'}

worn quail
#

ok remove the " from the dbl token

arctic arch
#

your JSON has a syntax error

worn quail
#

dbltoken = ["Authorization":"token"]

prisma dawn
#

i don't have an s at position zero

arctic arch
#

neko see the headers line

#

your object isnt being converted to valid json

worn quail
#

ok I'm just gonna leave at this point

vapid cape
#

the s in position 0 is server_count

arctic arch
#

it's probably just server_count=1234

vapid cape
#

your json is not being serialized

prisma dawn
#

that's weird, I do it the same way when I post to another website and it works fine

vapid cape
#

its probably being sereialized to server_count=1234

#

try with json=payload

prisma dawn
#

ok

vapid cape
#

and check the error again

prisma dawn
#

{'error': 'Unexpected token " in JSON at position 0'}

arctic arch
#

that's really weird

prisma dawn
#

indeed

arctic arch
#

can you do the request again now

#

tell me when its done

vapid cape
#

maybe the internal json serializer is broken

prisma dawn
#

yup yup

#

ok it gave a 200

arctic arch
#

was that the sign that you did it

prisma dawn
#

was what the sign?

arctic arch
#

whatever

#

so it worked now

prisma dawn
#

oh well it works now

#

yup yup

#

i think the problem was that the dbltoken was encased in double quotes instead of single quotes

arctic arch
#

python seems to be weird with json

prisma dawn
#

indeed

arctic arch
#

that doesnt really make any sense

prisma dawn
#

well when I made it single quotes, it worked

vapid cape
#

wtf

#

but json shuold be double quotes, not single?

arctic arch
#

or maybe the json thing is inconsistent

prisma dawn
#

¯_(ツ)_/¯

arctic arch
#

tim

#

the token is in the headers

#

not the body

#

so its completely unrelated

sullen nymph
#

Let's use XML

vapid cape
#

so the problem was the headers? then why the unexpected json error lol

arctic arch
#

I dont think the api supports parsing xml

vapid cape
#

because content-type was not being set?

prisma dawn
#

content-type was fine

arctic arch
#

no the content type was set or you wouldnt get the json parsing error

#

-bots 376166105917554701

abstract mothBOT
sullen nymph
#

Content-Type should be set to application/json by default if you use json= iirc

prisma dawn
#

yeah it was

arctic arch
#

what was your server count

prisma dawn
#

what was it or what is it now

arctic arch
#

now

prisma dawn
#

1127

arctic arch
#

right

#

ok

#

I tried looking at the logs

#

but it turns out it's not logged when there's a json error

prisma dawn
#

huh

#

that should probably be added

arctic arch
#

was trying to see what the actual body was

sullen nymph
#

response.content to view response body