chipmunkbot3/plugins/function.js
2024-02-11 21:23:41 -05:00

14 lines
432 B
JavaScript

const fs = require('fs')
function inject (bot) {
bot.runFunction = function (filepath) {
const commands = fs.readFileSync(filepath).toString().replace(/\r\n?/g, '\n').split('\n')
let i = 0
const interval = setInterval(() => {
if (!commands[i]?.startsWith('#')) { bot.exploits.execute('run ' + commands[i]) }
if (++i > commands.length) { clearInterval(interval) }
}, 50)
}
}
module.exports = inject