Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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

mute command discord.py

await member.edit(mute = True)
Comment

PREVIOUS NEXT
Code Example
Python :: selenium-screenshot python 
Python :: install a specific version of django 
Python :: How do I set Conda to activate the base environment by default? 
Python :: open url python 
Python :: python how to find the highest number in a dictionary 
Python :: tkinter how to disable window resizing 
Python :: open choose files from file explorer python 
Python :: delete element of a list from another list python 
Python :: python random randint except a number 
Python :: pandas series values into strings 
Python :: plotly set axes limits 
Python :: how to clear console in python 
Python :: sklearn minmaxscaler pandas 
Python :: update jupyter notebook 
Python :: python turtle line thickness 
Python :: capture output of os.system in python 
Python :: installing wxpython on windows 10 
Python :: n random numbers python 
Python :: plot model 
Python :: pd.set_option show all rows 
Python :: add all string elements in list python 
Python :: pandas add character to string 
Python :: python deep copy of a dictionary 
Python :: dictionary from two columns pandas 
Python :: python pandas apply to one column 
Python :: 2 - 20 python 
Python :: django reverse 
Python :: replace cell pandas 
Python :: ipywidgets pip 
Python :: python count repeated elements in a list 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =