Fix permissions fetching for User Installable Bots #6457

Merged
Kowlin merged 8 commits from pr/fix/UIB-checks into V3/develop 2024-12-24 15:16:03 +01:00
Kowlin commented 2024-09-24 14:02:29 +02:00 (Migrated from github.com)

Description of the changes

This change fixes permissions regarding discord.Interactions and fetching permissions. Where this would fail where a bot isn't in the server (Yep, that's a thing now!) or doesn't have the channels cached in memory with interactions on User Installable Bots (UIBs) This fix pulls the permissions directly from the interaction, and gives the allowed permissions the interaction can use directly.

This will however sucks for bots trying to see if a person can ignore the ignore list. As its unclear to the bot if the author has manage_guild or similar permissions. But I see no other viable method of solving this.

Have the changes in this PR been tested?

Partially? (Lmao)

### Description of the changes This change fixes permissions regarding discord.Interactions and fetching permissions. Where this would fail where a bot isn't in the server (Yep, that's a thing now!) or doesn't have the channels cached in memory with interactions on User Installable Bots (UIBs) This fix pulls the permissions directly from the interaction, and gives the allowed permissions the interaction can use directly. This will however sucks for bots trying to see if a person can ignore the ignore list. As its unclear to the bot if the author has manage_guild or similar permissions. But I see no other viable method of solving this. ### Have the changes in this PR been tested? Partially? (Lmao)
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2024-11-20 23:30:24 +01:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Copilot reviewed 1 out of 1 changed files in this pull request and generated no suggestions.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no suggestions.
Jackenmen (Migrated from github.com) requested changes 2024-12-24 01:45:12 +01:00
@ -886,7 +886,12 @@ class Red(
if ctx.channel.type is not discord.ChannelType.private:
Jackenmen (Migrated from github.com) commented 2024-12-24 01:45:04 +01:00

Context can also be based on an interaction:

        if isinstance(ctx, discord.Message):
            perms = ctx.channel.permissions_for(author)
        else:
            # `permissions` attribute will use permissions from the interaction when possible,
            # or `ctx.channel.permissions_for(author)` for non-interaction contexts.
        	perms = ctx.permissions
`Context` can also be based on an interaction: ```suggestion if isinstance(ctx, discord.Message): perms = ctx.channel.permissions_for(author) else: # `permissions` attribute will use permissions from the interaction when possible, # or `ctx.channel.permissions_for(author)` for non-interaction contexts. perms = ctx.permissions ```
Jackenmen (Migrated from github.com) reviewed 2024-12-24 04:10:48 +01:00
Jackenmen (Migrated from github.com) left a comment
No description provided.
![](https://i.fluffy.cc/MKjDMmwXxZlqRTwnn070gVqZ8Rwh6d3p.gif)
Jackenmen (Migrated from github.com) approved these changes 2024-12-24 15:14:49 +01:00
SomewhatDamaged commented 2024-12-25 06:11:45 +01:00 (Migrated from github.com)

Huge thanks for this and all the work you do. Upgraded and my slash commands now work in threads (where the bot isn't).

\o/

🎉

Huge thanks for this and all the work you do. Upgraded and my slash commands now work in threads (where the bot isn't). \o/ 🎉
Sign in to join this conversation.
No reviewers
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!6457
No description provided.