fully implemented timeframes

This commit is contained in:
Davide Fantino 2022-09-18 01:19:19 +02:00
parent 418afc3b98
commit 30a34f683e

View File

@ -146,7 +146,7 @@ export default class MapVote extends DiscordBasePlugin {
this.verbose(1, "Blacklisted Layers/Levels: " + this.options.layerLevelBlacklist.join(', ')) this.verbose(1, "Blacklisted Layers/Levels: " + this.options.layerLevelBlacklist.join(', '))
// await this.checkUpdates(); // await this.checkUpdates();
this.timeframeOptionOverrider(); this.timeframeOptionOverrider();
setInterval(this.timeframeOptionOverrider, 5 * 60 * 1000) setInterval(this.timeframeOptionOverrider, 1 * 60 * 1000)
} }
async unmount() { async unmount() {
@ -179,9 +179,19 @@ export default class MapVote extends DiscordBasePlugin {
const timeNow = new Date(0, 0, 0, new Date().getHours(), new Date().getMinutes()); const timeNow = new Date(0, 0, 0, new Date().getHours(), new Date().getMinutes());
const activeTimeframes = this.or_options.timeFrames.filter(tfFilter); const activeTimeframes = this.or_options.timeFrames.filter(tfFilter);
console.log(activeTimeframes) let logTimeframe = "Active Time Frames: ";
let activeTfIds = [];
for (let atfK in activeTimeframes) {
const atf = activeTimeframes[ atfK ];
activeTfIds.push(atf.name || atf.id);
for(let o in atf.overrides){
this.options[o] = atf.overrides[o];
}
}
this.verbose(1, logTimeframe + activeTfIds.join(', '));
function tfFilter(tf) { function tfFilter(tf, key, arr) {
arr[ key ].id = key + 1;
const tfStartSplit = [ parseInt(tf.start.split(':')[ 0 ]), parseInt(tf.start.split(':')[ 1 ]) ]; const tfStartSplit = [ parseInt(tf.start.split(':')[ 0 ]), parseInt(tf.start.split(':')[ 1 ]) ];
const tfEndSplit = [ parseInt(tf.end.split(':')[ 0 ]), parseInt(tf.end.split(':')[ 1 ]) ]; const tfEndSplit = [ parseInt(tf.end.split(':')[ 0 ]), parseInt(tf.end.split(':')[ 1 ]) ];