When a user has the mute members permission discord.py does not recognize it.
@client.command()
@commands.has_permissions(mute_members=True)
async def mute(ctx, member: discord.member):
member_id = member.id
embed = discord.Embed(title=f'Muted {member.mention}')
await ctx.send(embed=embed)
with open("mute.json", "r") as f:
mute = json.load(f)
mute[str(member_id)] = f'{member_id}'
with open("mute.json", 'w') as f:
json.dump(mute, f, indent=4)
Make a command with the mute_members to true. I made sure I have the permissions multiple times.
The command works without console/terminal errors.
Error:
Ignoring exception in command mute:
Traceback (most recent call last):
File "/home/super_user_oppy/.local/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 892, in invoke
await ctx.command.invoke(ctx)
File "/home/super_user_oppy/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 790, in invoke
await self.prepare(ctx)
File "/home/super_user_oppy/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 743, in prepare
if not await self.can_run(ctx):
File "/home/super_user_oppy/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1011, in can_run
return await discord.utils.async_all(predicate(ctx) for predicate in predicates)
File "/home/super_user_oppy/.local/lib/python3.8/site-packages/discord/utils.py", line 324, in async_all
for elem in gen:
File "/home/super_user_oppy/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1011, in
return await discord.utils.async_all(predicate(ctx) for predicate in predicates)
File "/home/super_user_oppy/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1674, in predicate
raise MissingPermissions(missing)
discord.ext.commands.errors.MissingPermissions: You are missing Mute Members permission(s) to run this command.
mute members is a voice channel permissions so you need to use the commands.has_guild_permissions check instead.
Hmm asked around multiple discords and got 0 help.
we have an official support server https://discord.gg/dpy
Note, the cause of the error is that commands.has_permissions checks the channel permissions for the text channel the command was invoked in. Alternatively, you could check within the command or with a custom check for the specific voice channel permission.
For task list usage, see https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-github/about-task-lists.