feat: Add commands to remove lockdown from channels and servers
This commit is contained in:
parent
c32f7959b1
commit
6af16c43e2
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user