Cog-Creators / Cog-Creators/Red-DiscordBot

[Audio] Autoplay failure with User scope playlist

Open
#6,281 3 comments 0 reactions 0 assignees View on GitHub
Category: Cogs - Audio Status: PRs Welcome Type: Bug
Dominant language
Python
Stars
5.7k
Forks
2.5k
Avg merge
6d 16h
Merged PRs (30d)
1

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.