我制作了一个机器人,它在某个聊天消息被识别时说一个问题,并考虑下面的另一个聊天消息是否是正确的答案。但机器人认为,他说的问题是错误的答案,并说这是不正确的。
//setup & createbot
const mineflayer = require('mineflayer')
var settings = {
username: "Bot",
host: "localhost",
port: 64390,
};
const bot = mineflayer.createBot(settings);
//question
bot.on('chat', function(username, message) {
if (message==='problem'){
bot.chat('What is the color of apple?')
let state = true
state=true
while (state){
if (message==='red or green'){
bot.chat('correct.')
state = false
}else{
bot.chat('incorrect.')
state=false
}
}
}
});
bot.on('kicked', console.log)
bot.on('error', console.log)发布于 2022-02-20 02:03:32
添加
if (username === bot.username) return到函数的顶部
https://stackoverflow.com/questions/71182165
复制相似问题