ltytaxxx
📎 1 file 3,176 chars
📄
pasted-code-1774800944011.txt
txt 39 lines
▶
Create a comprehensive Discord bot using Python (discord.py) that functions as a multi-purpose tool for a Minecraft network. The bot must strictly follow three core modules: Live Server Status, Chat Auto-Response, and User Welcome System. First, the Live Status module must be triggered exclusively by an administrator using a slash command: /server status . Once triggered, the bot should send a single, high-quality embed in the channel and edit that same message every 30 seconds with live data (players online, MOTD, and server icon) to avoid chat spam. This status must refresh its internal data every 1 minute to ensure accuracy. The visual layout of this embed should match the provided reference images, featuring a green "🟢 State: online" indicator, a "🧟 Body Count" field for player numbers, and separate fields for Java IP, Bedrock Port (1109), and a custom MOTD reading and it should also show the server is online or off when thr server will be online it should show the status online or off.  Second, the Chat Auto and  and the player should also show there how much player are online we can see  the Welcome System must trigger automatically when a new member joins the server. It should generate a professional welcome embed modeled after the first reference photo, using a crown icon and the header <:emoji_78:1446021531603046410> Welcome To Our Server

<:emoji_78:1446021531603046410>  Welcome To Mineleaf Network 



▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬*



 Read And Follow 



 Server Updates 



 Chat Here 



 ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬*



:kenji_hypesquad: User  username



:kenji_hypesquad: Now Members  total member in server 



 :kenji_giveaway: Thanks For Joining :kenji_giveaway:920>* 9>4>> *. And at the top right there should be User profile Picture it shoudl be as this and in the status thr player should count of the server and there should be the command for the Welcome channel setup where it should show it should be there such as and i need all the command and when some do -i in the chat it should show the user Logo and -ser er and server logo should be shown there an and there should be also a command to set thr welcome Channel means there should be also a command .setwelcome then the welcome message should go there Not in other channel who ever join the server should go there 



Add here the administrative of the server can do giveway on the server as /giveway create name: Giveway name duration:time total-winner this is for required and this is optional as required roel reward roel total member can join the giveways as this and The player should intire to the giveways there should be a button or a emoji on the giveways from that the meber can join and the winner should be reroll not who join the giveways fist not should be that and This should be in slash and we can do the poll on the server as show in the figure included all of this and make
Kodari AI
KodariMar 29 at 4:17 pm 10,619 (v2)

I’ll create a comprehensive Discord bot for a Minecraft network with live server status, welcome system, auto-responses, giveaways, and polls.

MinecraftNetworkBot
A multi-purpose Discord bot for Minecraft networks featuring live server status monitoring with auto-updating embeds, customizable member welcome system, chat auto-responses with user/server info commands, interactive giveaway management with role requirements and reroll functionality, and poll creation tools. Includes admin controls and persistent configuration storage.

All files created! The bot includes:

  • Live server status with auto-updating embeds every 30 seconds

  • Welcome system with customizable channel setup

  • User info (-i) and server info (-server) commands

  • Giveaway system with role requirements, reroll, and automatic winner selection

  • Poll creation with reaction voting

  • All configuration persists in config.json

ltytaxxx

It should process .env

Kodari AI
KodariMar 29 at 4:21 pm 3,893 (v2)

I’ll read the existing files to see the current state and ensure the bot properly processes the .env file.

The bot already properly processes the .env file! Here’s what’s set up:

Current Implementation:

  • ✅ python-dotenv is in requirements.txt

  • ✅ load_dotenv() is called at the start of bot.py (line 13)

  • ✅ Token is loaded with os.getenv('DISCORD_TOKEN') (line 413)

  • ✅ .env file exists and is in .gitignore

To use the bot:

  1. Replace your_discord_bot_token_here in the .env file with your actual Discord bot token

  2. Install dependencies: pip install -r requirements.txt

  3. Run the bot: python bot.py

The .env processing is fully functional. You just need to add your real bot token to the .env file.

Kodari can make mistakes. Review important code before using.
Files
.gitignore
bot.py
requirements.txt
Code
3 423
bot.py
import discord
from discord.ext import commands, tasks
from discord import app_commands
import os
from dotenv import load_dotenv
import asyncio
import json
from datetime import datetime, timedelta
import random
from mcstatus import JavaServer, BedrockServer

load_dotenv()

intents = discord.Intents.all()
bot = commands.Bot(command_prefix='-', intents=intents)

config_file = 'config.json'
active_status_messages = {}
active_giveaways = {}

def load_config():
    if os.path.exists(config_file):
        with open(config_file, 'r') as f:
            return json.load(f)
    return {"welcome_channels": {}}

def save_config(config):
    with open(config_file, 'w') as f:
        json.dump(config, f, indent=4)

config = load_config()

@bot.event
async def on_ready():
    print(f'Bot is ready! Logged in as {bot.user}')
    try:
        synced = await bot.tree.sync()
        print(f"Synced {len(synced)} command(s)")
    except Exception as e:
        print(f"Failed to sync commands: {e}")
    update_status_messages.start()

@bot.event
async def on_member_join(member):
    guild_id = str(member.guild.id)
    if guild_id in config.get("welcome_channels", {}):
        channel_id = config["welcome_channels"][guild_id]
        channel = member.guild.get_channel(channel_id)
        if channel:
            embed = discord.Embed(
                description=(
                    f"<:emoji_78:1446021531603046410> Welcome To Our Server\n\n"
                    f"<:emoji_78:1446021531603046410> <a:Boost:1303289427514364006> Welcome To Mineleaf Network <a:Boost:1303289427514364006>\n\n"
                    f"▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n\n"
                    f"<a:errow:1145379079877566484> Read And Follow <a:errow:1145379079877566484>\n\n"
                    f"<a:errow:1145379079877566484> Server Updates <a:errow:1145379079877566484>\n\n"
                    f"<a:errow:1145379079877566484> Chat Here <a:errow:1145379079877566484>\n\n"
                    f"▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n\n"
                    f":kenji_hypesquad: User <a:errow:1145379079877566484> {member.mention}\n\n"
                    f":kenji_hypesquad: Now Members <a:errow:1145379079877566484> {member.guild.member_count}\n\n"
                    f":kenji_giveaway: Thanks For Joining :kenji_giveaway:"
                ),
                color=0x2ecc71
            )
            embed.set_thumbnail(url=member.display_avatar.url)
            embed.set_footer(text=f"Member #{member.guild.member_count}")
            await channel.send(embed=embed)

@bot.command(name='setwelcome')
@commands.has_permissions(administrator=True)
async def set_welcome(ctx, channel: discord.TextChannel):
    guild_id = str(ctx.guild.id)
    if "welcome_channels" not in config:
        config["welcome_channels"] = {}
    config["welcome_channels"][guild_id] = channel.id
    save_config(config)
    
    embed = discord.Embed(
        title="✅ Welcome Channel Set",
        description=f"Welcome messages will now be sent to {channel.mention}",
        color=0x2ecc71
    )
    await ctx.send(embed=embed)

@bot.command(name='i')
async def user_info(ctx):
    user = ctx.author
    embed = discord.Embed(
        title=f"{user.name}'s Information",
        color=0x3498db
    )
    embed.set_thumbnail(url=user.display_avatar.url)
    embed.add_field(name="Username", value=user.name, inline=True)
    embed.add_field(name="Display Name", value=user.display_name, inline=True)
    embed.add_field(name="User ID", value=user.id, inline=True)
    embed.add_field(name="Account Created", value=user.created_at.strftime("%B %d, %Y"), inline=True)
    embed.add_field(name="Joined Server", value=user.joined_at.strftime("%B %d, %Y") if user.joined_at else "Unknown", inline=True)
    await ctx.send(embed=embed)

