gunner2clean

make a bot that is able to do commands like !ban and etc

Kodari AI
KodariJul 17 at 3:38 am 1

I’ll create a Discord moderation bot with essential moderation commands.

ModerationBot
A Discord moderation bot with essential server management commands. Features include ban, kick, mute/unmute, warn tracking, and message purge. Uses a cog-based structure for modularity, command-specific permission checks, and JSON-based warning storage. Designed for easy setup with environment variables for the bot token.</project_descriptionI'll create a Discord moderation bot with essential moderation commands.
A Discord moderation bot with powerful moderation commands including ban, kick, timeout/mute, warn, purge, and channel management. Features include a warning system with persistent storage, timed mute support, embed-based responses, command error handling, and role-based permission checks. Designed for server moderation teams to efficiently manage their communities.

Project created. Here’s the structure:

File
Purpose
.env
Token storage
requirements.txt
Dependencies
config.py
Bot settings (prefix, colors, role names)
bot.py
Entry point, loads cogs, owner commands
cogs/moderation.py
All moderation commands
cogs/events.py
Event handlers (ready, errors)
utils/helpers.py
Embed builders, duration formatting
utils/database.py
JSON-based warning persistence

Commands available:

Command
Permission
Description
!kick @user [reason]
Kick Members
Kick a member
!ban @user [reason]
Ban Members
Ban a member
!unban <id/tag>
Ban Members
Unban a user
!timeout @user <duration> [reason]
Moderate Members
Timeout (e.g.
10m
,
2h
,
1d
)
!untimeout @user
Moderate Members
Remove timeout
!warn @user [reason]
Moderate Members
Warn a user (auto-bans at 3 warnings)
!warnings @user
Moderate Members
View warnings
!delwarn @user <id>
Moderate Members
Remove a specific warning
!clearwarns @user
Admin
Clear all warnings
!purge <amount>
Manage Messages
Bulk delete (1-100)
!lock [#channel]
Manage Channels
Lock a channel
!unlock [#channel]
Manage Channels
Unlock a channel
!slowmode <seconds> [#channel]
Manage Channels
Set slowmode
!nuke [#channel]
Admin
Clone + delete channel to reset it
!ping
Everyone
Bot latency
!servers
Bot Owner
List servers

To run: Edit .env with your token, then pip install -r requirements.txt && python bot.py.

Kodari can make mistakes. Review important code before using.
Files
cogs
utils
bot.py
config.py
requirements.txt
Code
9 483
bot.py
import discord
from discord.ext import commands
import os
import asyncio
from dotenv import load_dotenv

from config import PREFIX

load_dotenv()

TOKEN = os.getenv("<redacted>")
if not TOKEN or TOKEN == "<redacted>"
    raise ValueError("<redacted>")

intents = discord.Intents.all()

bot = commands.Bot(
    command_prefix=PREFIX,
    intents=intents,
    help_command=commands.DefaultHelpCommand(),
    case_insensitive=True,
)


@bot.command(name="ping", help="Check bot latency")
async def ping(ctx: commands.Context):
    await ctx.send(f"Pong! `{round(bot.latency * 1000)}ms`")


@bot.command(name="servers", help="List servers the bot is in")
@commands.is_owner()
async def servers(ctx: commands.Context):
    guilds = "\n".join(f"{g.name} ({g.id}) — {g.member_count} members" for g in bot.guilds)
    await ctx.send(f"**Servers ({len(bot.guilds)}):**\n{guilds}")


async def main():
    async with bot:
        for filename in ["cogs.moderation", "cogs.events"]:
            try:
                await bot.load_extension(filename)
                print(f"Loaded {filename}")
            except Exception as e:
                print(f"Failed to load {filename}: {e}")
        await bot.start("<redacted>")


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