Add color and embed utilities
This commit is contained in:
@@ -85,7 +85,7 @@ class Colour:
|
||||
self.value: int = value
|
||||
|
||||
@staticmethod
|
||||
def from_hex(self, value: str, base:int = None):
|
||||
def from_base(self, value: str, base:int = None):
|
||||
"""
|
||||
Initiate self.value from different base(hexidecimal, binary)
|
||||
=======
|
||||
|
||||
@@ -60,6 +60,8 @@ import re
|
||||
import sys
|
||||
import types
|
||||
import warnings
|
||||
from .embeds import Embed
|
||||
from .colors import Colour
|
||||
|
||||
from .errors import InvalidArgument
|
||||
|
||||
@@ -168,6 +170,41 @@ class CachedSlotProperty(Generic[T, T_co]):
|
||||
setattr(instance, self.name, value)
|
||||
return value
|
||||
|
||||
def generate_embed(header:str, content:str, footer:str, color=None): # Courtesy of Dank HadocK, my friend who coded this for my rewrite.
|
||||
"""
|
||||
Easy way to form embeds
|
||||
|
||||
This was made by Dank Had0cK, a valuable contributor on my fork. Thanks.
|
||||
|
||||
=====
|
||||
|
||||
header `str`:
|
||||
|
||||
Header of your embed
|
||||
|
||||
content `str`:
|
||||
|
||||
Content of your embed
|
||||
|
||||
footer `str`:
|
||||
|
||||
Footer of your embed
|
||||
|
||||
color `str` optional:
|
||||
|
||||
If it is None, color will default to 2F3136
|
||||
Hexstring of your color, uses color converter by Arkae to convert hex to int.
|
||||
"""
|
||||
|
||||
embed = Embed()
|
||||
embed.title = header
|
||||
embed.description = content
|
||||
if color is None:
|
||||
embed.color = Colour.from_base("0x2f3136")
|
||||
else:
|
||||
embed.color = Colour.from_base(color, 16)
|
||||
embed.set_footer(text=footer)
|
||||
return embed
|
||||
|
||||
class classproperty(Generic[T_co]):
|
||||
def __init__(self, fget: Callable[[Any], T_co]) -> None:
|
||||
|
||||
Reference in New Issue
Block a user