[Audio] Fix trying to send notify message with no channel object #6429

Merged
aikaterna merged 3 commits from fix-notify-no-channel into V3/develop 2024-08-26 19:53:31 +02:00
aikaterna commented 2024-08-08 20:54:47 +02:00 (Migrated from github.com)

Description of the changes

A user in Red support submitted this traceback.

image

The player object has a channel reference inside the extra information telling it where to display messages and the channel was deleted or unreachable. This change checks for a channel object before trying to fetch its permissions.

Have the changes in this PR been tested?

Yesn't

I tested this change and checked for the _has_notify_perms condition returning False when an audioset notify channel is set to a deleted channel. After this change the player continues playing without throwing an error when a track changes and a notify message or autoplay message needs to be sent. There are a lot of points where interacting with audio and sending a command will readjust the notify channel saved in the player, so there isn't much of a need to clear that non-existent channel object as it will do it on its own with most usage.

If someone else would like to do any kind of sanity check on this please feel free. Otherwise I'm mostly confident I didn't break more things. 🤞

### Description of the changes A user in Red support submitted this traceback. ![image](https://github.com/user-attachments/assets/c96185e9-e297-4140-9102-fbe0c893608f) The player object has a channel reference inside the extra information telling it where to display messages and the channel was deleted or unreachable. This change checks for a channel object before trying to fetch its permissions. ### Have the changes in this PR been tested? Yesn't I tested this change and checked for the _has_notify_perms condition returning False when an audioset notify channel is set to a deleted channel. After this change the player continues playing without throwing an error when a track changes and a notify message or autoplay message needs to be sent. There are a lot of points where interacting with audio and sending a command will readjust the notify channel saved in the player, so there isn't much of a need to clear that non-existent channel object as it will do it on its own with most usage. If someone else would like to do any kind of sanity check on this please feel free. Otherwise I'm mostly confident I didn't break more things. 🤞
PredaaA (Migrated from github.com) reviewed 2024-08-08 20:54:47 +02:00
Jackenmen (Migrated from github.com) requested changes 2024-08-10 19:01:22 +02:00
Jackenmen (Migrated from github.com) left a comment
  1. This changes the return type from bool to Optional[bool] and it's arguable whether it's more logical to return true or false from this function.
  2. The type hint for the channel argument already did not allow None. Presumably, this was intentional and the issue should be fixed at the call site instead. All but one of the calls to this method already check that the notify channel is not None before calling the method. The outlier can be found at:
    github.com/Cog-Creators/Red-DiscordBot@903992f48a/redbot/cogs/audio/core/events/cog.py (L201)
1. This changes the return type from `bool` to `Optional[bool]` and it's arguable whether it's more logical to return true or false from this function. 2. The type hint for the `channel` argument already did not allow `None`. Presumably, this was intentional and the issue should be fixed at the call site instead. All but one of the calls to this method already check that the notify channel is not None before calling the method. The outlier can be found at: https://github.com/Cog-Creators/Red-DiscordBot/blob/903992f48a5e616ebc0efbc21c7b832e4258782c/redbot/cogs/audio/core/events/cog.py#L201
Kowlin (Migrated from github.com) reviewed 2024-08-24 23:36:29 +02:00
Kowlin (Migrated from github.com) left a comment
No description provided.
LGTM
Jackenmen (Migrated from github.com) approved these changes 2024-08-26 19:53:22 +02:00
Jackenmen (Migrated from github.com) left a comment

LGTM.

LGTM.
Sign in to join this conversation.
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!6429
No description provided.