You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Futher improvements in components implementation (#204)
* Added support for actionrows in wait_for_component
(cherry picked from commit 4e2c310)
* Applied black formatting
(cherry picked from commit f4e34ff)
* Added message kwarg to wait_for_component, removed wait_for_any_component
(cherry picked from commit 06f3437)
* Exception for hidden+edit_origin
(cherry picked from commit 296792f)
* Warning on edit_origin when deferred with different state
(cherry picked from commit 1d33e7f)
* Changed exception types in get_components_ids and _get_messages_ids
(cherry picked from commit 3eb8c27)
* Added warning for send when deffered with different state
(cherry picked from commit 9e242ef)
* Tweaked docstrings
(cherry picked from commit 0ecd922)
* Moved component enums to model.py
(cherry picked from commit a664f4a)
* Fix ComponentContext.send()
(cherry picked from commit 3a6dee2)
* Applied pre_push
* Fixed bad merge result (bare except)
* Added component attribute to ComponentContext
* Applied changes from review
'Defers' the response, showing a loading state to the user
308
315
309
316
:param hidden: Whether the deferred response should be ephemeral . Default ``False``.
310
-
:param edit_origin: Whether the response is editing the origin message. If ``False``, the deferred response will be for a follow up message. Defaults ``False``.
317
+
:param edit_origin: Whether the type is editing the origin message. If ``False``, the deferred response will be for a follow up message. Defaults ``False``.
311
318
"""
312
319
ifself.deferredorself.responded:
313
320
raiseerror.AlreadyResponded("You have already responded to this command!")
321
+
314
322
base= {"type": 6ifedit_originelse5}
315
-
ifhiddenandnotedit_origin:
323
+
324
+
ifhidden:
325
+
ifedit_origin:
326
+
raiseerror.IncorrectFormat(
327
+
"'hidden' and 'edit_origin' flags are mutually exclusive"
Waits for any component interaction. Only accepts interactions based on the message ID given and optionally a check function.
199
+
Helper function - wrapper around 'client.wait_for("component", ...)'
200
+
Waits for a component interaction. Only accepts interactions based on the custom ID of the component or/and message ID, and optionally a check function.
200
201
201
202
:param client: The client/bot object.
202
203
:type client: :class:`discord.Client`
203
-
:param message: The message object to check for, or the message ID.
204
-
:type message: Union[discord.Message, int]
204
+
:param component: Custom ID or component dict (actionrow or button) or list of previous two.
205
+
:param message: The message object to check for, or the message ID or list of previous two.
206
+
:type component: Union[dict, str]
205
207
:param check: Optional check function. Must take a `ComponentContext` as the first parameter.
206
208
:param timeout: The number of seconds to wait before timing out and raising :exc:`asyncio.TimeoutError`.
207
209
:raises: :exc:`asyncio.TimeoutError`
208
210
"""
209
211
210
-
def_check(ctx):
212
+
ifnot (componentormessage):
213
+
raiseIncorrectFormat("You must specify component or message (or both)")
0 commit comments