add Color.random
This commit is contained in:
parent
b61b5b7414
commit
725f08e45d
@ -15,7 +15,7 @@ __title__ = 'discord'
|
|||||||
__author__ = 'Rapptz'
|
__author__ = 'Rapptz'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
__copyright__ = 'Copyright 2015-2020 Rapptz'
|
__copyright__ = 'Copyright 2015-2020 Rapptz'
|
||||||
__version__ = '1.5.1.5'
|
__version__ = '1.5.1.6a'
|
||||||
|
|
||||||
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
|
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ DEALINGS IN THE SOFTWARE.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import colorsys
|
import colorsys
|
||||||
|
import random
|
||||||
|
|
||||||
class Colour:
|
class Colour:
|
||||||
"""Represents a Discord role colour. This class is similar
|
"""Represents a Discord role colour. This class is similar
|
||||||
@ -118,6 +119,11 @@ class Colour:
|
|||||||
rgb = colorsys.hsv_to_rgb(h, s, v)
|
rgb = colorsys.hsv_to_rgb(h, s, v)
|
||||||
return cls.from_rgb(*(int(x * 255) for x in rgb))
|
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
|
@classmethod
|
||||||
def default(cls):
|
def default(cls):
|
||||||
"""A factory method that returns a :class:`Colour` with a value of ``0``."""
|
"""A factory method that returns a :class:`Colour` with a value of ``0``."""
|
||||||
|
@ -120,7 +120,8 @@ class AllowedMentions:
|
|||||||
everyone = self.everyone if other.everyone is default else other.everyone
|
everyone = self.everyone if other.everyone is default else other.everyone
|
||||||
users = self.users if other.users is default else other.users
|
users = self.users if other.users is default else other.users
|
||||||
roles = self.roles if other.roles is default else other.roles
|
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):
|
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)
|
||||||
|
@ -237,7 +237,7 @@ class MessageReference:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_message(cls, message):
|
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
|
.. versionadded:: 1.5.1.5
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ class MessageReference:
|
|||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
:class:`MessageReference`
|
: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)
|
return cls(message._state, message_id=message.id, channel_id=message.channel.id, guild_id=message.guild and message.guild.id)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user