Sunday, 7 May 2017

TypeError: Cannot read property 'setInt' of undefined

I am trying to call the variable setInt which has an anonymous function in my mute.js so I can run a setInterval from another file:

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);
};

Then in another class I try to require and execute it:

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

mute.setInt();

But I get the error TypeError: Cannot read property 'setInt' of undefined

I don't know what I did wrong, maybe I'm supposed to module.exports?



via Vlexing

No comments:

Post a Comment