GoldyBot.utility.goldy.colours
1from __future__ import annotations 2from typing import Literal 3import nextcord 4import GoldyBot 5from colorthief import ColorThief 6 7class Colours: 8 """Hardcoded GoldyBot colour codes. These can be used in Embeds and stuff.""" 9 AKI_PINK = 0xFF1493 10 AKI_ORANGE = 0xF4900C 11 AKI_RED = 0xff0051 12 AKI_BLUE = 0X75E6DA 13 BLUE = 0x3061f2 14 GREEN = 0x00FF00 15 LIME_GREEN = 0x8AFF65 16 YELLOW = 0xffff4d 17 PURPLE = 0xFF00FF 18 RED = 0xFF0000 19 GREY = 0x3B3B3B 20 WHITE = 0xFFFFFF 21 22 DISCORD_EMBED_INVISIBLE = 0x2F3136 23 """Makes the embed colour the same as the background essentially giving the embed a transparent colour.""" 24 25 def custom_colour(self, rgb:tuple=None, hex:int|str=None) -> Literal|int: 26 """ 27 Method to create custom colour with rgb or hex values. 28 (WARNING: Hex is currently not supported, if hex is entered value of ``WHITE`` will be returned.) 29 """ 30 if not rgb == None: 31 if isinstance(rgb, tuple): 32 return nextcord.Colour.from_rgb(rgb[0], rgb[1], rgb[2]).value 33 34 return self.WHITE 35 36 def get_colour_from_image(self, image_file:GoldyBot.files.File, quality:int=5) -> Literal|int: 37 """Returns most common colour from any image.""" 38 39 if isinstance(image_file, GoldyBot.WebFile): # It's a web file. 40 image_file:GoldyBot.WebFile 41 return self.custom_colour( 42 rgb=ColorThief(image_file.get_file()).get_color(quality) 43 ) 44 45 else: # It's a normal file. 46 return self.custom_colour( 47 rgb=ColorThief(image_file.file_path).get_color(quality) 48 ) 49 50class Colors(Colours): 51 pass 52 53 54 55# This section below is all Deprecated, use Colours enum class instead. 56AKI_PINK = Colours.AKI_PINK 57"""This is Deprecated, use ``Colours.AKI_PINK`` instead!""" 58AKI_ORANGE = Colours.AKI_ORANGE 59"""This is Deprecated, use ``Colours.AKI_ORANGE`` instead!""" 60AKI_RED = Colours.AKI_RED 61"""This is Deprecated, use ``Colours.AKI_RED`` instead!""" 62AKI_BLUE = Colours.AKI_BLUE 63"""This is Deprecated, use ``Colours.AKI_BLUE`` instead!""" 64BLUE = Colours.BLUE 65"""This is Deprecated, use ``Colours.BLUE`` instead!""" 66GREEN = Colours.GREEN 67"""This is Deprecated, use ``Colours.GREEN`` instead!""" 68YELLOW = Colours.YELLOW 69"""This is Deprecated, use ``Colours.YELLOW`` instead!""" 70PURPLE = Colours.PURPLE 71"""This is Deprecated, use ``Colours.PURPLE`` instead!""" 72RED = Colours.RED 73"""This is Deprecated, use ``Colours.RED`` instead!""" 74GREY = Colours.GREY 75"""This is Deprecated, use ``Colours.GREY`` instead!""" 76WHITE = Colours.WHITE 77"""This is Deprecated, use ``Colours.WHITE`` instead!"""
8class Colours: 9 """Hardcoded GoldyBot colour codes. These can be used in Embeds and stuff.""" 10 AKI_PINK = 0xFF1493 11 AKI_ORANGE = 0xF4900C 12 AKI_RED = 0xff0051 13 AKI_BLUE = 0X75E6DA 14 BLUE = 0x3061f2 15 GREEN = 0x00FF00 16 LIME_GREEN = 0x8AFF65 17 YELLOW = 0xffff4d 18 PURPLE = 0xFF00FF 19 RED = 0xFF0000 20 GREY = 0x3B3B3B 21 WHITE = 0xFFFFFF 22 23 DISCORD_EMBED_INVISIBLE = 0x2F3136 24 """Makes the embed colour the same as the background essentially giving the embed a transparent colour.""" 25 26 def custom_colour(self, rgb:tuple=None, hex:int|str=None) -> Literal|int: 27 """ 28 Method to create custom colour with rgb or hex values. 29 (WARNING: Hex is currently not supported, if hex is entered value of ``WHITE`` will be returned.) 30 """ 31 if not rgb == None: 32 if isinstance(rgb, tuple): 33 return nextcord.Colour.from_rgb(rgb[0], rgb[1], rgb[2]).value 34 35 return self.WHITE 36 37 def get_colour_from_image(self, image_file:GoldyBot.files.File, quality:int=5) -> Literal|int: 38 """Returns most common colour from any image.""" 39 40 if isinstance(image_file, GoldyBot.WebFile): # It's a web file. 41 image_file:GoldyBot.WebFile 42 return self.custom_colour( 43 rgb=ColorThief(image_file.get_file()).get_color(quality) 44 ) 45 46 else: # It's a normal file. 47 return self.custom_colour( 48 rgb=ColorThief(image_file.file_path).get_color(quality) 49 )
Hardcoded GoldyBot colour codes. These can be used in Embeds and stuff.
Makes the embed colour the same as the background essentially giving the embed a transparent colour.
26 def custom_colour(self, rgb:tuple=None, hex:int|str=None) -> Literal|int: 27 """ 28 Method to create custom colour with rgb or hex values. 29 (WARNING: Hex is currently not supported, if hex is entered value of ``WHITE`` will be returned.) 30 """ 31 if not rgb == None: 32 if isinstance(rgb, tuple): 33 return nextcord.Colour.from_rgb(rgb[0], rgb[1], rgb[2]).value 34 35 return self.WHITE
Method to create custom colour with rgb or hex values.
(WARNING: Hex is currently not supported, if hex is entered value of WHITE
will be returned.)
37 def get_colour_from_image(self, image_file:GoldyBot.files.File, quality:int=5) -> Literal|int: 38 """Returns most common colour from any image.""" 39 40 if isinstance(image_file, GoldyBot.WebFile): # It's a web file. 41 image_file:GoldyBot.WebFile 42 return self.custom_colour( 43 rgb=ColorThief(image_file.get_file()).get_color(quality) 44 ) 45 46 else: # It's a normal file. 47 return self.custom_colour( 48 rgb=ColorThief(image_file.file_path).get_color(quality) 49 )
Returns most common colour from any image.
Hardcoded GoldyBot colour codes. These can be used in Embeds and stuff.
This is Deprecated, use Colours.AKI_PINK
instead!
This is Deprecated, use Colours.AKI_ORANGE
instead!
This is Deprecated, use Colours.AKI_RED
instead!
This is Deprecated, use Colours.AKI_BLUE
instead!
This is Deprecated, use Colours.BLUE
instead!
This is Deprecated, use Colours.GREEN
instead!
This is Deprecated, use Colours.YELLOW
instead!
This is Deprecated, use Colours.PURPLE
instead!
This is Deprecated, use Colours.RED
instead!
This is Deprecated, use Colours.GREY
instead!
This is Deprecated, use Colours.WHITE
instead!