Utilities and JSON Database support #51

Closed
ghost wants to merge 6 commits from 2.0 into 2.0
2 changed files with 19 additions and 1 deletions
Showing only changes of commit 10d8a03d71 - Show all commits

View File

@@ -83,6 +83,24 @@ class Colour:
raise TypeError(f'Expected int parameter, received {value.__class__.__name__} instead.')
self.value: int = value
@staticmethod
def from_hex(self, value: str, base:int = None):
"""
Initiate self.value from different base(hexidecimal, binary)
=======
value `str` :
value in different base, e.g. white in hexidecimal, 0xffffff
base `int` (optional) :
base of your value, if you don't supply this, you have to add a prefix to your number, e.g. 0x or 0b
"""
return Colour(value = int(value, base=base))
def _get_byte(self, byte: int) -> int:
return (self.value >> (8 * byte)) & 0xff

View File

@@ -110,7 +110,7 @@ class CommandError(DiscordException):
from :class:`.Bot`\, :func:`.on_command_error`.
"""
def __init__(self, message: Optional[str] = None, *args: Any) -> None:
if message is not None:
if message: # replace 'if not none' with 'if message'
# clean-up @everyone and @here mentions
m = message.replace('@everyone', '@\u200beveryone').replace('@here', '@\u200bhere')
super().__init__(m, *args)