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
@@ -229,8 +227,7 @@ You may want a select menu to automatically stop working after a certain amount
229
227
```python
230
228
classMyView(discord.ui.View):
231
229
asyncdefon_timeout(self):
232
-
for child inself.children:
233
-
child.disabled =True
230
+
self.disable_all_items()
234
231
awaitself.message.edit(content="You took too long! Disabled all the components.", view=self)
235
232
236
233
@discord.ui.select(options= [...])
@@ -251,8 +248,7 @@ class MyView(discord.ui.View):
251
248
super().__init__(timeout=10) # specify the timeout here
252
249
253
250
asyncdefon_timeout(self):
254
-
for child inself.children:
255
-
child.disabled =True
251
+
self.disable_all_items()
256
252
awaitself.message.edit(content="You took too long! Disabled all the components.", view=self)
257
253
258
254
@discord.ui.select(options= [...])
@@ -263,8 +259,7 @@ class MyView(discord.ui.View):
263
259
</TabItem>
264
260
</Tabs>
265
261
266
-
Here, we loop through all the children of the view (buttons and select menus in the view) and disable
267
-
them. Then, we edit the message to show that the timeout was reached.
262
+
Here, we disable all buttons and select menus in the view. Then, we edit the message to show that the timeout was reached.
268
263
269
264
:::note
270
265
@@ -281,7 +276,7 @@ Normally, when the bot goes offline, all of its views stop working, even if they
281
276
views, but nothing will happen when you try to interact with them. This is a problem
282
277
if you are trying to create a self-role system, for example. This is where persistent views come in.
283
278
284
-
Persistent views work forever. When the bot goes offline, the buttons will stop working. However, when the bot comes back online, the buttons will start working again.
279
+
Persistent views work forever. When the bot goes offline, the buttons and select menus will stop working. However, when the bot comes back online, the buttons and select menus will start working again.
285
280
286
281
In a Persistent View, the timeout must be set to `None` and all the children in the view much have a `custom_id` attribute set.
287
282
@@ -299,7 +294,7 @@ class MyView(discord.ui.View):
0 commit comments