raghu123312

Create me a Discord bot like Corlbot with a dashboard and all features, and add a feature to set the icon and banner as the server owner needs for every server as the servers owner needs

Kodari AI
KodariJun 25 at 12:37 pm 85
CorlBotClone
A full-featured Discord bot with a web dashboard inspired by Corlbot. Includes moderation (ban/kick/mute/warn), auto-moderation (spam/links/bad words), welcome & leave messages, server event logging, reaction roles, giveaways, support tickets, polls, utility commands, and fun commands. Features a Discord OAuth2-powered web dashboard for per-server configuration, plus a dedicated server branding system letting server owners set their guild icon and banner via URL or file upload.

Hereโ€™s the full project โ€” bot + dashboard, all cogs, all templates, all wired together.

Plan:

  1. Core files: bot.py, database.py, config.py, requirements.txt, .env.example

  2. 11 cogs: moderation, automod, welcome, logging, roles, giveaways, tickets, polls, branding, utility, fun

  3. Dashboard: Flask app, OAuth2 auth, routes

  4. Dashboard templates: base layout, index, servers, all settings pages

  5. Static assets: CSS (dark Discord theme), JS



Hereโ€™s the complete setup guide:

๐Ÿš€ Quick Start

1. Install dependencies

Shell
pip install -r requirements.txt

2. Configure environment

Shell
cp .env.example .env
# Edit .env with your values

.env values you need:

Variable
Where to get it
DISCORD_TOKEN
โ†’ Bot โ†’ Token
DISCORD_CLIENT_ID
Developer Portal โ†’ General Information โ†’ Application ID
DISCORD_CLIENT_SECRET
Developer Portal โ†’ OAuth2 โ†’ Client Secret
DISCORD_REDIRECT_URI
Set as
http://localhost:5000/auth/callback
in OAuth2 Redirects
FLASK_SECRET_KEY
Any random string

3. Run the bot

Shell
python bot.py

The bot starts, loads all cogs, and automatically launches the dashboard on port 5000.


๐ŸŽจ Server Branding Commands

Command
Description
Who can use
!seticon <url>
Set server icon from URL
Server Owner / Admin
!seticon
+ attachment
Set icon from uploaded image
Server Owner / Admin
!setbanner <url>
Set banner (Level 2 required)
Server Owner / Admin
!removeicon
Remove server icon
Server Owner / Admin
!removebanner
Remove server banner
Server Owner / Admin
!setsplash <url>
Set invite splash (Level 1+)
Server Owner / Admin
!branding
View current icon & banner
Everyone

The dashboard branding page (/dashboard/<guildid>/branding) also allows drag-and-drop file upload or URL input for icon, banner, and splash โ€” exclusively visible to owners and admins.

Kodari can make mistakes. Review important code before using.
Files
cogs
dashboard
bot.py
config.py
database.py
requirements.txt
Code
32 4,191
bot.py
import discord
from discord.ext import commands
import os
import asyncio
import threading
import logging
import datetime
from dotenv import load_dotenv
from database import Database
import config

load_dotenv()

logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
    datefmt="%Y-%m-%d %H:%M:%S",
)
logger = logging.getLogger("CorlBot")


class CorlBot(commands.Bot):
    def __init__(self):
        intents = discord.Intents.all()
        super().__init__(
            command_prefix=self._get_prefix,
            intents=intents,
            help_command=None,
            case_insensitive=True,
        )
        self.db = Database()
        self.start_time: datetime.datetime = None

    async def _get_prefix(self, bot, message: discord.Message):
        if not message.guild:
            return config.DEFAULT_PREFIX
        prefix = await self.db.get_prefix(message.guild.id)
        return commands.when_mentioned_or(prefix)(bot, message)

    async def setup_hook(self):
        await self.db.initialize()
        for cog in config.COGS:
            try:
                await self.load_extension(cog)
                logger.info(f"Loaded: {cog}")
            except Exception as e:
                logger.error(f"Failed to load {cog}: {e}")
        await self.tree.sync()
        logger.info("Slash commands synced.")

    async def on_ready(self):
        self.start_time = datetime.datetime.utcnow()
        logger.info(f"Ready: {self.user} (ID: {self.user.id}) | {len(self.guilds)} guilds")
        await self.change_presence(
            activity=discord.Activity(
                type=discord.ActivityType.watching,
                name=f"{len(self.guilds)} servers | !help",
            )
        )
        self._start_dashboard()

    def _start_dashboard(self):
        from dashboard.app import create_app, set_bot

        app = create_app()
        set_bot(self)

        def run():
            app.run(
                host="0.0.0.0",
                port=config.DASHBOARD_PORT,
                debug=False,
                use_reloader=False,
            )

        t = threading.Thread(target=run, daemon=True, name="dashboard")
        t.start()
        logger.info(f"Dashboard running on port {config.DASHBOARD_PORT}")

    async def on_guild_join(self, guild: discord.Guild):
        await self.db.ensure_guild(guild.id)
        logger.info(f"Joined guild: {guild.name} ({guild.id})")

    async def on_command_error(self, ctx: commands.Context, error):
        if isinstance(error, commands.CommandNotFound):
            cmd = await self.db.get_custom_command(ctx.guild.id if ctx.guild else 0, ctx.invoked_with)
            if cmd:
                await ctx.send(cmd)
            return

        embed = discord.Embed(color=config.ERROR_COLOR)

        if isinstance(error, commands.MissingPermissions):
            embed.description = f"โŒ You need these permissions: `{'`, `'.join(error.missing_permissions)}`"
        elif isinstance(error, commands.BotMissingPermissions):
            embed.description = f"โŒ I need these permissions: `{'`, `'.join(error.missing_permissions)}`"
        elif isinstance(error, commands.MissingRequiredArgument):
            embed.description = f"โŒ Missing argument: `{error.param.name}`\nUsage: `{ctx.prefix}{ctx.command.qualified_name} {ctx.command.signature}`"
        elif isinstance(error, commands.BadArgument):
            embed.description = f"โŒ Invalid argument: {error}"
        elif isinstance(error, commands.CheckFailure):
            embed.description = "โŒ You don't have permission to use this command."
        elif isinstance(error, commands.CommandOnCooldown):
            embed.description = f"โณ Command on cooldown. Try again in `{error.retry_after:.1f}s`."
        else:
            logger.error(f"Unhandled error in {ctx.command}: {error}", exc_info=error)
            return

        await ctx.send(embed=embed, delete_after=8)


bot = CorlBot()


if __name__ == "__main__":
    if not config.DISCORD_TOKEN:
        logger.error("DISCORD_TOKEN is not set. Check your .env file.")
        exit(1)
    bot.run(config.DISCORD_TOKEN, log_handler=None)