Discord.py: Mute_members permission Not Fully Working

Created on 10 Aug 2020  路  4Comments  路  Source: Rapptz/discord.py

Summary

When a user has the mute members permission discord.py does not recognize it.

Reproduction Steps

@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.

Expected Results

The command works without console/terminal errors.

Actual Results

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.

Checklist

  • [ X ] I have searched the open issues for duplicates.
  • [ X ] I have shown the entire traceback, if possible.
  • [ X ] I have removed my token from display, if visible.

System Information

  • Python v3.8.2-final
  • discord.py v1.3.4-final
  • aiohttp v3.6.2
  • websockets v8.1
  • system info: Linux 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020
invalid

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings