pycord icon indicating copy to clipboard operation
pycord copied to clipboard

feat(commands): add support for typing.Literal[...] as command choices

Open Lumabots opened this issue 7 months ago • 0 comments

Summary

permit the usage of choice like so :

@bot.command()
async def test(ctx: discord.ApplicationContext, test: Literal["1", "2"]): ...

instead of needed to do

@bot.command()
@discord.option(name="test", choices=["1", "2"])
async def test(ctx: discord.ApplicationContext, test: ...

or

@bot.command()
async def test(ctx: discord.ApplicationContext, test: discord.Option(str, choices=["1", "2"])): ...

Information

  • [ ] This PR fixes an issue.
  • [x] This PR adds something new (e.g. new method or parameters).
  • [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • [ ] This PR is not a code change (e.g. documentation, README, typehinting, examples, ...).

Checklist

  • [x] I have searched the open pull requests for duplicates.
  • [x] If code changes were made then they have been tested.
    • [x] I have updated the documentation to reflect the changes.
  • [x] If type: ignore comments were used, a comment is also left explaining why.
  • [x] I have updated the changelog to include these changes.

Lumabots avatar May 16 '25 10:05 Lumabots