test
All checks were successful
Deploy Cletus Bot / deploy (push) Successful in 24s

This commit is contained in:
roberts 2025-05-10 20:11:26 -05:00
parent 1e239ef9ff
commit 643e039bd8

View file

@ -15,21 +15,21 @@ async function chatWithAI(prompt, aiConfig) {
async function generateAndSaveTask(taskName, aiConfig) { async function generateAndSaveTask(taskName, aiConfig) {
const prompt = ` const prompt = `
You are an AI assistant in a Minecraft world. The player wants a new bot task called "${taskName}". You are generating a Minecraft Mineflayer bot task. The task name is: "${taskName}".
Return only the Node.js code for a module that exports an async function with this signature:
\`\`\`js You must return only a valid Node.js module that:
module.exports = async function(bot, db, say) { - Exports: \`module.exports = async function(bot, db, say) { ... }\`
// Implement the logic here - Uses only valid Mineflayer API methods.
}; - Do NOT use \`bot.inventory.find()\`. Use \`bot.inventory.items().find(...)\` instead.
\`\`\` - If accessing blocks, use \`bot.findBlock()\`, \`bot.blockAt()\`, or \`bot.openBlock()\`.
Only return valid JavaScript. Do not include explanation or extra text. - Only respond with valid JavaScript code. No comments or markdown.
`.trim(); `.trim();
try { try {
const response = await chatWithAI(prompt, aiConfig); const response = await chatWithAI(prompt, aiConfig);
let taskCode = response.trim(); let taskCode = response.trim();
// Strip surrounding triple backticks if present // Remove wrapping backticks if present
if (taskCode.startsWith('```')) { if (taskCode.startsWith('```')) {
taskCode = taskCode.replace(/```[a-z]*\n?/i, '').replace(/```$/, '').trim(); taskCode = taskCode.replace(/```[a-z]*\n?/i, '').replace(/```$/, '').trim();
} }