vnftjs
Version:
Discord CommandHandler for TypeScript or JavaScript
32 lines • 954 B
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Script {
constructor() {
this.intervalTime = -1;
this.type = "Script";
this.triggered = false;
}
/**
* executes the function its holding, repeats in a interval if intervalTime is given
* @param {Client} bot the bot that should be passed the function as a parameter
*/
trigger(bot) {
if (this.triggered == false && this.funct) {
this.funct(bot);
if (this.intervalTime >= 0) {
this.intervalId = setInterval(this.funct, this.intervalTime, bot);
}
this.triggered = true;
}
}
stop() {
if (this.intervalId) {
clearInterval(this.intervalId);
}
}
set interval(time) {
this.intervalTime = time;
}
}
exports.Script = Script;
//# sourceMappingURL=Script.js.map