itzsharkiez

Maak een production-ready Discord bot in Node.js met discord.js v14 en mineflayer.

๐Ÿ“Œ DOEL Een Minecraft AFK bot service die meerdere gebruikers tegelijk kan hosten en die verkocht kan worden via Discord.

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” ๐Ÿ” AUTH & ROLLEN Gebruik role-based access control.

ADMIN ROLE ID: 1475219170349154486

USER ROLE ID: 1470659710364418123

Admins kunnen:

  • Alle bots bekijken
  • Bots van users starten/stoppen
  • Accounts beheren
  • Globale instellingen aanpassen
  • Alle actieve sessies zien

Users kunnen:

  • Alleen hun eigen Minecraft bot beheren
  • Hun eigen account linken
  • Hun eigen bot starten/stoppen
  • Instellingen wijzigen

Controleer rollen bij ELKE command en interaction.

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” โ›๏ธ MINECRAFT KOPPELING (MINEFLAYER) Users moeten hun Minecraft account kunnen linken met een slash command:

/link velden:

  • email
  • password
  • server_ip
  • version

Gebruik prismarine-auth voor Microsoft/Mojang login.

Sla data veilig op in:

  • sqlite database

Per user:

  • 1 actieve bot instantie

Features:

  • Auto reconnect bij kick / crash
  • Anti AFK (random bewegen / draaien / springen)
  • Auto /register en /login
  • Chat berichten sturen
  • Server join logging

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” ๐ŸŽฎ USER COMMANDS

/panel Stuurt een EMBED met knoppen:

KNOPPEN: โ–ถ Start bot โน Stop bot ๐Ÿ”„ Restart bot ๐Ÿ“Š Status โš™ Settings

/status Toont:

  • Online / Offline / Starting
  • Minecraft username
  • Server IP
  • Uptime
  • Laatste error

/unlink Verwijdert gekoppelde account

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” ๐Ÿ‘‘ ADMIN COMMANDS

/admin-panel Embed met:

  • Totaal aantal bots
  • Actieve bots
  • Bots per user

/force-start user /force-stop user /view user

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” ๐Ÿ’ฌ AUTO CHAT SYSTEEM Users kunnen instellen via panel:

  • Bericht inhoud
  • Interval in seconden

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” ๐Ÿง  EMBED DESIGN

Gebruik een mooie embed met:

Titel: ๐ŸŽฎ Minecraft AFK Bot Panel

Status indicator: ๐ŸŸข Online ๐Ÿ”ด Offline ๐ŸŸก Starting

Velden:

  • Username
  • Server
  • Uptime
  • Mode (AFK)

Gebruik Discord buttons en select menus.

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” ๐Ÿ“‚ PROJECT STRUCTUUR

Gebruik deze structuur:

/commands /events /mineflayer /database /embeds /utils

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” โš™๏ธ TECHNISCH

Gebruik:

  • Slash commands
  • InteractionCreate events
  • Config bestand
  • Environment variables
  • Error handling
  • Cooldowns
  • Logging systeem

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” ๐Ÿ’พ EXTRA

  • Bot moet meerdere users tegelijk ondersteunen
  • Memory leak preventie
  • Per user session manager
  • Graceful shutdown

Geef complete werkende code.

Kodari AI
KodariFeb 22 at 7:57 pm 1,148 (v2)
MinecraftAFKBot
A production-ready Discord bot built with Node.js and discord.js v14 that provides a Minecraft AFK bot service for multiple users. Users can link their Minecraft accounts via slash commands, manage AFK bots with features like auto-reconnect, anti-AFK movements, chat messaging, and server join logging. Implements role-based access control with admin and user roles, secure SQLite database storage, embeds with buttons for user panels, admin commands for moderation, and an auto-chat system. Supports concurrent sessions, memory leak prevention, and graceful shutdown.
MinecraftAFKBotService
A production-ready Discord bot service built with discord.js v14 and mineflayer, enabling multiple users to manage their own AFK Minecraft bots. Features role-based access control with admin and user roles, secure account linking via prismarine-auth, SQLite database storage, auto-reconnect, anti-AFK mechanisms, auto-chat system, and comprehensive command panels for bot management, status viewing, and administration.
Kodari can make mistakes. Review important code before using.
Files
commands
database
embeds
events
mineflayer
utils
config.js
deploy-commands.js
index.js
package.json
Code
21 734
index.js
const { Client, GatewayIntentBits, Collection } = require('discord.js');
const { token } = require('./config');
const fs = require('fs');
const path = require('path');

const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent,
  ],
});

client.commands = new Collection();

const commandsPath = path.join(__dirname, 'commands');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
  const filePath = path.join(commandsPath, file);
  const command = require(filePath);
  if ('data' in command && 'execute' in command) {
    client.commands.set(command.data.name, command);
  } else {
    console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
  }
}

const eventsPath = path.join(__dirname, 'events');
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));

for (const file of eventFiles) {
  const filePath = path.join(eventsPath, file);
  const event = require(filePath);
  if (event.once) {
    client.once(event.name, (...args) => event.execute(...args));
  } else {
    client.on(event.name, (...args) => event.execute(...args));
  }
}

client.login(token);