mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 10:17:59 -05:00
[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:
@@ -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",)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user