feat: Add commands to remove lockdown from channels and servers

This commit is contained in:
Slipstream 2025-05-27 21:45:11 -06:00
parent c32f7959b1
commit 6af16c43e2
Signed by: slipstream
GPG Key ID: 13E498CE010AC6FD

View File

@ -58,6 +58,34 @@ class LockdownCog(commands.Cog):
await interaction.followup.send("Server lockdown lifted.")
@lockdown.command(name="remove_channel")
@app_commands.describe(channel="The channel to unlock")
@app_commands.checks.has_permissions(manage_channels=True)
async def channel_remove(self, interaction: discord.Interaction, channel: discord.TextChannel = None):
"""Removes lockdown from a channel."""
channel = channel or interaction.channel
overwrite = channel.overwrites_for(interaction.guild.default_role)
if overwrite.send_messages is None or overwrite.send_messages is True:
await interaction.response.send_message("Channel is not locked down.", ephemeral=True)
return
overwrite.send_messages = None
await channel.set_permissions(interaction.guild.default_role, overwrite=overwrite)
await interaction.response.send_message(f"Channel {channel.mention} unlocked.")
@lockdown.command(name="remove_server")
@app_commands.checks.has_permissions(administrator=True)
async def server_remove(self, interaction: discord.Interaction):
"""Removes lockdown from the entire server."""
await interaction.response.defer()
for channel in interaction.guild.text_channels:
overwrite = channel.overwrites_for(interaction.guild.default_role)
overwrite.send_messages = None
await channel.set_permissions(interaction.guild.default_role, overwrite=overwrite)
await interaction.followup.send("Server unlocked.")
async def setup(bot):
await bot.add_cog(LockdownCog(bot))