#topgg-api
1 messages · Page 130 of 1
what's the $Builder because that's what seems to be the one causing trouble
it is authorization thing for verify that requests are coming from top.gg @restive otter
yeah
Builder is the Builder for the DiscordBotListAPI
this part https://cdn.hopefuls.de/961C
how do i get the dbl token?
make a dummy project and see if the same issue happens on there too
because it works perfectly with gradle
And how do i get my password?
java.lang.NoClassDefFoundError: okhttp3/Callback
at org.discordbots.api.client.DiscordBotListAPI$Builder.build(DiscordBotListAPI.java:54)
this is the error
go to https://top.gg/bot/BOT_ID/webhooks
most likely that is what you're missing
that's the line in the source code
return new DiscordBotListAPIImpl(token, botId);
okay thanks
yeah you most likely are just missing okhttp
same exact error? did you rebuild?
and yes I did rebuild
check if you see okhttp3 in your folder tree when opening it in winrar
otherwise, add these to your pom aswell
it's not in the tree
then you didn't add it to your pom, did you also add it to extract into your artifact aswell?
it's literally in my pom
so I should add these too ?
Yeah go ahead
Ok I added all of them
should I add them to be extracted too ?
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
How are you exporting your artifacts? through IntelliJ's Artifacts?
if so, make sure the libraries are added like this https://cdn.hopefuls.de/aAbI
how else I would get the jar ?
and it has all the other libraries extracted into it, such as gson, gson-runtime, json, okhttp, okio and slf4j right?
logger stuff
So I did all of this and now it silently doesn't work
so there is no error but it doesn't work either but only with the jar
works from intelij
It just doesn't do anything? add debug lines
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
so I should add that ?
If you haven't added slf4j yet, add it
it's here though
and it was before I "explicitly" added the dependency
slf4j-simple.jar
maybe I should have this @rain heart ?
try it, I'm still looking why it doesn't work
why is it saying dblapi.js is no longer maintained?
@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)
idk maybe it's just not maintained anymore
then what do they use now though?
read pins
o
ty
so to install
i need to add topgg-autoposter in additional node packages?
@rain heart
read pins
I gotta go for a few minutes, pls dm me or ping me if you find something
I mean it works flawlessly with gradle, one of many reasons why i hate maven
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 ;-;
kotlin/jvm/internal/Intrinsics Why does it need kotlin ?
No clue, maven is stinky that's why
I just tried it myself with maven, works perfectly
I don't have any clue why it doesn't work then really
why does it not work for me then
1 sec
here, my pom
is there anything weird in it ??
but can it check if someone voted ?
because it does log in for me
but it's when someone calls the vote reward command that it gives an error
I would suggest trying other methods, yeah
otherwise, just track the votes/rewards with your own webhook
I'll probably end up doing that lol
nah the pom looks fine to me
thanks for your help !
How are you trying to run it btw? do you have a mainfest etc?
java -jar ./Gamma.jar
that's how I run it
yeah no clue then unfortunately, the only thing i could suggest is trying it through gradle maybe
I'll think I'll use the webhook version anyway
thanks for your help !
and for your time !

@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
when i tried to access /webhooks on my bot's page
@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}`);
})```
yeah that's the old one
and this for the package top-gg/sdk
what's the new 1?
that's the example on the docs
this is what im using
what do i do?
the docs are subject to updates, the library-dev from the node package posted it in here and got it pinned
try clearing your cache
which one this? ```const AutoPoster = require('topgg-autoposter')
const poster = AutoPoster('topggtoken', client) // your djs client/shardingmanager or eris client```
that's autoposter for auto-posting your guild count
then what does the one i posted do?
oh wait
this the same thing
this was giving me errors
i am
but it's saying n/a
on top.gg
n/a means that you haven't posted your guild count yet
did you enter your guild count?
you need to post it yourself with the api
^
wait wdym?
i did
what errors
npm error
you need to read the docs on https://top.gg/api/docs#jslib
ah
i did
what about @top-gg/sdk then
and i used the same example
that gives me no errors
but
it says it's no longer maintained
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}`);
})```
and thats old
that's the one on the docs
which one is the new 1?
@top-gg/sdk or topgg-autoposter
instead of this
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
ty ❤️
btw you need to wait 30mins
and the package needs to be top-gg/sdk yeah?
yeh
for it to post?
yeah
oh okay
or you can lower the time
how? lol sorry
but dont lower it too much
o
what's the minimium?
lemme see
okay thanks
60 times per min = 1hr ratelimit
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
lol
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)```
okay thanks alot 😄
@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
then whats your client defined as
wdym?
or did you putted it below your client
i put it above
put it below
put it below
o
just not below the token
im confusion rn
same
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
dbd? 
npm package
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
trying
idk how does dbd
work
so you maybe need to post it yourself
not with the package

still rebooting the bot
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! ---------```
d.js works with dbd
shard ids?
k
is client defined on your code(d.js)
yes
i know why
wait i'm confusion
i do
whats your dbd client defined as?
bot.command({
i actually dont my brain is confusion help
this is what sharded dbd clients looks like
const bot = new dbd.bot({
sharding: true,
shardAmount: 2,
token: "token",
prefix: "prefix"
})
i never used dbd.js
dosent has to be like that
can have a seperate file named shard.js
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.```
oh the shard
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
interesting, didn't know dbd supported the djs sharding manager.
it does
honestly, you may want to ask in the dbd support server how to get the shard id properly when using the djs sharding manager.
well i did remove the shard
because the dbd docs dont mention this.
gave me this error
@jaunty plank sorry for ping again
interesting.
can you show your definition of client?
without token*
yeah sure 1sec
const bot = new dbd.Bot({
token: "TOKEN",
prefix: "$getServerVar[prefix]"
});```
so, in your code example(the one im replying to) you use client, not bot. how is client defined?
i'm confused
how is client defined, as you use in your code here.
https://i.imgur.com/akirC6p.png
you show the definition of bot here, but not client.
what i sent is what people sent me
sorry i'm bad at understanding and English is not my main language
so, i need to know what your code looks like to help you. not what others said.
like what commands look like?
commands doesnt matter for posting guild count.
i need to know:
- the code you are currently using to post server count.
- the error you are having.
- any related code to #1(if you use client, i need to know what your definition of client is.)
$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()
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
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.
can you use shards under 150 guilds?
yes, but sharding under a few thousand guilds is generally less performative and uses more ram.
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.
for dsl is there weekend
multiplier
dont know about dsl tbh.
how do i get notifed if somoene voted for my bot
you can use webhooks.
what language is your bot written in?
that's pretty much the essentials
thats done with html and css
o
@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
:)
oh lmao
is there anyway
i can get like a template
for the description
and then just edit it
no, you have to make it yourself
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
i know
i can do inspect element
do it
it says in article
but the thing is how do i save it
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
but this is #topgg-api for top.gg api, so best is to move over to #development
How do I do a test vote on my bot ?
sorry
and alright
Are we allowed to uh award currency for voting for the bot?
yes
as long as it is only the bot they're voting for
more on that here https://top.gg/api/docs#votes
nah that is not allowed
rip
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
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.
the on_dbl_vote event receives requests, the intilization creates a webhook receiver for you.
i think you need http://
yeah http:// is needed aswwell
alright let me try this.
Can anyone help me how to do get rewarded for voting
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?
Ok
;
Hello, how can I setup multiple vote reward, like 5 votes= a special rank?
What is the code that allows you to know the votes?
what
Hello, how can I setup multiple vote reward, like 5 votes= a special rank?
Use the webhook system. On each vote, increment a number attached to a user ID. On 5th vote, reward the user
We could just mute those who refuse to move channels
maybe he meant 'is it allowed'
can anyone make a vote webhook , idk how to do it
There are bots that handle that
which one
There’s only 2 I know of
How can i do this?
Is it configured on the site
Yes
What did you enter on the website?
useful
why does it matter?
?
the ip address should appear in the code
no it shouldn’t
0.0.0.0 isn't a valid public IP address
I mean, it's the password, I'm not sure i should share it
Bleh, the password doesn't matter to me
Your URL just needs to be in a format such as http://IP.of.your.machine:5000/dblwebhook
its still not working
what error are u facing brother?
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
If it is on a bot, make sure your bot is approved aswell
whats the ratelimit for /bots/~Bot ID/check endpoint?
60 requests per minute
if exceeded, 1 hour block
k, thanks
for webhook sned do i doo `https://discord.com/api/webhooks/id/token/top.gg
please re-read the docs, as you seem to be really confused
k
Hey guys what is api
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
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
👀 knock knock it's the unexpected mod guests
Let's take this to #general or #general-int as it happens to be outside of top.gg API discussion
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 👀
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 
Depends tbh. See if the codebase is decent enough for a start
so not worth it
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
I literally made a whole ready-to-use Webhook library for both bot- and server based webhooks 
Because i was really bored and couldn't sleep
Where can I get the api so u see the amount of servers my bot is in at the site?
@slim storm post the sourcecode on GitHub and i could look how i can add the Webhook library to it
- 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]
Yeah probably gonna remove the debug thing sooner or later
Though was it generally understandable?

Pretty much straightforward
I'm glad
Well, it is similar in a way to Javacord's listener stuff which made it easier for me 
That's pretty much based on Javacord, yeah
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”
Try posting manually
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)```
Either works
Bot is a subclass of Client but all you really need is an object with guilds property
oh and .user.id too
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
Oh dear
yeah can you reinstall dblpy from GitHub for now?
hey how to use api
I’ll do this when I have time tmr
I’ll let you know how it goes
Sure, no sweat
Hmm
For discord.js library see pinned messages
kk
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)
Did you also enter the webhook on your bot page settings? did you set everything related to webhooks in your dbl consctructor?
@restive otter https://top.gg/api/docs
ok .
Yea I just had the same issue. Someone suggested I had done something wrong with the webserver or dbl constructor but I didn't. So I just ended up using the webserver alone without dblpy and it's working flawlessly.. I suggest you also do this or at least look into it
Alr thanks
Where do you get the dbl_token for your server?
For a server?
top.gg/servers doesn't have a api
With webhooks
By using a webserver..
ok
You wanna add the webserver information to your server information so Top.gg sends it your upvotes
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?
Yea I'm going to.. I'm just away from my PC and curious as I'm seeing a few errors.
yeah just go ahead
how do I do test vote?
Not that i know of, if it's invalid, you just get 401'd
most bot specific endpoints don't need an ID
take a look at official libs to get an idea
ah I see it now, thanks
like posting to /bots/stats is the same as /bots/id/stats
but id is just replaced with the id of requesting token
Hi everyone
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
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
I do java, not python. My python experience is very limited lol
you java?
yea
cool
yes
K
welp another question:
How do I get/find my API token?
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))
also should this be in #topgg-api or like #development ?
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?
on_guild_post() listens to when it actually happens, you have to enable posting for it to ever be called (I think)
@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!
oh nvm
for servers, you need a webhook
Okay how would I do the webhook @rain heart
you need to know how to code for that
I know how to code how would I do is there an API for it?
what language?
anything js py Java php
i made a java library for webhooks if you know how to work with libraries https://github.com/Hopefuls/topggwebhooks4j
Java Webhook Library for Top.gg. Contribute to Hopefuls/topggwebhooks4j development by creating an account on GitHub.
Thanks ur a life saver bruh
anybody using heroku and python here? i was wondering how you setup your Procfile to also listen to the webhooks
ok
sorry
all g
Vote count increases by two instead of one but webhook will send one request still
Oh sry thought I sent in support
My bad,,anyway thx
Oo sorry
discord.py on_dbl_vote event doesnt work for me
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
well im self hosting so do i just give it my own ip address and do some port forwarding magic?
yes that could work
ok
@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
What's the URL you entered on the website?
beancord.ddns.net (its a dynamic ip i setup for my other project)
omg my ip address changed nvm forgot to update my dns
it still didnt work
sad
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.
upvotes not votes
It will be changed in v1.0
Oh yeah its upvotes, the documentation says getbotvotes so i got confused. ty
probably
is a webhook neccesary for on_dbl_vote event?
yes
just make a request to the api and see if you get a 401 or so
How do you make a request?
Huh
There's no way to catch it while defining token?
Like let dbl = new DBL(token)
are you trying to setup discord-based login?
When i do
dbl.webhook.on("vote")```
It says can't read property on of undefined
setInterval(() => {
dbl.postStats(client.guilds.cache.size, client.shard.ids)
}, 1800000);
});```I post it this way i am using d.js v12
If there is a mistake I would be glad if you ping me
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?
});
the webhook doesnt work for me
did you enter the url on your bot page settings?
yes
make a test request with postman or any rest client
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
How can I make my bot send a message when someone voted my bot?
Did you have an idea? @rain heart
no clue
There's only 400 bad request errors
@mortal ore What language r u using for the webhook
nvm i got it fixed
alr
there was an internal server issue cause of which the logs werent working properly
thanks!
is from servers, not bots ._.
There's no simpler way to make a dbl event to trigger when someone votes for the bot instead of using express?
the only way of using webhooks is with an http server
can anyone send me the code for when you vote for the bot it will show ;-;
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
did it print?
Nope
It loads the cog
but doesn't print the Server count posted successfully part
try calling await self.dblpy.post_guild_count() and see if there's any error since the lib suppress any http exceptions
I'll let you know in 30
@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 
Ya...
I think I was smoking something when I decided to suppress exceptions
kek
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
am i doing something wrong here
Oops wrong channel
nah this is the right channel
Read channel topic
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
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
wdym by "change code from module exports"
oh ok
did you add your dbl token?
@hot axle how do I make it so the file executes?
Yeah
But there's no console error
Ima get a new token maybe
also, i'd suggest using that inside your main file for testing
Yeah idk how to transfer it
I changed to index.js
So @rain heart the issue now is it says client is not defined
define client
can't help you then
....
Well, even tho it was without ur help,I managed to post stats
${vote.user} will return the user id
Then what will return the user name and their tag?
Ok, thanks
hello I wanted to know how we do so that the bot says who voted on top.gg on the show?
dbl.postStats(client.guilds.size); when you upload your stats like this, how can you stop people just doing dbl.postStats("99999");
by having common sense
People will get their bot deleted off the site (or even get blocked from the api completely) if they do that
Okay
Indeed
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
whats wrong, i might be able to help
ok thanks
so its just not working, i can update guild count and do other stuff
receiving votes is not working
hm
no errors or anything, just not working
are you using the api or the flask webhook?
api
oh wait are you using python?
yeah
heh
do you have an open ip/domain.
is there any errors on testing the webhook?
did you enter it on your top.gg bot page?
is it valid?
did you test it with a request client?
dm me/send it in here what you have entered there
ok sure
i hope youre not asking me lmao
haha
with the poststats method
@fickle zealot nothing is running on that port
got it
...
give me a min
there is literally nothing running on that port, make sure you've entered the correct port, followed the docs etc
rdc
my bad
i'll set up another port
yeah, i'm gonna test it now
its still not working
i set the port to 5000
yeah
you have all of these defined too, right? https://cdn.hopefuls.de/gN4S
no
oh
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
Because it's deprecated and won't be used in v1.0
oh, i didnt realise it needed to be the same in the bot as well
ah thanks
P.S. it works for 0.4.0
hehe phew
it still doesnt work, does this have anything to do with it, if so how do i fix it?
did you fix this too?
yeah
what is URL defined as?
leaked IP and wrong path
and ip leak 
heh, its just functions for my bot, like embeds
wrong path?
see this
in webhook_path yes
yeah but that fn only exist in that __init__ scope, but nevermind
hmm ok
currently only used in the __init__
theres more
yeah nevermind
Sometimes I feel like f"/{webhook_path.split('/')[-1]}" might be needed
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
/ imo
yeah same thought
It's more verbose and understandable
yup yup
you input the whole thing that you deleted before to the site, didn't you?
yup
that was actually already like that
i only changed the port
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
so my friend does most of the server stuff, we don't know what aiohttp is
hmm
according to the docs https://cdn.hopefuls.de/i9Cn
so do i have to set up an aiohttp session for it to work?
No no, it should work as you did now
Are you sure you are loading the cog?
Is the port open and forwarded?
Do you have a firewall blocking the requests?
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
cog is loaded, i can update guild count and stuff
ok so thats good i think
ill check
does dblpy need port 80 open for aiohttp?
bc if its being used for something else will that stop it from working?
yeah yeah ik
such as 5000 or so in your case
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?
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
you wont be able to get any past votes from the point of setting up your own tracking
Okay
@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 ?
data is a dict, so ig data['user']
thanks

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)
they're indeed making a post endpoint 
J
sure, what do you need help with?
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
for the old library it will always log 0.0.0.0 as 0.0.0.0 just means "any available ip"
ok
just when you fill in the site use the right ip
you need to fill in the URL on your bots edit page, in the webhook section.
with the auth
sure, heres an example
http://0.0.0.0:4982/dblwebhook
filled in with the correct ip.
so the 0.0.0.0 is replaced by my ip?
yep








