22 lines
430 B
JavaScript
22 lines
430 B
JavaScript
|
function inject (bot, options) {
|
||
|
bot.cloop = {
|
||
|
list: [],
|
||
|
|
||
|
add (command, interval) {
|
||
|
this.list.push({ timer: setInterval(() => bot.core.run(command), interval), command, interval })
|
||
|
},
|
||
|
|
||
|
remove (index) {
|
||
|
clearInterval(this.list[index].timer)
|
||
|
},
|
||
|
|
||
|
clear () {
|
||
|
for (const cloop of this.list) clearInterval(cloop.timer)
|
||
|
|
||
|
this.list = []
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = inject
|