pycord icon indicating copy to clipboard operation
pycord copied to clipboard

`permissions_for` returning wrong permissions

Open Snawe opened this issue 2 years ago • 5 comments

Summary

permissions_for returning wrong permissions

Reproduction Steps

When you use channel.permissions_for, and you remove the "View Channel" permission, it still returns true.

NOTE:

  • Code below works with v2.4.1
  • But does not work with py-cord-dev-2.5.0rc5

Minimal Reproducible Code

I created a cog with:

    @slash_command()
    async def test_perm(self, ctx: discord.ApplicationContext):
        member = ctx.guild.get_member(self.bot.user.id)
        perm = ctx.channel.permissions_for(member)
        await ctx.response.send_message("🚫" if not perm.view_channel else "✅")

Expected Results

🚫if "View Channel" permission is denied. Else ✅

Actual Results

With py-cord-dev-2.5.0rc5: Always ✅ With py-cord 2.4.1: 🚫 or ✅, depending on the actual permission set

Intents

default

System Information

  • Python v3.9.4-final
  • py-cord-dev v2.5.None-candidate
    • py-cord-dev pkg_resources: v2.5.0rc5
  • aiohttp v3.8.3

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.

Additional Context

No response

Snawe avatar Dec 09 '23 08:12 Snawe

@Pycord-Development/contributors please work on this :)

Lulalaby avatar Feb 29 '24 19:02 Lulalaby

Heyhey, after some consideration this will be held off until 2.6 as it's rather intricate. Instead of ctx.channel.permissions_for(member) (where member is the bot), you should use ctx.app_permissions.

NeloBlivion avatar Mar 02 '24 06:03 NeloBlivion

Do you know if there's an alternative to interaction.app_permissions that does not require coming from a slash command event? I use permissions_for a lot so this is keeping me in 2.4

Haptein avatar Mar 13 '24 01:03 Haptein

This issue only affects interactions; you can safely use permissions_for elsewhere

NeloBlivion avatar Mar 13 '24 02:03 NeloBlivion

(To elaborate, the issue is specifically because we update permissions from interaction.channel incorrectly; you could circumvent this again by using bot.get_channel, assuming you haven't disabled cache)

NeloBlivion avatar Mar 13 '24 02:03 NeloBlivion