0

I trying to make list command to list the stored data for this code , I tried a lot but it doesn't work for me,

client.on("message", message=>{
    if(!message.guild)return;
    if(message.content.startsWith(prefix + "add")){
    let user = message.mentions.users.first()
        
        if(!user) return message.channel.send('**:x: You have to mention someone first.**')
            if(db.fetch(`owner_${user.id}`)) return message.channel.send("**This user is already exists**")
        
        db.set(`owner_${user.id}`, true)
        message.channel.send(new Discord.MessageEmbed().setColor('#4C6E70').setDescription(`**${user} Done.**`)).then(async msg => {
            msg.react("✅")
        })
    }
 }
    });
Sarite
  • 41
  • 6

1 Answers1

1

The command you're showing right now is a command that adds owners to your bot which has nothing to do with listing them, if you want to show all the data the quick.db database has of you, simply use db.all()

Altought if you want something more efficient I recommend you start using an array to store the owners of your bot using db.push() It would look something like this :

client.on("message", message=>{
    if(!message.guild)return;
    if(message.content.startsWith(prefix + "add")){
    let user = message.mentions.users.first()
        
        if(!user) return message.channel.send('**:x: You have to mention someone first.**')
            let owners = db.get('owners') || [] // If there's no owners it will always return an empty array
            if(owners.includes(user.id)) return message.channel.send("**This user is already exists**")
        
        db.push(`owners`,user.id)
        message.channel.send(new Discord.MessageEmbed().setColor('#4C6E70').setDescription(`**${user} Done.**`)).then(async msg => {
            msg.react("✅")
        })
    }
 }
    });

With the array set, to list the owners you can use db.get() !

    // ...
    if(message.content.startsWith(prefix + "owners")){
      let owners = db.get('owners')
      if(!owners) return message.channel.send('There are no owners!')
      else  message.channel.send('The owners are ' + owners.join(' and '))
    }
Staxlinou
  • 1,351
  • 1
  • 5
  • 20