Automating Your Minecraft Server with a Discord Bot

Published on

Restart the server from Discord. Check player count without joining. Get crash alerts at 3 AM. Here is how to build or set up a Discord bot that manages your Minecraft server.

Written by Jochem, CEO of Space-Node, 5-10 years experience in game server hosting, VPS infrastructure, and 24/7 streaming solutions. Read author bio →

discord bot minecraft server automation guide

You are lying in bed and a player messages you: "The server is down." You get up, open your laptop, log into the panel, click Start. Two minutes of your life gone for something a bot could do in seconds.

A Discord bot connected to your server panel or game server lets you manage, monitor, and automate without ever opening the panel.


Option 1: DiscordSRV (Plugin-Level Automation)

DiscordSRV is a Minecraft plugin that bridges in-game chat with Discord. It also supports console access through Discord.

Setting Up Console Access

In plugins/DiscordSRV/config.yml, enable the console channel:

DiscordConsoleChannelId: "YOUR_CHANNEL_ID"

Create a private channel in Discord (only admins can see it). Paste the channel ID. Restart the server.

Now you can type Minecraft commands directly in that Discord channel:

say Server restarting in 5 minutes!
stop
whitelist add NewPlayer
ban GriefingPlayer griefing

The bot executes commands as if you typed them in the server console. Lock this channel to admin-only roles.

See our full DiscordSRV setup guide for complete configuration.


Option 2: Pterodactyl API Bot

If your server runs on Pterodactyl (like Space-Node), you can use the Pterodactyl API to control the server from a Discord bot.

What the API Can Do

EndpointAction
POST /servers/{id}/powerStart, stop, restart, kill the server
GET /servers/{id}/resourcesGet CPU, RAM, disk usage, player count
POST /servers/{id}/commandSend a console command
GET /servers/{id}Get server status and details

Creating an API Key

In the Pterodactyl panel:

  1. Click your profile (top right)
  2. Go to API Credentials
  3. Create a new API key
  4. Copy the key (you only see it once)

Simple Discord Bot (Node.js)

Here is a minimal bot that can restart your server:

const { Client, GatewayIntentBits } = require('discord.js');
const fetch = require('node-fetch');

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

const PANEL_URL = 'https://panel.yourhost.com';
const API_KEY = 'your-api-key';
const SERVER_ID = 'your-server-id';

client.on('messageCreate', async message => {
  if (!message.member.roles.cache.some(r => r.name === 'Admin')) return;

  if (message.content === '!restart') {
    await fetch(`${PANEL_URL}/api/client/servers/${SERVER_ID}/power`, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${API_KEY}`,
        'Content-Type': 'application/json',
        'Accept': 'application/json'
      },
      body: JSON.stringify({ signal: 'restart' })
    });
    message.reply('Server is restarting.');
  }

  if (message.content === '!status') {
    const res = await fetch(`${PANEL_URL}/api/client/servers/${SERVER_ID}/resources`, {
      headers: {
        'Authorization': `Bearer ${API_KEY}`,
        'Accept': 'application/json'
      }
    });
    const data = await res.json();
    const state = data.attributes.current_state;
    const memory = Math.round(data.attributes.resources.memory_bytes / 1024 / 1024);
    const cpu = data.attributes.resources.cpu_absolute.toFixed(1);
    message.reply(`Status: ${state} | RAM: ${memory} MB | CPU: ${cpu}%`);
  }
});

client.login('your-discord-bot-token');

Host this bot on the same VPS as your panel, or on a separate small server.


Option 3: Pre-Built Bots

If you do not want to code, several pre-built Discord bots work with Minecraft server panels:

BotFeatures
Crafty ControllerWeb panel + Discord integration
PteroBotPterodactyl API integration, power commands
YAGPDB + WebhooksCustom commands that trigger API calls

Search for "Pterodactyl Discord bot" on GitHub for community-built options.


Automated Alerts

The most valuable automation is crash alerts. If your server goes offline at 3 AM, you want to know immediately instead of waking up to angry messages.

Webhook Alerts

Create a Discord webhook in your alerts channel. Set up a cron job on the server that checks if the Minecraft process is running:

#!/bin/bash
# Check every 5 minutes if the server is online
if ! curl -s "https://panel.yourhost.com/api/client/servers/$SERVER_ID/resources" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Accept: application/json" | grep -q '"running"'; then

  curl -H "Content-Type: application/json" \
    -d '{"content":"The Minecraft server is DOWN. Check the panel."}' \
    "https://discord.com/api/webhooks/YOUR_WEBHOOK_URL"
fi

Add to crontab:

*/5 * * * * /home/user/check-server.sh

This pings your Discord channel if the server is not running. Simple and effective.


Scheduled Tasks

Use cron or your panel's scheduler to automate routine tasks:

TaskScheduleCommand
Daily restart4:00 AMPower signal: restart
Backup reminderSunday 2:00 AMDiscord webhook message
Player count logEvery hourAPI check + log to file
World border warningBefore expansion eventsConsole command via API

Security Considerations

  • Never share API keys in public channels or repositories
  • Restrict bot commands to admin-only Discord roles
  • Use a separate API key for the bot (so you can revoke it without affecting panel access)
  • The console channel in DiscordSRV gives full server access, so lock it down

Space-Node's Pterodactyl panel includes a full API for automation. Create bots, set up monitoring, and automate your server management. Get started here.

Host your Minecraft automation Discord bot 24/7 on Space-Node

Jochem

About the Author

Jochem, CEO of Space-Node, expert in game server hosting, VPS infrastructure, and 24/7 streaming solutions with 5-10 years experience.

Since 2023
500+ servers hosted
4.8/5 avg rating

I specialize in Minecraft, FiveM, Rust, and 24/7 streaming infrastructure, operating enterprise-grade AMD Ryzen 9 hardware in Netherlands datacenters.

View my full bio and credentials →

Start Your MC Server Now Today

Join content creators worldwide who trust our Minecraft infrastructure. Setup is instant and support is always available. Start from €0.90/mo (Dirt) or €2.70/mo (Coal) and go live in minutes.