Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- from discord.ext import commands
- from easy_pil import Editor, load_image_async, Font
- client = commands.Bot(command_prefix="-", intents=discord.Intents.default())
- tree = client.tree
- @client.event
- async def on_ready():
- synced = await tree.sync()
- print(f"Synced {len(synced)} Command(s)")
- levels = {
- "745601141827567737": {
- "level": 12,
- "cXP": 500,
- "rXP": 1000
- },
- "941082828312027248": {
- "level": 50,
- "cXP": 20000,
- "rXP": 21000
- }
- }
- @tree.command(name="level", description="shows user rank data")
- async def _level(interaction: discord.Interaction, user: discord.User):
- level = levels[str(user.id)]["level"]
- cXP = levels[str(user.id)]["cXP"]
- rXP = levels[str(user.id)]["rXP"]
- percentage = cXP / rXP
- card = Editor("./imgs/bg.png")
- avatar = await load_image_async(user.display_avatar.url)
- cAvatar = Editor(avatar).resize((200, 200)).circle_image()
- font = Font("./fonts/onestroke.TTF", size=40)
- card.paste(cAvatar, (30, 25))
- card.rectangle((250, 120), width=615 * percentage,
- height=40, fill="#FACF11", radius=20)
- card.text(
- (252, 62),
- f"{user.name}",
- font=font, color="#000"
- )
- card.text(
- (250, 60),
- f"{user.name}",
- font=font, color="#FACF11"
- )
- card.text(
- (262, 172),
- f"Level: {level}" + " " + f"XP: {cXP} / {rXP}",
- font=font, color="#000"
- )
- card.text(
- (260, 170),
- f"Level: {level}" + " " + f"XP: {cXP} / {rXP}",
- font=font, color="#FACF11"
- )
- file = discord.File(card.image_bytes, filename="card.png")
- await interaction.response.send_message(file=file)
- client.run("TOKEN")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement