Skip to content

FlagConverter not usable on app_commands #10358

@hellow554

Description

@hellow554

Summary

FlagConvert not usable on app_commands

Reproduction Steps

This might be a duplicate of #9641. If yes, feel free to close this.

Minimal Reproducible Code

class RaceFlags(commands.FlagConverter):
    goal: str | None = None
    when: str | None = None
    streaming_required: bool = False
    race_info: str | None = None
    announce: bool = False

class LadxrRace(commands.Cog):
    @app_commands.command()
    @app_commands.guild_only()
    async def communityrace(
        self,
        interaction: Interaction,
        *,
        flags: RaceFlags,
    ) -> None:
        pass

Expected Results

it should just work :)

Actual Results

    | Traceback (most recent call last):
    |   File "/home/marcel/projects/discord_bot/v2.0/.venv/lib/python3.14/site-packages/discord/ext/commands/bot.py", line 962, in _load_from_module_spec
    |     spec.loader.exec_module(lib)  # type: ignore
    |     ~~~~~~~~~~~~~~~~~~~~~~~^^^^^
    |   File "<frozen importlib._bootstrap_external>", line 762, in exec_module
    |   File "<frozen importlib._bootstrap>", line 491, in _call_with_frames_removed
    |   File "/home/marcel/projects/discord_bot/v2.0/src/windfish/discord/cogs/ladxr_race.py", line 32, in <module>
    |     class LadxrRace(commands.Cog):
    |     ...<65 lines>...
    |             await interaction.followup.send(f"Your raceroom url: {url}")
    |   File "/home/marcel/projects/discord_bot/v2.0/src/windfish/discord/cogs/ladxr_race.py", line 45, in LadxrRace
    |     @app_commands.command()
    |      ~~~~~~~~~~~~~~~~~~~~^^
    |   File "/home/marcel/projects/discord_bot/v2.0/.venv/lib/python3.14/site-packages/discord/app_commands/commands.py", line 2065, in decorator
    |     return Command(
    |         name=name if name is not MISSING else func.__name__,
    |     ...<5 lines>...
    |         extras=extras,
    |     )
    |   File "/home/marcel/projects/discord_bot/v2.0/.venv/lib/python3.14/site-packages/discord/app_commands/commands.py", line 688, in __init__
    |     self._params: Dict[str, CommandParameter] = _extract_parameters_from_callback(callback, callback.__globals__)
    |                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "/home/marcel/projects/discord_bot/v2.0/.venv/lib/python3.14/site-packages/discord/app_commands/commands.py", line 384, in _extract_parameters_from_callback
    |     param = annotation_to_parameter(resolved, parameter)
    |   File "/home/marcel/projects/discord_bot/v2.0/.venv/lib/python3.14/site-packages/discord/app_commands/transformers.py", line 837, in annotation_to_parameter
    |     (inner, default, validate_default) = get_supported_annotation(annotation)
    |                                          ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
    |   File "/home/marcel/projects/discord_bot/v2.0/.venv/lib/python3.14/site-packages/discord/app_commands/transformers.py", line 796, in get_supported_annotation
    |     raise TypeError(f'unsupported type annotation {annotation!r}')
    | TypeError: unsupported type annotation <class 'windfish.discord.cogs.ladxr_race.RaceFlags'>
    |
    | The above exception was the direct cause of the following exception:
    |
    | Traceback (most recent call last):
    |   File "/home/marcel/projects/discord_bot/v2.0/.venv/lib/python3.14/site-packages/discord/client.py", line 846, in start
    |     await self.login(token)
    |   File "/home/marcel/projects/discord_bot/v2.0/.venv/lib/python3.14/site-packages/discord/client.py", line 689, in login
    |     await self.setup_hook()
    |   File "/home/marcel/projects/discord_bot/v2.0/src/windfish/discord/discord.py", line 47, in setup_hook
    |     await self.load_extension(mod, package=str(__package__))
    |   File "/home/marcel/projects/discord_bot/v2.0/.venv/lib/python3.14/site-packages/discord/ext/commands/bot.py", line 1040, in load_extension
    |     await self._load_from_module_spec(spec, name)
    |   File "/home/marcel/projects/discord_bot/v2.0/.venv/lib/python3.14/site-packages/discord/ext/commands/bot.py", line 965, in _load_from_module_spec
    |     raise errors.ExtensionFailed(key, e) from e
    | discord.ext.commands.errors.ExtensionFailed: Extension 'windfish.discord.cogs.ladxr_race' raised an error: TypeError: unsupported type annotation <class 'windfish.discord.cogs.ladxr_race.RaceFlags'>

Intents

all

System Information

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    unconfirmed bugA bug report that needs triaging

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions