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 · 6 comments · May be fixed by #2658
Open
3 tasks done

permissions_for returning wrong permissions #2281

Snawe opened this issue Dec 9, 2023 · 6 comments · May be fixed by #2658
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
@Paillat-dev
Copy link
Contributor

Paillat-dev commented Nov 28, 2024

6a72ff0

6a72ff0eede452d55d22b6134bd519d5669b263c is the first bad commit
commit 6a72ff0eede452d55d22b6134bd519d5669b263c (HEAD)
Author: UK <41271523+NeloBlivion@users.noreply.github.com>
Date:   Tue Apr 25 18:43:25 2023 +0100

    feat: Received Interactions come with a channel object (#2025)



    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    Co-authored-by: Lala Sabathil <lala@pycord.dev>

 CHANGELOG.md                  |  4 ++++
 discord/channel.py            |  4 +++-
 discord/interactions.py       | 46 +++++++++++++++++++++++++++++++++----------
 discord/types/interactions.py |  2 ++
 4 files changed, 45 insertions(+), 11 deletions(-)

@Paillat-dev Paillat-dev linked a pull request Nov 28, 2024 that will close this issue
9 tasks
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

Successfully merging a pull request may close this issue.

6 participants