#topgg-api

1 messages · Page 130 of 1

restive otter
rain heart
#

oh then it is correct it seems like

#

are you sure you're running the correct jar?

river kestrel
#

what's the $Builder because that's what seems to be the one causing trouble

willow spindle
#

it is authorization thing for verify that requests are coming from top.gg @restive otter

river kestrel
rain heart
#

Builder is the Builder for the DiscordBotListAPI

blazing mauve
#

how do i get the dbl token?

rain heart
#

make a dummy project and see if the same issue happens on there too

#

because it works perfectly with gradle

river kestrel
rain heart
#

ohh

#

give me a second

willow spindle
rain heart
#

most likely that is what you're missing

river kestrel
#

that's the line in the source code

return new DiscordBotListAPIImpl(token, botId);

restive otter
#

okay thanks

rain heart
#

yeah you most likely are just missing okhttp

river kestrel
#

I added that and it still does the error

#

:(

rain heart
#

same exact error? did you rebuild?

river kestrel
river kestrel
#

it's not in the tree

rain heart
#

then you didn't add it to your pom, did you also add it to extract into your artifact aswell?

river kestrel
river kestrel
rain heart
#

Yeah go ahead

river kestrel
#

Ok I added all of them

river kestrel
rain heart
#

yes

#

did you also do that with okhttp?

river kestrel
#

they're all in the extract thingy now

#

let me check if it works

#
java.lang.NoClassDefFoundError: okhttp3/Callback
        at org.discordbots.api.client.DiscordBotListAPI$Builder.build(DiscordBotListAPI.java:54)
#

Still this @rain heart

rain heart
#

How are you exporting your artifacts? through IntelliJ's Artifacts?

river kestrel
rain heart
#

and it has all the other libraries extracted into it, such as gson, gson-runtime, json, okhttp, okio and slf4j right?

river kestrel
#

slf4j what's this one

#

let me check

rain heart
#

logger stuff

river kestrel
#

so there is no error but it doesn't work either but only with the jar

#

works from intelij

rain heart
#

It just doesn't do anything? add debug lines

river kestrel
#
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
#

maybe I should fix this

rain heart
#

lemme check what logger version the api uses

#

the one the api uses

river kestrel
#

so I should add that ?

rain heart
#

If you haven't added slf4j yet, add it

river kestrel
river kestrel
#

slf4j-simple.jar

#

maybe I should have this @rain heart ?

rain heart
#

try it, I'm still looking why it doesn't work

fallen forge
#

why is it saying dblapi.js is no longer maintained?

river kestrel
#

@rain heart I added the simple thingy and now it gives me another error

#
java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
        at okhttp3.HttpUrl$Builder.scheme(HttpUrl.kt)
        at org.discordbots.api.client.impl.DiscordBotListAPIImpl.<clinit>(DiscordBotListAPIImpl.java:26)
        at org.discordbots.api.client.DiscordBotListAPI$Builder.build(DiscordBotListAPI.java:54)
river kestrel
fallen forge
#

then what do they use now though?

rain heart
#

read pins

fallen forge
#

o

#

ty

#

so to install

#

i need to add topgg-autoposter in additional node packages?

#

@rain heart

rain heart
#

read pins

fallen forge
#

it dosent say

#

wait nvm

#

im just blind

river kestrel
rain heart
#

I mean it works flawlessly with gradle, one of many reasons why i hate maven

river kestrel
#

😔

#

I didn't know what I was getting into

blazing mauve
#

i integrated my bot so it shows the server count, but how do i make it show the Lib the bots written in? it says "Unknown" for me ;-;

river kestrel
rain heart
#

No clue, maven is stinky that's why

river kestrel
#

uh

#

is there an easy way to switch to gradle then ?

rain heart
#

I just tried it myself with maven, works perfectly

#

I don't have any clue why it doesn't work then really

river kestrel
#

why does it not work for me then

#

1 sec

#

is there anything weird in it ??

rain heart
#

yeah I'll check

river kestrel
#

because it does log in for me

#

but it's when someone calls the vote reward command that it gives an error

rain heart
#

I would suggest trying other methods, yeah

#

otherwise, just track the votes/rewards with your own webhook

river kestrel
#

I'll probably end up doing that lol

rain heart
#

nah the pom looks fine to me

river kestrel
#

thanks for your help !

rain heart
#

How are you trying to run it btw? do you have a mainfest etc?

river kestrel
#

java -jar ./Gamma.jar

river kestrel
rain heart
#

yeah no clue then unfortunately, the only thing i could suggest is trying it through gradle maybe

river kestrel
#

I'll think I'll use the webhook version anyway

#

thanks for your help !

#

and for your time !

rain heart
fallen forge
#

@rain heart getting this error [..................] - rollbackFailedOptional: verb npm-session d2bba7a89076f05 [..................] - rollbackFailedOptional: verb npm-session d2bba7a89076f05 [..................] - rollbackFailedOptional: verb npm-session d2bba7a89076f05 [..................] - rollbackFailedOptional: verb npm-session d2bba7a89076f05 [..................] - rollbackFailedOptional: verb npm-session d2bba7a89076f05 [..................] - rollbackFailedOptional: verb npm-session d2bba7a89076f05 [..................] - rollbackFailedOptional: verb npm-session d2bba7a89076f05 [..................] - rollbackFailedOptional: verb npm-session d2bba7a89076f05 [..................] - rollbackFailedOptional: verb npm-session d2bba7a89076f05 [..................] - rollbackFailedOptional: verb npm-session d2bba7a89076f05 [..................] - rollbackFailedOptional: verb npm-session d2bba7a89076f05 npm ERR! Error while executing: npm ERR! /usr/bin/git ls-remote -h -t ssh://git@github.com/top-gg/sdk.git npm ERR! npm ERR! No user exists for uid 999 npm ERR! fatal: Could not read from remote repository. npm ERR! npm ERR! Please make sure you have the correct access rights npm ERR! and the repository exists. npm ERR! npm ERR! exited with error code: 128 npm ERR! A complete log of this run can be found in: npm ERR! /home/container/.npm/_logs/2021-01-23T18_51_12_194Z-debug.log

rain heart
#

no clue about npm

fallen forge
#

imma go cry in my corner

#

lmao

#

did repository get deleted?

rain heart
#

oh wait

#

sdk.git?

#

isn't the repo node-sdk?

fallen forge
#

wait it is?

#

it dosent say that on the docs

restive otter
fallen forge
#

@rain heart i have been using this

const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);

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

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

yeah that's the old one

fallen forge
#

and this for the package top-gg/sdk

rain heart
fallen forge
rain heart
fallen forge
#

that's the example on the docs

fallen forge
restive otter
rain heart
#

the docs are subject to updates, the library-dev from the node package posted it in here and got it pinned

fallen forge
fallen forge
rain heart
#

that's autoposter for auto-posting your guild count

fallen forge
#

then what does the one i posted do?

rain heart
#

oh wait

rain heart
#

Yeah nvm what i said, try to use that one you replied to

#

im just smart rn

fallen forge
#

but it's saying n/a

rain heart
#

n/a means that you haven't posted your guild count yet

#

did you enter your guild count?

fallen forge
#

no

#

dosen't it do it automatically?

rain heart
#

you need to post it yourself with the api

restive otter
#

^

rain heart
#

first make sure you entered your top.gg api token

fallen forge
fallen forge
restive otter
fallen forge
rain heart
restive otter
#

ah

restive otter
#

what about @top-gg/sdk then

fallen forge
#

and i used the same example

fallen forge
#

but

#

it says it's no longer maintained

restive otter
#

i think you use dblapi.js

#

then

fallen forge
#

no i changed it or should of

#

this is what i'm using

#
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);

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

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

and thats old

fallen forge
#

that's the one on the docs

fallen forge
restive otter
#

@top-gg/sdk or topgg-autoposter

fallen forge
#

no i mean

#

what code do i use?

#

at the client part

restive otter
#
const client = Discord.Client() // Your discord.js client

const Topgg = require('@top-gg/sdk')

const api = new Topgg.Api('Your top.gg token')

setInterval(() => {
  api.postStats({
    serverCount: client.guilds.cache.size,
    shardId: client.shard.ids[0], // if you're sharding
    shardCount: client.options.shardCount
  })
}, 1800000)
#

this one

fallen forge
#

ty ❤️

restive otter
#

btw you need to wait 30mins

fallen forge
#

and the package needs to be top-gg/sdk yeah?

restive otter
#

yeh

fallen forge
restive otter
#

yeah

fallen forge
#

oh okay

restive otter
#

or you can lower the time

fallen forge
#

how? lol sorry

restive otter
#

but dont lower it too much

fallen forge
#

or cpu?

restive otter
#

Nope

#

Ratelimit

fallen forge
#

o

restive otter
fallen forge
#

what's the minimium?

restive otter
#

lemme see

fallen forge
#

okay thanks

restive otter
#

60 times per min = 1hr ratelimit

fallen forge
#

so

#

am i able to do i 1m

#

then change it again

#

lol just to see if it worked

restive otter
#

do 1m for now(60000ms)

#

then if it works

#

i tried running the api and an express server in different files all called from 1 file and the express server broke

#

wait

#

lol

#

not 60k

fallen forge
#

lol

restive otter
#

lol

#

wait i was right

#

yeah

fallen forge
#

where do i change the number? lol

#

The end part? ```const client = Discord.Client() // Your discord.js client

const Topgg = require('@top-gg/sdk')

const api = new Topgg.Api('Your top.gg token')

setInterval(() => {
api.postStats({
serverCount: client.guilds.cache.size,
shardId: client.shard.ids[0], // if you're sharding
shardCount: client.options.shardCount
})
}, 1800000)```

restive otter
#

the 1800000

#

the last part

#

i think

#

yeah

fallen forge
#

okay thanks alot 😄

restive otter
#

but i cant run and top.gg api side by side

#

in js

fallen forge
#

@restive otter it keeps saying this now serverCount: client.guilds.cache.size,
^
ReferenceError: client is not defined
at Timeout._onTimeout (/home/container/server.js:9:18)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)

#

and is restarting my bot each minute

restive otter
#

then whats your client defined as

fallen forge
#

wdym?

restive otter
#

or did you putted it below your client

fallen forge
#

i put it above

restive otter
#

put it below

fallen forge
#

and i deleted const client

#

as it kept saying not defined

restive otter
#

put it below

fallen forge
#

wait

#

no it is below

restive otter
#

o

fallen forge
#

just not below the token

restive otter
#

im confusion rn

fallen forge
#

same

restive otter
#

cuz idk how your code looks like

#

so cant help you

fallen forge
#

1m

#

const Topgg = require('@top-gg/sdk')

const api = new Topgg.Api('top.gg token')

setInterval(() => {
  api.postStats({
    serverCount: client.guilds.cache.size,
    shardId: client.shard.ids[0], // if you're sharding
    shardCount: client.options.shardCount
  })
}, 60000)
#

@restive otter

#

removed the token

restive otter
#

dbd? waitWhat

fallen forge
#

npm package

restive otter
#

i mean

#

const Discord = require("discord.js")
const client = new Discord.Client()

const Topgg = require('@top-gg/sdk')

const api = new Topgg.Api('top.gg token')

setInterval(() => {
  api.postStats({
    serverCount: client.guilds.cache.size,
    shardId: client.shard.ids[0], // if you're sharding
    shardCount: client.options.shardCount
  })
}, 60000)```
#

lol

#

i think would work

fallen forge
#

trying

restive otter
#

idk how does dbd

#

work

#

so you maybe need to post it yourself

#

not with the package

fallen forge
#

hmm

#

i might just switch to djs if it does not work lmao

restive otter
#

or

#

wait

#

how do you get guild count in dbd.js

fallen forge
#

$serverCount

#

or

#

with djs

restive otter
fallen forge
restive otter
#

ok

#

Well

#

its not like d.js

#

so

#

idk what to do

fallen forge
#
shardId: client.shard.ids[0], // if you're sharding
^
TypeError: Cannot read property 'ids' of null
at Timeout._onTimeout (/home/container/server.js:13:27)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
[WISP] Server marked as OFF
[WISP] ---------- Detected server process in a crashed state! ---------```
restive otter
#

yeah that wont work

#

because its d.js code and not dbd.js

fallen forge
#

d.js works with dbd

restive otter
#

o

#

maybe get rid of it

fallen forge
#

shard ids?

restive otter
#

dont mind shards

#

idk yeah

#

only Server count

fallen forge
#

k

restive otter
#

is client defined on your code(d.js)

fallen forge
#

yes

restive otter
#

i know why

fallen forge
#

wait i'm confusion

restive otter
#

you dont have any shards

#

so its null

fallen forge
restive otter
#

oh

#

ok

#

i mean

#

hmmm

jaunty plank
#

whats your dbd client defined as?

fallen forge
restive otter
#

i actually dont my brain is confusion help

jaunty plank
#

this is what sharded dbd clients looks like

const bot = new dbd.bot({
    sharding: true,
    shardAmount: 2,
    token: "token",
    prefix: "prefix"
})
restive otter
#

i never used dbd.js

fallen forge
#

can have a seperate file named shard.js

jaunty plank
#

can you show your code for your client?

#

specifically the initialization line?

fallen forge
#
name:"say",
code:`$say[$message]`})```
#

just an example

#

but

#

bot

jaunty plank
#

that looks like a command

#

not a shard

fallen forge
#

didnt go down now

#
at Api.postStats (/home/container/node_modules/@top-gg/sdk/dist/structs/Api.js:93:19)
at Timeout._onTimeout (/home/container/server.js:11:7)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
(node:38) 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:38) [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.```
fallen forge
#

1sec

#

const shards = new ShardingManager("./server.js", {
 token: "Your token",
 totalShards: "auto" // You can change the amount of totalShards, but I recommend to you using it on "auto":)
});

shards.on("shardCreate", shard => {
 console.log(`[${new Date().toString().split(" ", 5).join(" ")}] Launched shard #${shard.id}`);
});

shards.spawn(shards.totalShards, 10000);
#

@jaunty plank

jaunty plank
#

interesting, didn't know dbd supported the djs sharding manager.

fallen forge
#

it does

jaunty plank
#

honestly, you may want to ask in the dbd support server how to get the shard id properly when using the djs sharding manager.

fallen forge
#

well i did remove the shard

jaunty plank
#

because the dbd docs dont mention this.

fallen forge
#

and the bot didnt reboot

#

but

fallen forge
#

@jaunty plank sorry for ping again

jaunty plank
#

interesting.

jaunty plank
#

without token*

fallen forge
#

yeah sure 1sec

#
const bot = new dbd.Bot({
token: "TOKEN", 
prefix: "$getServerVar[prefix]" 
});```
jaunty plank
fallen forge
#

i'm confused

jaunty plank
fallen forge
#

what i sent is what people sent me

#

sorry i'm bad at understanding and English is not my main language

jaunty plank
#

so, i need to know what your code looks like to help you. not what others said.

fallen forge
#

like what commands look like?

jaunty plank
#

commands doesnt matter for posting guild count.

#

i need to know:

  1. the code you are currently using to post server count.
  2. the error you are having.
  3. any related code to #1(if you use client, i need to know what your definition of client is.)
fallen forge
#

$serverCount for gulid count
error is (node:38) UnhandledPromiseRejectionWarning: Error: Missing Server Count at Api.postStats (/home/container/node_modules/@top-gg/sdk/dist/structs/Api.js:93:19) at Timeout._onTimeout (/home/container/server.js:11:7) at listOnTimeout (internal/timers.js:554:17) at processTimers (internal/timers.js:497:7) (node:38) 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:38) [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. without the shard if with shard then it keeps reooting the bot each minute
definition of client if i'm undertanding this correct it's bot.onMessage()

jaunty plank
# fallen forge is this correct?

hey, I am asking in the dbd support server about getting server count properly for separate libraries.
from the sounds of it, dbd might not support standard variable's for use with other libraries, which means dbd might not support posting server count to top.gg

fallen forge
#

oof :/

jaunty plank
# fallen forge oof :/

Alright, lets try using this lib instead. It should be a lot simpler.
https://www.npmjs.com/package/topgg-autoposter
In your terminal you will need to run npm i topgg-autoposter.
Then in your main file.

const AutoPoster = require('topgg-autoposter')
const ap = AutoPoster('topggtoken', client)

Client may need to be called bot, I'm not sure what you use.

restive otter
#

can you use shards under 150 guilds?

rapid kettle
#

yes

jaunty plank
#

yes, but sharding under a few thousand guilds is generally less performative and uses more ram.

jaunty plank
#

op, it might be for dbd

const AutoPoster = require('topgg-autoposter')
const ap = AutoPoster('topggtoken', bot.client)
#

^ yep, just tested, for anyone using dbd.js or anyone providing support down the line for this lib, bot.client is what you want to use with the autoposter.

pliant oak
#

for dsl is there weekend

#

multiplier

river kestrel
#

I switched to gradle

#

I hope this will solve all my problems

pliant oak
#

for dsl is there weekend
multiplier

jaunty plank
#

dont know about dsl tbh.

restive otter
#

how do i get notifed if somoene voted for my bot

jaunty plank
#

you can use webhooks.

restive otter
#

h

#

ok

jaunty plank
#

what language is your bot written in?

restive otter
#

python

jaunty plank
restive otter
#

ty

#

what else can i do

#

i have auto post

#

and vote webhook

rain heart
#

that's pretty much the essentials

restive otter
#

oh

#

what about the fancy description

#

how do i do tht

jaunty plank
#

thats done with html and css

restive otter
#

o

rain heart
restive otter
#

Ohhhhhhh

#

I see

river kestrel
#

@rain heart HOW I SOLVED MY PROBLEM :
Switching to gradle broke even more things so I went back to maven. I fixed my problem by just deleting and recreating my artifact from dependencies

#

so it all works now

#

:)

rain heart
#

oh lmao

restive otter
#

is there anyway

#

i can get like a template

#

for the description

#

and then just edit it

rain heart
#

no, you have to make it yourself

restive otter
#

k

#

i have some knowledge of css and html

#

but

#

ight ill see

#

ill try

#

ill just use ide and coy and pase

#

copy and paste

#

wait a sec

#

i can do inspect element

#

and do it

rain heart
#

again, don't steal

#

best is to make it yourself

restive otter
#

i know

#

i can do inspect element

#

do it

#

it says in article

#

but the thing is how do i save it

rain heart
#

as you would normally edit your bot page

#

if you made any changes with inspect element, copy what you changed, put it in a notepad and add it to your bot page

red cove
#

How do I do a test vote on my bot ?

hasty sapphire
#

Are we allowed to uh award currency for voting for the bot?

rain heart
#

yes

#

as long as it is only the bot they're voting for

hasty sapphire
#

oh i meant like reviewing the bot

#

sorry

rain heart
#

nah that is not allowed

hasty sapphire
#

rip

red cove
#

im here

#

so i just run a basic webserver?

#
import sys, datetime, json, re
from flask import Flask, request, abort, jsonify
import os

app = Flask(__name__)

@app.route('/test', methods=['GET', 'POST'])
def test():
    return jsonify(dict(request.headers))

@app.route('/dblwebhook', methods=['POST'])
def webhook():
    sys.stdout.flush()
    if request.headers.get('Authorization') == "supersecretpassword":
      print (request.json.get('user')) # ID of the user
      print (request.json.get('bot')) # ID of the bot
      print (request.json.get('type')) # test or upvoting
      return '', 200
    else:
        abort(400)


if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0', port=5000)```
#

like so?

#

I'm confused exactly how the on_dbl_vote event works

jaunty plank
#

what does the url look like on top.gg? replace the ip with ip or something.

#

if you are hosting at home, or on a vps that requires it, you will need to port forward.

#

if you have any firewalls you will also need to open it up for that port.

red cove
jaunty plank
#

the on_dbl_vote event receives requests, the intilization creates a webhook receiver for you.

#

i think you need http://

rain heart
#

yeah http:// is needed aswwell

red cove
#

alright let me try this.

thorn umbra
#

Can anyone help me how to do get rewarded for voting

graceful merlin
#

Hello, I created my web server using express and I will act. I'm thinking about how to create a webhook through my web server, can anyone help?

hot axle
#

use @top-gg/sdk

#

or read the docs to manually make an endpoint that receives the vote

graceful merlin
#

Ok

restive otter
#

;

buoyant vortex
#

Hello, how can I setup multiple vote reward, like 5 votes= a special rank?

split terrace
#

What is the code that allows you to know the votes?

split terrace
#

what

buoyant vortex
#

Hello, how can I setup multiple vote reward, like 5 votes= a special rank?

sullen nymph
#

Use the webhook system. On each vote, increment a number attached to a user ID. On 5th vote, reward the user

sullen nymph
#

We could just mute those who refuse to move channels

river kestrel
#

maybe he meant 'is it allowed'

restive otter
#

It's not working

thorn umbra
#

can anyone make a vote webhook , idk how to do it

rapid kettle
#

There are bots that handle that

thorn umbra
#

which one

rapid kettle
#

There’s only 2 I know of

restive otter
rapid kettle
#

Is it configured on the site

restive otter
#

Yes

sullen nymph
#

What did you enter on the website?

restive otter
rapid kettle
#

useful

sullen nymph
#

Very

#

Mind DMing me what you entered on the website?

restive otter
#

why does it matter?

rapid kettle
#

?

restive otter
#

the ip address should appear in the code

rapid kettle
#

no it shouldn’t

sullen nymph
#

0.0.0.0 isn't a valid public IP address

restive otter
#

I mean, it's the password, I'm not sure i should share it

sullen nymph
#

Bleh, the password doesn't matter to me

rapid kettle
#

0.0.0.0 is just a placeholder for all available ips

#

that’s shiv I’d trust him

sullen nymph
#

Your URL just needs to be in a format such as http://IP.of.your.machine:5000/dblwebhook

restive otter
#

its still not working

dire current
#

i guess i am facing the same

#

when i am pressing test webhook its working
but when i m trying to save the data the page keeps continue to load

rain heart
#

If it is on a bot, make sure your bot is approved aswell

radiant peak
#

whats the ratelimit for /bots/~Bot ID/check endpoint?

rain heart
#

60 requests per minute

#

if exceeded, 1 hour block

radiant peak
#

k, thanks

jolly veldt
rain heart
#

please re-read the docs, as you seem to be really confused

jolly veldt
#

k

rain heart
quaint copper
#

how do i check how many servers my ot is in

#

bot*

rain heart
#

with your code

rugged quarry
#

Hey guys what is api

rain heart
little matrix
#

TypeError: Cannot read property 'on' of undefined

  console.log(`User with ID ${vote.user} just voted!`);
});```
#

i am using dblapi.js

#
const dbl = new DBL(
    `token`, { webhookPort: 5000, webhookAuth: 'password' }, client
);```
#

yes

#

is that a reason, i am using dbl token of my another bot

#

because my 2nd bot is not approved yet 🙂

#

approved yet

#

because my 2nd bot is not approved yet 🙂

#

hmm

#

ok

#

i am just ready with the code

#

no maybe, else dbl was not supposed to keep separate tokens for bots

#

because with each token, we have to post with the bot's client on top.gg for showing server count

#

I dont have the webhook either

#

bot is not approved yet, so i think i wont get it

#

I know, yesterday i made voting feature and rewarding them for a server yesterday with webhooks

#

but till the bot gets approved , i can do nothing

#

it was for a server

#

now trying for a pending approval vot

#

bot

#

i have to wait until i get the token so

#

i need to post on top.gg api for server counts in top.gg page

#

yes ik

#

they cant either see the bot page

#

yes i know lol

#

i had it done for my corona bot

#

so i am just waiting for the bot to be approved

#

codes are ready

#

😉

#

No

#

1st point of 2nd para

sullen nymph
#

👀 knock knock it's the unexpected mod guests

#

Well yeah I don't think there's any active maintainer for it atm

#

I'm prone to believe that any library apart from Python and JS SDKs is outdated

#

Throw Veld a DM 👀

rain heart
#

I actually thought about making a pr to it with webhook support, though the last pr from 2019 is still waiting for review from nik WeirdChamp

sullen nymph
#

catshrug Depends tbh. See if the codebase is decent enough for a start

rain heart
#

so not worth it

sullen nymph
#

You might wanna DM Veld about that tbf

#

Might be seeing a new maintainer sure

rain heart
#

i mean the current version has unused vote classes, so it was planned

#

though im just too stupid with my current knowledge of Java on how to work with that

sullen nymph
#

Learn on the go (the way I did it) KEKW

rain heart
#

I literally made a whole ready-to-use Webhook library for both bot- and server based webhooks PeepoShy

#

Because i was really bored and couldn't sleep

jovial warren
#

Where can I get the api so u see the amount of servers my bot is in at the site?

rain heart
rain heart
#

@slim storm post the sourcecode on GitHub and i could look how i can add the Webhook library to it

tawdry wolf
#
  • Been using Hope's webhook (I was first bamboozled since there was a constructor that asked for a boolean for debug but the code was always true) [not really a question]
rain heart
#

Yeah probably gonna remove the debug thing sooner or later

rain heart
tawdry wolf
#

Pretty much straightforward

rain heart
#

I'm glad

tawdry wolf
#

Well, it is similar in a way to Javacord's listener stuff which made it easier for me kokoHappy

rain heart
#

That's pretty much based on Javacord, yeah

deep nova
#

Alright so idk why the API doesn’t post the server count to top.gg
I’ve checked the following:

  • dblpy and necessary dependents installed
  • Cog structure is correct, it is in a file named dblpy.py in the cogs folder for my bot
  • I’m using the base automatic posting provided in the API with the token https://top.gg/api/docs#pylib

But after waiting a good 30 minutes, the server count does not appear.
There is also no message stating “Server count posted successfully”

sullen nymph
#

Try posting manually

deep nova
#

I'm trying that right now

#

see how that goes

deep nova
#

uhh for those that use discord.py, does it need to be a Client object or does the discord.ext.commands.Bot object work as well for the bot in this class?

classdbl.DBLClient(bot: discord.client.Client, token: str, autopost: bool = False, **kwargs)```
sullen nymph
#

Either works

#

Bot is a subclass of Client but all you really need is an object with guilds property

#

oh and .user.id too

deep nova
#

hm

#

alright

#

now I keep getting this one error

#
object Lock can't be used in 'await' expression
#

more specifically, this happens after a TypeError happened when attempting to post guild server count

#

so I suspect something is wrong with the API itself, tho I have no clue how to check

sullen nymph
#

Oh dear

sullen nymph
restive otter
#

hey how to use api

deep nova
#

I’ll let you know how it goes

sullen nymph
#

Sure, no sweat

restive otter
#

bruh

#

im asking how to use api send docs

sullen nymph
#

For discord.js library see pinned messages

restive otter
compact creek
#

So I've got this setup but it doesn't seem to print when a test vote is sent...

    @commands.Cog.listener()
    async def on_dbl_vote(self, data):
        print(data)
rain heart
#

Did you also enter the webhook on your bot page settings? did you set everything related to webhooks in your dbl consctructor?

restive otter
#

thx

#

But I mean how in any box I put it in Top.gg ?

#

@rain heart

rain heart
#

yes

#

read the docs

#

it will explain

restive otter
#

ok .

red cove
compact creek
#

Alr thanks

quick needle
#

Where do you get the dbl_token for your server?

rain heart
quick needle
#

For a server?

rain heart
quick needle
#

oh

#

how do I get people who upvote your server then

rain heart
#

With webhooks

red cove
quick needle
#

ok

red cove
#

You wanna add the webserver information to your server information so Top.gg sends it your upvotes

red cove
#

When looking up bots with the API if the field doesn't have a value is it still present? Like say they haven't used the API to update server count.. will server_count return as None or 0?

rain heart
#

I'd say try it

#

i assume it's either 0 or null

red cove
#

Yea I'm going to.. I'm just away from my PC and curious as I'm seeing a few errors.

rain heart
#

yeah just go ahead

keen snow
#

how do I do test vote?

rain heart
#

Not that i know of, if it's invalid, you just get 401'd

hearty lintel
#

most bot specific endpoints don't need an ID

#

take a look at official libs to get an idea

keen snow
#

ah I see it now, thanks

hearty lintel
#

like posting to /bots/stats is the same as /bots/id/stats

#

but id is just replaced with the id of requesting token

ashen skiff
#

Hi everyone

golden tinsel
#

I am have just added the dbl lib to my requirements.txt file, I am hosting on heroku and got this error:

       ERROR: No matching distribution found for dbl (from -r /tmp/build_c85ce3ff_/requirements.txt (line 8))```

My ``requirements.txt`` file looks like this:

discord.py
dpymenus
requests
jsonbin
discord-pretty-help
quickchart.io
psycopg2
dbl

#

p.s. ping me

#

is it safe for me to ping someone...?

#

@bold fulcrum sorry for the ping but I saw you were a verified dev, so far I have not found anything on google

rapid kettle
#

its dblpy

#

innit?

golden tinsel
#

yeah

#

I think I am realizing that

#

when I looked back at the docks

#

I am now regretting that ping

#

yep it is dblpy, my app compiled fine

bold fulcrum
#

I do java, not python. My python experience is very limited lol

rapid kettle
#

you java?

bold fulcrum
#

yea

rapid kettle
#

cool

bold fulcrum
#

yes

slow cedar
#

K

golden tinsel
#

