FridayNightFunkinBoyfriendBot/src/modules/command_loop.js

29 lines
708 B
JavaScript
Raw Normal View History

2024-07-07 15:44:16 -04:00
function command_loop (bot, options, config) {
bot.cloop = {
list: [],
add (command, interval) {
2024-08-09 23:26:27 -04:00
setTimeout(() => {
this.list.push({ timer: setInterval(() => bot.core.run(command), interval), command, interval })
}, 10)
bot.on('end', () => {
this.clear()
})
2024-07-07 15:44:16 -04:00
},
remove (index) {
clearInterval(this.list[index].timer)
2024-07-20 20:27:17 -04:00
bot.cloop.list.splice(index, 1)
2024-07-07 15:44:16 -04:00
},
clear () {
for (const cloop of this.list) clearInterval(cloop.timer)
this.list = []
}
}
2024-08-09 23:26:27 -04:00
/* bot.on('end', () => {
// clearInterval(this.list);
for (const cloop of this.list) console.log(cloop)
console.log('e')
})*/
2024-07-07 15:44:16 -04:00
}
module.exports = command_loop;