Skip to content

Commit

Permalink
feat: add set_timeout method on menu context
Browse files Browse the repository at this point in the history
  • Loading branch information
Aschubel committed Aug 28, 2024
1 parent 0092c29 commit eda0bb9
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lightbulb/components/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,18 @@ def extend_timeout(self, length: float) -> None:
"""
self._timeout.shift(length)

def set_timeout(self, timeout: float) -> None:
"""
Override the menu's timeout, resetting it to the given value.
Args:
timeout: The number of seconds to set the timeout for.
Returns:
:obj:`None`
"""
self._timeout.update(asyncio.get_running_loop().time() + timeout)

Check warning on line 408 in lightbulb/components/menus.py

View check run for this annotation

Codecov / codecov/patch

lightbulb/components/menus.py#L408

Added line #L408 was not covered by tests

def selected_values_for(self, select: Select[T]) -> Sequence[T]:
"""
Get the values the user selected for the given select menu.
Expand Down Expand Up @@ -424,7 +436,8 @@ def selected_values_for(self, select: Select[T]) -> Sequence[T]:
resolved_data.members.get(sf)
or resolved_data.users.get(sf)
or resolved_data.roles.get(sf)
or resolved_data.channels[sf] # type: ignore[reportArgumentType]
# type: ignore[reportArgumentType]
or resolved_data.channels[sf]
)

return resolved
Expand Down

0 comments on commit eda0bb9

Please sign in to comment.