A library with leveling cards for your discord bot.
Project description
DiscordLevelingCard
A library with Rank cards for your discord bot.
now create your own custom rank cards!
card preview
card1
card2
card3
same as card2 but with background
installation
for pypi version
pip install discordlevelingcard
for github developement version
pip install git+https://github.com/krishsharma0413/DiscordLevelingCard
How To Use
If you don't provide path
then the method will return bytes
which can directly be used in discord.py/disnake/pycord/nextcord 's File class
.
Example
since no path was provided, it returns bytes which can directly be used in discord.py and its fork's File class.
from disnake.ext import commands
from DiscordLevelingCard import RankCard, Settings
import disnake
client = commands.Bot()
# define background, bar_color, text_color at one place
card_settings = Settings(
background="url or path to background image",
text_color="white",
bar_color="#000000"
)
@client.slash_command(name="rank")
async def user_rank_card(ctx, user:disnake.Member):
await ctx.response.defer()
a = RankCard(
settings=card_settings,
avatar=user.display_avatar.url,
level=1,
current_exp=1,
max_exp=1,
username="cool username"
)
image = await a.card1()
await ctx.edit_original_message(file=disnake.File(image, filename="rank.png")) # providing filename is very important
Documentation
RankCard class
__init__
method
RankCard(
settings: Settings,
avatar:str,
level:int,
current_exp:int,
max_exp:int,
username:str,
rank: Optional[int] = None
)
-
settings
- Settings class from DiscordLevelingCard. -
avatar
- avatar image url. -
level
- level of the user. -
current_exp
- current exp of the user. -
max_exp
- max exp of the user. -
username
- username of the user. -
rank
- rank of the user. (optional)
methods
card1
card2
card3
Sandbox class
__init__
method
RankCard(
settings: Settings,
avatar:str,
level:int,
current_exp:int,
max_exp:int,
username:str,
cacheing:bool = True,
rank: Optional[int] = None
)
-
settings
- Settings class from DiscordLevelingCard. -
avatar
- avatar image url. -
level
- level of the user. -
current_exp
- current exp of the user. -
max_exp
- max exp of the user. -
username
- username of the user. -
rank
- rank of the user. (optional) -
cacheing
- if set toTrue
then it will cache the image and will not regenerate it again. (default isTrue
)
methods
custom_card1
Settings class
__init__
method
Settings(
background: Union[PathLike, BufferedIOBase, str],
bar_color: Optional[str] = 'white',
text_color: Optional[str] = 'white',
background_color: Optional[str]= "#36393f"
)
-
background
- background image url or file-object inrb
mode.4:1
aspect ratio recommended.
-
bar_color
- color of the bar [example: "white" or "#000000"] -
text_color
- color of the text [example: "white" or "#000000"] -
background_color
- color of the background [example: "white" or "#000000"]
card1 method
RankCard.card1(resize: int = 100)
attribute
resize
: resize the final image. (default is 100, treat it as a percentage.)
returns
bytes
which can directly be used withindiscord.File
class.
card2 method
RankCard.card2(resize: int = 100)
attribute
resize
: resize the final image. (default is 100, treat it as a percentage.)
returns
bytes
which can directly be used withindiscord.File
class.
card3 method
RankCard.card3(resize: int = 100)
attribute
resize
: resize the final image. (default is 100, treat it as a percentage.)
returns
bytes
which can directly be used withindiscord.File
class.
custom_card1 method
Sandbox.custom_card1(card_colour:str = "black", resize: int = 100)
attribute
resize
: resize the final image. (default is 100, treat it as a percentage.)card_colour
: color of the card. (default is black)
returns
bytes
which can directly be used withindiscord.File
class.
examples
custom_card3 method
Sandbox.custom_card3(
resize:int = 100,
senstivity:int = 200,
card_colour: str = "black",
border_width: int = 25,
border_height: int = 25,
avatar_frame: str = "curvedborder",
avatar_size: int = 260,
avatar_position: tuple = (53, 36),
text_font: str = "levelfont.otf",
username_position: tuple = (330,130),
username_font_size: int = 50,
level_position: tuple = (500,40),
level_font_size: int = 50,
exp_position: tuple = (775,130),
exp_font_size: int = 50,
)
attribute
resize
: resize the final image. (default is 100, treat it as a percentage.)senstivity
: senstivity of the avatar frame. (default is 200)card_colour
: color of the card. (default is black)border_width
: width of the border. (default is 25)border_height
: height of the border. (default is 25)avatar_frame
: avatar frame. (default is "curvedborder")avatar_size
: size of the avatar. (default is 260)avatar_position
: position of the avatar. (default is (53, 36))text_font
: font of the text. (default is "levelfont.otf")username_position
: position of the username. (default is (330,130))username_font_size
: font size of the username. (default is 50)level_position
: position of the level. (default is (500,40))level_font_size
: font size of the level. (default is 50)exp_position
: position of the exp. (default is (775,130))exp_font_size
: font size of the exp. (default is 50)
returns
bytes
which can directly be used withindiscord.File
class.
examples
if you want to see changelog then click here
please star the repository if you like it :D
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for discordlevelingcard-0.5.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40ff5bc9980628c94384677cefa71109fc6f8f96b5b4e88b34045d8c126a8663 |
|
MD5 | f4da5cdc1eae8b65f746f2e542be8954 |
|
BLAKE2b-256 | c34c410fc5ded7a7f192c5be0f704e45b25d09348a58c6d143b1b397e38fa364 |
Hashes for discordlevelingcard-0.5.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3252a68a455cab46e9beb9a328da1b3408623f5fd33c34d404376852c6cf7f16 |
|
MD5 | d3d85a07fd4d5c568e3559f9a466faff |
|
BLAKE2b-256 | 4a5710dccfdce6c42e64ca9ca648af173d644602ab34a21085f9943a6a884771 |