Cog-Creators / Red-DiscordBot

A multi-function Discord bot
https://docs.discord.red
GNU General Public License v3.0
4.72k stars 2.3k forks source link

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

Closed aikaterna closed 2 weeks ago

aikaterna commented 1 month ago

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. 🤞