简体   繁体   中英

How to create an id array in quick.db Discord.js

I'm trying to make a local black list of members. But I ran into a problem that the bot does not create an array, but inserts only one value

const db = require("quick.db")
module.exports.run = async (discord, bot, message, args, p) => {
    db.push(`black_${message.guild.id}`, args[0])
    const bl = db.get(`black_${message.guild.id}`)
    message.channel.send(`${bl}`)
}
module.exports.help = {
    name: 'black',
    aliases: [''],
    description: ''
}

Is there any other way to create an array for each server?

Using await and different constructor might fix your issue.

const { QuickDB } = require("quick.db");
const db = QuickDB();

module.exports.run = async (discord, bot, message, args, p) => {
    await db.push(`black_${message.guild.id}`, args[0])
    const bl = await db.get(`black_${message.guild.id}`)
    message.channel.send(`${bl}`)
}
module.exports.help = {
    name: 'black',
    aliases: [''],
    description: ''
}

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