Answer the question
In order to leave comments, you need to log in
Understand understand why the mut command does not work?
Here is the code
#временный мут
@bot.command(pass_context = True)
@commands.has_any_role('mute' , 908382396112592926 ) #Вводите название вашей роли и её ID
async def mute(ctx, member: discord.Member = None, time: int = None, reason = None ):
muted_role = discord.utils.get( ctx.message.guild.roles, name = mute )
if member is None:
await ctx.send(embed = discord.Embed(description = f'{ ctx.author.name }, **обязательно укажите (@Rall пример) пользователя!**', color = 5574e0 ))
await ctx.message.add_reaction( '❌' )
else:
if time is None:
await ctx.send(embed = discord.Embed(description = f'{ ctx.author.name }, **обязательно укажите время (минуты)!**', color = 5574e0 ))
await ctx.message.add_reaction( '❌' )
else:
if muted_role is None:
await ctx.send(embed = discord.Embed(description = f'{ ctx.author.name }, **обязательно создайте роль mute!**', color = 5574e0 ))
await ctx.message.add_reaction( '❌' )
else:
await member.add_roles(muted_role, reason = reason, atomic = True)
await ctx.message.add_reaction( '✅' )
await asyncio.sleep(time * 60)
await member.remove_roles(muted_role)
discord.ext.commands.errors.MissingAnyRole: You are missing at least one of the required roles: 'mute'
Answer the question
In order to leave comments, you need to log in
How to understand? Turn on your head and read the documentation.
@commands.has_any_role('mute' , 908382396112592926 )
A check() that is added that checks if the member invoking the command has any of the roles specified . This means that if they have one out of the three roles specified, then this check will return True.
muted_role = discord.utils.get( ctx.message.guild.roles, name = mute )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question