(Discord)SQLite 2值1列错误

问题描述 投票:1回答:1

我是一个不和谐的机器人开发人员,并切换到SQLite我之前有一些错误和问题,但这已得到修复。我创建了多个表后,我收到一个错误,我似乎无法弄清楚这是错误:

(node:17024) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: SQLITE_ERROR: 2 values for 1 columns
(node:17024) [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.

我查看了所有的表,列,值,但似乎没有错,这是我的代码:

client.sql.get(`SELECT * FROM settings WHERE guildid = "${message.guild.id}"`).then(row => {
        if(!row) {
            client.sql.run(`INSERT INTO settings (guildid, prefix, lang, color, admin, mod, user, autor, channel) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`, [message.guild.id, '!', 'en', '#ffffff', 'admin', 'mod', 'false', 'false', 'false'])
            client.gprefix = '!';
        } else {
            client.gprefix = row.prefix;
        }
    }).catch(() => {
        client.sql.run(`CREATE TABLE IF NOT EXISTS settings (guildid text NOT NULL, prefix text NOT NULL, lang text NOT NULL, color text NOT NULL, admin text NOT NULL, mod text NOT NULL, user text NOT NULL, autor text NOT NULL, channel text NOT NULL)`)
        client.sql.run(`INSERT INTO settings (guildid, prefix, lang, color, admin, mod, user, autor, channel) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`, [message.guild.id, '!', 'en', '#ffffff', 'admin', 'mod', 'false', 'false', 'false'])
            client.gprefix = '!';
    })
    // FARM
    client.sql.get(`SELECT * FROM farm WHERE userid = "${message.author.id}"`).then(row => {
        if(!row) {
            client.sql.run(`INSERT INTO farm (userid, money, xp, level, chickens, farmers, delivery, wizard, omega, robot, goldchick, cegg, ucegg, regg, eegg, legg, megg, elite, daily, collected, car, house, farm) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [message.author.id, 200, 0, 1, 0, 0, 0, '❓', '❓', '❓', '❓', 0, 1, 0, 0, 0, 0, 'false', 0, message.createdTimestamp, 10, 10, 10])
        }
    }).catch(() => {
        client.sql.run(`CREATE TABLE IF NOT EXISTS farm (userid text NOT NULL, money integer NOT NULL, xp integer NOT NULL, level integer NOT NULL, chickens integer NOT NULL, farmers integer NOT NULL, delivery integer NOT NULL, wizard text NOT NULL, omega text NOT NULL, robot text NOT NULL, goldchick text NOT NULL, cegg integer NOT NULL, ucegg integer NOT NULL, regg integer NOT NULL, eegg integer NOT NULL, legg integer NOT NULL, megg integer NOT NULL, elite text NOT NULL, daily integer NOT NULL, collected text NOT NULL, car integer NOT NULL, house integer NOT NULL, farm integer NOT NULL)`)
        client.sql.run(`INSERT INTO farm (userid, money, xp, level, chickens, farmers, delivery, wizard, omega, robot, goldchick, cegg, ucegg, regg, eegg, legg, megg, elite, daily, collected, car, house, farm) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [message.author.id, 200, 0, 1, 0, 0, 0, '❓', '❓', '❓', '❓', 0, 1, 0, 0, 0, 0, 'false', 0, message.createdTimestamp, 10, 10, 10])
    })
    // USERS
    client.sql.get(`SELECT * FROM users WHERE userid = "${message.author.id}"`).then(row => {
        if(!row) {
            client.sql.run(`INSERT INTO users (blacklisted, reason) VALUES (?, ?)`, ['false', 'None'])
            client.blacklisted = 'false'
            client.blackreason = 'None'
        } else {
            client.blacklisted = row.blacklisted
            if(client.blacklisted === 'true') {
            client.blackreason = row.reason;
            return message.channel.send(`You are blacklisted from the bot due to \`${client.blackreason}\`\n\n*Being blacklisted means that you can not use the bot*`).then(m => {
                msg.delete(10000)
            })
            }
        }
    }).catch(() => {
        client.sql.run(`CREATE TABLE IF NOT EXISTS users (blacklisted, reason)`)
        client.sql.run(`INSERT INTO users (blacklisted) VALUES (?, ?)`, ['false', 'None'])
    })

由于Rewire这个问题已经解决了谢谢!

javascript database sqlite discord discord.js
1个回答
0
投票

我用了:

(blacklisted) VALUES (?, ?)

并不是

(blacklisted, reason) VALUES (?, ?)

这使它成为1列的2个值,我在上面修正了这个^

© www.soinside.com 2019 - 2024. All rights reserved.