-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Description
Summary
ForumChannels cannot be used as an app_command annotation
Reproduction Steps
Upgraded to 2.1a on commits dated 9/15/22.
Attempted to use ForumChannel as a annotation/converter in an app command
TypeError is thrown when Cog is loaded:
Minimal Reproducible Code
`class ReproduceCog(Cog):
def __init__(self, bot):
self.bot = bot
@app_commands.command(name='reproduce')
async def reproduce(self, interaction: discord.Interaction, channel: discord.ForumChannel):
await interaction.response.send_message(channel.name)
`
Expected Results
Responds with the channel name
Actual Results
Traceback (most recent call last):
2022-09-17T04:03:06.325918700Z File "/usr/local/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 934, in _load_from_module_spec
2022-09-17T04:03:06.325921300Z spec.loader.exec_module(lib) # type: ignore
2022-09-17T04:03:06.325923700Z File "", line 883, in exec_module
2022-09-17T04:03:06.325926100Z File "", line 241, in _call_with_frames_removed
2022-09-17T04:03:06.325928600Z File "/home/bot/amelia/cogs/reproducecog.py", line 21, in
2022-09-17T04:03:06.325931100Z class ReproduceCog(Cog):
2022-09-17T04:03:06.325933500Z File "/home/bot/amelia/cogs/reproducecog.py", line 27, in ReproduceCog
2022-09-17T04:03:06.325935900Z async def reproduce(self, interaction: discord.Interaction, channel: discord.ForumChannel):
2022-09-17T04:03:06.325938300Z File "/usr/local/lib/python3.10/site-packages/discord/app_commands/commands.py", line 2010, in decorator
2022-09-17T04:03:06.325940700Z return Command(
2022-09-17T04:03:06.325943000Z File "/usr/local/lib/python3.10/site-packages/discord/app_commands/commands.py", line 680, in init
2022-09-17T04:03:06.325945500Z self._params: Dict[str, CommandParameter] = _extract_parameters_from_callback(callback, callback.globals)
2022-09-17T04:03:06.325960600Z File "/usr/local/lib/python3.10/site-packages/discord/app_commands/commands.py", line 393, in _extract_parameters_from_callback
2022-09-17T04:03:06.325963400Z param = annotation_to_parameter(resolved, parameter)
2022-09-17T04:03:06.325965700Z File "/usr/local/lib/python3.10/site-packages/discord/app_commands/transformers.py", line 831, in annotation_to_parameter
2022-09-17T04:03:06.325968200Z (inner, default, validate_default) = get_supported_annotation(annotation)
2022-09-17T04:03:06.325970600Z File "/usr/local/lib/python3.10/site-packages/discord/app_commands/transformers.py", line 790, in get_supported_annotation
2022-09-17T04:03:06.325973000Z raise TypeError(f'unsupported type annotation {annotation!r}')
2022-09-17T04:03:06.325975400Z TypeError: unsupported type annotation <class 'discord.channel.ForumChannel'>
2022-09-17T04:03:06.325977800Z
2022-09-17T04:03:06.325980100Z The above exception was the direct cause of the following exception:
2022-09-17T04:03:06.325982400Z
2022-09-17T04:03:06.325984700Z Traceback (most recent call last):
2022-09-17T04:03:06.325987400Z File "/usr/local/lib/python3.10/asyncio/events.py", line 80, in _run
2022-09-17T04:03:06.325989900Z self._context.run(self._callback, *self._args)
2022-09-17T04:03:06.325992200Z File "/home/bot/amelia/main.py", line 25, in bot_task_callback
2022-09-17T04:03:06.325994600Z raise future.exception()
2022-09-17T04:03:06.325996800Z File "/home/bot/amelia/main.py", line 61, in run_bot
2022-09-17T04:03:06.325999200Z await bot.start(token)
2022-09-17T04:03:06.326001500Z File "/usr/local/lib/python3.10/site-packages/discord/client.py", line 745, in start
2022-09-17T04:03:06.326003900Z await self.login(token)
2022-09-17T04:03:06.326006200Z File "/usr/local/lib/python3.10/site-packages/discord/client.py", line 589, in login
2022-09-17T04:03:06.326008600Z await self.setup_hook()
2022-09-17T04:03:06.326010900Z File "/home/bot/amelia/bot.py", line 56, in setup_hook
2022-09-17T04:03:06.326013200Z await self._load_extension(ext)
2022-09-17T04:03:06.326015500Z File "/home/bot/amelia/bot.py", line 63, in _load_extension
2022-09-17T04:03:06.326017900Z await self.load_extension(name)
2022-09-17T04:03:06.326020200Z File "/usr/local/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 1012, in load_extension
2022-09-17T04:03:06.326022600Z await self._load_from_module_spec(spec, name)
2022-09-17T04:03:06.326024900Z File "/usr/local/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 937, in _load_from_module_spec
2022-09-17T04:03:06.326027400Z raise errors.ExtensionFailed(key, e) from e
2022-09-17T04:03:06.326029700Z discord.ext.commands.errors.ExtensionFailed: Extension 'amelia.cogs.reproducecog' raised an error: TypeError: unsupported type annotation <class 'discord.channel.ForumChannel'>
Intents
members, guilds, messages
System Information
- Python v3.10.7-final
- discord.py v2.1.0-alpha
- discord.py metadata: v2.1.0a4593+gb5dc9e54
- aiohttp v3.7.4.post0
- system info: Linux 4.9.184-linuxkit Fix issue with author changing type #1 SMP Tue Jul 2 22:58:16 UTC 2019
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