FridayNightFunkinBoyfriendBot/ChomensJS/plugins/cloop.js

26 lines
600 B
JavaScript
Raw Permalink Normal View History

2023-12-17 14:55:27 -05:00
function inject (bot) {
bot.cloop = {
list: [],
add (command, interval, list = true) {
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 }