wokibalaka

Make me a discord bot that has commands for all moderation powers, has text to speech or voice channels, can log messages, and everything else using every permission it has

Kodari AI
KodariJun 27 at 6:45 pm 42
OmniGuardBot
A fully-featured Discord moderation and utility bot leveraging every available permission. Includes complete moderation suite (ban, kick, mute, timeout, warn, purge, lockdown), text-to-speech in voice channels, comprehensive event & message logging, server administration tools (channel/role/emoji management), user info, polls, announcements, and invite tracking. All data persisted via SQLite. Built with discord.py using both prefix and slash commands.

Planning files before writing:

  • main.py — bot entry, cog loader, DB init

  • database.py — SQLite wrapper (warnings, log channels, configs)

  • cogs/moderation.py — ban, kick, mute, timeout, warn, purge, lock, slowmode, role ops

  • cogs/voice.py — join/leave, TTS via gTTS, move members, voice mute/deafen

  • cogs/logging_cog.py — message edit/delete, joins/leaves, voice state, role/channel changes

  • cogs/admin.py — channel/role/emoji CRUD, server settings, announcements, invites

  • cogs/utility.py — server info, user info, role info, polls, avatar, ping

  • requirements.txt — all deps

  • .env — token placeholder

  • config.json — prefix + color config


Here’s every file created and what it does:

File
Purpose
main.py
Bot entry point, cog loader, slash command sync, global error handler
database.py
Async SQLite wrapper — warnings, log channels, mute roles, invites
cogs/moderation.py
ban, softban, unban, kick, timeout, mute, warn, purge, slowmode, lock, role ops, nick, dehoist, massban, prune
cogs/voice.py
join/leave, TTS via gTTS (queued), voicemute/deafen, move, moveall, disconnectall
cogs/logging_cog.py
Messages (edit/delete/bulk), members (join/leave/ban/update), voice state, channels, roles, emojis, server, invites
cogs/admin.py
Channel/category CRUD, role CRUD, emoji management, announcements, server icon/banner, invites, permission overrides
cogs/utility.py
serverinfo, userinfo, avatar, ping, botinfo, uptime, channelinfo, membercount, rolecount, permissions, polls
config.json
Prefix and embed colors
.env
Bot token placeholder
requirements.txt
All dependencies

Quick start:

Shell
pip install -r requirements.txt
# Edit .env and add your token
python main.py

After the bot is running, do !sync (owner only) to register all slash commands globally. Set up logging with !setlog message #channel, !setlog mod #mod-logs, etc.

wokibalaka

Add a verification command that requires making the bot an authorized app and have the permission “join servers for you” included. With that make a command that can make everyone who authorized the app to be joined in the server the command is used in

Kodari can make mistakes. Review important code before using.
Files
cogs
config.json
database.py
main.py
requirements.txt
Code
9 1,919
main.py
import discord
from discord.ext import commands
import os
import json
import logging
from dotenv import load_dotenv
import database

load_dotenv()

logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
    handlers=[
        logging.FileHandler("bot.log"),
        logging.StreamHandler()
    ]
)
log = logging.getLogger("OmniGuardBot")

with open("config.json") as f:
    config = json.load(f)

intents = discord.Intents.all()

bot = commands.Bot(
    command_prefix=config["prefix"],
    intents=intents,
    help_command=None,
    case_insensitive=True,
    description="OmniGuardBot — Full moderation, voice, logging, and admin control."
)
bot.config = config


COGS = [
    "cogs.moderation",
    "cogs.voice",
    "cogs.logging_cog",
    "cogs.admin",
    "cogs.utility",
]


@bot.event
async def on_ready():
    await database.init_db()
    log.info(f"Logged in as {bot.user} (ID: {bot.user.id})")
    await bot.change_presence(
        activity=discord.Activity(
            type=discord.ActivityType.watching,
            name=f"{config['prefix']}help | Guarding your server"
        )
    )
    try:
        synced = await bot.tree.sync()
        log.info(f"Synced {len(synced)} slash commands.")
    except Exception as e:
        log.error(f"Failed to sync slash commands: {e}")


