Dblapi.js https request fail Discord Bot


#1

https://usagix.glitch.me

So, I was trying to get vote updates from https://discordbots.org/ using webhooks so my code was trying with this

const app = express();

app.get("/", (request, response) => {
  console.log("Ping received!");
  response.sendStatus(200);
});

// listen for requests :)
const listener = app.listen(process.env.PORT, function() {
  console.log('Your app is listening on port ' + listener.address().port);
});
const DBL = require('dblapi.js');

const http = require('http');


const server = http.createServer(app);
const dbl = new DBL(process.env.DBLTOKEN, { webhookAuth: process.env.DBLAUTH, webhookServer: server });

dbl.webhook.on('ready', hook => {
  console.log(`Webhook running with path ${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});



server.listen(5000, () => {
  console.log('Listening');
});```

#2

Your project can only listen on a single port, but you’re trying to use two in your code. You could define an additional handler in your webhook code that whatever service you’re using to keep the bot awake can ping instead of the Express route you’ve created.