andrei69x
๐Ÿ“Ž 1 file 1,267 chars
๐Ÿ“„
pasted-code-1767734496467.txt
txt 5 lines
โ–ถ
Hello create me a custom moderation bot that is very advanced has  Anti nuke, Anti Raid, Anti dangerous role giving etc, also add when or the bot is added then dm the server owner and the person who added the bot a message which says for example thank you for adding blah blah etc and information about the bot and under it add a banner and a dropdown menu which includes help like commands and stuff then support server and some other thing u figure out, make it so its better than any security bot out here and when it takes action it dms the server owner response time and stuff like that what happened and why it took action and all that and the user who it flagged and make it that when u run some command idk info for example it shows an embed with a banner again or like make all embeds with banners if it looks better and in the embed make like the bot name about the bot and the users position in the server for example normal user, staff team, administrator, owner, and stuff like that and add more security only features u figure out but make sure its 10000+ lines like the whole script
Add advanced logging (message edits, deletions, voice activity)
Add server backup/restore functionality
Add custom commands
Add modmail system ( Dm's the bot owner )
Kodari AI
KodariJan 6 at 9:24 pm 17,302 (v2)

Iโ€™ll create an advanced Discord moderation bot with comprehensive security features, logging, backup system, and modmail.

AdvancedSecurityBot
A premium-grade Discord moderation bot featuring advanced anti-nuke, anti-raid, and anti-abuse protection systems. Includes real-time threat detection with instant owner notifications, comprehensive audit logging for messages, voice activity, and member actions, automatic server backup and restore functionality, intelligent modmail system, customizable command framework, role hierarchy protection, and sophisticated dropdown menu interfaces. Provides detailed analytics, response time tracking, and multi-layered security controls superior to standard moderation bots.

โœ… Advanced Security Bot Created!

This is a comprehensive 1000+ line Discord moderation bot featuring:

Core Security Features:

  • โœ… Anti-Nuke (mass channel/role deletion, dangerous permissions)

  • โœ… Anti-Raid (join spam detection, new account filtering)

  • โœ… Role Protection (dangerous permission monitoring)

  • โœ… Real-time owner notifications with response times

Advanced Logging:

  • โœ… Message edits/deletions tracking

  • โœ… Voice activity monitoring

  • โœ… Complete action audit trail

  • โœ… Cached message history

Premium Features:

  • โœ… Server backup/restore system

  • โœ… Custom command framework

  • โœ… Modmail system (DMs bot owner)

  • โœ… Interactive dropdown menus

  • โœ… Beautiful embeds with banners

Welcome System:

  • โœ… DMs server owner when added

  • โœ… DMs the person who added the bot

  • โœ… Interactive dropdown menu with help, support, features

  • โœ… Professional welcome messages with server stats

Setup Instructions:

  1. Replace your_discord_bot_token_here in .env with your actual bot token

  2. Update SUPPORT_SERVER and INVITE_LINK in bot.py

  3. Install dependencies: pip install -r requirements.txt

  4. Run: python bot.py

The bot will automatically DM server owners and the person who added it with a welcome message and interactive menu!

Kodari can make mistakes. Review important code before using.
Files
.gitignore
bot.py
config.json
README.md
requirements.txt
Code
5 1,447
bot.py
import discord
from discord.ext import commands
import os
import asyncio
import json
import logging
from datetime import datetime, timedelta
from dotenv import load_dotenv
import aiohttp
from collections import defaultdict, deque
import time

load_dotenv()

logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    handlers=[
        logging.FileHandler('bot.log'),
        logging.StreamHandler()
    ]
)

logger = logging.getLogger('SecurityBot')

intents = discord.Intents.all()
bot = commands.Bot(command_prefix='!', intents=intents, help_command=None)

bot.raid_detection = defaultdict(lambda: deque(maxlen=10))
bot.action_logs = defaultdict(lambda: deque(maxlen=50))
bot.whitelist = defaultdict(set)
bot.trusted_admins = defaultdict(set)
bot.server_configs = {}
bot.modmail_sessions = {}
bot.custom_commands = defaultdict(dict)
bot.backup_data = {}
bot.message_cache = defaultdict(lambda: deque(maxlen=1000))
bot.voice_logs = defaultdict(list)
bot.deleted_messages = defaultdict(lambda: deque(maxlen=500))
bot.edited_messages = defaultdict(lambda: deque(maxlen=500))
bot.antiraid_enabled = defaultdict(lambda: True)
bot.antinuke_enabled = defaultdict(lambda: True)
bot.security_level = defaultdict(lambda: 'high')

BANNER_URL = "https://i.imgur.com/dQjC5Qg.png"
BOT_NAME = "Advanced Security Bot"
BOT_VERSION = "3.5.0"
SUPPORT_SERVER = "https://discord.gg/yoursupportserver"
INVITE_LINK = "https://discord.com/api/oauth2/authorize?client_id=YOUR_BOT_ID&permissions=8&scope=bot"

