rebolex.li

Create a discord Security Bot Named R.B.L.X. . AND THIS BOT DEVELOPED BY Rebolex and this bot works like. Antinuke logic. Have some commnds like -/antinuke enable,/antinuke disable./antinuke whitelist add <user> /antinuke whitelist remove <user> then /antinuke punishment set <kick/ban/timeout>.The top role holder of server can only manage this bot /antinuke system everything and must have administration owner and top role holder with administrative only able to config this bot and use antinuke commands and also the user added by this command too /antinuke admin add <user> /antinuke admin remove <user> and will give punishment to the non whitelisted user or who is trying to nuke server like - Kick member, baning member, deleting multiple channel and renameing multiple channel, creating multiple channel and it will instant kick and ban them but not whitelisted person

Kodari AI
KodariMar 23 at 9:47 am 8,254 (v2)

I’ll create a comprehensive Discord security bot with anti-nuke protection and advanced management features.

RBLXSecurityBot
R.B.L.X. is an advanced Discord security bot developed by Rebolex that provides comprehensive anti-nuke protection. Features include real-time monitoring of suspicious activities like mass kicks, bans, channel deletions, and modifications. Includes whitelist system, admin management, customizable punishments (kick/ban/timeout), and audit log tracking. Only server owners and top-role administrators can configure the system, ensuring maximum security against server raids and malicious actions.

✅ R.B.L.X. Security Bot created successfully!

The bot includes:

  • ✅ Complete anti-nuke protection with audit log monitoring

  • ✅ Slash commands for all features (/antinuke with autocomplete)

  • ✅ Whitelist system to protect trusted users

  • ✅ Admin management system (/antinuke admin add/remove)

  • ✅ Configurable punishments (kick/ban/timeout)

  • ✅ Permission system (only owner, top admin role holders, or added admins can configure)

  • ✅ Real-time detection of mass kicks, bans, channel deletions/creations/modifications

  • ✅ Automatic punishment for suspicious activities

  • ✅ Configuration persistence with JSON storage

  • ✅ Beautiful embeds with branding (“Developed by Rebolex”)

To run: Add your Discord bot token to .env, install requirements (pip install -r requirements.txt), and run python bot.py

Kodari can make mistakes. Review important code before using.
Files
.gitignore
bot.py
README.md
requirements.txt
Code
4 494
bot.py
import discord
from discord.ext import commands
from discord import app_commands
import json
import os
from dotenv import load_dotenv
from datetime import datetime, timedelta
from collections import defaultdict
import asyncio

load_dotenv()

intents = discord.Intents.default()
intents.guilds = True
intents.members = True
intents.bans = True
intents.message_content = True

bot = commands.Bot(command_prefix='!', intents=intents)

CONFIG_FILE = 'config.json'
ACTION_THRESHOLD = 3
ACTION_TIMEFRAME = 10

action_tracker = defaultdict(lambda: defaultdict(list))

def load_config():
    if os.path.exists(CONFIG_FILE):
        with open(CONFIG_FILE, 'r') as f:
            return json.load(f)
    return {}

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

def get_guild_config(guild_id):
    config = load_config()
    guild_id_str = str(guild_id)
    if guild_id_str not in config:
        config[guild_id_str] = {
            'enabled': False,
            'whitelist': [],
            'admins': [],
            'punishment': 'ban'
        }
        save_config(config)
    return config[guild_id_str]

def update_guild_config(guild_id, guild_config):
    config = load_config()
    config[str(guild_id)] = guild_config
    save_config(config)

def is_authorized(guild: discord.Guild, member: discord.Member):
    if guild.owner_id == member.id:
        return True
    
    if member.guild_permissions.administrator:
        top_role = None
        for m in guild.members:
            if m.guild_permissions.administrator:
                if top_role is None or (m.top_role.position > top_role.position):
                    top_role = m.top_role
        
        if member.top_role == top_role:
            return True
    
    guild_config = get_guild_config(guild.id)
    if member.id in guild_config['admins']:
        return True
    
    return False

def is_whitelisted(guild_id, member_id):
    guild_config = get_guild_config(guild_id)
    return member_id in guild_config['whitelist']

