@@ -560,9 +560,12 @@ def _sanity_check(self) -> None:
560
560
def _queue_task (self , coro : Listener , event : BaseEvent , * args , ** kwargs ) -> asyncio .Task :
561
561
async def _async_wrap (_coro : Listener , _event : BaseEvent , * _args , ** _kwargs ) -> None :
562
562
try :
563
- if not isinstance (_event , (events .Error , events .RawGatewayEvent )):
564
- if coro .delay_until_ready and not self .is_ready :
565
- await self .wait_until_ready ()
563
+ if (
564
+ not isinstance (_event , (events .Error , events .RawGatewayEvent ))
565
+ and coro .delay_until_ready
566
+ and not self .is_ready
567
+ ):
568
+ await self .wait_until_ready ()
566
569
567
570
if len (_event .__attrs_attrs__ ) == 2 and coro .event != "event" :
568
571
# override_name & bot & logging
@@ -1046,11 +1049,7 @@ async def wait_for_modal(
1046
1049
def predicate (event ) -> bool :
1047
1050
if modal .custom_id != event .ctx .custom_id :
1048
1051
return False
1049
- if not author :
1050
- return True
1051
- if author != to_snowflake (event .ctx .author ):
1052
- return False
1053
- return True
1052
+ return author == to_snowflake (event .ctx .author ) if author else True
1054
1053
1055
1054
resp = await self .wait_for ("modal_completion" , predicate , timeout )
1056
1055
return resp .ctx
@@ -1085,7 +1084,7 @@ async def wait_for_component(
1085
1084
asyncio.TimeoutError: if timed out
1086
1085
1087
1086
"""
1088
- if not ( messages or components ) :
1087
+ if not messages and not components :
1089
1088
raise ValueError ("You must specify messages or components (or both)" )
1090
1089
1091
1090
message_ids = (
@@ -1105,9 +1104,7 @@ def _check(event: events.Component) -> bool:
1105
1104
)
1106
1105
wanted_component = not custom_ids or ctx .custom_id in custom_ids
1107
1106
if wanted_message and wanted_component :
1108
- if check is None or check (event ):
1109
- return True
1110
- return False
1107
+ return bool (check is None or check (event ))
1111
1108
return False
1112
1109
1113
1110
return await self .wait_for ("component" , checks = _check , timeout = timeout )
@@ -1242,7 +1239,7 @@ def add_interaction(self, command: InteractionCommand) -> bool:
1242
1239
1243
1240
if group is None or isinstance (command , ContextMenu ):
1244
1241
self .interaction_tree [scope ][command .resolved_name ] = command
1245
- elif group is not None :
1242
+ else :
1246
1243
if not (current := self .interaction_tree [scope ].get (base )) or isinstance (current , SlashCommand ):
1247
1244
self .interaction_tree [scope ][base ] = {}
1248
1245
if sub is None :
@@ -1754,9 +1751,7 @@ def get_ext(self, name: str) -> Extension | None:
1754
1751
Returns:
1755
1752
A extension, if found
1756
1753
"""
1757
- if ext := self .get_extensions (name ):
1758
- return ext [0 ]
1759
- return None
1754
+ return ext [0 ] if (ext := self .get_extensions (name )) else None
1760
1755
1761
1756
def __load_module (self , module , module_name , ** load_kwargs ) -> None :
1762
1757
"""Internal method that handles loading a module."""
0 commit comments