Skip to content

Commit 61a1433

Browse files
authored
__
1 parent 3ee00e0 commit 61a1433

File tree

3 files changed

+38
-38
lines changed

3 files changed

+38
-38
lines changed

discord/ui/core.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,30 +72,30 @@ def __init__(
7272
self.add_item(item)
7373

7474
loop = asyncio.get_running_loop()
75-
self.__cancel_callback: Callable[[View], None] | None = None
76-
self.__timeout_expiry: float | None = None
77-
self.__timeout_task: asyncio.Task[None] | None = None
78-
self.__stopped: asyncio.Future[bool] = loop.create_future()
75+
self._cancel_callback: Callable[[View], None] | None = None
76+
self._timeout_expiry: float | None = None
77+
self._timeout_task: asyncio.Task[None] | None = None
78+
self._stopped: asyncio.Future[bool] = loop.create_future()
7979

8080
def __repr__(self) -> str:
8181
return f"<{self.__class__.__name__} timeout={self.timeout} children={len(self.children)}>"
8282

83-
async def __timeout_task_impl(self) -> None:
83+
async def _timeout_task_impl(self) -> None:
8484
while True:
8585
# Guard just in case someone changes the value of the timeout at runtime
8686
if self.timeout is None:
8787
return
8888

89-
if self.__timeout_expiry is None:
89+
if self._timeout_expiry is None:
9090
return self._dispatch_timeout()
9191

9292
# Check if we've elapsed our currently set timeout
9393
now = time.monotonic()
94-
if now >= self.__timeout_expiry:
94+
if now >= self._timeout_expiry:
9595
return self._dispatch_timeout()
9696

9797
# Wait N seconds to see if timeout data has been refreshed
98-
await asyncio.sleep(self.__timeout_expiry - now)
98+
await asyncio.sleep(self._timeout_expiry - now)
9999

100100
@property
101101
def _expires_at(self) -> float | None:

discord/ui/modal.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ def __repr__(self) -> str:
9292
return f"<{self.__class__.__name__} {attrs}>"
9393

9494
def _start_listening_from_store(self, store: ModalStore) -> None:
95-
self.__cancel_callback = partial(store.remove_modal)
95+
self._cancel_callback = partial(store.remove_modal)
9696
if self.timeout:
9797
loop = asyncio.get_running_loop()
98-
if self.__timeout_task is not None:
99-
self.__timeout_task.cancel()
98+
if self._timeout_task is not None:
99+
self._timeout_task.cancel()
100100

101-
self.__timeout_expiry = time.monotonic() + self.timeout
102-
self.__timeout_task = loop.create_task(self.__timeout_task_impl())
101+
self._timeout_expiry = time.monotonic() + self.timeout
102+
self._timeout_task = loop.create_task(self._timeout_task_impl())
103103

104104
def _dispatch_timeout(self):
105105
if self._stopped.done():
@@ -208,10 +208,10 @@ def stop(self) -> None:
208208
"""Stops listening to interaction events from the modal."""
209209
if not self._stopped.done():
210210
self._stopped.set_result(True)
211-
self.__timeout_expiry = None
212-
if self.__timeout_task is not None:
213-
self.__timeout_task.cancel()
214-
self.__timeout_task = None
211+
self._timeout_expiry = None
212+
if self._timeout_task is not None:
213+
self._timeout_task.cancel()
214+
self._timeout_task = None
215215

216216
async def wait(self) -> bool:
217217
"""Waits for the modal to be submitted."""

discord/ui/view.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def is_components_v2(self) -> bool:
360360
async def _scheduled_task(self, item: Item[V], interaction: Interaction):
361361
try:
362362
if self.timeout:
363-
self.__timeout_expiry = time.monotonic() + self.timeout
363+
self._timeout_expiry = time.monotonic() + self.timeout
364364

365365
allow = await self.interaction_check(interaction)
366366
if not allow:
@@ -371,26 +371,26 @@ async def _scheduled_task(self, item: Item[V], interaction: Interaction):
371371
return await self.on_error(e, item, interaction)
372372

373373
def _start_listening_from_store(self, store: ViewStore) -> None:
374-
self.__cancel_callback = partial(store.remove_view)
374+
self._cancel_callback = partial(store.remove_view)
375375
if self.timeout:
376376
loop = asyncio.get_running_loop()
377-
if self.__timeout_task is not None:
378-
self.__timeout_task.cancel()
377+
if self._timeout_task is not None:
378+
self._timeout_task.cancel()
379379

380-
self.__timeout_expiry = time.monotonic() + self.timeout
381-
self.__timeout_task = loop.create_task(self.__timeout_task_impl())
380+
self._timeout_expiry = time.monotonic() + self.timeout
381+
self._timeout_task = loop.create_task(self._timeout_task_impl())
382382

383383
def _dispatch_timeout(self):
384-
if self.__stopped.done():
384+
if self._stopped.done():
385385
return
386386

387-
self.__stopped.set_result(True)
387+
self._stopped.set_result(True)
388388
asyncio.create_task(
389389
self.on_timeout(), name=f"discord-ui-view-timeout-{self.id}"
390390
)
391391

392392
def _dispatch_item(self, item: Item[V], interaction: Interaction):
393-
if self.__stopped.done():
393+
if self._stopped.done():
394394
return
395395

396396
if interaction.message:
@@ -403,14 +403,14 @@ def _dispatch_item(self, item: Item[V], interaction: Interaction):
403403

404404
def is_finished(self) -> bool:
405405
"""Whether the view has finished interacting."""
406-
return self.__stopped.done()
406+
return self._stopped.done()
407407

408408
def is_dispatchable(self) -> bool:
409409
return any(item.is_dispatchable() for item in self.children)
410410

411411
def is_dispatching(self) -> bool:
412412
"""Whether the view has been added for dispatching purposes."""
413-
return self.__cancel_callback is not None
413+
return self._cancel_callback is not None
414414

415415
def is_persistent(self) -> bool:
416416
"""Whether the view is set up as persistent.
@@ -427,17 +427,17 @@ def stop(self) -> None:
427427
428428
This operation cannot be undone.
429429
"""
430-
if not self.__stopped.done():
431-
self.__stopped.set_result(False)
430+
if not self._stopped.done():
431+
self._stopped.set_result(False)
432432

433-
self.__timeout_expiry = None
434-
if self.__timeout_task is not None:
435-
self.__timeout_task.cancel()
436-
self.__timeout_task = None
433+
self._timeout_expiry = None
434+
if self._timeout_task is not None:
435+
self._timeout_task.cancel()
436+
self._timeout_task = None
437437

438-
if self.__cancel_callback:
439-
self.__cancel_callback(self)
440-
self.__cancel_callback = None
438+
if self._cancel_callback:
439+
self._cancel_callback(self)
440+
self._cancel_callback = None
441441

442442
async def wait(self) -> bool:
443443
"""Waits until the view has finished interacting.
@@ -451,7 +451,7 @@ async def wait(self) -> bool:
451451
If ``True``, then the view timed out. If ``False`` then
452452
the view finished normally.
453453
"""
454-
return await self.__stopped
454+
return await self._stopped
455455

456456
def disable_all_items(self, *, exclusions: list[Item[V]] | None = None) -> Self:
457457
"""

0 commit comments

Comments
 (0)