The .mute
command doesn't work for some reason. Can someone help me out?
My code:
@client.command(pass_context=True)
async def mute(ctx, arg):
user = client.get_user(int(arg))
role = get(user.server.roles, name="Muted")
async with ctx.typing():
time.sleep(1)
await ctx.send('Muted: ', '<@', int(arg), '>')
client.add_roles(user, role)
Replace your mute
command with this:
@client.command(pass_context=True)
async def mute(ctx, id: int):
member = await ctx.guild.fetch_member(id)
role = discord.utils.get(ctx.guild.roles, name = 'Muted')
async with ctx.typing():
time.sleep(1)
await ctx.send(f'Muted: {member.mention}')
await member.add_roles(role)
Note: I recommend replacing time.sleep(1)
with await asyncio.sleep(1)
. In this case you'll have to import asyncio
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.