Pycord-Development / pycord

Pycord is a modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python
https://docs.pycord.dev
MIT License
2.74k stars 462 forks source link

feat: implement positional flags #2443

Open Vioshim opened 6 months ago

Vioshim commented 6 months ago

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

Checklist

Lulalaby commented 4 months ago

@Vioshim please work on dorus comment and resolve conflcts