#topgg-api
1 messages · Page 93 of 1
I tried the suggestions such as making it into an atomic but that didn't work
java ^
well java is a typed lang, I assume you're just missing the type
ah wait
I 'm an idiot
what's the error show?
You can try to cast it, afaik it returns a boolean and not an AtomicBoolean
but Idk for sure
@spiral steeple sorry for ping
Did you know anything about 401 cloudflare rejection?
Unautherized should mean you don't have a correct token
Yes
Do you use the correct http method?
Normally the 401 from top.gg for invalid tokens isnt a cloudflare rejection I dont think
Yep
can you show me what it says?
It says cloudflare tho
0|projectb | server: 'cloudflare',
0|projectb | 'cf-ray': '5abb70c919671752-FRA'
0|projectb | },
0|projectb | ok: false,
Send code
0|projectb | Error: 401 Unauthorized
0|projectb | at IncomingMessage.<anonymous> (/root/projectbump/node_modules/dblapi.js/src/index.js:118:25)
0|projectb | at IncomingMessage.emit (events.js:327:22)
0|projectb | at endReadableNT (_stream_readable.js:1221:12)
0|projectb | at processTicksAndRejections (internal/process/task_queues.js:84:21) {
0|projectb | raw: '{"error":"Unauthorized"}',
0|projectb | body: { error: 'Unauthorized' },
0|projectb | status: 401,
^ show the part where you made a new instance of dbl (usually like new DBL(x, {...}, client) dont show the token though
and if you're sure the token is correct, regen it and try again
@spiral steeple everytime I press refresh on top gg it saying different token every time
ofc
Why?
Right so how do I know what to use
Generate new one
If it changes everytime lol
int he code yes
It needs to be placed in the header of the http request
Show your code, but exclude the token
Which one bot js or index js?
idk where you do the request
I might just be tempbanned from the api
Hence when I need a staff member
As it worked earlier on and now it's not at all
@solar spoke well you arent listening are you ......
You didn't send your code, we asked 3 times
I've already said 50 times
Its nothing to do with my code..m
It was working earlier today
And then I regen and put it on my main bot and now It wont connect
is the issue a different platform?
ie, you where on windows, moved to linux, and the issue came up?
wtf is an atomic boolean
ikr
Bruh
Atomic boolean lmao
💥
It's like an atomic wedgie but backwards
Someone api for NimoTV?
This channel is specifically for the DBL api
Can someone help me in dbl webhook please
Its showing me this
1|dbl | 209.97.134.24 - - [30/Jun/2020 21:56:23] "POST /dbl HTTP/1.1" 404 -
1|dbl | 209.97.134.24 - - [30/Jun/2020 21:57:23] "GET /dbl HTTP/1.1" 404 -
1|dbl | 209.97.134.24 - - [30/Jun/2020 21:57:46] "POST /dblwebhook HTTP/1.1" 404 -
1|dbl | 209.97.134.24 - - [30/Jun/2020 21:58:46] "GET /dblwebhook HTTP/1.1" 404 -```
What's your webhook_path
Does the vote event trigger at exactly the same time someone votes?
Or it takes time?
Normally only a couple secs delay
so I tried adding the API to my bot's main class
this happened
Exception in thread "main" java.lang.NoClassDefFoundError: org/discordbots/api/client/DiscordBotListAPI$Builder
at com.Main.main(Main.java:23)
Caused by: java.lang.ClassNotFoundException: org.discordbots.api.client.DiscordBotListAPI$Builder
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 1 more
dbl isn`t working
u trying to import dbl into dbl bruh
It was working before 😄
The Bot dont tell me anything....
what it is supposed to tell u
ahhh 😄
ehmmm Create parameter
?
hold on
my bot has officially ceased to respond to my commands
and will not turn off
@novel laurel it may be running in background
@peak patrol ehmmm, is this normal that dbl isnt in the main extensions?
task manager boi
this isn't on my pc
i ! am stupid at the moment ...
it's on a vm
😄
oh
and it's running on tmux
@novel laurel which os
searching up how to do that now
should be
ok
I can send code now
I found out how to kill tmux sessions
basically
@peak patrol which parts of the code should I send
the part where I'm initializing api or where I'm calling setStats()?
which is causing issue
maybe cause of os difference
Exception in thread "main" java.lang.NoClassDefFoundError: org/discordbots/api/client/DiscordBotListAPI$Builder
at com.Main.main(Main.java:23)
Caused by: java.lang.ClassNotFoundException: org.discordbots.api.client.DiscordBotListAPI$Builder
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 1 more
this doesn't seem like an OS issue
new Thread(()->{
while(true) {
int servers = j.getGuilds().size();
j.getPresence().setActivity(Activity.playing("!bwhelp | " + servers + " servers"));
api.setStats(servers);
try{
Thread.sleep(3000);
}catch(InterruptedException e){
e.printStackTrace();
}
}
}).start();
i.e. every 3 seconds update status
but that's clearly not it, it's probably the initialization
because it says it's missing Builder
could it be a missing import statement?
man that's bs
changing the operating system shouldn't do a damn thing
well nevermind
I can confirm it's not the operating system, just something goes wrong when I try to run the jar I build
@peak patrol
neither do I
my online class started srry i wont be able to reply try searching google or ask for help at stackoverflow or r/codingzombie@crude plinth @novel laurel
okay @peak patrol see yea
@restive otter
api nasıl kurulur
ok
can i know from u the discord server name plz?
what
server name i think i joines the wrong
Maybe
yes can u tell me the name
-api
THIS CHANNEL IS ONLY FOR SUGGESTIONS/HELP/BUGS TO DO WITH OFFICIAL TOP.GG API LIBRARIES AND API DOCS FOUND AT
https://top.gg/api/docs
This user has no bots
-api
Is it just me or are vote webhooks taking a really long time
yes
I have vote locked commands so users think that the bot is broken since the webhook hasnt arrived yet
no it's not normal, webhooks normally take 1-2 seconds after vote
top.gg has been a bit sluggish regarding the api recently
-api
Api is a mod only command
and that was a very poor minimod attempt
LOL
if i want to test my webhook with reqbin
how would i do that
is it a post request
using basic auth
A POST request with Authorization header containing the value from Authorization field on the website
Same port and everything?
it's hosted on a VPS
i saved before testing, yes
i copied the URL from the code into the DBL URL
its not 0.0.0.0 is it
yeah
it works on reqbin
i copied the address, authentication, and made my own content which fit the DBL format
and it works
i checked with Galaxygate and no firewall rules are needed
yeah GG doesnt add that stuff for ya
@jaunty plank so is there any rules that need to be added. do you know of any specifics
it should be completly open on a fresh install for their VPS's on linux
Windows may be a different story
hmmm
@tepid harness add http:// to the url
already have it @vapid cape
so your full url is http://xxx.xxx.xxx.xxx:5000/dblwebhook right?
and you sure galaxygate doesnt block that specific port
why did you pick that port?
did you ever try port 5000 to test?
Yes
maybe someone might be willing to team view to you. You are going to have to do some more digging to get the help
anyone willing to work with Humanoid some more. He can provide code snippets or anything else that you need to help troubleshoot it
im just trying to help him find help LOL 🙂
galaxygate doesnt block ports, im on galaxygate too
@tepid harness is there anymore information or code snippets you can provide
? (node:389508) UnhandledPromiseRejectionWarning: Error: 401 Unauthorized
? at IncomingMessage.<anonymous> (C:\Users\ARDA\Desktop\Discord\node_modules\dblapi.js\src\index.js:118:25)
? at IncomingMessage.emit (events.js:323:22)
? at endReadableNT (_stream_readable.js:1204:12)
? at processTicksAndRejections (internal/process/task_queues.js:84:21)
?
? (node:389508) 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: 3)
?
check if member dbl voted error
very new here, how would I use discord.py and this api to get the votes and reward users when they vote?
^^^ I’m with you on this was going to ask the same lmao
^^^^ Lol same
@severe osprey @restive otter @hasty heath
Look at the dblpy section on the API page it shows how to use the dblpy module
[dblapi.js autopost] The provided client is not supported. Please add an issue or pull request to the github repo https://github.com/DiscordBotList/dblapi.js

I had just passed the Discord.Client instance
Eris?
Discord.js
Intresting
The logged in client?
I'm not sure if it needs to be logged in
🤔
If you can't figure out the auto posting, you can manually post stats too
Yeah I know, but the vote event doesn't even get triggered either
I want to use that event to activate daily reward :v
wait wait
no.. the construction is right 
@molten galleon you need to pass in the instantialized client
well it is
as second or third parameter
I'm passing it as third param
show code?
const dbl = new DBL(config.dbl, { webhookAuth: auth, webhookServer: server }, client);
and client is new Discord.Client() ?
yeah
but i mean, you dont need to login before passing it
as long as you login somewhere
what version of djs btw
how about console.log(client) the line before?
I'm sure client is fine, but still I'll do
Just updated Discord.js version to 12.2.0, still :v
do you do some kind offloading or require discord.js any differently than normal?
nope
2.4.0
const Discord = require("discord.js");
const DBL = require("dblapi.js");
both are required normally 🤷♂️
Just do manual posting
try doing console.log(client instanceOf Discord.Client)
I've had a similar kind of bug with a newer version of d.js, but it wasn't with dbl api
what about instanceOf Discord.exports.Client
wait no
client instanceof require.cache(require.resolve("discord.js")).exports.Client
shouldnt matter

and any idea why do I not receive vote updates?
dbl.webhook.on('vote', vote => {
db.client.set(`vote_${vote.user}`, true);
});
I tried logging, there's no log :v
And webhook.on ready event logs fine
uh, wait
so it's a d.js client but fails the check?
apparently yes
yea
although instanceof checks work fine
did you setup your url and auth in top.gg?
@vapid cape ops I hadn't done that, did it now, and does it affect the auto post thing? i guess no
no, webhooks are independent

when you did console.log(client) did you scroll up the log and check the object name?
did it say Client {
https://cdn.discordapp.com/attachments/412006692125933568/728203808777175103/unknown.png
what do you get if you console.log this with the client you pass in instead of evaling
that above screenshot is a log from app.js just a line above DBL is insanciated
yeah but try logging that
I did log that, without eval
what if you do ```js
let client;
let dbl = new DBL("token",{opts},client = new Discord.Client())
...
console.log(client);
const dbl = new DBL(config.dbl, { webhookAuth: auth, webhookServer: server }, client);
aaand that ss is the logged client
const client = new Discord.Client();
my client is declared like this 
config.dbl is the token, if it matters
the only thing i can think of is that somehow there are 2 versions of discord.js loaded, in two different paths, and each is being required from a different path
try console.log(Object.keys(require.cache)) after the new DBL line
see if somehow there are 2 paths for discord.js in the wall of text
LOl
wtf
Magic
remove the log and check again
Honestly this kind of weird shit happens all the time
as soon as you add debug code it fixes itself
developer hell
but how can it happen
ask mr compiler
ask mr interpreter
is there some sort of event which triggers when I click "Test" on edit page? if so, which one is it?
the vote event
where is your bot hosted
digi ocean
how did you format your url
oh wait it was url
url on the site pointing to the correct ip?
port open on firewall?
auth thing correct on both ends?
got it

I used the domain, but without correct port, while webhook server was running on port 5000
and now its fine, I changed port
Did field titles and footers become bold?
yes (wrong channel btw)
can i use a webhook to store votes or do i need to use console.log?
Webhooks are used to push data, not pull it
Console.log is used to log data, not store it
pls help, vote isnt defined, hole embed code thing.
const VoteEmbed = new Discord.MessageEmbed()
.setTitle(`e`)
.setColor("#c75dc9")
.addField(`Voter`, vote.user)
.addField(`Time`, vote.time)
.addField(`Weekend doubler`, dbl.isWeekend())
.setFooter("**Dbl** voting system. ");
DblVoter.webhook.on("vote", (vote) => {
console.log(`User with ID ${vote.user} just voted!`);
webhookClient.send(`${VoteEmbed}`, {
username: `Spider Vote`,
avatarURL:
"https://cdn.discordapp.com/icons/702134225528291368/66d4c03d4c8d064fc884ba70d32134f6.webp",
embeds: [VoteEmbed],
});
});```
seriously?
you can't use a variable outside of its scope
it doesn't work like that
{} are walls
what starts inside brackets die inside those brackets
hmm
What can cause a long delay on my webhook recieving the post request? (takes up to 10 mins)
server-side issues
@slim smelt did you add your client?
new DBL("token",client)
is it the same client you login with?
ie ```js
client = new Discord.Client()
dbl = new DBL("top.gg token",client)
...
client.login("discord token")
all in your main file
@slim smelt can i see full code?
@slim smelt you're using the wrong client
you're doing bot = new Client() and using new DBL("token",client)
your client is bot not client
so you have to do new DBL("token",bot)
and remove all those extra client lines
Who has the giveaway code lines?
its against the rules for us to give you copy paste code @restive otter
ie spoonfeeding
My corrector tells me that n against the rules for us to give you copy the paste code
I didn't understand what you said
we are not allowed to give you an exact answer, we can point you in the correct direction however
Ok
i need help with this, the api is telling me that i have not voted
20:49:02.438 VoteCommand ERROR uid: 214829164253937674
20:49:02.439 VoteCommand ERROR hasVoted: false
When i have clearly voted
{"username":"fernandopal","discriminator":"8931","id":"214829164253937674","avatar":"c9a22e30ba58b379e273c735e4e06856"}
I'm using the java library and the code provided in the github site
api.hasVoted(member.getId()).whenComplete((hasVoted, e) -> {
LOGGER.error("uid: " + member.getId());
LOGGER.error("hasVoted: " + hasVoted);
});
Its so frustrating bc idk what's wrong with it
(im logging it as an error just for testing, ignore that xD)
the api is quite slow recently
ive heard people talking about it taking 30 minutes.
for the webhook to send*
still the same 2h later
People use Discord.java? -Nice
is that JDA?
yes
i just got a 503 backend fetch error..
nvm that was one time
i feel like it was because cloudflare
Top show the amount of servers I have on my discord bot, all I need is the constructor with it's options and the client added correct?
Or would I have to use the postStats method everytime the guildCreate event is sent. (discord.js)
Hold up, you can make it so people can vote through the bot?
yes
Sick
Huh?
does dblapi.js work with sharding?
yes it does
I need to update manually or I can do like, pass something in the constructor for auto server count posting?
if you give it your client, it should post automatically
yeah but while sharding, do I give client to it in all the spawned processes? 🤔
thats one way of doing it
each process will send its own guild count with its shard id, and top.gg will reassemble it in their backend
another way of doing it is to use fetchClientValues or broadcastEval to fetch all guild counts and manually send a single request, either from the sharding manager or from a single shard
I see. I'll try the first method lol
someone can help my with the vote api (discord.py)
-ask2ask @tender ingot
@tender ingot
Don't ask to ask.
Just ask your question, it wastes time if you say "i need help" or "can someone help me?" instead of just saying what the problem is. Save your time and other people's time and just ask the question.
Please read https://dontasktoask.com/ for an explanation on why this is an issue.
@trail sigil i need vote count not server count
honestly, i dont have a clue because i dont do python lol
just wait for someone who can answer your question ig
Thank you it's really important to me@trail sigil
@bitter terrace can u help me with this
import dbl
import discord
from discord.ext import commands
class TopGG(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.token = 'dbl_token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True)
votes = self.dblpy.get_bot_upvotes() # this is the line you need
def setup(bot):
bot.add_cog(TopGG(bot))
this should work. but I am not sure at all.
get_bot_upvotes returns a coroutine, so you need to await it
``Authentication is performed with the Authorization HTTP header in the format Authorization: TOKEN`
whats the url?
ty
oh yeah, forgot it needs await
hey guys does anyone know how to fix this at all thanks
0|projectb | Error: 400 Bad Request
0|projectb | at IncomingMessage.<anonymous> (/root/projectbump/node_modules/dblapi.js/src/index.js:118:25)
0|projectb | at IncomingMessage.emit (events.js:327:22)
0|projectb | at endReadableNT (_stream_readable.js:1221:12)
0|projectb | at processTicksAndRejections (internal/process/task_queues.js:84:21) {
0|projectb | raw: '{"error":"Required parameter server_count or shards missing"}',
0|projectb | body: { error: 'Required parameter server_count or shards missing' },
dbl.postStats(client.guilds.cache.size, client.shard.ids, client.shard.count);
setInterval(() => dbl.postStats(client.guilds.cache.size, client.shard.ids, client.shard.count), 900000);```
but its not missing it
fixed it i think lol
The library already automatically does poststats when you start it btw.
And does the loop and all that
clicking on test is supposed to send get or post request on a webhook is specified?
POST request with type key with value test in request body
How can I add people who vote to a list I have no idea how to handle api requests
the http request that top.gg sends to your webhook will contain an user ID
save that ID to the desired list or fetch that ID to get the user object
Yeah how do I handle that http request
Hey I've never used webhooks before. How would one integrate api into their bot in order to allow a voting system with reward
And how to define and accept data from them
Yeah how do I handle that http request
@sonic forum the http request will contain the data either in the body (POST) or in the url (GET)
top.gg api sends via POST
so all you gotta do is get the body of the request, and parse it to json
And how to define and accept data from them
@ruby blaze same for you
dbl.getVotes().then(votes => {
console.log(votes);
});
this isn't working
no error but doesn't console.log anything
ping me please
https://top.gg/api/bots/BOTID/votes doesn't seem to be accurate. On top.gg, it says 70. But this endpoint returns an array of 41 vote objects.
Is it delayed?
dbl.getVotes().then(votes => {
console.log(votes);
});
this isn't working
@frozen jolt this returns an empty array for me. So I'm using the API manually.

is there a way to test the voting to see if it works without actually voting? I do not want to wait 12 hours to test my changes
and do I need to specify anything for the vote? Or can this be the only dblpy code I have?
async def on_dbl_vote(data):
print(data)```
is there a way to test the voting to see if it works without actually voting? I do not want to wait 12 hours to test my changes
@hasty heath use the test button near the save button
ok thanks
(d.py)
i'm assuming there's a way to do like, a vote reward feature using the API
could anyone give me a lead on it
probably this actually, isn't it
poggers this is gonna be fun
so i am using this webhook tester service to see what it sends
but its not sending anything
am providing the tester webhook url and then clicking on test
what is webhook_auth="" for?
oh is it app route?
yes
any ideas why am i not getting any requests
i used a webhook tester service to test but didnt work
now i am using a flask ngrok based web server
still not getting any post request from api
@vapid cape u have any idea whats wrong?
ef init(self, bot):
self.bot = bot
self.token = 'blah blah' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True,webhook_path='ngrok link ',webhook_auth="authorisation password")
top.gg webhook tester
@app.route('/')
def api_root():
return "Welcome again"
@app.route('/discord',methods =['POST'])
def api_di_message():
if request.headers['Content-type']=='application/json':
idk = json.dumps(request.json)
print(idk)
if __name__ == "__main__":
app.run(debug=True)```
you copy pasted the webhook tester url into your top.gg url?
did you press save before pressing test?
you need to save first
wait do u have to press save
oof
lmao i have been gettin the error for 2 days
ty
lemme check
you can also test your server using reqbin or postman
hi
i need help with top.gg webhook events for discord.py
i want to set up a webhook inside of my bot
somebody help me before i die
what do i put in webhook url
@sullen nymph this should be fine right?
@sullen nymph this should be fine right?
@onyx cipher remove the slash after the port, ip:port
before*
that xD
does colon need to stay?
yes
before*
@bitter terrace when i dont think on it i usually put it wrong
lol
yeah
@commands.Cog.listener()
async def on_dbl_test(self, data):
testing = self.bot.get_channel(712639566774796298)
await testing.send("tested")
print("TESTED")
print(data)
here is how i set up the event
but it still isn't printing "Tested"
when i test the webhook
hmm. is it running on your pc or a server?
I think you need to forward port 5000 then.
you can check if your http server is accessible from this site https://www.yougetsignal.com/tools/open-ports/
just put IP and port 5000
The port forwarding tester is a utility used to identify your external IP address and detect open ports on your connection. This tool is useful for finding out if your port forwarding is setup correctly or if your server applications are being blocked by a firewall.
that's why
you need to forward this port. or you can use something like https://ngrok.com
ngrok secure introspectable tunnels to localhost webhook development tool and debugging tool
Why did my guild counter randomly stop updating but votes work
you need to forward this port. or you can use something like https://ngrok.com
@bitter terrace how do i forward this port
ngrok secure introspectable tunnels to localhost webhook development tool and debugging tool
He gave you a link ...
@onyx cipher if you want to know how to do port forwarding, you need to search on google. it depends on your router etc.
lol
ok what if i had to do this on my VPS?
then you'd just need to allow the port on your firewall
xD
apt-get install ufw
hm

inactive
@bitter terrace wait
i can't ssh into my machine anymore
it says
what the fuck
what do i do now
fuck
Was your only way into the vm via ssh?
yes
Try Google then
do not tell me its all gone please
Let's hope not
hm that never happens to me. is it on GCP? @onyx cipher
try this @onyx cipher https://serverfault.com/a/971789
webhook should work on that vps now
yes it is
Why doesnt my guild count work
-servercount
To have your bot's server count displayed on DBL, please read the documentation on server/shard posting. Click here to see the docs.. You may also find #312614469819826177 useful; however it is strongly discouraged as most of the examples are extremely outdated.
ensure it is all setup properly, as show in the docs
if it is... then what errors are you getting?
@commands.Cog.listener()
async def on_dbl_test(self, data):
testing = self.bot.get_channel(712639566774796298)
await testing.send("tested")
print("TESTED")
print(data)
@bitter terrace this must print "Tested" when i test the webhook right
No errors vote rewards are even working
if everything else is right, yeah
this is my url
does it look fine?
@bitter terrace (sorry for the ping , im in a hurry)
np
ok does the url look fine
and yeah it looks good
lol
go back to the yougetsignal site
The port forwarding tester is a utility used to identify your external IP address and detect open ports on your connection. This tool is useful for finding out if your port forwarding is setup correctly or if your server applications are being blocked by a firewall.
check if the port is open
Lol
ok check that when the bot is on
should i restart my machine?
nope. it should work
oh try this
netstat -tulpn
it should tell you which ports are open
Sup
I have a question regarding the webhook
when creating the DBLClient, what value do I insert in the webhook_path section?
Whatever you want the path to be
It doesn't matter?
doesn't matter what you choose. but you must use the same path on top.gg webhook url field
^
i really need to set up this webhook
Its just the url path they push data to
The path part is just the something
The entire thing is the whole url
no / between ip and :port
do i only have to use port 5000?
22?
@bitter terrace
you should go for a port higher than 1024
^ all the low ones are commonly used
Yep
Do you have multiple firewalls on?
sudo ufw enable
sudo ufw allow 5000
i did all this
but port 5000 is still fucking with me
@onyx cipher it only stays open when your bot script is running
lets see
k
@bitter terrace
so what now?
I always allow all on that. Let me get a screenshot of that
ok here
find this @onyx cipher
Who is able to help with my webhook? Nothing is making it work for tests
or when I vote...
it won't console log with the example code from the api docs when I input my info in
is it running on your pc? or a vps?
you will need port forwarding if you're using your pc
yeah idk how to do that 🙃
scuffed way - use google cloud functions as a webhook lul
?
or use ngrok
I've never heard of that...is it free?
yes
awesome I'll look into it but I'll probably be back with questions
https://ngrok.com here lol
ngrok secure introspectable tunnels to localhost webhook development tool and debugging tool
ok
@bitter terrace sorry for the ping...ok so I got it fired up and have this on my screen...what do I do now? https://prnt.sc/tbtsq8 there's more above but idk if it's secret so I'm not showing it lol
yes js
ok, so you have a http server running right?
I really appreciate this...I've been trying for like a month and just can't get it without using a host lol
whatever that picture is is what I have so far lol
do you mean a local webserver?
yeah, like the express or http module
i did ngrok http 80 and that stuff popped up
oh wait...where will it say someone voted?
it will send a signal(webhook request) to your program
yeah I'm lost lol
um
you know how an api, you send a request to get data?
a webhook is an api, but the opposite.
data gets pushed to you, rather than you pulling it
the official library will make the webserver(webhook) for you, if you configure it to
-api
THIS CHANNEL IS ONLY FOR SUGGESTIONS/HELP/BUGS TO DO WITH OFFICIAL TOP.GG API LIBRARIES AND API DOCS FOUND AT
https://top.gg/api/docs
Also, no @cobalt canyon
ok
Begging for boosts is not allowed
What can cause a long delay on my webhook recieving the post request? (takes up to 10 mins)
const server = createServer((req, res) => {
if (req.url === '/dblwebhook' && req.method === 'POST') {
if (config.dbl !== req.headers.authorization) return _returnResponse(res, 403)
if (req.headers['content-type'] !== 'application/json') return _returnResponse(res, 400)
let data = ''
req.on('data', (chunk) => data += chunk)
req.on('end', async () => {
if (data) {
try {
const value = JSON.parse(data);
if (value.query === '') value.query = undefined;
if (value.query) value.query = parse(value.query.substr(1))
return _returnResponse(res, 200, 'Webhook successfully received')
} catch (e) {
return _returnResponse(res, 400)
}
} else {
return _returnResponse(res, 400)
}
})
}
})
server.listen(5000)
function _returnResponse(res: ServerResponse, statusCode: number, data?: string) {
res.statusCode = statusCode
res.end(data);
}``` my webhook
-api
I couldn't do the voting system. is there anyone he can help??
lol same, im not even sure where to start
What library are you using?
Covers how to use the webhook
already have it up
Looks like you just set the webhook path auth and port
What does your DBLClient look like
Are you hosting any webhook rn
have you tried reading dblpy.rtfd.io for reference
yea
like i see that i need
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='password', webhook_port=5000)```
this
where is your bot hosted?
yes
a loop
Sa
i am able to recieve webhook on my windows pc
but when i follow same procedure on ubuntu vps
its not recieving anything . do i have to provide any special permissions?
Hi just wondering about webhooks as well, I have set up a post route, and I can make a request to that myself but when I click test on the webhook on my bot it doesn't work 
yes corect ip and port
just basically isnt recieving post request on ubuntu
on my pc windows i get post request but on my vps ubuntu it doesnt work
on mine ofc
what is 0 and what is 1?
0 - not voted
1 - voted
Thx

My code is```js
let fetched = await fetch("https://top.gg/api/bots/697318252744933406/votes").then(async res => await res.json())
return "Votes: "+fetched.length
this isn't sending the total votes of the bot it just says ``"undefined"`` when i just done length it says ``"[Object object]"``
yes
okay thx
how to add my token at body?
fetch("https://top.gg/api/"+client.user.id+"/votes", {
headers: { 'Content-Type': 'application/json' }
}).then(res => res.json())
i mean what header key i need to add for my token
"What is here?": "my token :)"
Authorization
thx
cache
doubt cache would be 200 off
they can be
;-;
discord can cache things for months
It's not a discord cache though...
ye, but caches can last very long periods of time
🤔
its been 5 days since voting reset
those 200 votes, coulda happened today
And what does that have anything to do with top.gg and a value in the embed description
for the command
Just that value see the code
my point was caches can last long periods of time
not that discord and top.gg caches are related
Hm
You could just use a GET to the bot endpoint instead of using .length
because /votes is oddly delayed
317 users voted in last 12 hours (/votes)
Wont show monthly?
You're sending a request to /:id/votes which returns votes for last 12 hours
/votes doesnt do monthly that's user_id/check mb, but it's still weird :P
Then other?
/bots/bot_id and monthlyPoints
/:id returns a JSON where monthlyPoints key returns monthly votes
its bots
that's a JSON
api/bots ?
yes
psure its monthly points
monthlyPoints
i like how firefox shows json
ikr
all the browsers do, dont they?
Not really, Firefox has a special way of processing JSON
there's also JSONs in arrays
sorry still got a problem with webhooks, does the test feature actually work? I cant seem to get the request
it does work

does anyone here use express for their route? that could have a quick check of my code :P
I can post to it and access the route but when i hit the big ol' test button it doesnt work :/
your domain
as long as there's code to handle the requests coming from top.gg, you can use your machine's IP directly
There's official libraries with examples that you can use
you can dig around with the source code if you don't want to use them
does dblpy support rewrite? It looks like the code is for non rewrite discord.py
Latest dblpy supports 1.0.0+ only :^)
okey dokey
sorry for so many questions, what would my webhook url be if it is on my vps? Just the ip of the system?
you dont have an internal ip?
no I do, it is the same as public
I guess I must have made my code wrong, nothing happened :P
then again it is just the default code but with my token
you need to tell it to make the webhook by setting the parameters iirc
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
for example with js
yeah, it does that
self.dblpy = dbl.DBLClient(self.bot, self.token, webhook_path='/dblwebhook', webhook_auth='PASSWORD', webhook_port=5000)
then the url will be
pubip:port/dblwebhook



