aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/utilities/colour.py
diff options
context:
space:
mode:
authorGravatar bradtimmis <[email protected]>2021-11-11 16:54:10 -0500
committerGravatar bradtimmis <[email protected]>2021-11-11 16:54:10 -0500
commited1fb463c4e04fa4628e46df33144a4b5c579b82 (patch)
tree56fc9de430317cc6bdcddfad2549e1d1df5789e8 /bot/exts/utilities/colour.py
parentcleanup: change main command docstring to be more clear (diff)
fix: remove async call for match_colour_name
Diffstat (limited to 'bot/exts/utilities/colour.py')
-rw-r--r--bot/exts/utilities/colour.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/bot/exts/utilities/colour.py b/bot/exts/utilities/colour.py
index b233fc1e..ed69beaf 100644
--- a/bot/exts/utilities/colour.py
+++ b/bot/exts/utilities/colour.py
@@ -159,7 +159,15 @@ class Colour(commands.Cog):
@colour.command()
async def name(self, ctx: commands.Context, *, user_colour_name: str) -> None:
"""Create an embed from a name input."""
- hex_colour = await self.match_colour_name(ctx, user_colour_name)
+ hex_colour = self.match_colour_name(ctx, user_colour_name)
+ if hex_colour is None:
+ name_error_embed = discord.Embed(
+ title="No colour match found.",
+ description=f"No color found for: `{user_colour_name}`",
+ colour=discord.Color.dark_red()
+ )
+ await ctx.send(embed=name_error_embed)
+ return
hex_tuple = ImageColor.getrgb(hex_colour)
await self.send_colour_response(ctx, hex_tuple)
@@ -234,7 +242,7 @@ class Colour(commands.Cog):
colour_name = None
return colour_name
- async def match_colour_name(self, ctx: commands.Context, input_colour_name: str) -> Union[str, None]:
+ def match_colour_name(self, ctx: commands.Context, input_colour_name: str) -> Union[str, None]:
"""Convert a colour name to HEX code."""
try:
match, certainty, _ = rapidfuzz.process.extractOne(
@@ -243,12 +251,7 @@ class Colour(commands.Cog):
score_cutoff=80
)
except (ValueError, TypeError):
- name_error_embed = discord.Embed(
- title="No colour match found.",
- description=f"No color found for: `{input_colour_name}`",
- colour=discord.Color.dark_red()
- )
- await ctx.send(embed=name_error_embed)
+ return None
return f"#{self.colour_mapping[match]}"