Add Colour.random factory method

This commit is contained in:
Caio Alexandre
2020-11-21 22:16:41 -05:00
committed by Rapptz
parent 25f23ec113
commit 896a5bef1d
+6
View File
@@ -25,6 +25,7 @@ DEALINGS IN THE SOFTWARE.
"""
import colorsys
import random
class Colour:
"""Represents a Discord role colour. This class is similar
@@ -117,6 +118,11 @@ class Colour:
"""A factory method that returns a :class:`Colour` with a value of ``0``."""
return cls(0)
@classmethod
def random(cls):
"""A factory method that returns a :class:`Colour` with a random value."""
return cls.from_hsv(random.random(), 1, 1)
@classmethod
def teal(cls):
"""A factory method that returns a :class:`Colour` with a value of ``0x1abc9c``."""