Untitled
import discord from discord.ext import commands intents = discord.Intents.default() intents.guilds = True intents.guild_messages = True bot = commands.Bot(command_prefix="!", intents=intents) @bot.event async def on_ready(): print(f"Logged in as {bot.user}") # Undo channel creation @bot.event async def on_guild_channel_create(channel): await channel.delete() print(f"Channel {channel.name} created and then deleted.") # Undo channel deletion @bot.event async def on_guild_channel_delete(channel): guild = channel.guild # Attempt to recreate the channel with the same settings if isinstance(channel, discord.TextChannel): await guild.create_text_channel(name=channel.name, category=channel.category, position=channel.position, topic=channel.topic, nsfw=channel.is_nsfw(), overwrites=channel.overwrites, slowmode_delay=channel.slowmode_delay) elif isinstance(channel, discord.VoiceChannel): await guild.create_voice_channel(name=channel.name, category=channel.category, position=channel.position, bitrate=channel.bitrate, user_limit=channel.user_limit, overwrites=channel.overwrites) elif isinstance(channel, discord.CategoryChannel): await guild.create_category(name=channel.name, position=channel.position, overwrites=channel.overwrites) print(f"Channel {channel.name} deleted and then recreated.") bot.run('YOUR_BOT_TOKEN')
Leave a Comment