1@client.command(description="Unmutes a specified user.")
2@commands.has_permissions(manage_messages=True)
3async def unmute(ctx, member: discord.Member):
4 mutedRole = discord.utils.get(ctx.guild.roles, name="Muted")
5
6 await member.remove_roles(mutedRole)
7 await member.send(f" you have unmutedd from: - {ctx.guild.name}")
8 embed = discord.Embed(title="unmute", description=f" unmuted-{member.mention}",colour=discord.Colour.light_gray())
9 await ctx.send(embed=embed)
1@client.command(description="Mutes the specified user.")
2@commands.has_permissions(manage_messages=True)
3async def mute(ctx, member: discord.Member, *, reason=None):
4 guild = ctx.guild
5 mutedRole = discord.utils.get(guild.roles, name="Muted")
6
7 if not mutedRole:
8 mutedRole = await guild.create_role(name="Muted")
9
10 for channel in guild.channels:
11 await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=False)
12 embed = discord.Embed(title="muted", description=f"{member.mention} was muted ", colour=discord.Colour.light_gray())
13 embed.add_field(name="reason:", value=reason, inline=False)
14 await ctx.send(embed=embed)
15 await member.add_roles(mutedRole, reason=reason)
16 await member.send(f" you have been muted from: {guild.name} reason: {reason}")
17
1#Timed mute this format: 1d, 20s, 30m, etc..
2@bot.command(aliases=['tempmute'])
3@commands.has_permission(manage_messages=True)
4async def mute(ctx, member: discord.Member=None, time=None, *, reason=None):
5if not member:
6 await ctx.send("You must mention a member to mute!")
7elif not time:
8 await ctx.send("You must mention a time!")
9else:
10 if not reason:
11 reason="No reason given"
12 #Now timed mute manipulation
13 try:
14 seconds = time[:-1] #Gets the numbers from the time argument, start to -1
15 duration = time[-1] #Gets the timed maniulation, s, m, h, d
16 if duration == "s":
17 seconds = seconds * 1
18 elif duration == "m":
19 seconds = seconds * 60
20 elif duration == "h":
21 seconds = seconds * 60 * 60
22 elif duration == "d":
23 seconds = seconds * 86400
24 else:
25 await ctx.send("Invalid duration input")
26 return
27 except Exception as e:
28 print(e)
29 await ctx.send("Invalid time input")
30 return
31 guild = ctx.guild
32 Muted = discord.utils.get(guild.roles, name="Muted")
33 if not Muted:
34 Muted = await guild.create_role(name="Muted")
35 for channel in guild.channels:
36 await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=False)
37 await member.add_roles(Muted, reason=reason)
38 muted_embed = discord.Embed(title="Muted a user", description=f"{member.mention} Was muted by {ctx.author.mention} for {reason} to {time}")
39 await ctx.send(embed=muted_embed)
40 await asyncio.sleep(seconds)
41 await member.remove_roles(Muted)
42 unmute_embed = discord.Embed(title="Mute over!", description=f'{ctx.author.mention} muted to {member.mention} for {reason} is over after {time}")
43 await ctx.send(embed=unmute_embed)