Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start of attempted Queue refactor. #255

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions wavelink/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ def __call__(self, client: discord.Client, channel: VocalGuildChannel) -> Self:
return self

def __init__(
self, client: discord.Client = MISSING, channel: Connectable = MISSING, *, nodes: list[Node] | None = None
self,
client: discord.Client = MISSING,
channel: Connectable = MISSING,
*,
nodes: list[Node] | None = None,
) -> None:
super().__init__(client, channel)

Expand Down Expand Up @@ -203,7 +207,12 @@ async def _do_recommendation(self):

weighted_history: list[Playable] = self.queue.history[::-1][: max(5, 5 * self._auto_weight)]
weighted_upcoming: list[Playable] = self.auto_queue[: max(3, int((5 * self._auto_weight) / 3))]
choices: list[Playable | None] = [*weighted_history, *weighted_upcoming, self._current, self._previous]
choices: list[Playable | None] = [
*weighted_history,
*weighted_upcoming,
self._current,
self._previous,
]

# Filter out tracks which are None...
_previous: deque[str] = self.__previous_seeds._queue # type: ignore
Expand Down Expand Up @@ -299,7 +308,7 @@ async def _search(query: str | None) -> T_a:
track._recommended = True
added += await self.auto_queue.put_wait(track)

random.shuffle(self.auto_queue._queue)
random.shuffle(self.auto_queue._items)
logger.debug(f'Player "{self.guild.id}" added "{added}" tracks to the auto_queue via AutoPlay.')

@property
Expand Down Expand Up @@ -488,7 +497,12 @@ async def _dispatch_voice_update(self) -> None:
logger.debug(f"Player {self.guild.id} is dispatching VOICE_UPDATE.")

async def connect(
self, *, timeout: float = 10.0, reconnect: bool, self_deaf: bool = False, self_mute: bool = False
self,
*,
timeout: float = 10.0,
reconnect: bool,
self_deaf: bool = False,
self_mute: bool = False,
) -> None:
"""

Expand Down
Loading
Loading