diff --git a/voicelink/views/queue.py b/voicelink/views/queue.py index 5a8dc23..69e1521 100644 --- a/voicelink/views/queue.py +++ b/voicelink/views/queue.py @@ -52,12 +52,6 @@ class QueueView(PaginationView): """ def __init__(self, player: "Player", author: discord.Member, is_queue: bool = True) -> None: - - self.player: Player = player - self.is_queue: bool = is_queue - self.total_duration = self.calculate_total_duration() - self.response: discord.Message = None - super().__init__( Pagination["Track"]( items=player.queue.tracks() if is_queue else list(reversed(player.queue.history())), @@ -66,18 +60,22 @@ class QueueView(PaginationView): author ) + self.player: Player = player + self.is_queue: bool = is_queue + self.total_duration = self.calculate_total_duration() + self.response: discord.Message = None + def calculate_total_duration(self) -> str: """Calculate the total duration of the tracks.""" try: - return format_ms(sum(track.length for track in self.pagination._items)) + return format_ms(sum(track.length for track in self.pagination.items)) except Exception: return "∞" def format_description(self, tracks: list["Track"], texts: list[str]) -> str: """Format the description for the embed based on current tracks.""" now_playing = ( - texts[1].format(self.player.current.uri, - f"```{self.player.current.title}```") + texts[1].format(self.player.current.uri, f"```{self.player.current.title}```") if self.player.current else texts[2].format("None") ) diff --git a/voicelink/views/utils/pagination.py b/voicelink/views/utils/pagination.py index 3a48070..339dab3 100644 --- a/voicelink/views/utils/pagination.py +++ b/voicelink/views/utils/pagination.py @@ -165,4 +165,14 @@ class Pagination(Generic[T]): Returns: int: The total number of items across all pages. """ - return len(self._items) \ No newline at end of file + return len(self._items) + + @property + def items(self) -> List[T]: + """ + Gets the list of all items in the pagination. + + Returns: + List[T]: The list of all items. + """ + return self._items \ No newline at end of file