2018-12-23 19:06:32 +00:00
|
|
|
import discord
|
|
|
|
import asyncio
|
|
|
|
from discord.ext import commands
|
2018-12-23 19:59:42 +00:00
|
|
|
from config import log_channel, staff_role_ids, named_roles, community_channels, general_channels
|
2018-12-23 19:06:32 +00:00
|
|
|
|
2018-12-23 19:15:44 +00:00
|
|
|
|
2018-12-23 19:06:32 +00:00
|
|
|
class Lockdown:
|
|
|
|
"Lockdown Commands"
|
|
|
|
|
|
|
|
def __init__(self, bot):
|
|
|
|
self.bot = bot
|
|
|
|
|
|
|
|
@commands.has_permissions(manage_messages=True)
|
|
|
|
@commands.command(pass_context=True)
|
|
|
|
async def lock(self, ctx):
|
2018-12-23 19:15:44 +00:00
|
|
|
"""Locks the channel"""
|
|
|
|
log_chan = self.bot.get_channel(log_channel)
|
2018-12-23 19:06:32 +00:00
|
|
|
if ctx.message.channel in community_channels:
|
2018-12-23 19:59:42 +00:00
|
|
|
roles = (named_roles["hacker"], named_roles["community"])
|
2018-12-23 19:06:32 +00:00
|
|
|
else:
|
2018-12-23 19:59:42 +00:00
|
|
|
roles = named_roles["participant"]
|
2018-12-23 19:06:32 +00:00
|
|
|
overwrites = ctx.message.channel.overwrites_for(roles[0])
|
2018-12-23 19:15:44 +00:00
|
|
|
if not overwrites.send_message:
|
|
|
|
await ctx.send("This channel is already locked!")
|
2018-12-23 19:06:32 +00:00
|
|
|
return
|
|
|
|
overwrites.send_message = False
|
|
|
|
overwrites.add_reactions = False
|
2018-12-23 19:15:44 +00:00
|
|
|
await asyncio.gather(*(self.bot.edit_channel_permissions(ctx.channel, role, overwrites) for role in roles))
|
2018-12-23 19:06:32 +00:00
|
|
|
await ctx.send("🔒 Channel locked down. Only staff members may speak. Do not bring the topic to other channels or risk disciplinary actions.")
|
2018-12-23 19:15:44 +00:00
|
|
|
await log_chan.send(f"Channel Lockdown for {ctx.channel.mention} by {ctx.author.mention}")
|
|
|
|
|
2018-12-23 19:08:34 +00:00
|
|
|
|
2018-12-23 19:06:32 +00:00
|
|
|
def setup(bot):
|
2018-12-23 19:15:44 +00:00
|
|
|
bot.add_cog(Lockdown(bot))
|