pycord icon indicating copy to clipboard operation
pycord copied to clipboard

feat: implement positional flags

Open Vioshim opened this issue 1 year ago • 5 comments

Summary

This allows FlagConverters to be used after the first text expression, for example

class HandleText(FlagConverter, prefix="--", delimiter=" "):
    text: str = commands.flag(positional=True)
    flip: bool = False
    
@bot.bridge_command()
async def welcome(ctx: bridge.BridgeContext, *, flags: HandleText):
    text = flags.text[::-1] if flags.flip else flags.text
    await ctx.respond(text)

# ?welcome Hello world
# ?welcome Hello world --flip True
# ?welcome --text Hello world
# ?welcome --text Hello world --flip True

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.
  • [ ] If type: ignore comments were used, a comment is also left explaining why.
  • [X] I have updated the changelog to include these changes.

Vioshim avatar Apr 30 '24 18:04 Vioshim

@Vioshim please work on dorus comment and resolve conflcts

Lulalaby avatar Jul 01 '24 13:07 Lulalaby