Skip to content

Commit

Permalink
Fix estimate colors
Browse files Browse the repository at this point in the history
  • Loading branch information
0x16c3 committed Sep 13, 2021
1 parent 25f5f28 commit 9274017
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
10 changes: 8 additions & 2 deletions cogs/api/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,14 @@ async def send_embed(
loop = asyncio.get_event_loop()

estimate = await loop.run_in_executor(None, self.get_picture_color)
colors = len(estimate) - 1

color = discord.Color.from_rgb(estimate[0], estimate[1], estimate[2])
if colors < 0:
color = color_main
else:
color = discord.Color.from_rgb(
estimate[0], estimate[min(1, colors)], estimate[min(2, colors)]
)

embed = discord.Embed(
title=f"{self.name}'s Profile",
Expand Down Expand Up @@ -755,4 +761,4 @@ def embed_string(self, items: List) -> Dict[str, str]:
elif isinstance(items[0], Studio):
return None
else:
raise TypeError("invalid item type in items")
raise TypeError("invalid item type in items")
11 changes: 8 additions & 3 deletions cogs/controller.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# discord imports
from os import terminal_size
import discord
from discord.ext import commands
import asyncio
Expand Down Expand Up @@ -870,7 +869,9 @@ def check_author(cctx: ComponentContext):
),
color=color_errr,
)
await button_ctx.edit_origin(content="An error occured!", embed=embed)
await button_ctx.edit_origin(
content="An error occured!", embed=embed
)
return

user: Activity = await Activity.create(
Expand Down Expand Up @@ -914,7 +915,11 @@ def check_author(cctx: ComponentContext):
)

except:
await message.delete()
try:
await message.delete()
except discord.errors.NotFound:
pass

break

return
Expand Down

0 comments on commit 9274017

Please sign in to comment.