chipmunkbot3/plugins/cloop.js

18 lines
381 B
JavaScript
Raw Normal View History

2024-02-11 21:23:41 -05:00
function inject (bot) {
bot.cloops ??= []
setInterval(() => {
bot.cloops.forEach((cloop, i) => {
if (!cloop.timeout) loop(i)
})
}, 1)
function loop (i) {
if (bot.cloops[i] == null) { return }
bot.cloops[i].timeout = true
bot.core.run(bot.cloops[i].command)
setTimeout(() => loop(i), bot.cloops[i].interval)
}
}
module.exports.bot = inject