2017-11-11 9 views
-1
const prefix = "s!"; 
var dailyCheck = sql.get(`SELECT daily FROM scores WHERE userId = "${msg.author.id}"`); 


bot.on("message", function (msg) { 
    if (msg.author.bot) return; 
    if (msg.content.toLowerCase = prefix + "dailies") { 
     var daily = dailies(msg); 
     daily; } 
    }); 
bot.on("message", function dailies(msg) { 
    reset.setInterval(function() { 
     var date = new Date(); 
     if (date.getHours() === 15 && date.getMinutes() === 0) { 
      sql.run(`UPDATE scores SET daily = 0`); 
     } 
    }, 60000); 
    sql.run("CREATE TABLE IF NOT EXISTS scores (userId TEXT, daily INTEGER, glimmer INTEGER, wr INTEGER, rotw INTEGER)").then() => { 
     if (!row) { 
      // I get the error of unexpected token "." in the next line. 
      sql.run("CREATE TABLE IF NOT EXISTS scores (userId TEXT, points INTEGER, level INTEGER)").then() => { 
      sql.run("INSERT INTO scores (userId, daily, points, wr, rotw) VALUES (?, ?, ?, ?, ?)", [msg.author.id, 1, 200, 0, 0]); 
      msg.channel.send('Thank you for joining Playing Destiny Fast! You have 200 glimmer available!'); 
     } else if (dailyCheck = 1) { 
      msg.channel.send('You have already accepted your daily rewards! Come back after the daily reset (9am PST) to claim again.'); 
     } else { 
      sql.run(`UPDATE scores SET glimmer = ${row.glimmer + 200}, daily = 1, WHERE userId = ${msg.author.id}`); 
      msg.channel.send('${message.author.id} has claimed their 200 daily glimmer! Total: ${row.glimmer}'); 
     } 
    }); 
}); 

具体的には、「予期しないトークン」を受け取っています。 sql.run(CREATE...でエラーが発生しました。これを修正する方法を教えてください。予期しないトークンエラーを修正するにはどうすればよいですか?

+0

今後タイトルにタグを追加しないでください。タグはタグフィールドに入ります。 – Daedalus

答えて

1

sql.runのいずれかで.thenを誤って使用しています。
.then() => {は、あなたができない場所で矢印機能を作成しようとしているので無効です。
代わりに矢印の機能を.thenメソッドに渡し、予期しないトークンエラーを取り除くように、.then(() => {にする必要があります。

固定されたバージョン(reset.setIntervalの後にブロックをこれに置き換えてください)。

sql.run("CREATE TABLE IF NOT EXISTS scores (userId TEXT, daily INTEGER, glimmer INTEGER, wr INTEGER, rotw INTEGER)").then(() => { 
    if (!row) { 
     // I get the error of unexpected token "." in the next line. 
     sql.run("CREATE TABLE IF NOT EXISTS scores (userId TEXT, points INTEGER, level INTEGER)").then(() => { // this is where the issue was occurring 
      sql.run("INSERT INTO scores (userId, daily, points, wr, rotw) VALUES (?, ?, ?, ?, ?)", [msg.author.id, 1, 200, 0, 0]); 
      msg.channel.send('Thank you for joining Playing Destiny Fast! You have 200 glimmer available!'); 
     }); 
    } else if (dailyCheck = 1) { 
     msg.channel.send('You have already accepted your daily rewards! Come back after the daily reset (9am PST) to claim again.'); 
    } else { 
     sql.run(`UPDATE scores SET glimmer = ${row.glimmer + 200}, daily = 1, WHERE userId = ${msg.author.id}`); 
     msg.channel.send('${message.author.id} has claimed their 200 daily glimmer! Total: ${row.glimmer}'); 
    } 
}); 

は、私は(一般的に)あなたがエラーがありました示し、時にはあなたがそれらを修正するのに役立ちますVSCodeまたは何か他のもの、のようなIDEを使用することをお勧め。

+0

これは私の以前の問題を修正しましたが、間違いがありました。このコードはsqlite3モジュールを探しますが、sqlite3をインストールしていないため、このボットに使用しないため、見つけられません。助言がありますか? –

+0

@MaverickRiver新しい質問をして、あなたが使っているライブラリを述べてください。 – Daedalus

関連する問題