pycord
pycord copied to clipboard
pages.Paginator.send() context does not accept BridgeContext
Summary
The context argument for paginator.send() function does not currently accept BridgeContext
Reproduction Steps
- Make a command using discord.ext.bridge
- Create paginator object
- Send the paginator object using
paginator.send()
and use context provided by the command as the context for the function
Minimal Reproducible Code
from discord.ext import bridge, pages
client = bridge.Bot(command_prefix=commands.when_mentioned_or("!"), intents=discord.Intents.all())
@client.bridge_command()
async def paginate(ctx):
embeds = [] # list of embeds, in actual code this will always be filled with at least 1 embed
paginator = pages.Paginator(pages=embeds)
await paginator.send(ctx=ctx)
client.run("Bot token")
Expected Results
The page sent correctly.
Actual Results
An error raised:
Ignoring exception in command paginate:
Traceback (most recent call last):
File "C:\Users\ACER\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 126, in wrapped
ret = await coro(arg)
File "C:\Users\ACER\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 856, in _invoke
await self.callback(ctx, **kwargs)
File "e:\Discord Bots (after return lol)\VoteBot\main.py", line 191, in paginate
await paginator.send(ctx=ctx)
File "C:\Users\ACER\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\pages\pagination.py", line 880, in send
raise TypeError(f"expected Context not {ctx.__class__!r}")
TypeError: expected Context not <class 'discord.ext.bridge.context.BridgeApplicationContext'>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\ACER\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 993, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\ACER\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 357, in invoke
await injected(ctx)
File "C:\Users\ACER\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 134, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: expected Context not <class 'discord.ext.bridge.context.BridgeApplicationContext'>
Intents
discord.Intents.all()
System Information
- Python v3.10.2-final
- py-cord v2.0.0-candidate
- py-cord pkg_resources: v2.0.0rc1
- aiohttp v3.8.1
- system info: Windows 10 10.0.19043
Checklist
- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.
Additional Context
No response
If you look at the code (and even the error message) carefully, you'll notice that the send()
function only accepts discord.ext.commands.Context
, and what you're providing is discord.ext.bridge.BridgeApplicationContext
.
If you look at the code (and even the error message) carefully, you'll notice that the
send()
function only acceptsdiscord.ext.commands.Context
, and what you're providing isdiscord.ext.bridge.BridgeApplicationContext
.
I did look at the code and the error. What I'm trying to say here is that discord.ext.pages
hasn't yet supported BridgeContext which used in discord.ext.bridge
.
Nope. BridgeContext
is a base class for BridgeApplicationContext
and BridgeExtContext
which is actually provided to your Bridge Command callback depending on how the command was executed. This simple fact is actually how you can tell how your Bridge Command was called.
I can reproduce this error. There are workarounds, such as checking the difference between BridgeApplicationContext
and BridgeExtContext
to determine if paginator.send
or paginator.respond
should be used, or, flat out using paginator.respond
, which works for both types of BridgeContext
. Regardless, allowing BridgeApplicationContext
instead of solely BridgeExtContext
in paginator.send
is probably something that should be done (probably a relatively easy PR if anyone wants).