From 832524eb56cc1a50acc122f361e294cea9f9577d Mon Sep 17 00:00:00 2001 From: tumGER <25822956+tumGER@users.noreply.github.com> Date: Sun, 23 Dec 2018 20:06:32 +0100 Subject: [PATCH] Implement lock --- cogs/links.py | 11 ++++++++++- cogs/lockdown.py | 31 +++++++++++++++++++++++++++++++ config.py.template | 5 +++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 cogs/lockdown.py diff --git a/cogs/links.py b/cogs/links.py index 77104f5..93fbb44 100644 --- a/cogs/links.py +++ b/cogs/links.py @@ -11,9 +11,18 @@ class Links: @commands.command(hidden=True) async def pegaswitch(self, ctx): - """test""" + """Link to the Pegaswitch repo""" await ctx.send("https://github.com/reswitched/pegaswitch") + @commands.command(hidden=True, aliases=["atmos"]) + async def Atmosphere(self, ctx): + """Link to the Atmosphere repo""" + await ctx.send("https://github.com/atmosphere-nx/atmosphere") + + @commands.command(hidden=True, aliases=["guides"]) + async def guide(self, ctx): + """Link to the guide(s)""" + await ctx.send("*AtlasNX's SDSetup-Guide:* https://guide.teamatlasnx.com \n *Noirscape's Guide:* http://switchguide.xyz/ \n *Pegaswitch Guide:* https://switch.hacks.guide/") def setup(bot): bot.add_cog(Links(bot)) diff --git a/cogs/lockdown.py b/cogs/lockdown.py new file mode 100644 index 0000000..e2f5d80 --- /dev/null +++ b/cogs/lockdown.py @@ -0,0 +1,31 @@ +import discord +import asyncio +from discord.ext import commands +from config import modlog_channel, staff_role_ids, participant_role, community_channels, general_channels, hacker_role, community_role + +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): + "Locks the channel" + if ctx.message.channel in community_channels: + roles = (hacker_role, community_role) + else: + roles = participant_role + overwrites = ctx.message.channel.overwrites_for(roles[0]) + if overwrites.send_message == False: + await ctx.send("The Channel is already locked!") + return + overwrites.send_message = False + overwrites.add_reactions = False + await asyncio.gather(*(self.bot.edit_channel_permissions(ctx.message.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.") + ctx.send_message(modlog_channel, "Channel Lockdown for {channel} by {user}".format(ctx.message.channel.mention, ctx.message.author.mention)) + +def setup(bot): + bot.add_cog(Lockdown(bot)) \ No newline at end of file diff --git a/config.py.template b/config.py.template index dca47dc..787f4fe 100644 --- a/config.py.template +++ b/config.py.template @@ -25,3 +25,8 @@ staff_role_ids = [526384077679624192, # Team role in NotSwitched modlog_channel = 526377735908491284 # Log channel in NotSwitched welcome_channel = 526372470752673792 # rules-info channel in NotSwitched participant_role = 526378358129557506 # participant role in NotSwitched +community_role = 526378381839695872 # community role in NotSwitched +hacker_role = 526471781184176139 # hacker role in NotSwitched + +community_channels = ["526378423468425236"] # All channels only accessable with the community role +general_channels = ["526372255052201995"] # All channels everyone can access \ No newline at end of file