welp another question:
How do I get/find my API token?

rain heart
golden tinsel
#

thx, I just found it : )

#

and... guess what, another question :/
I am getting this error:

2021-01-26T00:06:00.026541+00:00 app[worker.1]: TypeError: object Lock can't be used in 'await' expression```
with this code
```py
from discord.ext import commands, tasks

import dbl


class TopGG(commands.Cog):
    """
    This example uses tasks provided by discord.ext to create a task that posts guild count to top.gg every 30 minutes.
    """

    def __init__(self, bot):
        self.bot = bot
        self.token = '<><><><>'  # set this to your DBL token
        self.dblpy = dbl.DBLClient(self.bot, self.token)
        self.update_stats.start()

    def cog_unload(self):
        self.update_stats.cancel()

    @tasks.loop(minutes=30)
    async def update_stats(self):
        """This function runs every 30 minutes to automatically update your server count."""
        await self.bot.wait_until_ready()
        try:
            server_count = len(self.bot.guilds)
            await self.dblpy.post_guild_count(server_count)
            print('Posted server count ({})'.format(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))
wind sun
#

  def __init__(self, client):
    self.client = client
    self.token = os.environ["topgg_key"]
    self.dblpy = dbl.DBLClient(self.client,self.token,autopost=True)
  
  async def on_guild_post():
    print("Server count posted. :D")

  
def setup(client):
  client.add_cog(DSLCount(client))```

like in this
how do I define the autopost?
#

or do I need to do something like the above thing?

golden tinsel
#

you need something like above

#

but uhh it gives me the error

wind sun
#

🤔

#

what do you mean?

#

and alright

golden tinsel
#

on_guild_post() listens to when it actually happens, you have to enable posting for it to ever be called (I think)

deep nova
#

@sullen nymph yep building from source works

#

the version is very different as well 1.0.0 instead of 0.4.0 from pip

#

thanks!

restive otter
#

How would I check if a user has voted for my server on top.gg

rain heart
#

oh nvm

#

for servers, you need a webhook

restive otter
#

Okay how would I do the webhook @rain heart

rain heart
#

you need to know how to code for that

restive otter
rain heart
#

what language?

restive otter
#

anything js py Java php

rain heart
restive otter
gusty quartz
#

anybody using heroku and python here? i was wondering how you setup your Procfile to also listen to the webhooks

jovial kiln
white trellis
#

my bad

#

wrong dev server

jovial kiln
#

ok

white trellis
#

sorry

jovial kiln
#

all g

sullen nymph
#

Vote count increases by two instead of one but webhook will send one request still

full wigeon
#

Guys I added my bot to top.gg but still it does not show up on search result

rain heart
#

though the team is aware

full wigeon
#

Oh sry thought I sent in support

My bad,,anyway thx

bright quartz
#

I need some help

rain heart
#

wrong channel

bright quartz
zenith pewter
#

also how do i get my dbl token

#

i want to reward the user with some bot currency when they vote for my bot

#

oh ok

#

ty

#

aight

#

what shud i set my webook url and authorization to

#

is it something i just make up?

#

ok

#

so how do i get the webhook url for my bot

#

so it sends to my bot

rain heart
#

it's the ip of your server you're hosting it on

#

http://ip:port/path

zenith pewter
#

well im self hosting so do i just give it my own ip address and do some port forwarding magic?

rain heart
#

yes that could work

zenith pewter
#

ok

zenith pewter
#

@rain heart that didnt work

#

i did the port forwarding and all but it didnt

#
TOKEN = os.getenv("BEAN_TOKEN")
DBL_TOKEN = os.getenv("BEAN_DBL_TOKEN")
DBL_AUTH = os.getenv("DBL_AUTH")
dbl_client = dbl.DBLClient(bot, DBL_TOKEN, webhook_port=8080, webhook_auth=DBL_AUTH)
#

this is how im doing the thing

#

in code

sullen nymph
#

What's the URL you entered on the website?

zenith pewter
#

omg my ip address changed nvm forgot to update my dns

#

it still didnt work

#

sad

dire imp
#
Failed to update server count in top.gg ['Traceback (most recent call last):\n', '  File "/home/runner/HandCricketBotDiscord/eventloops.py", line 48, in update_stats\n    topggvotes = await self.dblpy.get_bot_votes()\n', "AttributeError: 'DBLClient' object has no attribute 'get_bot_votes'\n"]
#

im not using the webhook btw.

sullen nymph
#

It will be changed in v1.0

dire imp
#

Oh yeah its upvotes, the documentation says getbotvotes so i got confused. ty

sullen nymph
#

.........

#

I really need a separate branch for non-stable versions' docs

rain heart
#

probably

zenith pewter
#

is a webhook neccesary for on_dbl_vote event?

rain heart
#

yes

cursive steppe
#

How do you catch error if token is invalid?

#

I tried try{} catch{} it didn't work

rain heart
#

just make a request to the api and see if you get a 401 or so

cursive steppe
#

How do you make a request?

rain heart
#

get your own bots votes or smth

cursive steppe
#

Huh

#

There's no way to catch it while defining token?

#

Like let dbl = new DBL(token)

restive otter
#

@rain heart

#

im quite confused

#

what do we do here?

knotty garnet
#

are you trying to setup discord-based login?

restive otter
cursive steppe
#

When i do

