add Color.random

This commit is contained in:
iDutchy 2020-11-19 18:46:42 -06:00
parent b61b5b7414
commit 725f08e45d
4 changed files with 12 additions and 5 deletions

View File

@ -15,7 +15,7 @@ __title__ = 'discord'
__author__ = 'Rapptz'
__license__ = 'MIT'
__copyright__ = 'Copyright 2015-2020 Rapptz'
__version__ = '1.5.1.5'
__version__ = '1.5.1.6a'
__path__ = __import__('pkgutil').extend_path(__path__, __name__)

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
@ -118,6 +119,11 @@ class Colour:
rgb = colorsys.hsv_to_rgb(h, s, v)
return cls.from_rgb(*(int(x * 255) for x in rgb))
@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 default(cls):
"""A factory method that returns a :class:`Colour` with a value of ``0``."""

View File

@ -120,7 +120,8 @@ class AllowedMentions:
everyone = self.everyone if other.everyone is default else other.everyone
users = self.users if other.users is default else other.users
roles = self.roles if other.roles is default else other.roles
return AllowedMentions(everyone=everyone, roles=roles, users=users)
replied_user = self.replied_user if other.replied_user is default else other.replied_user
return AllowedMentions(everyone=everyone, roles=roles, users=users, replied_user=replied_user)
def __repr__(self):
return '{0.__class__.__qualname__}(everyone={0.everyone}, users={0.users}, roles={0.roles})'.format(self)
return '{0.__class__.__qualname__}(everyone={0.everyone}, users={0.users}, roles={0.roles}, replied_user={0.replied_user})'.format(self)

View File

@ -237,7 +237,7 @@ class MessageReference:
@classmethod
def from_message(cls, message):
"""Creates a :class:`MessageReference` from an existing :class:`Message`
"""Creates a :class:`MessageReference` from an existing :class:`Message`.
.. versionadded:: 1.5.1.5
@ -249,7 +249,7 @@ class MessageReference:
Returns
-------
:class:`MessageReference`
A reference to the message
A reference to the message.
"""
return cls(message._state, message_id=message.id, channel_id=message.channel.id, guild_id=message.guild and message.guild.id)