|
2 | 2 | import string |
3 | 3 | import asyncio |
4 | 4 | import typing |
5 | | -from io import BytesIO |
6 | 5 | from datetime import datetime, timedelta |
7 | | -from traceback import print_exc |
8 | 6 |
|
9 | 7 | import discord |
10 | 8 | from discord.ext.commands import UserInputError, CommandError |
11 | 9 |
|
12 | | -from colorthief import ColorThief |
13 | 10 |
|
14 | | -from core.decorators import async_executor |
15 | | -from core.utils import is_image_url, days, match_user_id, parse_image_url |
| 11 | +from core.utils import is_image_url, days, match_user_id |
16 | 12 | from core.models import Bot, ThreadManagerABC, ThreadABC |
17 | 13 |
|
18 | 14 |
|
@@ -579,31 +575,6 @@ async def find_or_create(self, recipient): |
579 | 575 | return await self.find(recipient=recipient) or \ |
580 | 576 | await self.create(recipient) |
581 | 577 |
|
582 | | - @staticmethod |
583 | | - @async_executor() |
584 | | - def _do_get_dc(image, quality): |
585 | | - with BytesIO(image) as f: |
586 | | - return ColorThief(f).get_color(quality=quality) |
587 | | - |
588 | | - async def get_dominant_color(self, url=None, quality=10): |
589 | | - """ |
590 | | - Returns the dominant color of an image from a URL |
591 | | - (misc) |
592 | | - """ |
593 | | - url = parse_image_url(url) |
594 | | - |
595 | | - if not url: |
596 | | - raise ValueError('Invalid image url passed.') |
597 | | - try: |
598 | | - async with self.bot.session.get(url) as resp: |
599 | | - image = await resp.read() |
600 | | - color = await self._do_get_dc(image, quality) |
601 | | - except Exception: |
602 | | - print_exc() |
603 | | - return discord.Color.blurple() |
604 | | - else: |
605 | | - return discord.Color.from_rgb(*color) |
606 | | - |
607 | 578 | def _format_channel_name(self, author): |
608 | 579 | """Sanitises a username for use with text channel names""" |
609 | 580 | name = author.name.lower() |
|
0 commit comments