dbl.webhook.on("vote")```
It says can't read property on of undefined
restive otter
#

If there is a mistake I would be glad if you ping me

foggy cave
#

Hi, i need help whit the webhook vote system for server list

#

I have this:

#
app.listen(3000, () => {
const uwu = new Discord.WebhookClient("webhookID", "webhookTOken")
//What i put here?
});
zenith pewter
rain heart
#

did you enter the url on your bot page settings?

zenith pewter
#

yes

rain heart
#

make a test request with postman or any rest client

zenith pewter
#

ok

#

i tried to use the tester on the top.gg site where u enter the url and stuf

rain heart
#

dm me the url you've entered

#

I'll tell you if it would work or not

#

make sure it is http:// not https://

#

make sure the port is there too etc

zenith pewter
#

oh

#

i forgot the port

violet panther
#

How can I make my bot send a message when someone voted my bot?

restive otter
rain heart
#

no clue

restive otter
#

There's only 400 bad request errors

quick needle
#

@mortal ore What language r u using for the webhook

mortal ore
#

nvm i got it fixed

quick needle
#

alr

mortal ore
#

there was an internal server issue cause of which the logs werent working properly

#

thanks!

quick needle
#

np

#

😄

foggy cave
#

is from servers, not bots ._.

cursive steppe
#

There's no simpler way to make a dbl event to trigger when someone votes for the bot instead of using express?

hot axle
#

the only way of using webhooks is with an http server

onyx monolith
#

can anyone send me the code for when you vote for the bot it will show ;-;

acoustic peak
#
from discord.ext import commands
import dbl

class TopGG(commands.Cog):

    def __init__(self, client):
        self.client = client
        self.command = 0
        print("--> Loaded Top.GG cog.")
        self.token = 'You will never find out'
        self.dblpy = dbl.DBLClient(self.client, self.token, autopost=True)

    @commands.Cog.listener()
    async def on_guild_post(self):
        print("Server count posted successfully")

def setup(client):
    client.add_cog(TopGG(client))

I waited an hour but my bot hasn't updated it's value, still shows N/A

restive otter
#

did it print?

acoustic peak
#

Nope

#

It loads the cog

#

but doesn't print the Server count posted successfully part

restive otter
#

try calling await self.dblpy.post_guild_count() and see if there's any error since the lib suppress any http exceptions

acoustic peak
#

I'll let you know in 30

restive otter
#

@sullen nymph What about dispatching guild_post_error or something when it errors inside the auto_post loop?

#

actually since you can listen to http logging, idk if that's gonna be useful mmulu

sullen nymph
#

I think I was smoking something when I decided to suppress exceptions

restive otter
#

kek

split terrace
#

bonsoir j'aimerais savoir comment on fait pour que le bot puisse send un message des qu'une personne vote sur le site top.gg merci de m'aider s'il vous plaît

restive otter
misty comet
#

Oops wrong channel

hot axle
#

nah this is the right channel

misty comet
#

Read channel topic

hot axle
#

yeah

#

it includes help with the top.gg libs

misty comet
#

Oki gracias

#

For some reason my botpost code is not working.
In index.js I have const botpost = require("./botpost.js") And in botpost.js I got the following

exports.run = async function run(client) {
    const DBL = require("dblapi.js");
    const dbl = new DBL('token', client); 
    // Optional events
    dbl.on('posted', () => {
     console.log('Server count posted to top.gg!');
    });
    
    dbl.on('error', e => {
    console.log(`Oops! ${e}`);
    });
    
    setInterval(() => {
        dbl.postStats(client.guilds.size, client.shards.Id, client.shards.total);
    }, 240000);
}
#

It used to work before

hot axle
#

client.guilds doesn't have a size property

#

use client.guilds.cache.size

misty comet
#

Ohhh

#

But uh

#

I don't think it even executes there's no error in console

#

Yup it doesn't execute

#

@hot axle how can I change the code from module exports so that I can put it in index.js

hot axle
#

wdym by "change code from module exports"

misty comet
#

Hold on

#

I think I found the issue

#

I forgot the client.login

hot axle
#

oh ok

misty comet
#

Still

#

Not posting stats

#

-_-

rain heart
#

did you add your dbl token?

misty comet
#

@hot axle how do I make it so the file executes?

misty comet
#

But there's no console error

#

Ima get a new token maybe

rain heart
#

also, i'd suggest using that inside your main file for testing

misty comet
#

Yeah idk how to transfer it

#

I changed to index.js

#

So @rain heart the issue now is it says client is not defined

rain heart
#

define client

misty comet
#

I added client.login but doesn't work -_-

#

How do I do that

#

I use DBD.js

#

😒

rain heart
#

can't help you then

misty comet
#

....

misty comet
violet panther
#

${vote.user} will return the user id
Then what will return the user name and their tag?

rain heart
#

Nothing

#

you need to query that through your discord library you're using

violet panther
#

Ok, thanks

split terrace
#

hello I wanted to know how we do so that the bot says who voted on top.gg on the show?

restive otter
#

dbl.postStats(client.guilds.size); when you upload your stats like this, how can you stop people just doing dbl.postStats("99999");

rain heart
#

People will get their bot deleted off the site (or even get blocked from the api completely) if they do that

restive otter
#

Okay

rain heart
#

@sullen nymph

#

this dude is smart

sullen nymph
#

Indeed

fickle zealot
#

hi im having a little trouble with webhooks in python

#

i had a look up in the chat, still couldnt figure out what i was doing wrong

restive otter
fickle zealot
#

ok thanks

#

so its just not working, i can update guild count and do other stuff

#

receiving votes is not working

restive otter
#

hm

fickle zealot
#

no errors or anything, just not working

restive otter
#

are you using the api or the flask webhook?

fickle zealot
#

api

restive otter
#

oh wait are you using python?

fickle zealot
#

yeah

restive otter
#

alr then were cool

#

so

fickle zealot
#

heh

restive otter
#

do you have an open ip/domain.

fickle zealot
#

yeah

#

which we've used for mc and other things

#

so it works

restive otter
#

is there any errors on testing the webhook?

fickle zealot
#

nah

#

nothing comes up

#

oh and on_dbl_test is undocumented

#

idk why

restive otter
#

so put this

#

i guess you have it already

rain heart
#

did you enter it on your top.gg bot page?

#

is it valid?

#

did you test it with a request client?

fickle zealot
#

ok so

#

i've entered it, yes

#

is it valid, the ip is

rain heart
#

dm me/send it in here what you have entered there

fickle zealot
#

ok sure

restive otter
#

so my question

#

uh what is the way to post shard count?

fickle zealot
#

i hope youre not asking me lmao

restive otter
#

since i don’t think its in the documents

#

nah lol

fickle zealot
#

haha

rain heart
#

@fickle zealot nothing is running on that port

restive otter
#

got it

fickle zealot
#

give me a min

rain heart
#

there is literally nothing running on that port, make sure you've entered the correct port, followed the docs etc

fickle zealot
#

my bad

#

i'll set up another port

rain heart
#

use the common one 5000

#

i think it is on the docs aswell

fickle zealot
#

its still not working

#

i set the port to 5000

rain heart
#

not getting any response from 5000 either

#

python, correct?

fickle zealot
#

yeah

rain heart
fickle zealot
#

yes

#

with webhook path, is https://top.gg/bot/711934102906994699/webhooks correct?

restive otter
#

no

fickle zealot
#

oh

restive otter
#

it's in http://{ip}:{webhook_port}{webhook_path} format, for instance the port is 3000 and the path is /webhook, so the url you will pass is gonna be http://{ip}:3000/webhook

sullen nymph
fickle zealot
#

oh, i didnt realise it needed to be the same in the bot as well

fickle zealot
sullen nymph
#

P.S. it works for 0.4.0

fickle zealot
#

hehe phew

fickle zealot
fickle zealot
#

yeah

rain heart
#

how does your constructor from the api definition look like

#

like the parameters

fickle zealot
#

DBL is from import dbl as DBL

sullen nymph
#

what is URL defined as?

restive otter
#

I'm curious what that fn assignment is for

#

pass only /dblwebhook

sullen nymph
#

leaked IP and wrong path

restive otter
#

and ip leak poggies

fickle zealot
fickle zealot
sullen nymph
fickle zealot
#

literally only write /dblwebhook?

#

nothing else

sullen nymph
#

in webhook_path yes

restive otter
fickle zealot
#

hmm ok

fickle zealot
#

theres more

restive otter
#

yeah nevermind

sullen nymph
#

Sometimes I feel like f"/{webhook_path.split('/')[-1]}" might be needed

restive otter
#

yes

#

actually, if people had enough effort to read the docs, it's not needed lol

rain heart
#

shiv, need your opinion: what would be more "understandable" when defining the webhook path for a webhook? with a / or without it? https://cdn.hopefuls.de/UP69

sullen nymph
#

/ imo

rain heart
#

yeah same thought

sullen nymph
#

It's more verbose and understandable

rain heart
#

yup yup

fickle zealot
#

ok i am very confused

#

i set url to /dblwebhook

#

and it still doesnt work

restive otter
#

you input the whole thing that you deleted before to the site, didn't you?

fickle zealot
#

that was actually already like that

#

i only changed the port

rain heart
#

though i can guarantee you it isn't because of the webhook, if your aiohttp would be working, i would get a response without using any paths

fickle zealot
rain heart
#

as far as i know that's what dblpy uses

#

for the webhooks

fickle zealot
#

hmm

rain heart
sullen nymph
#

aiohttp is the package dblpy uses

#

both for the webhook and API requests

fickle zealot
rain heart
#

No no, it should work as you did now

sullen nymph
#

Are you sure you are loading the cog?

#

Is the port open and forwarded?

#

Do you have a firewall blocking the requests?

rain heart
#

Though i'm pretty sure that it isn't getting loaded, doesn't matter if the webhookpath im using is correct or not, it would tell me that it couldn't be found (or at least send me a response with headers)

#

and the ports are open, checked it myself

fickle zealot
fickle zealot
fickle zealot
fickle zealot
#

does dblpy need port 80 open for aiohttp?

#

bc if its being used for something else will that stop it from working?

rain heart
#

you cannot reuse a port

#

you have to use a port that is not used

fickle zealot
#

yeah yeah ik

rain heart
#

such as 5000 or so in your case

fickle zealot
#

im just asking

#

incase it needs port 80

#

for http requests from aiohttp

#

if so, that port is in use, and might that be why its not working?

rain heart
#

nah it doesn't use port 80

#

it uses the port you entered on your constructor

restive otter
#

is there a way to get a number of how many times a user voted? i wanted to make it in a db, but people voted before i set up the db

fickle zealot
#

thats a shame

rain heart
restive otter
#

Okay

serene bloom
#
@bot.event
async def on_dbl_vote(data):
    channel = client.get_channel(votechannelid)
    print(data)

How To Get User ID From This Data I Should Use data.user or what ?

restive otter
#

data is a dict, so ig data['user']

serene bloom
#

thanks

restive otter
dim wren
#

Hello you think I should put this in which event? ```js
app.post('/dblwebhook', webhook.middleware(), async(req, res) => {
try {
const user = await client.users.fetch(req.vote.user);
db.set(vote_${user.id} + 1)
let vote = db.get(vote_${user.id})
user.send('test');
} catch (error) {
console.error(error);
}
})

