#topgg-api
1 messages · Page 47 of 1
visual studio code? yes
are u familiar with debugging? you should put a break point where you are defining voteUser and see what you get
@restive otter are you using the function in the dbl library?
the dbl api not work
it always return null
"error":"No query userId, add ?userId= to your request
pls 
@sudden rampart ?
dont randomly ping for help
He is Java programmer
I'd try a google search for post requests in java
how often do people update their stats?
yeah do a google search on post requests and adding parameters to the body
@restive otter this channel is only for help with the DBL api, but before you try to make a bot please learn the programming language you are using
Srry
is there a way to get the users who voted for your bot? (.NET)
Hello everyone, I'm having problems to install python library... Can someone help me ?
@shell flume never ask for generic help, always just send all the details including relevant code and any error details, and wait for someone to respond
@rigid wasp you can check if https://github.com/DiscordBotList/DBL-dotnet-Library supports it, if it doesn't you will need to directly access the http api
no "$MY_LANG > $YOUR_LANG!!!111!!1!!1!" kthx
ha
@sudden rampart scratch > java !!!111!!1!!1! kthx
scratchcord
How do I check on command if the user Voted (Webhook, Discord.JS)
read the docs
there is an endpoint too
Yo how to get the users tag on vote i've tried vote.user.tag shows up as undefined
vote.user returns the user id
yeah
I'm trying to make like a vote logs so when someone votes it shows up with their id and tag
u would have to define the user then .tag
np
How do you set up the webhook? (.NET) sorry i have no experience with webhooks
I have barley any experience too lol
could never get listener working in c#. I moved to other means 😂
im back @restive otter
hey could I get a hand off any dev isn't anything too complicated just confused over the "then" function
Assuming is js, "The then() method returns a Promise. It takes up to two arguments: callback functions for the success and failure cases of the Promise." Taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then
okay, Thanks 😄
also #development
@loud gulch how do i set up a web server?
So do I need to npm install all of those?
I have no idea what Im doing lmao
const dbl = new DBL("mytoken", { webhookPort: 5000, webhookAuth: 'mypassword' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});``` would that work?
mytoken and mypassword are actually my token and password I know that
Literally just took it from the docs 
But it aint working so I got some reading to do I guess
The URL in webhook on DBL is a discord webhook or am I an idiot?
That one I mean
Yes that doesnt help me
So what do I put there 🤔
Im in there right now
Not much there that helps me
"Start by setting up your webhook URL in the edit form of your bot on this site, it can be found at https://discordbots.org/bot/:ID/edit once you have entered the URL you want the webhook to be sent to, you're all set! If you need help setting up webhooks inside of your bot don't be afraid to ask in our discord server in our #topgg-api channel."
what url would it send to is what I mean
Like an example*
A webhook in web development is a method of augmenting or altering the behaviour of a web page, or web application, with custom callbacks. These callbacks may be maintained, modified, and managed by third-party users and developers who may not necessarily be affiliated with ...
set that to your domain/ip where you have an http server listening for the webhook request
so I do need a domain
an ip is enough
So can I set it to my vps's ip and listen on that?
Yeah
All I needed, thanks
- wrong channel
- no
o ok
I guess that wasnt all I needed lol, do I just put http://ip in the webhook part of dbl then?
http://ip:port/path
are port and path something I need to get or is it just random stuff
I'd assume its something I need to get
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});```
My console logged http://0.0.0.0:5000/dblwebhook when I did it at first so should I keep dblwebhook and 5000 port the same?
what options did you pass
the ip will be localhost so remove the webhook server argument
i’m not even sure if it has a host option imma check docs
It does thats where i got it from
yea
so do I just not enclose it in strings?
quotes*
Lol
or like webhookServer: localhost
or something
Got a good place to learn about http.Server type then?
options.webhookServerhttp.ServerYesAn existing server to run the webhook on. Will activate webhook when set.
When I do that it says 0.0.0.0.0
which means localhost smh
Makes sense
what port is it running on
on the edit page, for your webhook put https://url:5000/dblwebhook
Yea I have it in there already
ok then you should be good
I hit test nothing happened got me feeling good lol
No
cool your webhook works
hmm
console.log(`User with ID ${vote.user} just voted!`);
});
do you have an authorization header?
alright so you need to put an option webhookAuth with that value
Its in there
if you have not already in your dbl config
oh ok
maybe there is a test vote event
webhookAuth: pass
o
https://ipofmyvps:5000/dblwebhook would be right no? (replacing ipofmyvps with the actual ip of my vps obviously, is what I have on the dbl page)
Yeah, can you reach it manually from your browser
refused to connect
but its the ip they gave me
"sent invalid response" is what it tells me
Do I need to use something else?
Well did some digging
THat'd explain it
LOL
I can get a free ssl gateway from them whatever that means 
Oh
Not what I want
Could I just get some free domain 
So if I register a domain will it work then? because my providers are stupid. Basically can it be any domain if I own it?
Why you need a domain?
Well make sure your host is allowing it to be accessed
Would I just need to use my IP then?
Yeah IP would work
doesn't seem your provider allow it to connect, so may need to switch provider
If thats the case I just wont put this in too much work tbh it took me 3 hours to switch to this one 
¯_(ツ)_/¯
How do I put in an http.Server if it isnt a string?
you pass the object?
It's not going to make a difference, it's only there if you wish to reuse an existing server instead of creating a new one
You either create a new Server object from http pkg, or pass it an existing one
Thanks npm ;-;
I just wanted a documentation
is it only a few bots that works to get like dbl.getBot(username)
What do you mean @restive otter
I can getBot('Luca') and getBot('PokeCord') but I can't get my bot by username
I'm not sure, but doing it by name probably only works on certified bots with vanity urls
try getting your bot by ID
ye that works.. but how is @abstract moth getting them all by name?
oh wait it has to be in the server
yeah prob
ugh
Hello, how to get a voter's tag? (Webhook)
${vote.user} is voter's id
@old grail What library and language are you using?
discord.js
<Client>.users.get(vote.user).tag``` will be their tag
Thanks 👍
:)
im using discord.py i put the api code in my bot file add the dbl token in it also installed dblpy in requirements.txt but still my bot not showimg server counts
what did i missed?
Register the cog @restive otter
?
Are you using discord.py rewrite version ?
Wait a second i gave you an example
im using python-3.6.5
initial_extensions = ['cogs.simple',
'cogs.members',
'cogs.owner']
bot = commands.Bot(command_prefix=get_prefix, description='A Rewrite Cog Example')
# Here we load our extensions(cogs) listed above in [initial_extensions].
if __name__ == '__main__':
for extension in initial_extensions:
try:
bot.load_extension(extension)
except Exception as e:
print(f'Failed to load extension {extension}.', file=sys.stderr)
traceback.print_exc()```
As you may see in extensions you put the file name
So create a dbl file
And put 'dbl' in initial_extensions
i should put this in main file?
Then the if statement Will load extensions
Yes
You should
Just put a list and the if that load everything
So is it working ? @restive otter
Hey!
I need help to integrate a vote system to my bot.
I first wanted to use the vote checker (user per user) and then I wanted the webhook.
I have 2 questions, what is the best and how would I use the Best solution.
Tanks for the help you will give ^^
Webhook would be best
You're using python?
Should have examples
I've a problem with the API (python):
I just ctrl+c ctrl+v the example and modify my token
and then, I get this message 'DiscordBotsOrgAPI' object has no attribute 'dbl'
For sure, I install dblpy
@polar mirage no vote arent implemented
In the api
:/
@glacial obsidian have you installed dbl ?
Have you registered the cog
And which version of dpy are you using
I checked everything and I think there was a bug in the installation of dbl, on my other PC it works properly
So yse python -m pip uninstall
Use*
Actuelly
Actually*
Wesley there isnt any webhook implementation
I barely use python so I can't do much more than pointing to the docs.
I managed to install dbl correctly but it's weird that I have a 403 forbidden error
Forbidden: Forbidden (status code: 403): {"error":"Forbidden"}```as if my token (api key) was wrong
It probably is
That's what I thought but even changing it the problem persists
Moin
Okay, I fixed it. I delete api.py who contain :
import dbl
import discord
from discord.ext import commands
import aiohttp
import asyncio
import logging
class DiscordBotsOrgAPI:
"""Handles interactions with the discordbots.org API"""
def __init__(self, bot):
self.bot = bot
self.token = 'dbl_token' # set this to your DBL token
self.dblpy = dbl.Client(self.bot, self.token)
self.bot.loop.create_task(self.update_stats())
async def update_stats(self):
"""This function runs every 30 minutes to automatically update your server count"""
while True:
logger.info('attempting to post server count')
try:
await self.dblpy.post_server_count()
logger.info('posted server count ({})'.format(len(self.bot.guilds)))
except Exception as e:
logger.exception('Failed to post server count\n{}: {}'.format(type(e).__name__, e))
await asyncio.sleep(1800)
def setup(bot):
global logger
logger = logging.getLogger('bot')
bot.add_cog(DiscordBotsOrgAPI(bot)) ```
And in my main code bot.py I enter this code :
## | Api Discord List prérequis | ##
url = "https://discordbots.org/api/bots/YOUR_DISCORD_BOT_ID/stats"
headers = {"Authorization" : dbltoken}
@bot.event
async def on_ready():
payload = {"server_count" : len(bot.servers)}
async with aiohttp.ClientSession() as aioclient:
await aioclient.post(url, data=payload, headers=headers)
async def on_server_join(server):
payload = {"server_count" : len(bot.servers)}
async with aiohttp.ClientSession() as aioclient:
await aioclient.post(url, data=payload, headers=headers)
async def on_server_remove(server):
payload = {"server_count" : len(bot.servers)}
async with aiohttp.ClientSession() as aioclient:
await aioclient.post(url, data=payload, headers=headers)
I just ctr+c / ctrl + v the code of @bleak coyote
you need the public ip to where your bot is hosted, and the specified port you want to listen on
its what you set
Ok, but where is the password 😄
You set it...
In the authorization field
👍
where is your bot hosted
heroku
I dont think they give you the ip
I think heroku gives u a link?
Maybe
no
is there a link you have? like deathcore.heroku.com or something? that takes you to your project?
yes its probably that
yeah probably
is there a place in heroku to add ports or something?
you would add one that you chose, that isnt used yet. then your link would probably be https://wolves-zone.herokuapp.com:5000
5000 being whichever port you specify
that looks like a configuration file. you wouldn't open a port to your project in there
hmm
you cant add it there
you'll get a randomly assigned port number and you will need to use process.env.PORT in your code
const app = express();
app.set('port', (process.env.PORT || 4000));
//Start Server
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});
i think i found it
yes just use process.env.PORT
bot.listen(process.env.BOT_TOKEN)
no...
its process.env.PORT
and are you using dblapi.js and express at the same time?
if yes then you will have to connect them
that code is copy pasted from a site I just saw
yes
dont copy paste random code
just use dblapi.js
https://discordbots.org/api/docs#jslib @dense cargo
what do you want to do
just dbl.on(...
do you want to do something when someone votes?
well you need to use webhooks
and its easy
if you know the language you're using and/or you can follow instructions
i don't understand 
const DBL = require('dblapi.js');
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
let voteChannel = bot.channels.get("id");
voteChannel.send(`${vote.user} just voted the bot.`)
});
if i do this
it will work?
change 5000 to process.env.PORT
ok
@loud gulch How do i set up a web server?
@rigid wasp what language
.net
it tells me about website hosting
i got the webhook to work somehow
but when someone votes
or i click the test thing
i get this
looks like some heroku error
you need a web dyno
how do i use the dbl webhook in general
@rigid wasp DBL will make a POST request to the specified URL
to what url though
to the url you put in the edit page
i dont have anywhere to receive the post request
well then you cant use the webhook 
you'll need to set up a webserver to use it
you could use node.js and use the dblapi.js package
but for any other language you'll need to set up your own webserver
can the url be a local host?
lmao
lmao
Hey ^-^" I don't know, how I can post the Server count, User Count (or whatever it's called) and the Shard count 😅 Can anyone help me?
I use JavaScript
Or Node.JS
Already did that
did you look at https://discordbots.org/api/docs#jslib then?
And my Bot gives me like 200 Error messages in one second
I am doing it right
no youre not
what errors are you getting
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('TOKEN', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
Is this right?
@humble bison ReferenceError: e is not defined
Thats the error
don't tell me that you included the new Discord.Client
It's the Example
what node version are you using @blazing radish
New Error: SyntaxError: Unexpected token )

