Cog-Creators / Red-DiscordBot

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

[Audio] Autoplay failure with User scope playlist #6281

Open aikaterna opened 10 months ago

aikaterna commented 10 months ago

What Red version are you using?

3.5.5

Cog name

Audio

Command name

autoplay

What did you expect to happen?

I expected a Red playlist saved with the User scope would be able to be used as an autoplay playlist.

What actually happened?

A User scoped playlist, set in [p]audioset autoplay playlist, is never started on bot start nor does [p]autoplay queue a song from that playlist.

In running in verbose mode, this traceback is offered on bot start or while using [p]autoplay.

VERBOSE [red.cogs.Audio.api.AudioAPIInterface] Failed to fetch playlist for autoplay
Traceback (most recent call last) 
/Users/aikaterna/red38/lib/python3.8/site-packages/redbot/cogs/audio/apis/interface.py:938 in autoplay
❱ 938 playlist = await get_playlist(
/Users/aikaterna/red38/lib/python3.8/site-packages/redbot/cogs/audio/apis/playlist_interface.py:392 in get_playlist
❱ 392 raise RuntimeError(f"That playlist does not exist for the following scope: {scope}") 
RuntimeError: That playlist does not exist for the following scope: USERPLAYLIST

User scoped playlists are saved in the SQL db as the user ID as the value in the scope_id column. However, when loading playlists with the get_playlist function, we are passing in the bot's ID instead of the playlist owner's user ID, which causes the lookup to fail on User scoped playlists.

https://github.com/Cog-Creators/Red-DiscordBot/blob/76abb7cab2c28bda3ad5e939b3d07250cdd99d7f/redbot/cogs/audio/apis/interface.py#L940

The autoplaylist config value we're looking at to start that get_playlist lookup only offers the playlist ID, so not sure if we should be doing another lookup at that point to fetch the true author instead of assuming it's the bot ID.

How can we reproduce this error?

  1. Have the bot running in verbose debug mode to view the traceback
  2. Set a User scoped playlist as the playlist in [p]audioset autoplay playlist
  3. Use [p]autoplay or set autoplay to start with [p]audioset autoplay toggle and then restart the bot

Anything else?

Additional context: The fact that user playlists don't work for auto play is intentional - because auto play is a guild level feature meaning guild and global scoped playlists should work for it, but user not so, as we may exposing user data to users in a server that the playlist author/manager is no longer in. There should be an error show to the user when trying to set a user scoped playlist as an autoplay playlist.

sxliang3093 commented 7 months ago

Hey! I would love to work on this! Thank you

sxliang3093 commented 7 months ago

I was wondering if the project manager could assign me this issue? Thanks!

Flame442 commented 7 months ago

@sxliang3093, You are free to create a PR for any issue labeled as "Accepted" or "PRs welcome". We don't generally assign people to issues outside of core contributors. When we don't have a great line of communication with a contributor and don't have a PR already created, we don't know if/when they decide to abandon working on the issue. If you create a PR, it will be linked to this issue to make it clear that it is in active development, and we can see the progress towards fixing this issue. Feel free to label your PR as a draft if you have not yet fully resolved this issue.

If you need any additional help contributing, feel free to reach out in our discord support server.