Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @client.command(aliases = ['tmute'])
- @commands.has_permissions(manage_roles = True)
- @commands.bot_has_guild_permissions(manage_roles = True)
- async def tempmute(ctx , member: discord.Member , time , * , reason=None):
- global mute_role, perms
- guild = ctx.guild
- if discord.utils.get(ctx.guild.roles , name = "Muted"):
- mute_role = discord.utils.get(guild.roles , name = "Muted" or "muted" or "Knast" or "Mute" or "mute")
- else:
- perms = discord.Permissions(send_messages = False , add_reactions = False , connect = False , speak = False)
- await guild.create_role(name = "Muted" , permissions = perms)
- mute_role = discord.utils.get(guild.roles , name = "Muted")
- for channel in guild.text_channels:
- await channel.set_permissions(mute_role , send_messages = False , add_reactions = False , connect = False , speak = False)
- if mute_role in member.roles:
- await ctx.channel.send(f"{member} ist bereits gemuted")
- else:
- if member.guild_permissions.administrator:
- isadminembed = discord.Embed(title = "Error" ,
- description = f"{ctx.author.mention} du kannst keine Server Administratoren muten!" ,
- color = 0xff2200)
- isadminembed.set_author(name = f"{client.user.name}#{client.user.discriminator}" ,
- icon_url = f"{client.user.avatar_url}")
- await ctx.channel.send(embed = isadminembed)
- elif member.id == ctx.author.id:
- isyourself = discord.Embed(title = "Fehler" ,
- description = f"{ctx.author} du kannst dich nicht selber muten!" ,
- color = 0xff2200)
- isyourself.set_footer(text = f"User-ID: {ctx.author.id}")
- isyourself.set_author(name = f"{ctx.author}" , icon_url = f"{ctx.author.avatar_url}")
- isyourself.timestamp = datetime.datetime.utcnow()
- await ctx.send(embed = isyourself)
- else:
- time_conversion = {"s": 1 , "m": 60 , "h": 3600 , "d": 86400 , "w": 604800 , "M": 2419200 , "y": 29030400}
- mute_time = int(time[:-1]) * time_conversion[time[-1]]
- for i in member.roles:
- try:
- await member.remove_roles(i)
- await member.add_roles(mute_role)
- except:
- pass
- if reason is None:
- reason = "No Reason provided"
- mutedembed = discord.Embed(title = "Tempmute" ,
- description = f"{member} wurde von {ctx.author} gemuted\n\nZeit: {mute_time}s\nGrund: {reason}" ,
- color = 0xff2200)
- mutedembed.set_author(name = f"{client.user.name}#{client.user.discriminator}" ,
- icon_url = f"{client.user.avatar_url}")
- mutedembed.set_footer(text = f"User-ID: {member.id}")
- await ctx.channel.send(embed = mutedembed)
- await asyncio.sleep(mute_time)
- for i in member.roles:
- try:
- await member.add_roles(i)
- await member.remove_roles(mute_role)
- except:
- pass
- embed = discord.Embed(color = 0xff2200 , title = "Mute vorbei" ,
- description = f"Der Mute von {member} ist vorbei!")
- embed.set_footer(text = f"User-ID: {member.id}")
- embed.set_author(name = f"{ctx.author}" , icon_url = f"{ctx.author.avatar_url}")
- await ctx.send(embed = embed)
- @tempmute.error
- async def on_command_error(ctx , error):
- if isinstance(ctx , commands.RoleNotFound):
- raise error
- @tempmute.error
- async def on_command_error(ctx , error):
- if isinstance(ctx , commands.CommandInvokeError):
- raise error
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement