_tamimhassan_

Made a plugin that can run discord bot and it should create a main.py and it will work in 1.21.1 paper

Kodari AI
KodariFeb 11 at 3:16 pm 7,937 (v2)

I’ll create a Paper plugin that manages and runs a Discord bot written in Python.

DiscordBotRunner
A Paper plugin that creates and runs a Python Discord bot directly from Minecraft. Automatically generates main.py with discord.py bot code, manages the Python process lifecycle, and provides in-game commands to control the bot. Features include automatic bot startup/shutdown, configuration management for Discord token and bot settings, and real-time status monitoring. Supports custom bot commands and event handling through config.

Plugin created! DiscordBotRunner will create and manage a Python Discord bot from your Paper 1.21.1 server.

What it does:

  • Creates main.py with a complete Discord bot

  • Manages Python process lifecycle (start/stop/restart)

  • In-game commands to control the bot

  • Auto-starts on server startup (configurable)

  • Logs Discord bot output to server console

Setup:

  1. Build and install the plugin

  2. Install Python dependencies: pip install -r requirements.txt (in plugin folder)

  3. Add token to config.yml

  4. Use /discordbot start or restart server

Commands:

  • /discordbot start|stop|restart|status

Discord Bot Commands:

  • !ping - Test response

  • !hello - Greeting

  • !info - Bot information

The generated Python bot includes proper intents, error handling, and activity status. All bot output appears in your server console with [Discord Bot] prefix.

_tamimhassan_

this plugin can install python dependency itself?

Kodari AI
KodariFeb 11 at 3:27 pm 5,699 (v2)

No, this plugin does NOT automatically install Python dependencies.

Looking at the code:

  1. What it DOES do:

    • Creates requirements.txt with needed dependencies (discord.py, aiohttp)

    • Creates the main.py bot file

    • Runs the Python bot using the configured Python executable

  2. What it DOESN’T do:

    • Install the Python dependencies automatically

    • Run pip install -r requirements.txt

Users must manually install dependencies:

Shell
cd plugins/DiscordBotRunner/
pip install -r requirements.txt

This is shown in the README installation steps and in the error message when the bot fails to start:

Plain Text
"Make sure Python 3.8+ is installed and discord.py is available"
"Install with: pip install -r requirements.txt"

Would you like me to add automatic dependency installation? I could add a feature that:

  • Detects if dependencies are installed

  • Automatically runs pip install -r requirements.txt on first startup or when missing

  • Logs the installation progress to console

_tamimhassan_

yes

Kodari AI
KodariFeb 11 at 3:28 pm 786 (v2)

I need more context to help you. What would you like me to do with the DiscordBotRunner plugin?

For example:

  • Add a new feature?

  • Fix a bug?

  • Review the code?

  • Create new commands or managers?

  • Modify existing functionality?

Please describe what you’d like me to work on.

_tamimhassan_

Detects if dependencies are installed Automatically runs pip install -r requirements.txt on first startup or when missing Logs the installation progress to console

_tamimhassan_
  • Detects if dependencies are installed -Automatically runs pip install -r requirements.txt on first startup or when missing Logs the installation progress to console
Kodari AI
KodariFeb 11 at 3:30 pm 6,110 (v2)

I’ll add automatic Python dependency detection and installation to the plugin. Let me first check the current implementation.

I’ll add automatic dependency detection and installation with console logging.

Added automatic dependency detection and installation:

  • Checks if discord.py is installed before starting the bot

  • Auto-runs pip install -r requirements.txt on first startup or when dependencies are missing

  • Logs all installation progress to console with [pip] prefix

  • New config option python.auto-install-dependencies (defaults to true)

  • Can be manually triggered on bot restart

_tamimhassan_

there's a error

1 image attached
Kodari AI
KodariFeb 11 at 3:45 pm 9,037 (v2)

I can see the plugin is failing to install Python dependencies because pip3 is not found. Let me check the current code to understand how dependencies are being installed.

I can see the issue. The plugin is trying to run pip3 directly, but it’s not available in your container environment. The better approach is to use python3 -m pip which uses Python’s module system to run pip.

Fixed! The issue was that the plugin was trying to run pip3 directly, which isn’t available in your container environment.

What changed:

  • Changed pip installation from pip3 install -r requirements.txt to python3 -m pip install -r requirements.txt

  • This uses Python’s module system to run pip, which is much more reliable in containers

  • Updated error messages to show the correct command format

Reload the plugin and it should now install dependencies properly using Python’s built-in pip module.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
README.md
Code
7 593
src/main/java/com/discordbotrunner/DiscordBotRunner.java
package com.discordbotrunner;

import com.discordbotrunner.commands.DiscordBotCommand;
import com.discordbotrunner.managers.BotManager;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class DiscordBotRunner extends JavaPlugin {
    
    private BotManager botManager;
    
    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.botManager = new BotManager(this);
        
        getCommand("discordbot").setExecutor(new DiscordBotCommand(this));
        
        botManager.createPythonBot();
        
        if (getConfig().getBoolean("python.auto-start", true)) {
            getServer().getScheduler().runTaskLater(this, () -> {
                botManager.startBot();
            }, 40L);
        }
        
        getLogger().info("DiscordBotRunner has been enabled!");
    }
    
    @Override
    public void onDisable() {
        if (botManager != null) {
            botManager.stopBot();
        }
        getLogger().info("DiscordBotRunner has been disabled!");
    }
    
    public String getMessage(String path) {
        return getConfig().getString("messages." + path, "&cMessage not found: " + path)
            .replace("&", "§");
    }
}