feat(Colour): factory method for `#RRGGBB` color codes
Summary
This PR adds a new factory method .from_hex_str to disnake.Colour which accepts strings in the form of "#RRGGBB".
This is particularly useful in code editors that provide a color picker when they detect a color code.
Checklist
- [x] If code changes were made, then they have been tested
- [x] I have updated the documentation to reflect the changes
- [x] I have formatted the code properly by running
uv run nox -s lint - [x] I have type-checked the code by running
uv run nox -s pyright
- [ ] 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, ...)
ext.commands.ColourConverter also handles hex colors of various formats, it could probably make use of this new method too.
ext.commands.ColourConverteralso handles hex colors of various formats, it could probably make use of this new method too.
I did expect there being a converter for this, but I'm not convinced this simple method is going to be of much use to it.
I can see these two relevant methods: https://github.com/DisnakeDev/disnake/blob/9ebc9deac902989e6d0c96e93f8726aeb14e4af9/disnake/ext/commands/converter.py#L705-L714 https://github.com/DisnakeDev/disnake/blob/9ebc9deac902989e6d0c96e93f8726aeb14e4af9/disnake/ext/commands/converter.py#L738-L757
...but they perform work/validation that goes beyond simply stripping the leading # and parsing as base 16. It also seems to support 3-digit #RGB format.