Skip to content

Commit

Permalink
Add server silence command
Browse files Browse the repository at this point in the history
  • Loading branch information
ZechCodes committed Jul 9, 2020
1 parent 7004a07 commit 43d6683
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions beginner/cogs/admin.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down

0 comments on commit 43d6683

Please sign in to comment.