21
21
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
22
DEALINGS IN THE SOFTWARE.
23
23
"""
24
+ import copy
24
25
from typing import Dict , List , Optional , Union
25
26
26
27
import discord
@@ -397,12 +398,14 @@ async def disable(
397
398
for item in self .children :
398
399
if item not in self .custom_view_items or include_custom :
399
400
item .disabled = True
400
-
401
- await self .message .edit (
402
- content = page if isinstance (page , str ) else None ,
403
- embeds = [] if isinstance (page , str ) else page ,
404
- view = self ,
405
- )
401
+ if page :
402
+ await self .message .edit (
403
+ content = page if isinstance (page , str ) else None ,
404
+ embeds = [] if isinstance (page , str ) else page ,
405
+ view = self ,
406
+ )
407
+ else :
408
+ await self .message .edit (view = self )
406
409
407
410
async def cancel (
408
411
self ,
@@ -418,16 +421,18 @@ async def cancel(
418
421
page: Optional[Union[:class:`str`, Union[List[:class:`discord.Embed`], :class:`discord.Embed`]]]
419
422
The page content to show after canceling the paginator.
420
423
"""
421
- for item in self .children :
422
- if include_custom :
423
- self .clear_items ()
424
- elif item not in self .custom_view_items :
424
+ items = copy .copy (self .children )
425
+ for item in items :
426
+ if item not in self .custom_view_items or include_custom :
425
427
self .remove_item (item )
426
- await self .message .edit (
427
- content = page if isinstance (page , str ) else None ,
428
- embeds = [] if isinstance (page , str ) else page ,
429
- view = self ,
430
- )
428
+ if page :
429
+ await self .message .edit (
430
+ content = page if isinstance (page , str ) else None ,
431
+ embeds = [] if isinstance (page , str ) else page ,
432
+ view = self ,
433
+ )
434
+ else :
435
+ await self .message .edit (view = self )
431
436
432
437
async def goto_page (self , page_number = 0 ) -> discord .Message :
433
438
"""Updates the paginator message to show the specified page number.
0 commit comments