diff options
| author | Maselkov <[email protected]> | 2021-03-28 12:28:35 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-03-28 06:28:35 -0400 |
| commit | baa1ab058b53f5c6570c110103269096d1e58f00 (patch) | |
| tree | 70a148d0a0483ca2c457e10c17f35c1d269e4a2a | |
| parent | Fallback to empty string for unavailable guild __str__ (diff) | |
| download | discord.py-baa1ab058b53f5c6570c110103269096d1e58f00.tar.xz discord.py-baa1ab058b53f5c6570c110103269096d1e58f00.zip | |
Add an optional seed parameter for Colour.random
| -rw-r--r-- | discord/colour.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/discord/colour.py b/discord/colour.py index c6e3dd67..fbf9aaef 100644 --- a/discord/colour.py +++ b/discord/colour.py @@ -119,7 +119,7 @@ class Colour: return cls(0) @classmethod - def random(cls): + def random(cls, *, seed=None): """A factory method that returns a :class:`Colour` with a random hue. .. note:: @@ -128,8 +128,16 @@ class Colour: with maxed out saturation and value. .. versionadded:: 1.6 + + Parameters + ------------ + seed: Optional[Union[:class:`int`, :class:`str`, :class:`float`, :class:`bytes`, :class:`bytearray`]] + The seed to initialize the RNG with. If ``None`` is passed the default RNG is used. + + .. versionadded:: 1.7 """ - return cls.from_hsv(random.random(), 1, 1) + rand = random if seed is None else random.Random(seed) + return cls.from_hsv(rand.random(), 1, 1) @classmethod def teal(cls): |