1
1
1uXeR2021-08-16 17:05:09
Python
1uXeR, 2021-08-16 17:05:09

How to tempmute or mute discord.py for a while?

This is my mute code

@client.command( pass_context = True )
@commands.has_any_role( 860824791610032189, 876086379665301534 )

async def mute( ctx, member: discord.Member ):
    emb = discord.Embed( title = "Участник Был Замучен!", colour = discord.Color.blue() )
    await ctx.channel.purge( limit = 1 )

    emb.set_author( name = member.name, icon_url = member.avatar_url )
    emb.set_footer( text = "Его замутил {}".format( ctx.author.name ), icon_url = ctx.author.avatar_url )

    await  ctx.send( embed = emb )

    muted_role = discord.utils.get( ctx.message.guild.roles, name = "Muted" )

    await member.add_roles( muted_role )

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
retUrn3d, 2021-08-16
@1uXeR

This is a bad use case, but without the extra cost.
If the bot is reloaded while the person has a "mute". He will stay with him forever.

@client.command(pass_context=True)
@commands.has_any_role(860824791610032189, 876086379665301534)

async def mute( ctx, member: discord.Member, time: int):
    emb = discord.Embed(title="Участник Был Замучен!", colour=discord.Color.blue())
    await ctx.channel.purge(limit=1)

    emb.set_author(name=member.name, icon_url=member.avatar_url )
    emb.set_footer(text="Его замутил {}".format(ctx.author.name ), icon_url=ctx.author.avatar_url )
    
    await ctx.send(embed=emb)
    muted_role = discord.utils.get(ctx.message.guild.roles, name="Muted")
    await member.add_roles(muted_role)
    
    # Спим X секунд, перед тем как снять роль.
    await asyncio.sleep(time) 
    # Снимаем роль замученного.
    await member.remove_roles(muted_role)

Z
Zagir Majidov, 2021-08-16
@Zagir-vip

Here is a big, but the best code for mut over time as in Mee6
https://pastebin.com/Q7NNj46e #Just too many words!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question