From f1e4d371f11c1a58133f4e397b807c9b5918853b Mon Sep 17 00:00:00 2001 From: fl0w Date: Wed, 2 Mar 2022 01:52:06 -0500 Subject: [PATCH] feat: add Color object. --- interactions/api/models/misc.py | 87 +++++++++++++++++---------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/interactions/api/models/misc.py b/interactions/api/models/misc.py index 64d3311f1..3a92110f0 100644 --- a/interactions/api/models/misc.py +++ b/interactions/api/models/misc.py @@ -171,54 +171,55 @@ def __hash__(self): # but end users might. -class Format: +class Color(object): """ - This object is used to respectively format markdown strings - provided by the WYSIWYG text editor for ease-of-accessibility - and simple implementations into bots. + An object representing Discord branding colors. .. note:: - All base strings are given brackets before being f-string - parsable to make conversion simplified. - - .. warning:: - the ``stylize()`` method must be used if you're actually - looking to give a **str** specific result. + This object only intends to cover the branding colors + and no others. The main reason behind this is due to + the current accepted standard of using hex codes or other + custom-defined colors. """ - USER = "<@%s>" - USER_NICK = "<@!%s>" - CHANNEL = "<#%s>" - ROLE = "<@&%s>" - EMOJI = "<:%s:%d>" - EMOJI_ANIMATED = "" - TIMESTAMP = "" - TIMESTAMP_SHORT_T = "" - TIMESTAMP_LONG_T = "" - TIMESTAMP_SHORT_D = "" - TIMESTAMP_LONG_D = "" - TIMESTAMP_SHORT_DT = TIMESTAMP - TIMESTAMP_LONG_DT = "" - TIMESTAMP_RELATIVE = "" - - @classmethod - def stylize(cls, format: str, **kwargs) -> str: - r""" - This takes a format style from the object and - converts it into a usable string for ease. - - :param format: The format string to use. - :type format: str - :param \**kwargs: Multiple key-word arguments to use, where key=value is format=value. - :type \**kwargs: dict - :return: The formatted string. - :rtype: str - """ - new: str = f"" # noqa: F541 - for kwarg in kwargs: - if format == kwarg: - new %= format - return new + @property + def blurple(self) -> hex: + """Returns a hexadecimal value of the blurple color.""" + return 0x5865F2 + + @property + def green(self) -> hex: + """Returns a hexadecimal value of the green color.""" + return 0x57F287 + + @property + def yellow(self) -> hex: + """Returns a hexadecimal value of the yellow color.""" + return 0xFEE75C + + @property + def fuchsia(self) -> hex: + """Returns a hexadecimal value of the fuchsia color.""" + return 0xEB459E + + @property + def red(self) -> hex: + """Returns a hexadecimal value of the red color.""" + return 0xED4245 + + # I can't imagine any bot developers actually using these. + # If they don't know white is ff and black is 00, something's seriously + # wrong. + + @property + def white(self) -> hex: + """Returns a hexadecimal value of the white color.""" + return 0xFFFFFF + + @property + def black(self) -> hex: + """Returns a hexadecimal value of the black color.""" + return 0x000000 class MISSING: