gkceece

CREATE A DISCORD BOT HAT CAN MANAGE SERVER ,HAS BUILT IN MUSIC PLAYER,MOVER,LEVELING TRACKER,GOOD BYE,INVITE,WELCOME MESSAGE,

Kodari AI
KodariSep 8 at 7:11 am 2
ServerManagerBot
Discord bot managing servers with built-in music player, voice channel mover, leveling tracker, welcome/goodbye messages, and invite tracking. Uses discord.py, includes commands for moderation, music playback, user level progression, automated greeting/farewell notifications, and invite logging. Features configurable settings, database storage for levels and invites, and slash command support.
  1. Create the bot entry point with environment-based configuration, intents, extension loading, and centralized command error handling.

  2. Add persistent SQLite storage for guild greetings and leveling data.

  3. Add moderation/server-management commands, voice-channel mover tools, and invite utilities.

  4. Add a YouTube/FFmpeg music player with queue controls.

  5. Add welcome/goodbye messaging, XP tracking, rank, and leaderboard commands.

  1. Created a complete discord.py server-management bot with modular cogs.

  2. Added moderation commands: kick, ban, unban, timeout, purge, slowmode, lock, unlock, and server info.

  3. Added music playback with YouTube search/URLs, queue, pause, resume, skip, stop, and voice joining.

  4. Added voice-channel mover tools: move one member, move everyone, and move members to your channel.

  5. Added persistent SQLite leveling with XP, ranks, level-up notifications, and leaderboards.

  6. Added configurable welcome and goodbye messages with placeholders.

  7. Added server invite creation and bot OAuth invite commands.

  8. Added .env.example, dependency configuration, .gitignore, and setup documentation.

Run it with:

Shell
cp .env.example .env
pip install -r requirements.txt
python bot.py

FFmpeg must also be installed and available in your system PATH for music playback.

gkceece

what to do next

Kodari AI
KodariSep 8 at 7:25 am 1
  1. Create the Discord application

    • Click New Application.

    • Go to Bot β†’ Add Bot.

    • Copy the bot token. Never share it publicly.

  2. Enable required intents In Bot β†’ Privileged Gateway Intents, enable:

    • Presence Intent

    • Server Members Intent

    • Message Content Intent

  3. Configure the project From the project folder:

    Shell
    cp .env.example .env
    

    Open .env and add:

    Env
    DISCORD_TOKEN=your_bot_token_here
    PREFIX=!
    
  4. Install dependencies

    Shell
    pip install -r requirements.txt
    

    If pip does not work, try:

    Shell
    python -m pip install -r requirements.txt
    
  5. Install FFmpeg

    FFmpeg is required for music commands.

    • Windows: install FFmpeg and add its bin folder to PATH.

    • Ubuntu/Debian:

      Shell
      sudo apt update
      sudo apt install ffmpeg
      
    • macOS:

      Shell
      brew install ffmpeg
      
  6. Invite the bot In the Developer Portal, go to OAuth2 β†’ URL Generator and select:

    • bot

    • applications.commands

    Recommended permissions:

    • View Channels

    • Send Messages

    • Embed Links

    • Manage Messages

    • Kick Members

    • Ban Members

    • Moderate Members

    • Move Members

    • Connect

    • Speak

    Open the generated URL and add the bot to your server.

  7. Start the bot

    Shell
    python bot.py
    

    You should see a login message in the terminal.

  8. Test commands

    Try commands such as:

    Plain Text
    !help
    !serverinfo
    !rank
    !leaderboard
    !play song name
    !join
    !skip
    !move @user
    !invite
    
  9. Configure greetings

    Use the greeting commands shown by:

    Plain Text
    !help
    

    The bot will create its SQLite database automatically when it starts.

For production hosting, run it on a VPS, Railway, Render, or another service that supports persistent processes. Make sure the SQLite database is stored on persistent storage so level data is not lost.

gkceece

where to do this all

Kodari AI
KodariSep 8 at 7:28 am 1

Do everything in two places:

1. Discord Developer Portal

There you will:

  1. Create the bot application.

  2. Create the bot under Bot β†’ Add Bot.

  3. Copy the bot token.

  4. Enable:

    • Message Content Intent

    • Server Members Intent

    • Presence Intent

  5. Generate an invite link under OAuth2 β†’ URL Generator.

  6. Use the invite link to add the bot to your Discord server.

2. Your computer

Use a code editor such as Visual Studio Code.

Step 1: Create/open the project folder

Create a folder named:

Plain Text
ServerManagerBot

Put the bot files inside it:

Plain Text
ServerManagerBot/
β”œβ”€β”€ bot.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ .env.example
β”œβ”€β”€ README.md
β”œβ”€β”€ cogs/
└── services/

Open this folder in VS Code.

Step 2: Open the terminal

In VS Code, select:

Plain Text
Terminal β†’ New Terminal

Run the commands from this terminal.

Step 3: Create the environment file

On Windows, copy .env.example and rename the copy to:

Plain Text
.env

Open .env and add your token:

Env
DISCORD_TOKEN=paste_your_bot_token_here
PREFIX=!

Do not send this token to anyone.

Step 4: Install the Python packages

In the VS Code terminal, run:

Shell
python -m pip install -r requirements.txt

If that fails on Windows, try:

Shell
py -m pip install -r requirements.txt

Step 5: Install FFmpeg

FFmpeg is installed on your computer, not in Discord. It is required for music.

For Windows:

  1. Download FFmpeg from https://ffmpeg.org/download.html.

  2. Extract it.

  3. Add its bin folder to your Windows PATH.

  4. Restart VS Code.

Test it with:

Shell
ffmpeg -version

Step 6: Start the bot

In the same VS Code terminal, run:

Shell
python bot.py

Or on Windows:

Shell
py bot.py

Keep this terminal open. The bot is online while this command is running.

Where commands are used

After inviting the bot to your Discord server, type commands inside Discord channels:

Plain Text
!help
!serverinfo
!rank
!leaderboard
!invite
!join
!play music name
!skip
!move @username

The setup commands are run in the VS Code terminal. Bot commands are typed in Discord. The bot token and intents are configured in the Discord Developer Portal.

Kodari can make mistakes. Review important code before using.
Files
cogs
services
.gitignore
bot.py
README.md
requirements.txt
Code
13 852
bot.py
cp .env.example .env
pip install -r requirements.txt
python bot.py
import logging
import os

import discord
from discord.ext import commands
from dotenv import load_dotenv

from services.database import Database

load_dotenv()

logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s %(levelname)s %(name)s: %(message)s",
)
logger = logging.getLogger("kodari-bot")

TOKEN = os.getenv("DISCORD_TOKEN")
PREFIX = os.getenv("COMMAND_PREFIX", "!")
DATABASE_PATH = os.getenv("DATABASE_PATH", "bot.sqlite3")

intents = discord.Intents.default()
intents.members = True
intents.message_content = True
intents.voice_states = True


class ServerBot(commands.Bot):
    def __init__(self) -> None:
        super().__init__(
            command_prefix=PREFIX,
            intents=intents,
            help_command=commands.DefaultHelpCommand(no_category="Other commands"),
        )
        self.db = Database(DATABASE_PATH)

    async def setup_hook(self) -> None:
        extensions = (
            "cogs.moderation",
            "cogs.music",
            "cogs.mover",
            "cogs.leveling",
            "cogs.greetings",
            "cogs.invites",
        )
        for extension in extensions:
            await self.load_extension(extension)
            logger.info("Loaded extension %s", extension)

    async def close(self) -> None:
        self.db.close()
        await super().close()


bot = ServerBot()


@bot.event
async def on_ready() -> None:
    if bot.user is not None:
        logger.info("Logged in as %s (%s)", bot.user, bot.user.id)
        await bot.change_presence(activity=discord.Game(name=f"{PREFIX}help"))


@bot.event
async def on_command_error(ctx: commands.Context, error: commands.CommandError) -> None:
    if isinstance(error, commands.CommandNotFound):
        return
    if isinstance(error, commands.CommandOnCooldown):
        await ctx.send(f"Try again in {error.retry_after:.1f} seconds.", delete_after=5)
        return
    if isinstance(error, commands.MissingPermissions):
        await ctx.send("You do not have permission to use that command.", delete_after=6)
        return
    if isinstance(error, commands.BotMissingPermissions):
        await ctx.send("I am missing the permissions needed for that command.", delete_after=8)
        return
    if isinstance(error, commands.NoPrivateMessage):
        await ctx.send("That command can only be used in a server.", delete_after=6)
        return
    if isinstance(error, commands.MissingRequiredArgument):
        await ctx.send(f"Missing argument: `{error.param.name}`.", delete_after=6)
        return
    if isinstance(error, commands.BadArgument):
        await ctx.send("I could not understand one of those arguments.", delete_after=6)
        return
    if isinstance(error, discord.Forbidden):
        await ctx.send("Discord refused that action. Check my role position and permissions.", delete_after=8)
        return

    logger.exception("Unhandled command error in %s", getattr(ctx.command, "qualified_name", "unknown"), exc_info=error)
    await ctx.send("Something went wrong while running that command.", delete_after=8)


def main() -> None:
    if not TOKEN:
        raise RuntimeError("DISCORD_TOKEN is not set. Copy .env.example to .env and add your token.")
    bot.run(TOKEN, log_handler=None)


if __name__ == "__main__":
    main()