Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix re-entering configuration phase for bot #3558

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ connect: (client) => {
`socks` is declared with `const socks = require('socks').SocksClient` and uses [this](https://www.npmjs.com/package/socks) package.
Some servers might reject the connection. If that happens try adding `fakeHost: MC_SERVER_ADDRESS` to your createBot options.

### How to handle re-entering the configuration phase?

In the latest versions of the server, the bot needs to support re-entering the configuration phase. This can be managed by updating the `createBot` function to handle re-entering the configuration phase. Ensure that the bot's implementation includes logic to manage this phase transition.

# Common Errors

### `UnhandledPromiseRejectionWarning: Error: Failed to read asymmetric key`
Expand Down
9 changes: 9 additions & 0 deletions lib/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,14 @@ function createBot (options = {}) {
bot.supportFeature = bot.registry.supportFeature
setTimeout(() => bot.emit('inject_allowed'), 0)
}

bot.on('kicked', (reason, loggedIn) => {
console.log(`Bot ${bot.username} kicked for:`, reason, 'logged in:', loggedIn)
// Wait for a while before trying again
setTimeout(() => {
createBot(options) // Attempt to reconnect after some time
}, 3000) // Wait for 3 seconds (3000 ms)
})

return bot
}
Loading