mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-30 10:56:55 -05:00
25 lines
664 B
JavaScript
25 lines
664 B
JavaScript
function inject (bot) {
|
|
bot.cloop = {
|
|
list: [],
|
|
add (command, interval, list = true /* list is used in the cloop command listing and eaglercrash */) {
|
|
const id = setInterval(() => bot.core.run(command), interval)
|
|
|
|
const thingsToPush /* ig not the best variable name */ = { id, interval, command, list }
|
|
bot.cloop.list.push(thingsToPush)
|
|
|
|
return thingsToPush
|
|
},
|
|
remove (item) {
|
|
clearInterval(bot.cloop.list[item].id)
|
|
|
|
bot.cloop.list.splice(item, 1)
|
|
},
|
|
clear () {
|
|
for (const interval of bot.cloop.list) clearInterval(interval.id)
|
|
|
|
bot.cloop.list = []
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = { inject }
|