Open 112cxyz opened 2 years ago
Place the chat event outside of the spawn event.
bot.on("spawn", () => {
})
bot.on('chat', (username, message) => {
if (message === '!reboot') exit() // using pm2 to keep bot alive
else if (message === '!help') bot.chat('!reboot - Reboots Bot')
})
Versions
Detailed description of a problem
A clear and concise description of what the problem is, with as much context as possible. What are you building? What problem are you trying to solve?
Needed a simple player bot for a server I made that just afk's at a farm we made. I made it have a simple !reboot command and I left overnight. the bot got killed 12 times so I ran !help which tells you what !reboot does and it spammed it and got kicked for spam
I recreated it by killing the bot myself and each time I kill it it adds another line to the chat
Your current code
Expected behavior
It to say the command once.