lockdown: cleanup and fixes? :)
This commit is contained in:
parent
0a6fc96246
commit
785ea868da
1 changed files with 9 additions and 6 deletions
|
@ -3,6 +3,7 @@ import asyncio
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from config import log_channel, staff_role_ids, participant_role, community_channels, general_channels, hacker_role, community_role
|
from config import log_channel, staff_role_ids, participant_role, community_channels, general_channels, hacker_role, community_role
|
||||||
|
|
||||||
|
|
||||||
class Lockdown:
|
class Lockdown:
|
||||||
"Lockdown Commands"
|
"Lockdown Commands"
|
||||||
|
|
||||||
|
@ -12,20 +13,22 @@ class Lockdown:
|
||||||
@commands.has_permissions(manage_messages=True)
|
@commands.has_permissions(manage_messages=True)
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
async def lock(self, ctx):
|
async def lock(self, ctx):
|
||||||
"Locks the channel"
|
"""Locks the channel"""
|
||||||
|
log_chan = self.bot.get_channel(log_channel)
|
||||||
if ctx.message.channel in community_channels:
|
if ctx.message.channel in community_channels:
|
||||||
roles = (hacker_role, community_role)
|
roles = (hacker_role, community_role)
|
||||||
else:
|
else:
|
||||||
roles = participant_role
|
roles = participant_role
|
||||||
overwrites = ctx.message.channel.overwrites_for(roles[0])
|
overwrites = ctx.message.channel.overwrites_for(roles[0])
|
||||||
if overwrites.send_message == False:
|
if not overwrites.send_message:
|
||||||
await ctx.send("The Channel is already locked!")
|
await ctx.send("This channel is already locked!")
|
||||||
return
|
return
|
||||||
overwrites.send_message = False
|
overwrites.send_message = False
|
||||||
overwrites.add_reactions = False
|
overwrites.add_reactions = False
|
||||||
await asyncio.gather(*(self.bot.edit_channel_permissions(ctx.message.channel, role, overwrites) for role in roles))
|
await asyncio.gather(*(self.bot.edit_channel_permissions(ctx.channel, role, overwrites) for role in roles))
|
||||||
await ctx.send("🔒 Channel locked down. Only staff members may speak. Do not bring the topic to other channels or risk disciplinary actions.")
|
await ctx.send("🔒 Channel locked down. Only staff members may speak. Do not bring the topic to other channels or risk disciplinary actions.")
|
||||||
ctx.send_message(modlog_channel, "Channel Lockdown for {channel} by {user}".format(ctx.message.channel.mention, ctx.message.author.mention))
|
await log_chan.send(f"Channel Lockdown for {ctx.channel.mention} by {ctx.author.mention}")
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(Lockdown(bot))
|
bot.add_cog(Lockdown(bot))
|
Loading…
Reference in a new issue