hopefully fix player.guild bs (+ cleanup)

This commit is contained in:
VP 2021-12-27 10:34:01 +02:00
parent 5acc3625a0
commit d8388456f2
1 changed files with 9 additions and 7 deletions

View File

@ -6,6 +6,7 @@ from typing import (
) )
from discord import ( from discord import (
Client,
Guild, Guild,
VoiceChannel, VoiceChannel,
VoiceProtocol VoiceProtocol
@ -19,7 +20,6 @@ from .exceptions import FilterInvalidArgument, TrackInvalidPosition
from .filters import Filter from .filters import Filter
from .objects import Track from .objects import Track
from .pool import Node, NodePool from .pool import Node, NodePool
from .utils import ClientType
class Player(VoiceProtocol): class Player(VoiceProtocol):
@ -30,22 +30,24 @@ class Player(VoiceProtocol):
``` ```
""" """
def __call__(self, client: ClientType, channel: VoiceChannel): def __call__(self, client: Client, channel: VoiceChannel):
self.client: ClientType = client self.client: Client = client
self.channel: VoiceChannel = channel self.channel: VoiceChannel = channel
self._guild: Guild = channel.guild
return self return self
def __init__( def __init__(
self, self,
client: ClientType = None, client: Optional[Client] = None,
channel: VoiceChannel = None, channel: Optional[VoiceChannel] = None,
*, *,
node: Node = None node: Node = None
): ):
self.client = client self.client = client
self._bot = client self._bot = client
self.channel = channel self.channel = channel
self._guild = channel.guild if channel else None
self._node = node if node else NodePool.get_node() self._node = node if node else NodePool.get_node()
self._current: Track = None self._current: Track = None
@ -114,7 +116,7 @@ class Player(VoiceProtocol):
@property @property
def guild(self) -> Guild: def guild(self) -> Guild:
"""Property which returns the guild associated with the player""" """Property which returns the guild associated with the player"""
return self.channel.guild return self._guild
@property @property
def volume(self) -> int: def volume(self) -> int:
@ -127,7 +129,7 @@ class Player(VoiceProtocol):
return self._filter return self._filter
@property @property
def bot(self) -> ClientType: def bot(self) -> Client:
"""Property which returns the bot associated with this player instance""" """Property which returns the bot associated with this player instance"""
return self._bot return self._bot