Muted role now disables read perms in every single text channel

Added functionality to make sure that new channels have muted role overwrites
pull/8/head
sgoudham 4 years ago
parent d491533644
commit 8a34da5511

@ -291,19 +291,27 @@ class Moderation(Cog):
if not await check(ctx, members): if not await check(ctx, members):
with ctx.typing(): with ctx.typing():
# Get muted role from the server
role = discord.utils.get(ctx.guild.roles, name="Muted") role = discord.utils.get(ctx.guild.roles, name="Muted")
# Create muted role when no muted role exists and mute member(s)
if role is None: if role is None:
# Setting up the role permissions for the Muted Role
muted = await ctx.guild.create_role(name="Muted") muted = await ctx.guild.create_role(name="Muted")
# Removes permission to send messages in all channels for channel in ctx.guild.text_channels:
for channel in ctx.guild.channels: await channel.set_permissions(muted, read_messages=False)
await channel.set_permissions(muted, send_messages=False, read_messages=True)
# Send embed of the kicked member
await mute_members(self.bot.db, ctx, members, reason, muted) await mute_members(self.bot.db, ctx, members, reason, muted)
# Make sure that the Muted Role has the correct permissions before muting member(s)
else: else:
# Send embed of the kicked member
for channel in ctx.guild.text_channels:
perms = channel.overwrites_for(role)
if perms.read_messages:
perms.read_messages = False
await channel.set_permissions(role, overwrite=perms)
print(channel.name + "has been muted!")
await mute_members(self.bot.db, ctx, members, reason, role) await mute_members(self.bot.db, ctx, members, reason, role)
@command(name="unmute", aliases=["Unmute"], usage="`<member>...` `[reason]`") @command(name="unmute", aliases=["Unmute"], usage="`<member>...` `[reason]`")
@ -319,16 +327,19 @@ class Moderation(Cog):
if not await check(ctx, members): if not await check(ctx, members):
with ctx.typing(): with ctx.typing():
role = discord.utils.get(ctx.guild.roles, name="Muted") role = discord.utils.get(ctx.guild.roles, name="Muted")
if role is None: if role is None:
embed = Embed(description="**❌ No Muted Role Was Found! ❌**", embed = Embed(description="**❌ No Muted Role Was Found! ❌**",
colour=enso_embedmod_colours) colour=enso_embedmod_colours)
await ctx.send(embed=embed) await ctx.send(embed=embed)
else: else:
for member in members: for member in members:
if role in member.roles: if role in member.roles:
await ummute_members(self, ctx.message, members, reason) await ummute_members(self, ctx.message, members, reason)
unmute = True unmute = True
if role not in member.roles and unmute is False: if role not in member.roles and unmute is False:
embed = Embed(description=f"**❌ {member.mention} Is Not Muted! ❌**", embed = Embed(description=f"**❌ {member.mention} Is Not Muted! ❌**",
colour=enso_embedmod_colours) colour=enso_embedmod_colours)

Loading…
Cancel
Save