i meant(e)
should I remove the new in new DiscordClient(); ??
no
didnt you already make a discord client
no
i don't know
I'm tired
it's like 3 am here
ReferenceError: e is not defined Again
what node version
how can I update it again? ^-^"
I think I updated it to 11.4.2
^-^"
lol?
Oh
I updated discord.js not node.js
@blazing radish well i use the old n classic codes to send the guild count on a new guild add
const Discord = require("discord.js"),
client = new Discord.Client(),
DBL = require("dblapi.js"),
dbl = new DBL('TOKEN'); // don't add 'client' after the token!
dbl.postStats(serverCount)
.then(() => console.log('Server count posted!'))
.catch(() => { });
And when I wan't to add the amount of Shards I have for this bot? ^-^"
@tawdry spindle Pls tell me I just forgot to get the amount of Servers then this error appears ReferenceError: serverCount is not defined
o you have shards?
ok then change the dbl.postStats(serverCount) with dbl.postStats(client.guilds.size) and with dbl.postStats(client.guilds.size, client.shard.id, client.shard.count) when you start sharding ^^
Ok 😄
better discord list?
yes
@tawdry spindle https://totallynotavir.us/i/xt64.png
@restive otter that's for webhooks it has nothing to do with posting stats
oh
well i inserted the code into the bot
and I checked the website
and I don't see a server count
What's your code
const Discord = require("discord.js"),
client = new Discord.Client(),
DBL = require("dblapi.js"),
dbl = new DBL('TOKEN'); // don't add 'client' after the token!
dbl.postStats(client.guilds.size)
.then(() => console.log('Server count posted!'))
.catch(() => { });```
That will only post when the bot starts up
If you do put client after the token and you don't mess with dbl.postStats it will automatically post every 30 mins
That's the recommended way, putting client in the new dbl code after the token
hm
Like it looks like that
In the bots page
so it will take 30 minutes to show?
Wait...
What are you doing
Why do you have const client and const bot
Pick one and stick to it
ok bot then
forgot to change it
saved
But i got an error ofc
so I just deleted the line
Alright that's what it looks like now
Does that look right @plain timber
Well as I told you with that code it will only post when your bot starts up
It's recommended to not use dbl.postStats and instead just put bot after the token in the new dbl line
help anyone
Why does a test-vote send 2 requests? One with content, one without
How to find the webhook Auth password?
you decide it
?
You set it
https://discordbots.org/bot/your-bot-id/edit scroll down find authorization, you set it to whatever you want there (idk max or acceptable characters tho)
https://preach.yiff.church/i/rpde.png I posted the server count but it won't show the bot online, could anyone help?
preach.yiff.church
Probably one of the website administrators
mk
your bot probably isn't in the DBL Discord Server
check #mod-logs for why it was potentially kicked
Hey, what Content type header does the webhook post request send?
@azure pollen ?
Sorry for the ping, i'm really in a hurry
have you looked at pins
application/json
yes
k pal
k pal
k pal
did you pass the argument for webhook stuff
O
Ok
did you pass the argument for webhook on the dbl thing
?
you tested from dbl to webhook.site?
Yes
yeah figured.
After mine didnt work
Did you get a confirmation on the ready event that the webhook server started
It said webhook running on http://0.0.0.0:5000/dblwebhook
or whatever it says be default
by*
now, what's the curl command you typed
curl http:localhost:5000
and the // ?
are you absolutely sure that you aren't looking at some old log
no i'm talking about It said webhook running on http://0.0.0.0:5000/dblwebhook
now run lsof -i :5000 again
I got an output this time
?
now the curl
No output at all
add -v
now try ur browser
I did
Oh
it worked
tyvm
I still have no idea what the other issue was tho
not other*
But it works
no idea
Wrong channel
?
https://i.imgur.com/kXf0y6T.gifv
What's up with this?
You are probably posting stats twice from 2 different bots?
Nope same bot.
The 43 servers is from when I first got the api to work months ago and never messed with again until today. Got it work and now it's doing this.
Sometimes, numbers on sites like YouTube and Twitter jump up and down; subscriber counts lag, like-counts bounce all over the place. Why is it so hard for co...
hello, i am trying to set up displaying my bot's server count on the website. I am using heroku and have integrated all of the code needed with the token and everything as well as used the install for the api into the heroku console, yet i am still getting an error that can't find the dbl api module
go to your package.json and add it there
in the dependencies?
yes
alright thx!
do you know how to write a package.json?
i think i can get it anything specific to know?
Read this and then contemplate https://i.imgur.com/6z8PsjV.png
if I get 401 error does it means my token was reset ?
@tender garnet no it usually means you didn't include a token, 403 means wrong token/ip ban
Just run whatever code you run when they actually vote?
but I need to test to see if voting still works with the adjustmentsI made to the code
ill just have someone vote for the bot
If you're using webhooks, you can test them from the edit section
oh yea ;b
i found a bug that happens with my code. when ever i use the const listener for the port. the website no longer works. is there a way i can fix that?
@tepid garden are you using both dblapi.js and express on glitch?
yes
Instead of using webhookport in dblapi.js, use webhookServer: listener @tepid garden sry for late reply
yea i figured that out with help Thanks!
Yw
Yo so like on my bot page
the black background I coded in html
doesnt fill the entire page
how do I make it do so?
Or will it only go in that white box?
@restive otter wrong channel and just change your css
which channel?
how often can bot stats be set on dbl? and is it instantaneous?
@hollow wraith it is updated immediately but it may be cached
and the ratelimit is 60 reqs/min
ok, ty
isnt it 60/minute?
idk
doc says 60/m
what is the url to test a vote again
I used it before, is it testing a webhook on https://discordbots.org/api/docs#mybots? Or is it something else?
@bronze arch you can use the my bots page or the edit bot page
yes
it will send a webhook to the link you provide
it will give bot instead of user however
give bot? When i press Test webhook i get myself logged in the vote logs lol
not the bot
user does not get passed when you click test though, its replaced with bot inside the body of the post DBL sends. But it would be your user Id yes
it does pass your user
yes.. but user will no be defined.. lol nevermind
lmao
well ive tested it and it works
its the same as a real vote except type is test or whatever
but it does simulate a real vote with your user
^
So thats why i can cheat economy rewards when i test the webhook for no reason xD
That’s how mafia works
Would I have to host a website to use this webhook?
@dull fiber thats not how this channel works
@spring pebble just host a web server
yes basically a website
Oh okay
how do i post the status of the bot
?
🤔
@tepid garden what language
javascript
Are you using POST or actually using the api?
api
.poststats...
Yes.
Btw you don't need to use poststats if you include your client in the new dbl line, that will activate the autoposter
You can ignore shard stuff if your bot isn't sharded
Could you paste the new dbl line
Oh that means it's not in this server
The API is only for setting server and shard counts
what is a shard count
If your bot isn't in the server then either it left it got picked
The amount of shards your bot has
It's only for sharded bots
so how do i post status
It has to be here...
It will automatically get the online/offline status if your bot is in this server
Its not in the server
submit it and get accepted
Is this a joke, or? https://discordbots.org/bot/new go here
Then it was kicked/removed
why 😦
O
It wasnt kicked then, unless it wasnt found with a search.
But this is all not for this channel anyways
what channel then
2019-01-10T07:54:19.479569+00:00 app[worker.1]: Oops! Error: 401 Unauthorized```
I was 2 times get this error.
I've been regen the token.
And put the new one. Still.
401 usually means no token was sent
or invalid
@arctic arch Invalid? I've been regen the token and i put it again on process.env
And, restart the bot.
It said, Oops! Error: 401 Unauthorized
then maybe it wasn't sent
hmm..
could you send your code?
if you console.log process.env.DISCORD_BOTS in that file is it correct?
if you're using anything else than postStats, make sure the dblapi.js module is up to date
also you dont need to use postStats if you include the client in the new dbl line
as that will activate the autoposter
iirc
yes
dont see any error on console log.
why it's still error.
since you're on heroku, did you try checking your config vars if you have the key DISCORD_BOTS? they're under "settings" of your app.
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjUyMTk5NTQ2MzM2OTY4NzA0MCIsImJvdCI6dHJ1ZSwiaWF0IjoxNTQ3MTA2MTY3fQ.J8zcSoPzeAEDdN2pq9aEqBwlXQhgJCcw3ghq9Xc-YCo```
Don't worry, it've been regenerated.
But, since nothing wrong on it.
Ok. it's okay.
It's all done.
I'm getting a DiscordAPI: Missing Permissions error when I have the .postStats() in my main file.
How do I fix it ?
thats irrelevant
your bot doesn't have perimissions to do something in discord
but that's a topic for #development
Hey
Don't 'hello'-ing here. Go to the #general or #memes-and-media
Hi guys, I am trying to set up a webhook
I think I have succeded so far
But when people vote I don't get the consol.log message
Can I get some help?
Its console not consol
Yes ofc, sorry mistyped here
@unique vessel can u help a bit?
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});```
this outputs this Webhook running at http://0.0.0.0:5000/dblwebhook
does it mean that's wrong
or is it connected
Did you ever set up the webhook on your dbl page?
yes
Is your bot webhook url https://ipofhost:5000/dblwebhook
Thats what you put in the webhook url?
i took this from the documentation
yes
i need to put http://0.0.0.0:5000/dblwebhook
?
and port is still 5000?
Yes
i see cause it's running locally on that server
Can you test the webhook to see if it logs anything? If you have a vote listener anyways
yeah i have a dbl.webhook.on('ready', hook => { console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`); });
ops not this
console.log(`User with ID ${vote.user} just voted!`);```
Alright save and test it
No use test
oh, how can i test it?
sorry, i only got approved yesterday and trying to figure this out
on your edit page
at the bottom
Wait, did you every set anything in your dbl edit page for the webhook?

yes the token and the secret
new DBL(token, [client])
i used this
to create the dbl
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
as password i used my Authorization
.. no
there we go
i already put this url ^^
Then hit save and test
To ensure the requests come from dbl
is this correct then to create it const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
in the code i mean
i guess this is ok as i don't get 401 error
but still the test doesn't do anything
@snow sky want to chip in?
alright, from what i learned the dblapi.js webhook doesnt work
yeah
i have added the url, created a token, added an auth
seems to connect fine
but when a vote happens i see nothing on my console
so you can go to the webhook url and it work?
depends, is it your home ip or a vps
vps
does it have anti DDoS protection?
not sure so i wont then
good idea
Is the server on
Firewall?
portforwarding issues?
do you know how to use the http module in nodejs?
so what you can do is import the http module require('http')
k
let me look at my code real quick lol
then do js http.createServer((req, res) => { //we will mess around in here in a little bit });
but we still need to finish the code lol
do you have any verification in dbl
const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' });
using this
token is the one generated in the dbl settings
and password the authorization word
ok
we are going to have to check that the request that is being sent is actually POST, because thats how dbl sends the data, so a simple if (req.method === "POST') {... should work req, is the request coming from dbl and method is the type of request
k should i add this in that code?
inside the create server
yep and i output to console
oh i almost forgot, you should have .listen('5000') on the end of the http.createServer function
😄
whoops
not yet
if (req.method === "POST") {
console.log("Is post yes");
}
}).listen('5000');
brain ded for console message
lol
yep, don't worry i'm a dev as a profession 😃
after that we are going to check for the authorization from dbl, which comes in a header from the request, so just simply req.headers.authorization === 'password'
after the and statement in the if
ok
so inside the and statement, where your console.log is, we need to actually read the data from dbl, but the data comes in chunks, so how we do this is by adding every chunk we recieve onto a temporary string and then parsing it, into json that is
aha, can we check if this works first?
of course
i am still getting nothing
the .listen('5000') is giving an error
fek i forgot my secret
oof, im sorry, its not a string its a number, so remove the ' from the listen
i'll change it
Error: listen EADDRINUSE :::5000 0|bot | at Object._errnoException (util.js:1022:11)
remove the webhook settings from the dbl lib setup
so the { webhookPort: 5000, webhook: 'password'}
so its just empty {}
if i do the dbl.on is undefined
ok
it will look something like this https://alekeagle.tk/screenshots/G5Q3QMP4ak.png
the client thing is for if you want automatic shard and server count updates
do you have everything the bot uses defined as client or bot or something else
so like client.on or bot.on
ok, so now if you test it
- your webhook should start listening
- your server count will be posted
how our function is not posting anything
what bot are you doing this to?
what do u mean like link?
or just @ it
@restive otter
yep
ok, back to the webhook, if you test it, does it work?
i get nothing back form that function
the console outputs nothing
http.createServer((req, res) => {
if (req.method === "POST" && req.headers.authorization === 'pass') {
console.log("Is post yes");
}
});
its not listening
you need .listen(5000) i made the mistake earlier to put the 5000 in ' and it doesnt like that
http.createServer((req, res) => {
if (req.method === "POST" && req.headers.authorization === 'pass') {
console.log("Is post yes");
}
}).listen(5000);
yes
i don't see anything posted in console
if i press test button
oh wait
nope nothing
so frustrating 😦
your webhook address should be http://IP:5000/
and authorization should be the same on both sides
im sorry i couldnt help, its been a while since i set up a webhook
http.createServer((req, res) => {
if (req.method === "POST" && req.headers.authorization === 'pass') {
console.log("Is post yes");
} else {
console.log("not post");
}
}).listen(5000);
it says site can't be reached
idk how to help then im sorry

