Skip to content

Commit c4bd711

Browse files
authored
Add transparent color (#131)
1 parent 644054f commit c4bd711

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

discord/colour.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,31 @@ def nitro_pink(cls: Type[CT]) -> CT:
333333
.. versionadded:: 2.0
334334
"""
335335
return cls(0xf47fff)
336+
337+
@classmethod
338+
def embed_background(cls: Type[CT], theme: str = "dark") -> CT:
339+
"""A factory method that returns a :class:`Color` corresponding to the embed colors on discord clients, with a value of
340+
``0x2F3136`` (dark)
341+
``0xf2f3f5`` (light)
342+
``0x000000`` (amoled).
343+
344+
.. versionadded:: 2.0
345+
346+
Parameters
347+
-----------
348+
theme: :class:`str`
349+
The theme color to apply, must be one of "dark", "light", or "amoled".
350+
"""
351+
themes_cls = {
352+
"dark": 0x2F3136,
353+
"light": 0xf2f3f5,
354+
"amoled": 0x000000,
355+
}
356+
357+
if theme not in themes_cls:
358+
raise TypeError("Theme must be \"dark\", \"light\", or \"amoled\".")
359+
360+
return cls(themes_cls[theme])
336361

337362

338363
Color = Colour

0 commit comments

Comments
 (0)