我的机器人不和谐有问题,我更新了所有更好的 sqlite 快速数据库,但是当我启动机器人时总是出现相同的错误,有人可以帮助我吗?
PS C:\Users\berno\Desktop\Bot-Parfait-main> node index.js
C:\Users\berno\Desktop\Bot-Parfait-main\index.js:7
const table = new db.table('Prefix');
^
TypeError: db.table is not a constructor
at Object.<anonymous> (C:\Users\berno\Desktop\Bot-Parfait-main\index.js:7:15)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49
Node.js v20.11.0
PS C:\Users\berno\Desktop\Bot-Parfait-main>
还有我的代码:
const { Client, Intents, guild, Collection } = require('discord.js');
const Discord = require("discord.js")
const config = require('./config')
const { readdirSync } = require("fs")
const { QuickDB } = require("quick.db");
const db = new QuickDB();
const table = new db.table('Prefix');
const logembed = new db.table("embedlog")
ms = require("ms")
const color = config.app.color
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_BANS, Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS, Intents.FLAGS.GUILD_INTEGRATIONS, Intents.FLAGS.GUILD_WEBHOOKS, Intents.FLAGS.GUILD_INVITES, Intents.FLAGS.GUILD_VOICE_STATES, Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.GUILD_MESSAGE_TYPING, Intents.FLAGS.DIRECT_MESSAGES, Intents.FLAGS.DIRECT_MESSAGE_REACTIONS, Intents.FLAGS.DIRECT_MESSAGE_TYPING],
restTimeOffset: 0,
partials: ["USER", "CHANNEL", "GUILD_MEMBER", "MESSAGE", "REACTION"]
});
client.login(config.app.token);
client.commands = new Collection();
const { GiveawaysManager } = require('discord-giveaways');
client.giveawaysManager = new GiveawaysManager(client, {
storage: "./database.json",
updateCountdownEvery: 3000,
default: {
botsCanWin: false,
embedColor: "#FF0000",
reaction: "🎉"
}
});
提前谢谢!
我安装了最后一个更新并更新了代码。我已经尽力了。
错误非常明显,你无法从
db
构造一个新实例。您可以继续访问 db.table('Prefix')
,无需使用 new
关键字。使用 new
关键字会创建您正在使用它的对象的新实例。
更新您的代码以直接访问
db
,如下所示,一切都应该正常工作。
const table = db.table('Prefix');
const logembed = db.table("embedlog")
请告诉我这是否有帮助。