Dblapi.js - discord bot

#1

So im trying to make my discord bot catch everytime someone votes for it in discordbots.org, im using dblapi.js for this (https://discordbots.org/api/docs#jslib)

According to the following this thread,

I have to add this to my index.js:

 const http = require('http');
const express = require('express');
const app = express();
var server = require('http').createServer(app);
app.get("/", (request, response) => {
  console.log(Date.now() + " Ping Received");
  response.sendStatus(200);
});
const listener = server.listen(process.env.PORT, function() {
  console.log('Your app is listening on port ' + listener.address().port);
});
setInterval(() => {
  http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`);
}, 280000);

const Discord = require('discord.js')
const client = new Discord.Client();
const DBL = require('dblapi.js');
const dbl = new DBL(process.env.DBLTOKEN, { webhookServer: server, webhookAuth: //auth
}, client);

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

dbl.webhook.on('vote', vote => { //stuff });

But the logs says
:rainbow::ox: Your app is listening on port 3000
Webhook running at http://0.0.0.0:0/dblwebhook

as far as I understood, 0.0.0.0:0 should be (project_name).glitch.me:3000 so the bot could catch everytime someone votes and do the dbl.webhook.on(‘vote’ thing

what am i doing wrong?
Sorry for the long explanation, im a little confused with this

0 Likes

#2

Hello @koliron

Can you change the following:

To This:

const dbl = new DBL(process.env.DBLTOKEN, { webhookServer: listener, webhookAuth: //auth }, client);

And tell me how this goes for you!

1 Like

#3

hi @Callum-OKane!

image

unfortunately it did not work ):

0 Likes

#4

Can you test the webhook to make sure it works, I do not know what is wrong from the code you have provided, and it might only be like that but in actual fact it could be working normally!

0 Likes

#5

tested a few times, but i does not work:

image

nothing has appeared in the logs

1 Like

#6

i just talked with someone who had the same problem as me, he solved it with the same thing im doing, (but with server instead of listener)

i’ve tried to test it like that and it still doesnt work

0 Likes

#7

he told me he has the 0.0.0.0:0 thing and it works for him anyways

0 Likes

#8

Hey @koliron it would probably be helpful to be able to see your configuration. Can you share your project name?

0 Likes

#10

ok, somehow the test thing does not work but when someone votes it does! it worked with the listener thing, so thank you Callum-OKane!!

2 Likes

#11

No problem! @koliron :slight_smile:

Just make sure to mark the response with that answer as the solution so others can easily find the answer if they are experiencing the same problem!

Happy Glitching!

2 Likes

#12

Glad you got everything working, if you need any more help then make
sure to create a new topic and one of the community members will
respond and help you out!

0 Likes