lockdown: Add lockdown
This commit is contained in:
parent
178bd55a6e
commit
bc85174a51
4 changed files with 68 additions and 24 deletions
|
@ -26,10 +26,10 @@ Based on https://gitlab.com/ao/dpybotbase
|
||||||
- [x] Moderation: approve-revoke (community)
|
- [x] Moderation: approve-revoke (community)
|
||||||
- [x] Moderation: addhacker-removehacker (hacker)
|
- [x] Moderation: addhacker-removehacker (hacker)
|
||||||
- [x] Moderation: probate-unprobate (participant)
|
- [x] Moderation: probate-unprobate (participant)
|
||||||
- [ ] Moderation: lock-soft-unlock (channel lockdown)
|
- [x] Moderation: lock-softlock-unlock (channel lockdown)
|
||||||
- [ ] Moderation: timelock (channel lockdown with time)
|
- [ ] Moderation: timelock (channel lockdown with time)
|
||||||
- [ ] Moderation: mute-unmute
|
- [ ] Moderation: mute-unmute
|
||||||
- [ ] Moderation: mutetime
|
- [ ] Moderation: mutetime (mute with time)
|
||||||
- [x] Moderation: playing
|
- [x] Moderation: playing
|
||||||
- [x] Moderation: botnickname
|
- [x] Moderation: botnickname
|
||||||
- [x] Moderation: nickname
|
- [x] Moderation: nickname
|
||||||
|
|
|
@ -43,6 +43,7 @@ initial_extensions = ['cogs.common',
|
||||||
'cogs.err',
|
'cogs.err',
|
||||||
'cogs.verification',
|
'cogs.verification',
|
||||||
'cogs.logs',
|
'cogs.logs',
|
||||||
|
'cogs.lockdown',
|
||||||
'cogs.legacy',
|
'cogs.legacy',
|
||||||
'cogs.links',
|
'cogs.links',
|
||||||
'cogs.mod',
|
'cogs.mod',
|
||||||
|
|
|
@ -11,6 +11,14 @@ class Legacy:
|
||||||
await ctx.send("This command was replaced with `.revoke <user> <role>`"
|
await ctx.send("This command was replaced with `.revoke <user> <role>`"
|
||||||
" on Robocop-NG, please use that instead.")
|
" on Robocop-NG, please use that instead.")
|
||||||
|
|
||||||
|
@commands.command(hidden=True)
|
||||||
|
async def softlock(self, ctx):
|
||||||
|
"""Use .lock True"""
|
||||||
|
await ctx.send("This command was replaced with `.lock True`"
|
||||||
|
" on Robocop-NG, please use that instead.\n"
|
||||||
|
"Also... good luck, and sorry for taking your time. "
|
||||||
|
"Lockdown rarely means anything good.")
|
||||||
|
|
||||||
@commands.command(hidden=True, aliases=["addhacker"])
|
@commands.command(hidden=True, aliases=["addhacker"])
|
||||||
async def unprobate(self, ctx):
|
async def unprobate(self, ctx):
|
||||||
"""Use .approve <user> <role>"""
|
"""Use .approve <user> <role>"""
|
||||||
|
|
|
@ -1,33 +1,68 @@
|
||||||
import discord
|
|
||||||
import asyncio
|
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from config import log_channel, staff_role_ids, named_roles, community_channels, general_channels
|
import config
|
||||||
|
|
||||||
|
|
||||||
class Lockdown:
|
class Lockdown:
|
||||||
"Lockdown Commands"
|
|
||||||
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
@commands.has_permissions(manage_messages=True)
|
def check_if_staff(ctx):
|
||||||
@commands.command(pass_context=True)
|
return any(r.id in config.staff_role_ids for r in ctx.author.roles)
|
||||||
async def lock(self, ctx):
|
|
||||||
"""Locks the channel"""
|
@commands.guild_only()
|
||||||
log_chan = self.bot.get_channel(log_channel)
|
@commands.check(check_if_staff)
|
||||||
if ctx.message.channel in community_channels:
|
@commands.command()
|
||||||
roles = (named_roles["hacker"], named_roles["community"])
|
async def lock(self, ctx, soft: bool = False):
|
||||||
|
"""Prevents people from speaking in current channel, staff only."""
|
||||||
|
log_channel = self.bot.get_channel(config.log_channel)
|
||||||
|
|
||||||
|
if ctx.channel.id in config.community_channels:
|
||||||
|
roles = [config.named_roles["community"],
|
||||||
|
config.named_roles["hacker"]]
|
||||||
else:
|
else:
|
||||||
roles = named_roles["participant"]
|
roles = [config.named_roles["participant"],
|
||||||
overwrites = ctx.message.channel.overwrites_for(roles[0])
|
ctx.guild.default_role.id]
|
||||||
if not overwrites.send_message:
|
|
||||||
await ctx.send("This channel is already locked!")
|
for role in roles:
|
||||||
return
|
await ctx.channel.set_permissions(ctx.guild.get_role(role),
|
||||||
overwrites.send_message = False
|
send_messages=False,
|
||||||
overwrites.add_reactions = False
|
reason=str(ctx.author))
|
||||||
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.")
|
public_msg = "🔒 Channel locked down. "
|
||||||
await log_chan.send(f"Channel Lockdown for {ctx.channel.mention} by {ctx.author.mention}")
|
if not soft:
|
||||||
|
public_msg += "Only staff members may speak. "\
|
||||||
|
"Do not bring the topic to other channels or risk "\
|
||||||
|
"disciplinary actions."
|
||||||
|
|
||||||
|
await ctx.send(public_msg)
|
||||||
|
msg = f"🔒 **Lockdown**: {ctx.channel.mention} by {ctx.author.mention} "\
|
||||||
|
f"| {self.bot.escape_message(ctx.author)}"
|
||||||
|
# ":unlock: Channel unlocked."
|
||||||
|
await log_channel.send(msg)
|
||||||
|
|
||||||
|
@commands.guild_only()
|
||||||
|
@commands.check(check_if_staff)
|
||||||
|
@commands.command()
|
||||||
|
async def unlock(self, ctx):
|
||||||
|
"""Unlocks speaking in current channel, staff only."""
|
||||||
|
log_channel = self.bot.get_channel(config.log_channel)
|
||||||
|
|
||||||
|
if ctx.channel.id in config.community_channels:
|
||||||
|
roles = [config.named_roles["community"],
|
||||||
|
config.named_roles["hacker"]]
|
||||||
|
else:
|
||||||
|
roles = [config.named_roles["participant"],
|
||||||
|
ctx.guild.default_role.id]
|
||||||
|
|
||||||
|
for role in roles:
|
||||||
|
await ctx.channel.set_permissions(ctx.guild.get_role(role),
|
||||||
|
send_messages=True,
|
||||||
|
reason=str(ctx.author))
|
||||||
|
|
||||||
|
await ctx.send("🔓 Channel unlocked.")
|
||||||
|
msg = f"🔓 **Unlock**: {ctx.channel.mention} by {ctx.author.mention} "\
|
||||||
|
f"| {self.bot.escape_message(ctx.author)}"
|
||||||
|
await log_channel.send(msg)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
|
|
Loading…
Reference in a new issue