Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使错误延续_Javascript_Node.js_Sequelize.js_Discord.js - Fatal编程技术网

Javascript 使错误延续

Javascript 使错误延续,javascript,node.js,sequelize.js,discord.js,Javascript,Node.js,Sequelize.js,Discord.js,我对使用Sequelize还不熟悉,我试图为我正在开发的Discord机器人游戏创建一个货币系统。也许我把桌子弄错了,但我认为这种方法对我也适用。我还有一些文件,比如dbInit.js、dbObjects.js,在models文件夹中我有models/CurrencyShop.js、models/Users.js、models/UserItems.js,如果您需要查看这些文件,请告诉我 以下是错误: (node:5916) UnhandledPromiseRejectionWarning: Se

我对使用Sequelize还不熟悉,我试图为我正在开发的Discord机器人游戏创建一个货币系统。也许我把桌子弄错了,但我认为这种方法对我也适用。我还有一些文件,比如dbInit.js、dbObjects.js,在models文件夹中我有models/CurrencyShop.js、models/Users.js、models/UserItems.js,如果您需要查看这些文件,请告诉我

以下是错误:

(node:5916) UnhandledPromiseRejectionWarning: SequelizeDatabaseError: SQLITE_ERROR: no such table: users
    at Query.formatError (C:\Users\ryang\node_modules\sequelize\lib\dialects\sqlite\query.js:422:16)
    at Query._handleQueryResponse (C:\Users\ryang\node_modules\sequelize\lib\dialects\sqlite\query.js:73:18)
    at afterExecute (C:\Users\ryang\node_modules\sequelize\lib\dialects\sqlite\query.js:250:31)
    at Statement.errBack (C:\Users\ryang\node_modules\sqlite3\lib\sqlite3.js:16:21)
(node:5916) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:5916) [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.
这是我的
app.js
代码:

const Discord=require('Discord.js');
const client=new Discord.client();
const{Users,CurrencyShop}=require('./dbObjects');
const{Op}=require('sequelize');
const currency=new Discord.Collection();
常量前缀='!';
反映.定义属性(货币,“添加”{
值:异步函数添加(id、金额){
const user=currency.get(id);
如果(用户){
user.balance+=数量(金额);
返回user.save();
}
const newUser=wait Users.create({user\u id:id,balance:amount});
currency.set(id,newUser);
返回新用户;
},
});
反映.定义属性(货币“getBalance”{
值:函数getBalance(id){
const user=currency.get(id);
返回用户?用户余额:0;
},
});
client.once('ready',async()=>{
const storedBalances=await Users.findAll();
forEach(b=>currency.set(b.user_id,b));
log(`Logged as${client.user.tag}!`);
});
client.on('message',异步消息=>{
if(message.author.bot)返回;
currency.add(message.author.id,1);
如果(!message.content.startsWith(PREFIX))返回;
const input=message.content.slice(PREFIX.length.trim();
如果(!input.length)返回;
const[,command,commandArgs]=input.match(/(\w+)\s*([\s\s]*)/);
如果(命令=='balance'){
const target=message.indications.users.first()| | message.author;
返回message.channel.send(`${target.tag}有${currency.getBalance(target.id)}use

client.on('message',异步消息=>{
试一试{
if(message.author.bot)返回;
currency.add(message.author.id,1);
如果(!message.content.startsWith(PREFIX))返回;
const input=message.content.slice(PREFIX.length.trim();
如果(!input.length)返回;
const[,command,commandArgs]=input.match(/(\w+)\s*([\s\s]*)/);
如果(命令=='balance'){
const target=message.indications.users.first()| | message.author;

返回message.channel.send(`${target.tag}有${currency.getBalance(target.id)}控制台中是否应该弹出新的内容?我得到的错误与以前完全相同。它们的堆栈也没有任何不同。首先
未处理的PromisejectionWarning
您需要处理它,所以您如何处理我向您显示的错误,第二个错误是“SQLITE\u错误:没有这样的表:用户”,因此请检查是否为“用户”表存在于数据库中我的目录中确实有一个database.sqlite文件,但它是空的。我可以这样检查表吗?:从schema_name.table_name LIMIT 0中选择1;如果是,我应该把它放在哪里?您使用的是哪个数据库?我认为Sequelize会使用我创建的不同形式的表创建数据库。例如const newUser=wait创建({user\u id:id,余额:amount});