PragunSaini / vndb-api

An API wrapper for vndb.org API.
MIT License
14 stars 1 forks source link

Query CONTIMEOUT error #16

Closed ouchJP closed 3 years ago

ouchJP commented 3 years ago

Hi, I'm trying to make a discord bot using your package but anytime I send the command a second time the api blocks my request and gives me a CONTIMEOUT. What am I doing wrong?

code: 'CONTIMEOUT', message: 'Connection timed out', status: 'error'

const VNDB = require('vndb-api')

const vndb = new VNDB('clientname', {
  minConnection: 1,
  maxConnection: 10,
})

function rand(min, max) {
  let randomNum = Math.random() * (max - min) + min;
  return Math.floor(randomNum);
}

client.on('message', message => {
  if (message.content === '!vnrandom') {
    let x = rand(0, 30084)

vndb
  .query(`get vn basic (id = ${x})`)
  .then(response => {
    // Use the response
    console.log(response.items[0]['original'])
    message.channel.send("Your random VN is: " + JSON.stringify(response.items[0]['original']) + ' ' + JSON.stringify(response.items[0]['title']) + ` https://vndb.org/v${x})`);
  })
  .catch(err => {
    // Handle errors
    console.log(err)
  })
  .finally(() => {
    // Destroy the client and any connections
    vndb.destroy()
  })

}});
PragunSaini commented 3 years ago

Hi, Just asking...., were you able to resolve this issue ?