Skip to content
This repository has been archived by the owner on Nov 29, 2022. It is now read-only.

Commit

Permalink
'Refactored by Sourcery'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourcery AI authored and Drapersniper committed Aug 31, 2022
1 parent e127d96 commit a421879
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
8 changes: 4 additions & 4 deletions pylavcogs_shared/converters/equalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def convert(cls, ctx: PyLavContext, arg: str) -> str:
from pylav import EntryNotFoundError

try:
match = next(
if match := next(
filter(
lambda x: x.lower().startswith(arg.lower()),
[
Expand All @@ -39,10 +39,10 @@ async def convert(cls, ctx: PyLavContext, arg: str) -> str:
],
),
None,
)
if not match:
):
return match
else:
raise EntryNotFoundError
return match
except EntryNotFoundError as e:
raise commands.BadArgument(_("Bass boost with name `{arg}` not found.").format(arg=arg)) from e

Expand Down
76 changes: 38 additions & 38 deletions pylavcogs_shared/ui/sources/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ def __init__(self, guild_id: int, cog: CogT, history: bool = False): # noqa

@property
def entries(self) -> Iterable[Track]:
player = self.cog.lavalink.get_player(self.guild_id)
if not player:
if player := self.cog.lavalink.get_player(self.guild_id):
return player.history.raw_queue if self.history else player.queue.raw_queue
else:
return []
return player.history.raw_queue if self.history else player.queue.raw_queue

def is_paginating(self) -> bool:
return True
Expand All @@ -196,28 +196,28 @@ def get_starting_index_and_page_number(self, menu: QueueMenu) -> tuple[int, int]
return start, page_num

async def format_page(self, menu: QueueMenu, tracks: list[Track]) -> discord.Embed:
player = self.cog.lavalink.get_player(menu.ctx.guild.id)
if not player:
if player := self.cog.lavalink.get_player(menu.ctx.guild.id):
return (
await player.get_queue_page(
page_index=menu.current_page,
per_page=self.per_page,
total_pages=self.get_max_pages(),
embed=True,
messageable=menu.ctx,
history=self.history,
)
if player.current and (player.history.size() if self.history else True)
else await self.cog.lavalink.construct_embed(
description="There's nothing in recently played."
if self.history
else "There's nothing currently being played.",
messageable=menu.ctx,
)
)
else:
return await self.cog.lavalink.construct_embed(
description="No active player found in server.", messageable=menu.ctx
)
return (
await player.get_queue_page(
page_index=menu.current_page,
per_page=self.per_page,
total_pages=self.get_max_pages(),
embed=True,
messageable=menu.ctx,
history=self.history,
)
if player.current and (player.history.size() if self.history else True)
else await self.cog.lavalink.construct_embed(
description="There's nothing in recently played."
if self.history
else "There's nothing currently being played.",
messageable=menu.ctx,
)
)


class QueuePickerSource(QueueSource):
Expand All @@ -242,22 +242,22 @@ async def get_page(self, page_number):
return []

async def format_page(self, menu: QueuePickerMenu, tracks: list[Track]) -> discord.Embed:
player = self.cog.lavalink.get_player(menu.ctx.guild.id)
if not player:
if player := self.cog.lavalink.get_player(menu.ctx.guild.id):
return (
await player.get_queue_page(
page_index=menu.current_page,
per_page=self.per_page,
total_pages=self.get_max_pages(),
embed=True,
messageable=menu.ctx,
)
if player.current
else await self.cog.lavalink.construct_embed(
description="There's nothing currently being played.",
messageable=menu.ctx,
)
)
else:
return await self.cog.lavalink.construct_embed(
description="No active player found in server.", messageable=menu.ctx
)
return (
await player.get_queue_page(
page_index=menu.current_page,
per_page=self.per_page,
total_pages=self.get_max_pages(),
embed=True,
messageable=menu.ctx,
)
if player.current
else await self.cog.lavalink.construct_embed(
description="There's nothing currently being played.",
messageable=menu.ctx,
)
)

0 comments on commit a421879

Please sign in to comment.