sabri
sabri

Reputation: 3

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:

(node:26756) UnhandledPromiseRejectionWarning: TypeError: Input cannot be undefined

Upvotes: 0

Views: 74

Answers (1)

Androz2091
Androz2091

Reputation: 3005

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.

Upvotes: 1

Related Questions