Skip to content

Handle hex color codes with leading '#' #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion discord_webhook/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def set_color(self, color: Union[str, int]) -> None:
Set the color of the embed.
:param color: color code as decimal(int) or hex(string)
"""
self.color = int(color, 16) if isinstance(color, str) else color
self.color = int(color.lstrip("#"), 16) if isinstance(color, str) else color
if self.color is not None and self.color not in range(16777216):
raise ColorNotInRangeException(color)

Expand Down
1 change: 1 addition & 0 deletions tests/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def test__set_embed__timestamp(embed, timestamp):
@pytest.mark.parametrize(
"color, output",
[
("#03b2f8", 242424),
("03b2f8", 242424),
(333333, 333333),
],
Expand Down