fix interval
This commit is contained in:
parent
2a9f5873ff
commit
1eb45bbe8c
13
DynDnsBot.js
13
DynDnsBot.js
@ -18,14 +18,15 @@ export class DynDnsBot{
|
||||
});
|
||||
}
|
||||
setInterval(seconds = this.config.updateInterval, random = this.config.randomInterval){
|
||||
this.interval = setInterval(random
|
||||
?setTimeout(this.update, Math.random()*seconds*1000)
|
||||
:this.update,
|
||||
seconds*1000);
|
||||
let handler = (callback) => random
|
||||
?()=>setTimeout(callback, Math.random()*seconds*1000)
|
||||
:callback;
|
||||
this.interval = setInterval(handler(this.update), seconds*1000);
|
||||
this.update();
|
||||
}
|
||||
async getIp(){
|
||||
return await rest.get(this.config.ipApi).then(newIp => {
|
||||
return newIp;
|
||||
return await rest.get(this.config.ipApi).then(res => {
|
||||
return JSON.parse(res.text);
|
||||
}).catch(console.error);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user