added task generation
All checks were successful
Deploy Cletus Bot / deploy (push) Successful in 23s

This commit is contained in:
roberts 2025-05-10 19:57:09 -05:00
parent 2b5d49d5bc
commit 5f04f1344c

View file

@ -20,4 +20,20 @@ async function chatWithAI(message, overrides = {}) {
}
}
module.exports = { chatWithAI };
async function generateAndSaveTask(taskName, aiConfig = config.ai) {
const prompt = `Write a Mineflayer-compatible JavaScript task named "${taskName}".
The function should be defined as: module.exports = async function(bot, db, say) {...}
This task will be executed by an AI-powered Minecraft bot.
Do not include explanation, only the code.`;
try {
const code = await chatWithAI(prompt, aiConfig);
const filePath = path.join(__dirname, '../bot-tasks', `${taskName}.js`);
fs.writeFileSync(filePath, code, 'utf8');
console.log(`[AI] Task file generated: ${filePath}`);
} catch (err) {
console.error('[TASK GENERATION ERROR]', err.message);
}
}
module.exports = { chatWithAI, generateAndSaveTask };