async def track_action(guild_id, user_id, action_type):
    now = datetime.now()
    actions = action_tracker[guild_id][user_id]
    
    actions.append({'type': action_type, 'time': now})
    
    actions[:] = [a for a in actions if now - a['time'] < timedelta(seconds=ACTION_TIMEFRAME)]
    
    if len(actions) >= ACTION_THRESHOLD:
        return True
    return False

async def punish_user(guild: discord.Guild, member: discord.Member, punishment_type: str):
    try:
        if punishment_type == 'kick':
            await member.kick(reason='Anti-nuke: Suspicious activity detected')
        elif punishment_type == 'ban':
            await member.ban(reason='Anti-nuke: Suspicious activity detected')
        elif punishment_type == 'timeout':
            await member.timeout(timedelta(hours=24), reason='Anti-nuke: Suspicious activity detected')
        
        action_tracker[guild.id][member.id].clear()
        
        owner = guild.owner
        if owner:
            try:
                embed = discord.Embed(
                    title='🛡️ Anti-Nuke Action Taken',
                    description=f'**User:** {member.mention} ({member.name})\n**Action:** {punishment_type.upper()}\n**Reason:** Suspicious activity detected',
                    color=discord.Color.red(),
                    timestamp=datetime.now()
                )
                embed.set_footer(text='R.B.L.X. Security Bot by Rebolex')
                await owner.send(embed=embed)
            except:
                pass
    except Exception as e:
        print(f'Error punishing user: {e}')

@bot.event
async def on_ready():
    print(f'╔════════════════════════════════════════╗')
    print(f'║  R.B.L.X. Security Bot is ONLINE!    ║')
    print(f'║  Developed by: Rebolex                ║')
    print(f'║  Logged in as: {bot.user.name:<20} ║')
    print(f'╚════════════════════════════════════════╝')
    
    try:
        synced = await bot.tree.sync()
        print(f'Synced {len(synced)} slash commands')
    except Exception as e:
        print(f'Error syncing commands: {e}')

@bot.event
async def on_audit_log_entry_create(entry: discord.AuditLogEntry):
    guild = entry.guild
    guild_config = get_guild_config(guild.id)
    
    if not guild_config['enabled']:
        return
    
    if entry.user.bot:
        return
    
    if is_whitelisted(guild.id, entry.user.id):
        return
    
    if guild.owner_id == entry.user.id:
        return
    
    if is_authorized(guild, entry.user):
        return
    
    trigger_punishment = False
    
    if entry.action == discord.AuditLogAction.kick:
        trigger_punishment = await track_action(guild.id, entry.user.id, 'kick')
    
    elif entry.action == discord.AuditLogAction.ban:
        trigger_punishment = await track_action(guild.id, entry.user.id, 'ban')
    
    elif entry.action == discord.AuditLogAction.channel_delete:
        trigger_punishment = await track_action(guild.id, entry.user.id, 'channel_delete')
    
    elif entry.action == discord.AuditLogAction.channel_create:
        trigger_punishment = await track_action(guild.id, entry.user.id, 'channel_create')
    
    elif entry.action == discord.AuditLogAction.channel_update:
        trigger_punishment = await track_action(guild.id, entry.user.id, 'channel_update')
    
    if trigger_punishment:
        try:
            member = await guild.fetch_member(entry.user.id)
            await punish_user(guild, member, guild_config['punishment'])
        except Exception as e:
            print(f'Error fetching or punishing member: {e}')

@bot.tree.command(name='antinuke', description='Anti-nuke protection system management')
@app_commands.describe(
    action='Choose an action',
    subaction='Additional action parameter',
    user='Target user',
    punishment_type='Type of punishment (kick/ban/timeout)'
)
async def antinuke(
    interaction: discord.Interaction,
    action: str,
    subaction: str = None,
    user: discord.Member = None,
    punishment_type: str = None
):
    if not interaction.guild:
        await interaction.response.send_message('❌ This command can only be used in a server!', ephemeral=True)
        return
    
    if not is_authorized(interaction.guild, interaction.user):
        await interaction.response.send_message('❌ You do not have permission to use this command! Only server owner, top administrators, or added admins can manage anti-nuke settings.', ephemeral=True)
        return
    
    guild_config = get_guild_config(interaction.guild.id)
    
    if action == 'enable':