mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-26 04:33:00 -05:00
working
Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>
This commit is contained in:
@@ -8,7 +8,7 @@ from redbot.core import Config, commands
|
||||
from redbot.core.bot import Red
|
||||
from redbot.core.i18n import Translator
|
||||
|
||||
from .playlists import PlaylistScope, standardize_scope
|
||||
from .playlists import PlaylistScope, standardize_scope, get_all_playlist_converter
|
||||
|
||||
_ = Translator("Audio", __file__)
|
||||
|
||||
@@ -22,8 +22,8 @@ __all__ = [
|
||||
"get_playlist_converter",
|
||||
]
|
||||
|
||||
_config = None
|
||||
_bot = None
|
||||
_config: Config = None
|
||||
_bot: Red = None
|
||||
|
||||
_SCOPE_HELP = """
|
||||
Scope must be a valid version of one of the following:
|
||||
@@ -54,29 +54,18 @@ def _pass_config_to_converters(config: Config, bot: Red):
|
||||
|
||||
class PlaylistConverter(commands.Converter):
|
||||
async def convert(self, ctx: commands.Context, arg: str) -> dict:
|
||||
global_scope = await _config.custom(PlaylistScope.GLOBAL.value).all()
|
||||
guild_scope = await _config.custom(PlaylistScope.GUILD.value).all()
|
||||
user_scope = await _config.custom(PlaylistScope.USER.value).all()
|
||||
user_matches = [
|
||||
(uid, pid, pdata)
|
||||
for uid, data in user_scope.items()
|
||||
for pid, pdata in data.items()
|
||||
if arg == pid or arg.lower() in pdata.get("name", "").lower()
|
||||
]
|
||||
guild_matches = [
|
||||
(gid, pid, pdata)
|
||||
for gid, data in guild_scope.items()
|
||||
for pid, pdata in data.items()
|
||||
if arg == pid or arg.lower() in pdata.get("name", "").lower()
|
||||
]
|
||||
global_matches = [
|
||||
(None, pid, pdata)
|
||||
for pid, pdata in global_scope.items()
|
||||
if arg == pid or arg.lower() in pdata.get("name", "").lower()
|
||||
]
|
||||
global_matches = await get_all_playlist_converter(
|
||||
PlaylistScope.GLOBAL.value, _bot, arg, guild=ctx.guild, author=ctx.author
|
||||
)
|
||||
guild_matches = await get_all_playlist_converter(
|
||||
PlaylistScope.GUILD.value, _bot, arg, guild=ctx.guild, author=ctx.author
|
||||
)
|
||||
user_matches = await get_all_playlist_converter(
|
||||
PlaylistScope.USER.value, _bot, arg, guild=ctx.guild, author=ctx.author
|
||||
)
|
||||
|
||||
if not user_matches and not guild_matches and not global_matches:
|
||||
raise commands.BadArgument(_("Could not match '{}' to a playlist.").format(arg))
|
||||
|
||||
return {
|
||||
PlaylistScope.GLOBAL.value: global_matches,
|
||||
PlaylistScope.GUILD.value: guild_matches,
|
||||
|
||||
Reference in New Issue
Block a user