pycord
pycord copied to clipboard
feat(commands): add support for typing.Literal[...] as command choices
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: ignorecomments were used, a comment is also left explaining why. - [x] I have updated the changelog to include these changes.