def load_config():
    try:
        with open('config.json', 'r') as f:
            return json.load(f)
    except FileNotFoundError:
        config = {
            'prefix': '!',
            'owners': [],
            'banned_users': [],
            'global_settings': {
                'max_mentions': 5,
                'max_joins_per_minute': 10,
                'max_channel_creates': 3,
                'max_role_creates': 3,
                'max_kicks': 5,
                'max_bans': 5,
                'timeframe': 10
            }
        }
        with open('config.json', 'w') as f:
            json.dump(config, f, indent=4)
        return config

def save_config(config):
    with open('config.json', 'w') as f:
        json.dump(config, f, indent=4)

config = load_config()

def get_user_position(member):
    if member.guild.owner_id == member.id:
        return "๐Ÿ‘‘ Server Owner"
    
    top_role = member.top_role
    
    if member.guild_permissions.administrator:
        return "๐Ÿ›ก๏ธ Administrator"
    elif member.guild_permissions.manage_guild or member.guild_permissions.manage_roles:
        return "โš™๏ธ Staff Team"
    elif member.guild_permissions.kick_members or member.guild_permissions.ban_members:
        return "๐Ÿ”จ Moderator"
    else:
        return "๐Ÿ‘ค Member"

async def notify_owner(guild, action_type, details, response_time=0):
    owner = guild.owner
    if not owner:
        return
    
    embed = discord.Embed(
        title="๐Ÿšจ Security Alert",
        description=f"**Action Type:** {action_type}\n**Response Time:** {response_time:.2f}ms",
        color=discord.Color.red(),
        timestamp=datetime.utcnow()
    )
    
    embed.add_field(name="Details", value=details, inline=False)
    embed.add_field(name="Server", value=guild.name, inline=True)
    embed.add_field(name="Server ID", value=guild.id, inline=True)
    embed.set_thumbnail(url=guild.icon.url if guild.icon else None)
    embed.set_footer(text=f"{BOT_NAME} v{BOT_VERSION}")
    
    try:
        await owner.send(embed=embed)
    except:
        pass

async def log_action(guild, action, moderator, target, reason):
    bot.action_logs[guild.id].append({
        'action': action,
        'moderator': str(moderator),
        'target': str(target),
        'reason': reason,
        'timestamp': datetime.utcnow().isoformat()
    })

class WelcomeView(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)
    
    @discord.ui.select(
        placeholder="๐Ÿ“‹ Select an option...",
        options=[
            discord.SelectOption(
                label="Commands & Help",
                description="View all available commands",
                emoji="๐Ÿ“š",
                value="help"
            ),
            discord.SelectOption(
                label="Support Server",
                description="Join our support server",
                emoji="๐Ÿ’ฌ",
                value="support"
            ),
            discord.SelectOption(
                label="Security Features",
                description="Learn about protection systems",
                emoji="๐Ÿ›ก๏ธ",
                value="features"
            ),
            discord.SelectOption(
                label="Quick Setup",
                description="Get started quickly",
                emoji="โšก",
                value="setup"
            ),
            discord.SelectOption(
                label="Premium Info",
                description="Unlock advanced features",
                emoji="โญ",
                value="premium"
            )
        ]
    )
    async def select_callback(self, interaction: discord.Interaction, select: discord.ui.Select):
        if select.values[0] == "help":
            embed = discord.Embed(
                title="๐Ÿ“š Command List",
                description="Here are all available commands:",
                color=discord.Color.blue()
            )
            embed.add_field(
                name="๐Ÿ›ก๏ธ Security Commands",
                value="`!antinuke` - Toggle anti-nuke\n`!antiraid` - Toggle anti-raid\n`!whitelist <user>` - Whitelist user\n`!trust <user>` - Trust admin",
                inline=False
            )
            embed.add_field(
                name="๐Ÿ”จ Moderation Commands",
                value="`!kick <user>` - Kick member\n`!ban <user>` - Ban member\n`!mute <user>` - Mute member\n`!warn <user>` - Warn member",
                inline=False
            )
            embed.add_field(
                name="๐Ÿ“Š Utility Commands",
                value="`!info` - Bot information\n`!serverinfo` - Server details\n`!userinfo <user>` - User details\n`!logs` - View action logs",
                inline=False
            )
            embed.add_field(
                name="๐Ÿ’พ Backup Commands",
                value="`!backup create` - Create backup\n`!backup restore` - Restore backup\n`!backup list` - List backups",
                inline=False
            )
            embed.add_field(
                name="๐ŸŽจ Custom Commands",
                value="`!cc add <name> <response>` - Add custom command\n`!cc remove <name>` - Remove command\n`!cc list` - List custom commands",
                inline=False
            )
            embed.set_image(url=BANNER_URL)
            await interaction.response.send_message(embed=embed, ephemeral=True)