aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaio Alexandre <[email protected]>2020-11-19 12:23:59 -0300
committerRapptz <[email protected]>2020-11-21 22:16:41 -0500
commit896a5bef1d9726bfad771a1131a98f4130405d47 (patch)
tree81022879f7ec6134001f6b48a1208522b53bdeba
parentProperly document that categories throw 404's on create_invite. (diff)
downloaddiscord.py-896a5bef1d9726bfad771a1131a98f4130405d47.tar.xz
discord.py-896a5bef1d9726bfad771a1131a98f4130405d47.zip
Add Colour.random factory method
-rw-r--r--discord/colour.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/discord/colour.py b/discord/colour.py
index 804173a4..c2acfb4e 100644
--- a/discord/colour.py
+++ b/discord/colour.py
@@ -25,6 +25,7 @@ DEALINGS IN THE SOFTWARE.
"""
import colorsys
+import random
class Colour:
"""Represents a Discord role colour. This class is similar
@@ -118,6 +119,11 @@ class Colour:
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``."""
return cls(0x1abc9c)