简体   繁体   中英

Trying to do close and open command quick.db

const db = require("quick.db");

module.exports.run = async (client, message, args) => {
  let botfetch = db.fetch(`ddoskoruma_${message.guild.id}`);
  let kapaç = args[0];

    if (kapaç === "aç") {
      db.set(`ddoskoruma_${message.guild.id}`)
      console.log("Open")
    } else if (botfetch) {
      console.log("Already open.")
    }

    if (kapaç === "kapat") {
      db.delete(`ddoskoruma_${message.guild.id}`)
      console.log("Closed.")
    } else if (!botfetch) {
      console.log("Already close.")
    }
    }

module.exports.conf = {
  name: "ddoskoruma"
};

I am trying to do close and open commands with quick.db. I want to do if command already closed, reply "It's already closed/opened." but I'm trying this code for it but I'm getting this error:

(Sorry for my bad english)

(node:26756) UnhandledPromiseRejectionWarning: TypeError: Input cannot be undefined @ ID: ddoskoruma_640958795643617284

You need to provide a key and a value when you use db.set() . For example:

db.set(`ddoskoruma_${message.guild.id}`, 1);

Just edit this line and it will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM