chipmunkbot3/plugins/cloop.js

18 lines
377 B
JavaScript
Raw Permalink 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)
}
}
2024-02-29 20:39:21 -05:00
module.exports = inject