A simple Node.js bot that automates “away from keyboard” (AFK) activity in Minecraft servers — ideal for keeping servers online 24/7 (Aternos,etc.) or looting/farming while you’re away.
- Connects to a Minecraft server and performs periodic actions to keep the character “active”.
- Configurable delay/timer settings.
- Lightweight and easy to run in the background.
docker run -d \
-e SERVER_HOST="example.com" \
-e SERVER_PORT="25565" \
-e BOT_USERNAME="AFKBot" \
-e BOT_CHUNK="2" \
-e MC_VERSION="false" \
ninjayubaraj/minecraft-afk-bot:latest- Node.js (version 14 or later recommended)
- A Minecraft Java-Edition Server (Cracked).
-
Clone the repository:
git clone https://github.com/Ninja-Yubaraj/Minecraft-AFK-Bot.git cd Minecraft-AFK-Bot -
Install dependencies:
npm install
-
Setup the
.env:- Create a
.envfile and fill in your server address, port, etc.
- Create a
-
Run the bot:
node bot.js
The bot will connect and begin its AFK loop of actions.
- On startup, the bot connects to the server via a Minecraft protocol library (e.g.,
minecraft-protocolor similar). - It executes a configurable action (e.g., minor movement, chat ping, etc) every
delayBetweenActionsMsmilliseconds to keep the session alive. - You can customize the behaviour in
bot.jsto suit your server’s AFK rules (for example, bouncing between two positions, sending periodic chat messages, farming tasks, etc).
- Use this bot only on servers where AFK automation is allowed by the rules. Many servers ban automated AFK behaviour.
- The bot is provided as-is. It may not bypass anti-AFK detection or server protections. Use responsibly.
- Make sure your account is secured — using your main account may carry risk if the server flags automation.
- Modify
bot.jsto change the action sequence (for example: walk → turn → jump → chat). - Add new behaviours: e.g., auto-farm a block, collect items, deposit loot, etc.
- Integrate with a scheduler or cron job to run at specific times.
- Extend logging or monitoring (e.g., send a message when the bot disconnects).
- Contributions are welcome!
- If you add new features, please open a pull request with a clear description of what you’ve added/changed.
- Please keep code style consistent with existing files.
- Add tests or usage examples if you’re implementing more advanced behaviour.
For issues or improvements, you can open an Issue in this repository. You can also reach me (Yubaraj Sarkar) via GitHub as Ninja-Yubaraj.