Skip to content

Commit

Permalink
[Palette] Fix wrong logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuro-Rui committed Jul 21, 2024
1 parent 3f4c414 commit 8634ad2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion palette/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from redbot.core.commands import BadArgument, Converter

IMAGE_LINKS = re.compile(r"(https?:\/\/[^\"\'\s]*\.(?:png|jpg|jpeg|gif|png|svg)(\?size=[0-9]*)?)")
EMOJI_REGEX = re.compile(r"(<(a)?:[a-zA-Z0-9\_]+:([0-9]+)>)")
EMOJI_REGEX = re.compile(r"(<(a)?:[a-zA-Z0-9\_]+:([0-9]+)>)|(:[a-zA-Z0-9_]+:)")
MENTION_REGEX = re.compile(r"<@!?([0-9]+)>")
ID_REGEX = re.compile(r"[0-9]{17,}")

Expand Down
14 changes: 8 additions & 6 deletions palette/palette.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ async def palette(
- `[detailed]` Whether to show the colours in a detailed format (with rgb and hex). Defaults to False.
- `[sort]` Whether to sort the colours by rgb. Defaults to False.
"""
if not image and (attachments := ctx.message.attachments):
valid_attachments = [a for a in attachments if a.content_type in VALID_CONTENT_TYPES]
if valid_attachments:
image = valid_attachments[0].url
else:
image = str(ctx.author.display_avatar)
if not image:
image = str(ctx.author.display_avatar)
if attachments := ctx.message.attachments:
valid_attachments = [
a for a in attachments if a.content_type in VALID_CONTENT_TYPES
]
if valid_attachments:
image = valid_attachments[0].url
async with ctx.typing():
img = await self.get_img(ctx, str(image))
if isinstance(img, dict):
Expand Down

0 comments on commit 8634ad2

Please sign in to comment.