Skip to content

Paginator.disable does not work if not using a custom view #1082

@Ahsoka

Description

@Ahsoka

Summary

When using Paginator.disable method, it does not work when using not using a custom view.

Reproduction Steps

Simply make a paginator and trying to disable it will cause it to error out. See the code snippet below. Use the /create command a couple of times, then use the /disable command to disable the paginators you created.

For example you do:
/create
/create
/create

Then do /disable 1 to disable to the second one you created. As you will see bot will error out.

Minimal Reproducible Code

from discord.ext.pages import Paginator
from typing import List, Tuple

import discord

debug_guilds: List[int] = ...
assert debug_guilds is not ..., 'Fill in debug_guild(s)'
bot = discord.Bot(debug_guilds=debug_guilds)

paginators: List[
    Tuple[discord.ApplicationContext, Paginator]
]= []

@bot.slash_command()
async def create(ctx: discord.ApplicationContext):
    paginator = Paginator(['Hello!', 'There!'])
    paginators.append((ctx, paginator))
    await paginator.respond(ctx.interaction)

@bot.slash_command()
async def disable(ctx: discord.ApplicationContext, index: int = 0):
    if len(paginators) <= index:
        await ctx.respond('Invalid number, there are not that many paginators created.')
    else:
        await paginators[index][0].respond('Disabling this one!')
        await paginators[index][1].disable()

@bot.event
async def on_ready():
    print(f"{bot.user} is ready!")

token = ...
assert token is not ..., 'Use a valid token!'
bot.run(token)

Expected Results

It should disable the paginator.

Actual Results

The following error occurs:

Ignoring exception in command disable:
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\discord\commands\core.py", line 110, in wrapped
    ret = await coro(arg)
  File "C:\ProgramData\Anaconda3\lib\site-packages\discord\commands\core.py", line 774, in _invoke
    await self.callback(ctx, **kwargs)
  File "disable-pag.py", line 24, in disable
    await paginators[index][1].disable()
  File "C:\ProgramData\Anaconda3\lib\site-packages\discord\ext\pages\pagination.py", line 406, in disable
    if item not in self.custom_view.children or include_custom:
AttributeError: 'NoneType' object has no attribute 'children'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\discord\bot.py", line 767, in process_application_commands
    await ctx.command.invoke(ctx)
  File "C:\ProgramData\Anaconda3\lib\site-packages\discord\commands\core.py", line 306, in invoke
    await injected(ctx)
  File "C:\ProgramData\Anaconda3\lib\site-packages\discord\commands\core.py", line 116, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.commands.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'children'

Intents

Intents are not relevant here

System Information

OS: Windows 10
Python Version: 3.8.11
Pycord Version: 2.0.0b4

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions