Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

mute command discord.py

await member.edit(mute = True)
Comment

discord.py mute unmute

@bot.command()
@has_permissions(administrator=True)
async def mute(ctx, member: nextcord.Member=None, time=None, *, reason="No reason specified"):
    if member is None:
        embed = nextcord.Embed(title="Command: !mute",
                               description=f"**Description:** Mute a member, optional reason
**Cooldown:** 3 Seconds",
                               color=0x2596be)
        embed.add_field(name="Usage:", value=f"!mute [user] [time] (reason)", inline=False)
        embed.add_field(name="Example", value=f"!mute bean 5m Squishing Small ants", inline=False)
        await ctx.send(embed=embed)
    if time is None:
        embed = nextcord.Embed(title="Command: !mute",
                               description=f"**Description:** Mute a member, optional reason
**Cooldown:** 3 Seconds",
                               color=0x2596be)
        embed.add_field(name="Usage:", value=f"!mute [user] [time] (reason)", inline=False)
        embed.add_field(name="Example", value=f"!mute bean 5m Squishing Small ants", inline=False)
        await ctx.send(embed=embed)
    else:
        desctime = time
        guild = ctx.guild
        mutedRole = nextcord.utils.get(guild.roles, name="Muted")
        time_convert = {"s":1, "m":60, "h":3600, "d":86400, "w":604800, "mo":31536000}
        tempmute = int(time[0]) * time_convert[time[-1]]
        if not mutedRole:
            embed = nextcord.Embed(title="Setup Muted Role", description="No Muted role was found, please create one!")
            embed.set_footer(text="Due to issues I can't create one myself...")
            await ctx.send(embed=embed)
        else:
            embed = nextcord.Embed(title="Muted", description=f"{member.mention} was muted for {desctime}")
            embed.set_image(url="https://c.tenor.com/l1yJ91orR_kAAAAd/yt-battles-youre-muted.gif")
            embed.add_field(name="Reason", value=reason, inline=False)
            await ctx.send(embed=embed)
            embed = nextcord.Embed(title="Muted", description=f"You were muted in {ctx.guild.name} for {desctime}")
            embed.add_field(name="Reason", value=reason)
            embed.set_image(url="https://c.tenor.com/l1yJ91orR_kAAAAd/yt-battles-youre-muted.gif")
            embed.add_field(name="Times", value="s = seconds
m = minutes
h = hours
d = days
w = weeks
mo = months")
            await member.send(embed=embed)
            await member.add_roles(mutedRole, reason=reason)
            await asyncio.sleep(tempmute)
            embed = nextcord.Embed(title="Unmuted", description=f"You were unmuted in {ctx.guild.name}")
            await member.send(embed=embed)
            embed = nextcord.Embed(title="Unmuted", description=f"Unmuted {member.mention}")
            await ctx.send(embed=embed)
            await member.remove_roles(mutedRole)

@bot.command()
@has_permissions(administrator=True)
async def unmute(ctx, member: nextcord.Member):
    mutedRole = nextcord.utils.get(member.roles, name="Muted")
    if not mutedRole:
        embed = nextcord.Embed(title="Can't unmute", description="This user is not muted!")
        embed.set_footer(text="Did you mean !mute?")
        await ctx.send(embed=embed)
    else:
        embed = nextcord.Embed(title="Unmuted", description=f"You were unmuted in {ctx.guild.name}")
        await member.send(embed=embed)
        embed = nextcord.Embed(title="Unmuted", description=f"Unmuted {member.mention}")
        await ctx.send(embed=embed)
        await member.remove_roles(mutedRole)
Comment

PREVIOUS NEXT
Code Example
Python :: remove nan from list 
Python :: if else condition python 
Python :: dataframe change column types 
Python :: days calculator python 
Python :: python if statements 
Python :: scikit decision tree regressor 
Python :: break continue pass in python 
Python :: python label 
Python :: whatsapp bot python code 
Python :: how to find duplicates in pandas 
Python :: bounding box in pyplot 
Python :: pyton for 
Python :: pyplot.plot 
Python :: stdin and stdout in python 
Python :: store message sent by user in string discord py 
Python :: python check for exception 
Python :: corpus 
Python :: where python packages are installed 
Python :: how to add items in list in python 
Python :: transformer in pytorch 
Python :: matplotlib subplots share x axis 
Python :: Issue AttributeError: ‘numpy.ndarray’ object has no attribute ‘index’ 
Python :: python call function by string 
Python :: raspbian run a python script at startup 
Python :: python newton raphson 
Python :: python function to do comparison between two numbers 
Python :: python : search file for string 
Python :: python loop over list 
Python :: exercices pyton 
Python :: turtle write function in turtle package python 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =