加入时和离开语音通道时的人员时间减去

时间:2019-02-06 23:53:38

标签: discord.js

bot.on('voiceStateUpdate', (oldMember, newMember) => {
            let newUserChannel = newMember.voiceChannel
            let oldUserChannel = oldMember.voiceChannel
            let now = new Date();

            let time1 = now.getUTCSeconds()


            if (oldUserChannel === undefined && newUserChannel !== undefined) {

                console.log(time1)
                console.log("Hi")

            } else if (newUserChannel === undefined) {
                let now2 = new Date();
                let time2 = now2.getUTCSeconds()
                console.log(time2)
                console.log("bye")



            let db = new sqlite3.Database('./db/joinleave.db');
            // construct the insert statement with multiple placeholders
            // based on the number of rows
            let sql = 'INSERT INTO joinleave (id,joined,leave) VALUES (?,?,?) ';
            // output the INSERT statement
            console.log(sql);

            db.run(sql, [newUserChannel,time1,time2], function(err) {
              if (err) {
                return console.error(err.message);//err.message
              }
              console.log(`Rows inserted ${this.changes}`);
            });
            // close the database connection
            db.close();
             }
        });

here

我想减去某人离开语音通道时加入语音通道的时间,例如当他在18:30 pm加入6/2/2019并在5:30 am离开7/2/2019时,差值应该是11个小时。

0 个答案:

没有答案