Untitled
unknown
plain_text
21 days ago
905 B
3
Indexable
Never
import discord from discord.ext import commands intents = discord.Intents.default() intents.guilds = True bot = commands.Bot(command_prefix="!", intents=intents) # Define a list of whitelisted user IDs whitelisted_users = [123456789012345678, 234567890123456789] # Replace with actual user IDs @bot.event async def on_ready(): print(f"Logged in as {bot.user}") # Handle channel creation @bot.event async def on_guild_channel_create(channel): # Check if the user who created the channel is whitelisted audit_logs = await channel.guild.audit_logs(limit=1, action=discord.AuditLogAction.channel_create).flatten() creator = audit_logs[0].user if creator.id not in whitelisted_users: await channel.delete() print(f"Channel {channel.name} created by {creator.name} (ID: {creator.id}) and then deleted because they are not whitelisted.") bot.run('YOUR_BOT_TOKEN')
Leave a Comment