mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-11 04:17:58 +00:00
Don't store finished views/modals
This commit is contained in:
parent
caf0fbdc1b
commit
e6ef43139f
@ -1552,7 +1552,7 @@ class Messageable:
|
|||||||
data = await state.http.send_message(channel.id, params=params)
|
data = await state.http.send_message(channel.id, params=params)
|
||||||
|
|
||||||
ret = state.create_message(channel=channel, data=data)
|
ret = state.create_message(channel=channel, data=data)
|
||||||
if view:
|
if view and not view.is_finished():
|
||||||
state.store_view(view, ret.id)
|
state.store_view(view, ret.id)
|
||||||
|
|
||||||
if delete_after is not None:
|
if delete_after is not None:
|
||||||
|
@ -2653,7 +2653,7 @@ class ForumChannel(discord.abc.GuildChannel, Hashable):
|
|||||||
data = await state.http.start_thread_in_forum(self.id, params=params, reason=reason)
|
data = await state.http.start_thread_in_forum(self.id, params=params, reason=reason)
|
||||||
thread = Thread(guild=self.guild, state=self._state, data=data)
|
thread = Thread(guild=self.guild, state=self._state, data=data)
|
||||||
message = Message(state=self._state, channel=thread, data=data['message'])
|
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)
|
self._state.store_view(view, message.id)
|
||||||
|
|
||||||
return ThreadWithMessage(thread=thread, message=message)
|
return ThreadWithMessage(thread=thread, message=message)
|
||||||
|
@ -2694,7 +2694,7 @@ class Client:
|
|||||||
TypeError
|
TypeError
|
||||||
A view was not passed.
|
A view was not passed.
|
||||||
ValueError
|
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.
|
and all their components have an explicitly provided custom_id.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -2704,6 +2704,9 @@ class Client:
|
|||||||
if not view.is_persistent():
|
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')
|
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)
|
self._connection.store_view(view, message_id)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -784,7 +784,7 @@ class InteractionResponse(Generic[ClientT]):
|
|||||||
params=params,
|
params=params,
|
||||||
)
|
)
|
||||||
|
|
||||||
if view is not MISSING:
|
if view is not MISSING and not view.is_finished():
|
||||||
if ephemeral and view.timeout is None:
|
if ephemeral and view.timeout is None:
|
||||||
view.timeout = 15 * 60.0
|
view.timeout = 15 * 60.0
|
||||||
|
|
||||||
@ -954,8 +954,8 @@ class InteractionResponse(Generic[ClientT]):
|
|||||||
proxy_auth=http.proxy_auth,
|
proxy_auth=http.proxy_auth,
|
||||||
params=params,
|
params=params,
|
||||||
)
|
)
|
||||||
|
if not modal.is_finished():
|
||||||
self._parent._state.store_view(modal)
|
self._parent._state.store_view(modal)
|
||||||
self._response_type = InteractionResponseType.modal
|
self._response_type = InteractionResponseType.modal
|
||||||
|
|
||||||
async def autocomplete(self, choices: Sequence[Choice[ChoiceT]]) -> None:
|
async def autocomplete(self, choices: Sequence[Choice[ChoiceT]]) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user