Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

permissions_for returning wrong permissions #2281

Open
3 tasks done
Snawe opened this issue Dec 9, 2023 · 5 comments
Open
3 tasks done

permissions_for returning wrong permissions #2281

Snawe opened this issue Dec 9, 2023 · 5 comments
Labels
bug Something isn't working on hold
Milestone

Comments

@Snawe
Copy link
Contributor

Snawe commented Dec 9, 2023

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

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

Additional Context

No response

@Snawe Snawe added the unconfirmed bug A bug report that needs triaging label Dec 9, 2023
@Dorukyum Dorukyum added bug Something isn't working and removed unconfirmed bug A bug report that needs triaging labels Dec 10, 2023
@Dorukyum Dorukyum self-assigned this Dec 10, 2023
@Lulalaby Lulalaby added this to the v2.5 milestone Feb 29, 2024
@Lulalaby
Copy link
Member

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

@Dorukyum Dorukyum removed their assignment Mar 1, 2024
@Lulalaby Lulalaby modified the milestones: v2.5, v2.6 Mar 2, 2024
@NeloBlivion
Copy link
Member

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.

@Haptein
Copy link
Contributor

Haptein commented Mar 13, 2024

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

@NeloBlivion
Copy link
Member

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

@NeloBlivion
Copy link
Member

(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)

@Lulalaby Lulalaby modified the milestones: v2.6, v2.7 Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working on hold
Projects
None yet
Development

No branches or pull requests

5 participants