Pycord-Development/pycord

Error in cog bridge command ctx annotation

solaluset opened this issue · 0 comments

Summary

Annotating ctx in bridge command inside a cog raises error

Reproduction Steps

Run the following code

Minimal Reproducible Code

import os

from discord.ext.commands import Cog
from discord.ext.bridge import Bot, BridgeContext, bridge_command


class A(Cog):
    @bridge_command()
    async def cmd(self, ctx: BridgeContext):
        await ctx.send("ok")


bot = Bot()
bot.add_cog(A())
bot.run(os.getenv("TOKEN"))

Expected Results

The bot working fine (it works without the annotation)

Actual Results

Traceback (most recent call last):
  File "/data/data/com.termux/files/home/DandelionMusic/repro5.py", line 7, in <module>
    class A(Cog):
  File "/data/data/com.termux/files/home/DandelionMusic/repro5.py", line 8, in A
    @bridge_command()
     ^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/home/tests/lib/python3.11/site-packages/discord/ext/bridge/core.py", line 424, in decorator
    return BridgeCommand(callback, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/home/tests/lib/python3.11/site-packages/discord/ext/bridge/core.py", line 167, in __init__
    ) or BridgeSlashCommand(callback, **kwargs)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/home/tests/lib/python3.11/site-packages/discord/ext/bridge/core.py", line 82, in __init__
    super().__init__(func, **kwargs)
  File "/data/data/com.termux/files/home/tests/lib/python3.11/site-packages/discord/commands/core.py", line 693, in __init__
    self._validate_parameters()
  File "/data/data/com.termux/files/home/tests/lib/python3.11/site-packages/discord/commands/core.py", line 711, in _validate_parameters
    self.options = self._parse_options(params)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/home/tests/lib/python3.11/site-packages/discord/commands/core.py", line 769, in _parse_options
    option = Option(option)
             ^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/home/tests/lib/python3.11/site-packages/discord/commands/options.py", line 231, in __init__
    raise exc
  File "/data/data/com.termux/files/home/tests/lib/python3.11/site-packages/discord/commands/options.py", line 226, in __init__
    self.input_type = SlashCommandOptionType.from_datatype(input_type)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/home/tests/lib/python3.11/site-packages/discord/enums.py", line 815, in from_datatype
    raise TypeError(
TypeError: Invalid class <class 'discord.ext.bridge.context.BridgeContext'> used as an input type for an Option

Intents

None

System Information

/data/data/com.termux/files/home/tests/lib/python3.11/site-packages/discord/main.py:33: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
import pkg_resources

  • Python v3.11.6-final
  • py-cord v2.4.1-final
  • aiohttp v3.9.1
  • system info: Linux 4.14.232-QuicksilveR™-ReloadedOS-Edition #1 SMP PREEMPT Wed May 26 07:08:17 UTC 2021

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.

Additional Context

No response