Browse Source

Don't store finished views/modals

pull/7720/merge
z03h 2 years ago
committed by GitHub
parent
commit
e6ef43139f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      discord/abc.py
  2. 2
      discord/channel.py
  3. 5
      discord/client.py
  4. 6
      discord/interactions.py

2
discord/abc.py

@ -1552,7 +1552,7 @@ class Messageable:
data = await state.http.send_message(channel.id, params=params)
ret = state.create_message(channel=channel, data=data)
if view:
if view and not view.is_finished():
state.store_view(view, ret.id)
if delete_after is not None:

2
discord/channel.py

@ -2653,7 +2653,7 @@ class ForumChannel(discord.abc.GuildChannel, Hashable):
data = await state.http.start_thread_in_forum(self.id, params=params, reason=reason)
thread = Thread(guild=self.guild, state=self._state, data=data)
message = Message(state=self._state, channel=thread, data=data['message'])
if view:
if view and not view.is_finished():
self._state.store_view(view, message.id)
return ThreadWithMessage(thread=thread, message=message)

5
discord/client.py

@ -2694,7 +2694,7 @@ class Client:
TypeError
A view was not passed.
ValueError
The view is not persistent. A persistent view has no timeout
The view is not persistent or is already finished. A persistent view has no timeout
and all their components have an explicitly provided custom_id.
"""
@ -2704,6 +2704,9 @@ class Client:
if not view.is_persistent():
raise ValueError('View is not persistent. Items need to have a custom_id set and View must have no timeout')
if view.is_finished():
raise ValueError('View is already finished.')
self._connection.store_view(view, message_id)
@property

6
discord/interactions.py

@ -784,7 +784,7 @@ class InteractionResponse(Generic[ClientT]):
params=params,
)
if view is not MISSING:
if view is not MISSING and not view.is_finished():
if ephemeral and view.timeout is None:
view.timeout = 15 * 60.0
@ -954,8 +954,8 @@ class InteractionResponse(Generic[ClientT]):
proxy_auth=http.proxy_auth,
params=params,
)
self._parent._state.store_view(modal)
if not modal.is_finished():
self._parent._state.store_view(modal)
self._response_type = InteractionResponseType.modal
async def autocomplete(self, choices: Sequence[Choice[ChoiceT]]) -> None:

Loading…
Cancel
Save