added mute and unmute with text for translators
@@ -17,7 +17,8 @@ class Mod(commands.Cog):
return True
guild_roles = author.guild.roles
return (
- guild_roles.index(author.top_role) > guild_roles.index(victim.top_role) and not victim.id == author.guild.owner.id
+ guild_roles.index(author.top_role) > guild_roles.index(
+ victim.top_role) and not victim.id == author.guild.owner.id
)
@commands.command(name="purge", aliases=["p"])
@@ -189,6 +190,53 @@ class Mod(commands.Cog):
await self.db.clear_warns(user.id, ctx.guild.id)
await ctx.message.add_reaction(self.d.emojis.yes)
+ @commands.command(name="mute", aliases=["shutup", "silence", "shush", ])
+ @commands.guild_only()
+ async def mute(self, ctx, user: discord.Member):
+
+ if ctx.author.id == user.id:
+ await self.bot.send(ctx, ctx.l.mod.mute.stupid_1)
+ return
+
+ if not await self.perm_check(ctx.author, user):
+ await self.bot.send(ctx, ctx.l.mod.no_perms)
+ return
+
+ if not discord.utils.get(ctx.guild.roles, name="Mute"): # creating the role for the first time
+ perms = discord.Permissions(send_messages=False, embed_links=False, attach_files=False,
+ add_reactions=False) # pain.
+
+ await ctx.guild.create_role(name="Mute", permissions=perms)
+ mute = discord.utils.get(ctx.guild.roles, name="Mute")
+ for channel in ctx.guild.text_channels:
+ await channel.set_permissions(mute, send_messages=False, embed_links=False, attach_files=False,
+ add_reactions=False) # code do be copy paste tho
+
+ mute = discord.utils.get(ctx.guild.roles, name="Mute")
+ await user.add_roles(mute)
+ await self.bot.send(ctx, ctx.l.mod.mute.mute_msg.format(user))
+
+ @commands.command(name="unmute", aliases=["unshut"])
+ @commands.guild_only()
+ async def unmute(self, ctx, user: discord.Member):
+
+ if ctx.author.id == user.id:
+ await self.bot.send(ctx, ctx.l.mod.unmute.stupid_1)
+ return
+
+ if not await self.perm_check(ctx.author, user):
+ await self.bot.send(ctx, ctx.l.mod.no_perms)
+ return
+
+ mute = discord.utils.get(user.roles, name="Mute")
+
+ if mute:
+ await user.remove_roles(mute)
+ await self.bot.send(ctx, ctx.l.mod.unmute.unmute_msg.format(user))
+
+ else:
+ await self.bot.send(ctx, ctx.l.mod.unmute.stupid_2.format(user))
+
def setup(bot):
bot.add_cog(Mod(bot))
