Check if there's a raid
user_message_count = sum(1 for user_id, _ in recent_messages if user_id == message.author.id)
if user_message_count >= RAID_THRESHOLD:
# Possible raid detected, take action
await message.delete() # Delete the message
await message.author.ban(reason="Detected raiding behavior.")
print(f"Banned {message.author.name} for potential raid.")
await message.channel.send(f"User {message.author.name} was banned for raiding behavior.")
await client.process_commands(message)
Anti-Nuke: Monitor and react to mass message deletions or role changes
@client.event
async def on_guild_role_update(before, after):
# Check for any significant changes in roles that could indicate an attempt to nuke the server
if len(before.permissions) != len(after.permissions):
# Log the event, possibly alert staff
print(f"Role change detected: {before.name} -> {after.name}")
@client.event
async def on_guild_member_update(before, after):
# If user role changes significantly or if user becomes an admin unexpectedly
if "admin" in [role.name.lower() for role in before.roles] and "admin" not in [role.name.lower() for role in after.roles]:
print(f"Suspicious role removal detected for {after.name}")
@client.event
async def on_message_delete(message):
# If a large number of messages are deleted within a short time, it's a raid attempt
print(f"Message deleted in {message.channel.name} by {message.author.name}: {message.content}")
Command for bot owner to check suspicious users manually
@client.command()
async def check_suspicious(ctx):
if suspicious_users: {', '.join([str(user) for user in suspicious_users])}")
else:
await ctx.send("No suspicious users detected.")
Command to start the bot
@client.command()
async def start(ctx):
await ctx.send("Bot is now monitoring for raids and suspicious accounts!")
Run the bot with your token
client.run('YOUR_BOT_TOKEN')