Quick.db function error

(node:12503) UnhandledPromiseRejectionWarning: Error: Data @ ID: "para_678703128970919949" IS NOT A number.

11:02 AM

FOUND: "1"

11:02 AM

EXPECTED: number

11:02 AM

at Object.module.exports [as add] (/rbd/pnpm-volume/42d1176b-665d-47f4-b20b-5f12797c50c4/node_modules/.registry.npmjs.org/quick.db/7.0.0-b21/node_modules/quick.db/lib/add.js:29:36)

11:02 AM

at arbitrate (/rbd/pnpm-volume/42d1176b-665d-47f4-b20b-5f12797c50c4/node_modules/.registry.npmjs.org/quick.db/7.0.0-b21/node_modules/quick.db/bin/handler.js:279:25)

11:02 AM

at Object.add (/rbd/pnpm-volume/42d1176b-665d-47f4-b20b-5f12797c50c4/node_modules/.registry.npmjs.org/quick.db/7.0.0-b21/node_modules/quick.db/bin/handler.js:79:12)

11:02 AM

Jump Toat AnaOkuluWin (/app/komutlar/rob.js:144:6)

11:02 AM

Jump Toat message.channel.send.then.message (/app/komutlar/rob.js:127:15)

11:02 AM

at <anonymous>

11:02 AM

at process._tickCallback (internal/process/next_tick.js:189:7)

11:02 AM

(node:12503) 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(). (rejection id: 1)

11:02 AM

(node:12503) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I get such an error when I use quick.db in the function.
and code is here

function AnaOkuluWin(message, lvl, user) {
  var winMoney0 = Number(crimes[0].basePara);
  var winExp0 = Number(crimes[0].baseExp);

  randomMoney = Math.round(Math.random() * (winMoney0 - 1 + 1));
  randomExp = Math.round(Math.random() * (winExp0 - 1 + 1));
  db.add(`para_${message.author.id}`, randomMoney);
  db.add(`exp_${message.author.id}`, randomExp);
  const embed = {
    title: "Soygun Başarılı",
    color: 8084528,
    thumbnail: {
      url: user.displayAvatarURL
    },
    fields: [
      {
        name: "Soygun yapılan yer",
        value: crimes[0].name
      },
      {
        name: "Kazandığın para",
        value: randomMoney
      },
      {
        name: "Kazandığın exp",
        value: randomExp
      }
    ]
  };

  message.channel.send({ embed });
}

Hi @oztrkemre,

db.add() tries to add a number to an existing number. It looks like the code is sending it a number, so maybe what was in the database previously was a string "1" instead of a number 1.

1 Like
message.channel.send({ embed }).then(msg => {
    message.channel
      .awaitMessages(filter, {
        max: 1,
        time: 20000,
        errors: ["time"]
      })
      .then(collected => {
        var selected = collected.first().content;

        if (selected === "1") {
          // AnaOkulu
          const embed = {
            color: 14393562,
            image: {
              url:
                "https://cdn.glitch.com/8c8d7b3a-7b70-4154-b26a-02d4ef89ece4%2Fezgif.com-optimize.gif?v=1581964506843"
            },
            fields: [
              {
                name: crimes[0].name,
                value: "🧸🎨🍭🍬🍫"
              }
            ]
          };

          message.channel.send({ embed }).then(message => {
            setTimeout(() => {
              message.delete(1500);
            }, 1900);
            if (win >= percentage0) {
              AnaOkuluWin(message, lvl, user);
            } else message.channel.send(win + "<win|percentage>" + percentage0);
          });
        } else {
          setTimeout(() => {
            message.channel.send("Böyle bir soygun daha yok");
          }, 1000);
        }
      });
  });
};

The same code works here except for the set.timeout parts.