[Audio] Fix Attribute error raised by is_alone method when channel was None (#3122)

* Fix attribute Fixes #3120

Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>

* Chore

Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>
This commit is contained in:
Draper
2019-12-20 06:58:08 +00:00
committed by Michael H
parent 61f467a323
commit 0b042532fd
3 changed files with 58 additions and 65 deletions

View File

@@ -1,5 +1,6 @@
import asyncio
import contextlib
import functools
import os
import re
import time
@@ -10,10 +11,9 @@ import lavalink
from redbot.core import Config, commands
from redbot.core.bot import Red
from . import audio_dataclasses
from .converters import _pass_config_to_converters
from .playlists import _pass_config_to_playlist
__all__ = [
@@ -32,6 +32,7 @@ __all__ = [
"url_check",
"userlimit",
"is_allowed",
"rgetattr",
"CacheLevel",
"Notifier",
]
@@ -240,6 +241,18 @@ def userlimit(channel):
return True
def rsetattr(obj, attr, val):
pre, _, post = attr.rpartition(".")
return setattr(rgetattr(obj, pre) if pre else obj, post, val)
def rgetattr(obj, attr, *args):
def _getattr(obj2, attr2):
return getattr(obj2, attr2, *args)
return functools.reduce(_getattr, [obj] + attr.split("."))
class CacheLevel:
__slots__ = ("value",)