anchorxd0981

Develop a Discord bot that integrates with a Minecraft tiers website, allowing users to create and manage profiles linked to their Minecraft accounts. The bot should enable users to register their in-game names, change their skins (which will be displayed on the website), and track their ELO ratings through a Minecraft plugin. Ensure the bot utilizes a secure API key for authentication and includes features like profile updates, ELO tracking commands, and skin integration with the website's front-end.

Kodari AI
KodariMay 11 at 4:43 pm 9,232 (v2)
MinecraftTiersBot
A Discord bot that integrates with a Minecraft tiers website, allowing users to register and manage profiles linked to their Minecraft accounts. Features include IGN registration, skin updates displayed on the website, and ELO rating tracking synced via a Minecraft plugin. Secure API key authentication protects all endpoints. Users can update profiles, view ELO rankings, and manage skins directly from Discord, with all data reflected on the website's front-end in real time.

Here’s my plan before writing any code:

  • bot.py — Entry point, loads cogs, connects to Discord

  • config.py — Loads .env vars and exposes config constants

  • api.py — Async HTTP client wrapping all website API calls (auth, profiles, ELO, skins)

  • cogs/profile.py — /register, /profile, /update commands

  • cogs/elo.py — /elo, /leaderboard commands

  • cogs/skin.py — /skin command with Minecraft skin preview

  • cogs/admin.py — Admin-only commands for managing users

  • requirements.txt — Dependencies

  • .env.example — Template for environment variables

Here’s a summary of what was built:

Files created:

File
Purpose
bot.py
Entry point — boots the bot, loads all cogs, syncs slash commands
config.py
Loads and validates all
.env
variables at startup
api.py
Async HTTP client with
X-API-Key
auth for all website endpoints
cogs/profile.py
/register
,
/profile
,
/update
— user profile management
cogs/elo.py
/elo
,
/leaderboard
— ELO rating display and rankings
cogs/skin.py
/skin
,
/skinsearch
— skin URL updates and previews
cogs/admin.py
/admin-profile
,
/setelo
,
/removeuser
— admin-only controls
requirements.txt
Python dependencies
.env.example
Environment variable template

Setup steps:

  1. Copy .env.example → .env and fill in your values

  2. pip install -r requirements.txt

  3. python bot.py

All commands are slash commands. The API client sends X-API-Key on every request — your website backend just needs to validate that header on all /api/* routes.

anchorxd0981

how to add it to discord server

Kodari can make mistakes. Review important code before using.
Files
cogs
api.py
bot.py
config.py
requirements.txt
Code
8 560
bot.py
import discord
from discord.ext import commands
import logging
import asyncio
from config import DISCORD_TOKEN, API_BASE_URL, API_KEY
from api import TiersAPIClient

logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
)
logger = logging.getLogger(__name__)

COGS = [
    "cogs.profile",
    "cogs.elo",
    "cogs.skin",
    "cogs.admin",
]


class MinecraftTiersBot(commands.Bot):
    def __init__(self):
        intents = discord.Intents.default()
        intents.members = True
        super().__init__(command_prefix="!", intents=intents)
        self.api = TiersAPIClient(API_BASE_URL, API_KEY)

    async def setup_hook(self):
        for cog in COGS:
            try:
                await self.load_extension(cog)
                logger.info(f"Loaded cog: {cog}")
            except Exception as e:
                logger.error(f"Failed to load cog {cog}: {e}")

        await self.tree.sync()
        logger.info("Slash commands synced.")

    async def close(self):
        await self.api.close()
        await super().close()

    async def on_ready(self):
        logger.info(f"Logged in as {self.user} (ID: {self.user.id})")
        await self.change_presence(
            activity=discord.Activity(
                type=discord.ActivityType.watching,
                name="Minecraft Tiers | /register",
            )
        )

    async def on_app_command_error(
        self, interaction: discord.Interaction, error: discord.app_commands.AppCommandError
    ):
        logger.error(f"Unhandled app command error: {error}")
        msg = "❌ An unexpected error occurred. Please try again later."
        if interaction.response.is_done():
            await interaction.followup.send(msg, ephemeral=True)
        else:
            await interaction.response.send_message(msg, ephemeral=True)


async def main():
    bot = MinecraftTiersBot()
    async with bot:
        await bot.start(DISCORD_TOKEN)


if __name__ == "__main__":
    asyncio.run(main())