18 lines
381 B
JavaScript
18 lines
381 B
JavaScript
|
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
|