From 43d66832ded8266a9a4d245780165bcbe55749eb Mon Sep 17 00:00:00 2001 From: Zech Zimmerman Date: Wed, 8 Jul 2020 21:44:29 -0400 Subject: [PATCH] Add server silence command --- beginner/cogs/admin.py | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/beginner/cogs/admin.py b/beginner/cogs/admin.py index 88e0c9c1..d5bd07f5 100644 --- a/beginner/cogs/admin.py +++ b/beginner/cogs/admin.py @@ -1,10 +1,62 @@ from beginner.cog import Cog, commands +from beginner.colors import * import ast import discord import discord.ext.commands class Admin(Cog): + @Cog.group() + @commands.has_guild_permissions(manage_messages=True) + async def silence(self, ctx: discord.ext.commands.Context): + if ctx.invoked_subcommand: + return + + role = self.get_role("coders") + permissions = role.permissions + permissions.send_messages = False + await role.edit(permissions=permissions) + + await ctx.send( + embed=discord.Embed( + description="The server has been silenced. Use `!silence stop` to end the silence.", + color=RED, + title="Silence Activated" + ) + ) + + await self.get_channel("mod-action-log").send( + embed=discord.Embed( + description=f"The server has been silenced by {ctx.author.mention}.", + color=RED, + title="Silence Activated" + ) + ) + + @silence.command() + @commands.has_guild_permissions(manage_messages=True) + async def stop(self, ctx: discord.ext.commands.Context): + role = self.get_role("coders") + permissions = role.permissions + permissions.send_messages = True + await role.edit(permissions=permissions) + + await ctx.send( + embed=discord.Embed( + description="The server silence has been stopped.", + color=GREEN, + title="Silence Deactivated" + ) + ) + + await self.get_channel("mod-action-log").send( + embed=discord.Embed( + description=f"The server silence has been stopped by {ctx.author.mention}.", + color=GREEN, + title="Silence Deactivated" + ) + ) + @Cog.group() @commands.has_guild_permissions(manage_channels=True) async def channel(self, ctx: discord.ext.commands.Context):