diff --git a/fragments/448.feature.md b/fragments/448.feature.md new file mode 100644 index 00000000..d5ef9797 --- /dev/null +++ b/fragments/448.feature.md @@ -0,0 +1 @@ +Add `set_timeout` method to `MenuContext`. diff --git a/lightbulb/components/menus.py b/lightbulb/components/menus.py index b3987fd5..2aa73425 100644 --- a/lightbulb/components/menus.py +++ b/lightbulb/components/menus.py @@ -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) + def selected_values_for(self, select: Select[T]) -> Sequence[T]: """ Get the values the user selected for the given select menu.