aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/utilities/colour.py
diff options
context:
space:
mode:
authorGravatar bradtimmis <[email protected]>2021-11-09 19:48:09 -0500
committerGravatar bradtimmis <[email protected]>2021-11-09 19:48:09 -0500
commit385cb3aacf60bdaea67fe59890e9c5d894f9d65a (patch)
tree4ae8a5a6d585d9b490198486398ccc145c8dfdcf /bot/exts/utilities/colour.py
parentfix: handle alpha values in hex code (diff)
fix: add import, handle no name match in embed
-Added `import string` to use the `string.hexdigits` method to check hex codes. -Handled bug where no name match found would be repeated in the embed in the first line as well as the value for the Name field.
Diffstat (limited to 'bot/exts/utilities/colour.py')
-rw-r--r--bot/exts/utilities/colour.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/bot/exts/utilities/colour.py b/bot/exts/utilities/colour.py
index 7b128393..4528615b 100644
--- a/bot/exts/utilities/colour.py
+++ b/bot/exts/utilities/colour.py
@@ -2,6 +2,7 @@ import colorsys
import json
import pathlib
import random
+import string
from io import BytesIO
import discord
@@ -27,8 +28,6 @@ class Colour(commands.Cog):
async def send_colour_response(self, ctx: commands.Context, rgb: tuple[int, int, int]) -> None:
"""Create and send embed from user given colour information."""
name = self._rgb_to_name(rgb)
- if name is None:
- name = "No match found"
try:
colour_or_color = ctx.invoked_parents[0]
@@ -132,7 +131,9 @@ class Colour(commands.Cog):
hex_code = f"#{hex_code}"
if len(hex_code) not in (4, 5, 7, 9) or any(_ not in string.hexdigits+"#" for _ in hex_code):
raise commands.BadArgument(
- message=f"HEX values must be hexadecimal and take the form *#RRGGBB* or *#RGB*. User input was: `{hex_code}`.")
+ message="HEX values must be hexadecimal and take the form *#RRGGBB* or *#RGB*. "
+ f"User input was: `{hex_code}`."
+ )
hex_tuple = ImageColor.getrgb(hex_code)
if len(hex_tuple) == 4: