Skip to content

Conversation

Vioshim
Copy link
Contributor

@Vioshim Vioshim commented Apr 30, 2024

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.
  • 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

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

@JustaSqu1d JustaSqu1d added hold: documentation This pull request is missing documentation hold: changelog This pull request is missing a changelog entry labels Apr 30, 2024
@JustaSqu1d JustaSqu1d removed the hold: changelog This pull request is missing a changelog entry label May 22, 2024
@Dorukyum Dorukyum changed the title feat: Implements positional flags feat: implement positional flags Jun 28, 2024
Co-authored-by: Dorukyum <[email protected]>
Co-authored-by: JustaSqu1d <[email protected]>
Signed-off-by: Lala Sabathil <[email protected]>
@Lulalaby
Copy link
Member

Lulalaby commented Jul 1, 2024

@Vioshim please work on dorus comment and resolve conflcts

@JustaSqu1d JustaSqu1d added priority: medium Medium Priority feature Implements a feature python Pull requests that update Python code and removed hold: documentation This pull request is missing documentation labels Aug 7, 2024
@Lulalaby Lulalaby added this to the v2.7 milestone Aug 10, 2024
Lulalaby and others added 6 commits August 16, 2024 14:52
The typing import in flags.py has been updated to include the Optional module. This change ensures that the __commands_flag_positional__ attribute can accept a value of None.
@Lulalaby Lulalaby added priority: low Low Priority and removed priority: medium Medium Priority labels Mar 23, 2025
@Lulalaby
Copy link
Member

@Pycord-Development/contributors can we get some testing here :D

Copy link
Member

@Paillat-dev Paillat-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File "C:\Users\Jérémie\Documents\GitHub\pycord\thing.py", line 23, in <module>
    class BasicText(FlagConverter, prefix="--", delimiter=" "):
  File "C:\Users\Jérémie\Documents\GitHub\pycord\thing.py", line 24, in BasicText
    text: str = flag(positional=True)
                ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Jérémie\Documents\GitHub\pycord\discord\ext\commands\flags.py", line 143, in flag
    return Flag(
           ^^^^^
TypeError: Flag.__init__() got an unexpected keyword argument 'name'

The error does not seem to be caused by this PR, but rather by me using python 3.11. The error is not present in my testing when using python 3.10.

fix in #2759

Other than that, this seems to work to me, although I don't think I'm experienced enough with flags - and prefixed commands to assess with good certainty that everything works as expected.

@Lumabots
Copy link
Contributor

does this need testing or is it ready to merge ?

@Paillat-dev
Copy link
Member

Needs testing + doesn't work with python 3.11+

@Lulalaby
Copy link
Member

Lulalaby commented Aug 2, 2025

Merge conflicts

@Paillat-dev
Copy link
Member

@Lulalaby I think that OP is gone but I can fix these in a new pr. Lmk if ok

@Lulalaby
Copy link
Member

Lulalaby commented Aug 2, 2025

Sure go for it if you still think it's a good addition

@Vioshim
Copy link
Contributor Author

Vioshim commented Aug 4, 2025

My apologies, felt lost on how to be able to contribute in the project once i saw the things about merging conflicts or the documentation changes, so ended up lost on how to correct it alongside irl stuff, so my apologies for the lack of response

@Paillat-dev
Copy link
Member

@Vioshim no worries. Do you still want to work on this ? If lmk and I'll handle the merge conflicts and the rest

@Vioshim
Copy link
Contributor Author

Vioshim commented Aug 4, 2025

That'd be quite appreciated, thank you!!
@Paillat-dev

@Paillat-dev
Copy link
Member

No worries and thank you for your contribution !

@Paillat-dev
Copy link
Member

Paillat-dev commented Aug 4, 2025

@Lumabots Can I get some testing from you ? Specifically on python 3.11 and higher ?

@Lumabots
Copy link
Contributor

Lumabots commented Aug 4, 2025

@Lumabots Can I get some testing from you ? Specifically on python 3.11 and higher ?

Yep doing that tomorrow evening

@Lulalaby Lulalaby requested a review from a team as a code owner August 30, 2025 20:33
@Lulalaby Lulalaby force-pushed the master branch 2 times, most recently from b55c125 to 82659b2 Compare August 30, 2025 21:10
@Lulalaby Lulalaby removed the on hold label Aug 30, 2025
@Lulalaby Lulalaby requested a review from a team as a code owner September 1, 2025 12:31
Copy link
Contributor

@DA-344 DA-344 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm code wise, if this is tested and works then should be ready to merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Implements a feature hold: testing This pull request requires further testing priority: low Low Priority python Pull requests that update Python code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants