Skip to content

Commit e94b95b

Browse files
authored
feat: add Color object. (#611)
1 parent 7489f6f commit e94b95b

File tree

1 file changed

+44
-43
lines changed

1 file changed

+44
-43
lines changed

interactions/api/models/misc.py

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -171,54 +171,55 @@ def __hash__(self):
171171
# but end users might.
172172

173173

174-
class Format:
174+
class Color(object):
175175
"""
176-
This object is used to respectively format markdown strings
177-
provided by the WYSIWYG text editor for ease-of-accessibility
178-
and simple implementations into bots.
176+
An object representing Discord branding colors.
179177
180178
.. note::
181-
All base strings are given brackets before being f-string
182-
parsable to make conversion simplified.
183-
184-
.. warning::
185-
the ``stylize()`` method must be used if you're actually
186-
looking to give a **str** specific result.
179+
This object only intends to cover the branding colors
180+
and no others. The main reason behind this is due to
181+
the current accepted standard of using hex codes or other
182+
custom-defined colors.
187183
"""
188184

189-
USER = "<@%s>"
190-
USER_NICK = "<@!%s>"
191-
CHANNEL = "<#%s>"
192-
ROLE = "<@&%s>"
193-
EMOJI = "<:%s:%d>"
194-
EMOJI_ANIMATED = "<a:%s:%d>"
195-
TIMESTAMP = "<t:%s>"
196-
TIMESTAMP_SHORT_T = "<t:%s:t>"
197-
TIMESTAMP_LONG_T = "<t:%s:T>"
198-
TIMESTAMP_SHORT_D = "<t:%s:d>"
199-
TIMESTAMP_LONG_D = "<t:%s:D>"
200-
TIMESTAMP_SHORT_DT = TIMESTAMP
201-
TIMESTAMP_LONG_DT = "<t:%s:F>"
202-
TIMESTAMP_RELATIVE = "<t:%s:R>"
203-
204-
@classmethod
205-
def stylize(cls, format: str, **kwargs) -> str:
206-
r"""
207-
This takes a format style from the object and
208-
converts it into a usable string for ease.
209-
210-
:param format: The format string to use.
211-
:type format: str
212-
:param \**kwargs: Multiple key-word arguments to use, where key=value is format=value.
213-
:type \**kwargs: dict
214-
:return: The formatted string.
215-
:rtype: str
216-
"""
217-
new: str = f"" # noqa: F541
218-
for kwarg in kwargs:
219-
if format == kwarg:
220-
new %= format
221-
return new
185+
@property
186+
def blurple(self) -> hex:
187+
"""Returns a hexadecimal value of the blurple color."""
188+
return 0x5865F2
189+
190+
@property
191+
def green(self) -> hex:
192+
"""Returns a hexadecimal value of the green color."""
193+
return 0x57F287
194+
195+
@property
196+
def yellow(self) -> hex:
197+
"""Returns a hexadecimal value of the yellow color."""
198+
return 0xFEE75C
199+
200+
@property
201+
def fuchsia(self) -> hex:
202+
"""Returns a hexadecimal value of the fuchsia color."""
203+
return 0xEB459E
204+
205+
@property
206+
def red(self) -> hex:
207+
"""Returns a hexadecimal value of the red color."""
208+
return 0xED4245
209+
210+
# I can't imagine any bot developers actually using these.
211+
# If they don't know white is ff and black is 00, something's seriously
212+
# wrong.
213+
214+
@property
215+
def white(self) -> hex:
216+
"""Returns a hexadecimal value of the white color."""
217+
return 0xFFFFFF
218+
219+
@property
220+
def black(self) -> hex:
221+
"""Returns a hexadecimal value of the black color."""
222+
return 0x000000
222223

223224

224225
class MISSING:

0 commit comments

Comments
 (0)