#

(ping me if you know)

restive otter
#

they're indeed making a post endpoint christmasthink

glass frigate
viscid rock
#

J

dim wren
#

and how to do this ?

deft violet
#

can i get help in setting up my webhooks?

#

im using node.js

jaunty plank
#

sure, what do you need help with?

deft violet
#

so i have the

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

but this is what im getting returned

jaunty plank
#

for the old library it will always log 0.0.0.0 as 0.0.0.0 just means "any available ip"

deft violet
#

ok

jaunty plank
#

just when you fill in the site use the right ip

deft violet
#

wdym

#

sorry lol this is my first time doing webhooks

jaunty plank
#

you need to fill in the URL on your bots edit page, in the webhook section.

#

with the auth

deft violet
#

can you give me an example of the url?

#

auth is done

jaunty plank
#

sure, heres an example
http://0.0.0.0:4982/dblwebhook
filled in with the correct ip.

deft violet
#

so the 0.0.0.0 is replaced by my ip?

jaunty plank
#

yep

deft violet
#

oki

#

const dbl = new DBL(topggToken, { webhookPort: 0000, webhookAuth: key });

#

for the webhookport

#

can it just be random?

#

or what should it be

jaunty plank
#

it should be any available port.

#

any number from 2000 to 10000 should be fine.