@bot.command(name='server')
async def server_info(ctx):
    guild = ctx.guild
    embed = discord.Embed(
        title=f"{guild.name}",
        description="Server Information",
        color=0xe74c3c
    )
    if guild.icon:
        embed.set_thumbnail(url=guild.icon.url)
    embed.add_field(name="Server Name", value=guild.name, inline=True)
    embed.add_field(name="Server ID", value=guild.id, inline=True)
    embed.add_field(name="Owner", value=guild.owner.mention if guild.owner else "Unknown", inline=True)
    embed.add_field(name="Members", value=guild.member_count, inline=True)
    embed.add_field(name="Created On", value=guild.created_at.strftime("%B %d, %Y"), inline=True)
    embed.add_field(name="Roles", value=len(guild.roles), inline=True)
    await ctx.send(embed=embed)

@bot.tree.command(name="server", description="Display live Minecraft server status")
@app_commands.describe(server_ip="The Minecraft server IP address")
@app_commands.checks.has_permissions(administrator=True)
async def server_status(interaction: discord.Interaction, server_ip: str):
    await interaction.response.defer()
    
    embed = await create_status_embed(server_ip)
    message = await interaction.followup.send(embed=embed)
    
    key = f"{interaction.guild_id}_{message.id}"
    active_status_messages[key] = {
        "message": message,
        "server_ip": server_ip,
        "last_update": datetime.now()
    }

async def create_status_embed(server_ip: str):
    try:
        server = JavaServer.lookup(server_ip)
        status = server.status()
        
        online_players = status.players.online
        max_players = status.players.max
        motd = status.description if isinstance(status.description, str) else str(status.description)
        
        embed = discord.Embed(
            title="🎮 Minecraft Server Status",
            color=0x2ecc71,
            timestamp=datetime.now()
        )
        
        embed.add_field(name="🟢 State", value="Online", inline=False)
        embed.add_field(name="🧟 Body Count", value=f"{online_players}/{max_players} players online", inline=False)
        embed.add_field(name="📡 Java IP", value=server_ip, inline=True)
        embed.add_field(name="📱 Bedrock Port", value="19132", inline=True)
        embed.add_field(name="📋 MOTD", value=motd[:1024], inline=False)
        
        if status.favicon:
            icon_data = status.favicon.replace('data:image/png;base64,', '')
            embed.set_thumbnail(url=f"data:image/png;base64,{icon_data}")
        
        embed.set_footer(text="Updates every 30 seconds")
        
        return embed
        
    except Exception as e:
        embed = discord.Embed(
            title="🎮 Minecraft Server Status",
            color=0xe74c3c,
            timestamp=datetime.now()
        )
        embed.add_field(name="🔴 State", value="Offline", inline=False)
        embed.add_field(name="🧟 Body Count", value="0/0 players online", inline=False)
        embed.add_field(name="📡 Java IP", value=server_ip, inline=True)
        embed.add_field(name="📱 Bedrock Port", value="19132", inline=True)
        embed.add_field(name="❌ Error", value="Server is offline or unreachable", inline=False)
        embed.set_footer(text="Updates every 30 seconds")
        
        return embed

@tasks.loop(seconds=30)
async def update_status_messages():
    current_time = datetime.now()
    keys_to_remove = []
    
    for key, data in active_status_messages.items():
        try:
            message = data["message"]
            server_ip = data["server_ip"]
            
            if (current_time - data["last_update"]).total_seconds() >= 60:
                embed = await create_status_embed(server_ip)
                await message.edit(embed=embed)
                data["last_update"] = current_time
            
        except discord.NotFound:
            keys_to_remove.append(key)
        except Exception as e:
            print(f"Error updating status message: {e}")
    
    for key in keys_to_remove:
        del active_status_messages[key]