@bot.command(name="sync", hidden=True)
@commands.is_owner()
async def sync_slash(ctx):
    synced = await bot.tree.sync()
    await ctx.send(f"✅ Synced `{len(synced)}` slash commands.")


@bot.command(name="help")
async def help_command(ctx, *, category: str = None):
    embed = discord.Embed(
        title="OmniGuardBot — Help",
        color=bot.config["embed_color"]
    )
    categories = {
        "moderation": "ban, kick, softban, unban, mute, unmute, timeout, untimeout, warn, warnings, clearwarns, delwarn, purge, slowmode, lock, unlock, lockcategory, role, addrole, removerole, nick, massnick, dehoist",
        "voice": "join, leave, tts, stop, move, voicemute, voiceunmute, voicedeafen, voiceundeafen, moveall, disconnectall",
        "logging": "setlog, viewlogs, clearlog",
        "admin": "createchannel, deletechannel, renamechannel, createcategory, deletecategory, createtextchannel, createvoicechannel, createrole, deleterole, editrole, roleinfo, emoji, addemoji, delemoji, renameemoji, announcement, setprefix, servericon, serverbanner, inviteinfo, invites, prunembers",
        "utility": "serverinfo, userinfo, avatar, ping, poll, endpoll, rolecount, channelinfo, membercount, botinfo, uptime, permissions",
    }
    if category and category.lower() in categories:
        embed.title = f"Help — {category.capitalize()}"
        embed.description = f"`{config['prefix']}" + f"`, `{config['prefix']}".join(categories[category.lower()].split(", ")) + "`"
    else:
        embed.description = "Use `!help <category>` for detailed commands."
        for cat, cmds in categories.items():
            preview = ", ".join(cmds.split(", ")[:4])
            embed.add_field(name=f"📁 {cat.capitalize()}", value=f"`{preview}`, and more...", inline=False)
    embed.set_footer(text="OmniGuardBot • All permissions utilized")
    await ctx.send(embed=embed)


@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.MissingPermissions):
        await ctx.send(embed=discord.Embed(description=f"❌ You lack permission: `{', '.join(error.missing_permissions)}`", color=bot.config["error_color"]))
    elif isinstance(error, commands.BotMissingPermissions):
        await ctx.send(embed=discord.Embed(description=f"❌ I lack permission: `{', '.join(error.missing_permissions)}`", color=bot.config["error_color"]))
    elif isinstance(error, commands.MemberNotFound):
        await ctx.send(embed=discord.Embed(description="❌ Member not found.", color=bot.config["error_color"]))
    elif isinstance(error, commands.RoleNotFound):
        await ctx.send(embed=discord.Embed(description="❌ Role not found.", color=bot.config["error_color"]))
    elif isinstance(error, commands.ChannelNotFound):
        await ctx.send(embed=discord.Embed(description="❌ Channel not found.", color=bot.config["error_color"]))
    elif isinstance(error, commands.CommandNotFound):
        pass
    elif isinstance(error, commands.MissingRequiredArgument):
        await ctx.send(embed=discord.Embed(description=f"❌ Missing argument: `{error.param.name}`", color=bot.config["error_color"]))
    elif isinstance(error, commands.BadArgument):
        await ctx.send(embed=discord.Embed(description=f"❌ Bad argument: {error}", color=bot.config["error_color"]))
    elif isinstance(error, commands.CommandOnCooldown):
        await ctx.send(embed=discord.Embed(description=f"⏳ Cooldown. Try again in `{error.retry_after:.1f}s`.", color=bot.config["warn_color"]))
    else:
        log.error(f"Unhandled error in {ctx.command}: {error}", exc_info=error)


async def load_cogs():
    for cog in COGS:
        try:
            await bot.load_extension(cog)
            log.info(f"Loaded cog: {cog}")
        except Exception as e:
            log.error(f"Failed to load cog {cog}: {e}", exc_info=e)


async def main():
    async with bot:
        await load_cogs()
        await bot.start(os.getenv("DISCORD_TOKEN"))


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