TypeError:无法读取属性' setInt'未定义的

时间:2017-05-07 15:01:27

标签: javascript node.js sqlite discord

我试图在我的mute.js中调用具有匿名函数的变量setInt,这样我就可以从另一个文件中运行setInterval



module.exports = class MutePlayer extends commando.Command {

    async run(message, args) {
    
        var setInt = function() {
          setInterval(function() {
            //if the current dat in milli >= the milli end time
            if (Date.now() >= dateEnd) {
              //if true then unmute
              message.guild.member(user).removeRole(muted).then(() => {
                message.guild.member(user).send("You have been unmuted!");
                //deleting row with the temp data in it
                let stmt2 = db.prepare("DELETE FROM mute WHERE id = ?", function(err) {
                  if (err) return console.error(err);
                });
                //exe'ing and finalizing data
                stmt2.run(user.id);
                stmt2.finalize();
              });
            } else {
              //if not then show what minute it is and console.log
              counter++;
              console.log("It's not over yet! " + counter);
            }
          }, 60000);
        };
        
    }
}
module.export.module.exports = setInt;




然后在另一个类中我尝试要求并执行它:



var mute = require("../commands/moderation/mute.js").setInt;

mute.setInt();




但我收到错误TypeError: Cannot read property 'setInt' of undefined

我不知道自己做错了什么,也许我应该使用module.exports?

0 个答案:

没有答案